Instructions to use ibm-granite/granite-3.2-8b-instruct-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-granite/granite-3.2-8b-instruct-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ibm-granite/granite-3.2-8b-instruct-preview") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-3.2-8b-instruct-preview") model = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-3.2-8b-instruct-preview", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ibm-granite/granite-3.2-8b-instruct-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibm-granite/granite-3.2-8b-instruct-preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-3.2-8b-instruct-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ibm-granite/granite-3.2-8b-instruct-preview
- SGLang
How to use ibm-granite/granite-3.2-8b-instruct-preview with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ibm-granite/granite-3.2-8b-instruct-preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-3.2-8b-instruct-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ibm-granite/granite-3.2-8b-instruct-preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-3.2-8b-instruct-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ibm-granite/granite-3.2-8b-instruct-preview with Docker Model Runner:
docker model run hf.co/ibm-granite/granite-3.2-8b-instruct-preview
minor change
#8
by ranarag - opened
README.md
CHANGED
|
@@ -251,21 +251,22 @@ Remember, everyone learns at their own pace, so don't compare your progress with
|
|
| 251 |
<tr>
|
| 252 |
<td style="text-align:left; background-color: #DAE8FF; color: black;">Granite-3.1-8B-Instruct</td>
|
| 253 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">37.58</td>
|
| 254 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">
|
| 255 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">66.
|
| 256 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">28.
|
| 257 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">65.
|
| 258 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">68.
|
| 259 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">50.78</td>
|
| 260 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">79.
|
| 261 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">
|
| 262 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">
|
| 263 |
-
<td style="text-align:center; background-color: #DAE8FF; color: black;">
|
| 264 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">85.73</td>
|
| 265 |
</tr>
|
| 266 |
-
|
|
|
|
| 267 |
<tr>
|
| 268 |
-
<td style="text-align:left; background-color: #DAE8FF; color: black;">Granite-3.2-8B-Instruct-Preview</td>
|
| 269 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">55.23</td>
|
| 270 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">61.16</td>
|
| 271 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">66.93</td>
|
|
|
|
| 251 |
<tr>
|
| 252 |
<td style="text-align:left; background-color: #DAE8FF; color: black;">Granite-3.1-8B-Instruct</td>
|
| 253 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">37.58</td>
|
| 254 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">30.34</td>
|
| 255 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">66.77</td>
|
| 256 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">28.7</td>
|
| 257 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">65.84</td>
|
| 258 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">68.55</td>
|
| 259 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">50.78</td>
|
| 260 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">79.15</td>
|
| 261 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">89.63</td>
|
| 262 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">85.79</td>
|
| 263 |
+
<td style="text-align:center; background-color: #DAE8FF; color: black;">73.20</td>
|
| 264 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">85.73</td>
|
| 265 |
</tr>
|
| 266 |
+
|
| 267 |
+
|
| 268 |
<tr>
|
| 269 |
+
<td style="text-align:left; background-color: #DAE8FF; color: black;"><b>Granite-3.2-8B-Instruct-Preview</b></td>
|
| 270 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">55.23</td>
|
| 271 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">61.16</td>
|
| 272 |
<td style="text-align:center; background-color: #DAE8FF; color: black;">66.93</td>
|