granite 4.1 8b
ibm-granite/granite-4.1-8bgranite 4.1 8b (ibm-granite/granite-4.1-8b) is a granite 8.8B-parameter model from Ibm Granite with a 131,072-token context window and 131,072 max output tokens, priced at $0.05/1M input and $0.10/1M output tokens. Available via the haimaker.ai OpenAI-compatible API.
Overview
Model Summary: Granite-4.1-8B is a 8B parameter long-context instruct model finetuned from Granite-4.1-8B-Base using a combination of open source instruction datasets with permissive license and internally collected synthetic datasets. Granite 4.1 models have gone through an improved post-training pipeline, including supervised finetuning and reinforcement learning alignment, resulting in enhanced tool calling, instruction following, and chat capabilities.
Model Card
Granite-4.1-8B
Model Summary: Granite-4.1-8B is a 8B parameter long-context instruct model finetuned from Granite-4.1-8B-Base using a combination of open source instruction datasets with permissive license and internally collected synthetic datasets. Granite 4.1 models have gone through an improved post-training pipeline, including supervised finetuning and reinforcement learning alignment, resulting in enhanced tool calling, instruction following, and chat capabilities.- Developers: Granite Team, IBM
- HF Collection: Granite 4.1 Language Models HF Collection
- Technical Blog: Granite-4.1 Blog
- GitHub Repository: ibm-granite/granite-4.1-language-models
- Website: Granite Docs
- Release Date: April 29th, 2026
- License: Apache 2.0
- Summarization
- Text classification
- Text extraction
- Question-answering
- Retrieval Augmented Generation (RAG)
- Code related tasks
- Function-calling tasks
- Multilingual dialog use cases
- Fill-In-the-Middle (FIM) code completions
Install the following libraries:
pip install torch torchvision torchaudio
pip install accelerate
pip install transformers
Then, copy the snippet from the section that is relevant for your use case.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model_path = "ibm-granite/granite-4.1-8b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
drop device_map if running on CPU
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()
change input text as desired
chat = [
{ "role": "user", "content": "Please list one IBM Research laboratory located in the United States. You should only output its name and location." },
]
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
tokenize the text
input_tokens = tokenizer(chat, return_tensors="pt").to(device)
generate output tokens
output = model.generate(**input_tokens,
max_new_tokens=100)
decode output tokens into text
output = tokenizer.batch_decode(output)
print output
print(output[0])
Expected output:
<|start_of_role|>user<|end_of_role|>Please list one IBM Research laboratory located in the United States. You should only output its name and location.<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>IBM Almaden Research Laboratory, San Jose, California, United States.<|end_of_text|>Tool-calling: Granite-4.1-8B comes with enhanced tool calling capabilities, enabling seamless integration with external functions and APIs. To define a list of tools please follow OpenAI's function definition schema.
This is an example of how to use Granite-4.1-8B model tool-calling ability:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model_path = "ibm-granite/granite-4.1-8b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
drop device_map if running on CPU
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather for a specified city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "Name of the city"
}
},
"required": ["city"]
}
}
}
]
change input text as desired
chat = [
{ "role": "user", "content": "What's the weather like in Boston right now?" },
]
chat = tokenizer.apply_chat_template(chat, \
tokenize=False, \
tools=tools, \
add_generation_prompt=True)
tokenize the text
input_tokens = tokenizer(chat, return_tensors="pt").to(device)
generate output tokens
output = model.generate(**input_tokens,
max_new_tokens=100)
decode output tokens into text
output = tokenizer.batch_decode(output)
print output
print(output[0])
Expected output:
<|start_of_role|>system<|end_of_role|>You are a helpful assistant with access to the following tools. You may call one or more tools to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"type": "function", "function": {"name": "get_current_weather", "description": "Get the current weather for a specified city.", "parameters": {"type": "object", "properties": {"city": {"type": "string", "description": "Name of the city"}}, "required": ["city"]}}}
</tools>
For each tool call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.<|end_of_text|>
<|start_of_role|>user<|end_of_role|>What's the weather like in Boston right now?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|><tool_call>
{"name": "get_current_weather", "arguments": {"city": "Boston"}}
</tool_call><|end_of_text|>
Evaluation Results:
| Benchmarks | Metric | 3B Dense | 8B Dense | 30B Dense | |
|---|---|---|---|---|---|
| General Tasks | |||||
| MMLU | 5-shot | 67.02 | 73.84 | 80.16 | |
| MMLU-Pro | 5-shot, CoT | 49.83 | 55.99 | 64.09 | |
| BBH | 3-shot, CoT | 75.83 | 80.51 | 83.74 | |
| AGI EVAL | 0-shot, CoT | 65.16 | 72.43 | 77.80 | |
| GPQA | 0-shot, CoT | 31.70 | 41.96 | 45.76 | |
| SimpleQA | 3.68 | 4.82 | 6.81 | ||
| Alignment Tasks | |||||
| AlpacaEval 2.0 | 38.57 | 50.08 | 56.16 | ||
| IFEval Avg | 82.30 | 87.06 | 89.65 | ||
| ArenaHard | 37.80 | 68.98 | 71.02 | ||
| MTBench Avg | 7.57 | 8.61 | 8.61 | ||
| Math Tasks | |||||
| GSM8K | 8-shot | 86.88 | 92.49 | 94.16 | |
| GSM Symbolic | 8-shot | 81.32 | 83.70 | 75.70 | |
| Minerva Math | 0-shot, CoT | 67.94 | 80.10 | 81.32 | |
| DeepMind Math | 0-shot, CoT | 64.64 | 80.07 | 81.93 | |
| Code Tasks | |||||
| HumanEval | pass@1 | 81.71 | 85.37 | 88.41 | |
| HumanEval+ | pass@1 | 76.83 | 79.88 | 85.37 | |
| MBPP | pass@1 | 71.16 | 87.30 | 85.45 | |
| MBPP+ | pass@1 | 62.17 | 73.81 | 73.54 | |
| CRUXEval-O | pass@1 | 40.75 | 47.63 | 55.75 | |
| BigCodeBench | pass@1 | 32.19 | 35.00 | 38.77 | |
| MULTIPLE | pass@1 | 52.54 | 60.26 | 62.31 | |
| Eval+ Avg | pass@1 | 67.05 | 80.21 | 82.66 | |
| Tool Calling Tasks | |||||
| BFCL v3 | 60.80 | 68.27 | 73.68 | ||
| Multilingual Tasks | |||||
| MMMLU | 5-shot | 57.61 | 64.84 | 73.71 | |
| INCLUDE | 5-shot | 52.05 | 58.89 | 67.26 | |
| MGSM | 8-shot | 70.00 | 82.32 | 71.12 | |
| Safety | |||||
| SALAD-Bench | 93.95 | 95.80 | 96.41 | ||
| AttaQ | 81.88 | 81.19 | 85.76 | ||
| Tulu3 Safety Eval Avg | 66.84 | 75.57 | 78.19 | ||
| Benchmarks | # Langs | Languages |
|---|---|---|
| MMMLU | 11 | ar, de, en, es, fr, ja, ko, pt, zh, bn, hi |
| INCLUDE | 14 | hi, bn, ta, te, ar, de, es, fr, it, ja, ko, nl, pt, zh |
| MGSM | 5 | en, es, fr, ja, zh |
Granite-4.1-8B baseline is built on a decoder-only dense transformer architecture. Core components of this architecture are: GQA, RoPE, MLP with SwiGLU, RMSNorm, and shared input/output embeddings.
| Model | 3B Dense | 8B Dense | 30B Dense |
|---|---|---|---|
| Embedding size | 2560 | 4096 | 4096 |
| Number of layers | 40 | 40 | 64 |
| Attention head size | 64 | 128 | 128 |
| Number of attention heads | 40 | 32 | 32 |
| Number of KV heads | 8 | 8 | 8 |
| MLP / Shared expert hidden size | 8192 | 12800 | 32768 |
| MLP activation | SwiGLU | SwiGLU | SwiGLU |
| Sequence length | 131072 | 131072 | 131072 |
| Position embedding | RoPE | RoPE | RoPE |
| # Parameters | 3B | 8B | 30B |
- ⭐️ Learn about the latest updates with Granite: https://www.ibm.com/granite
- 📄 Get started with tutorials, best practices, and prompt engineering advice: https://www.ibm.com/granite/docs/
- 💡 Learn about the latest Granite learning resources: https://ibm.biz/granite-learning-resources
Features & Capabilities
| Mode | chat |
| Context Window | 131,072 tokens |
| Max Output | 131,072 tokens |
| Function Calling | Supported |
| Vision | Not supported |
| Reasoning | Not supported |
| Web Search | Not supported |
| Url Context | Not supported |
Technical Details
| Architecture | GraniteForCausalLM |
| Model Type | granite |
| Library | transformers |
API Usage
from openai import OpenAI
client = OpenAI(
base_url="https://api.haimaker.ai/v1",
api_key="YOUR_API_KEY",
)
response = client.chat.completions.create(
model="ibm-granite/granite-4.1-8b",
messages=[
{"role": "user", "content": "Hello, how are you?"}
],
)
print(response.choices[0].message.content)Frequently Asked Questions
What is the context window of granite 4.1 8b?
granite 4.1 8b (ibm-granite/granite-4.1-8b) has a 131,072-token context window and supports up to 131,072 output tokens per request.
How much does granite 4.1 8b cost?
granite 4.1 8b is priced at $0.05 per 1M input tokens and $0.10 per 1M output tokens when accessed via the haimaker.ai OpenAI-compatible API.
What features does granite 4.1 8b support?
granite 4.1 8b supports function calling.
How do I use granite 4.1 8b via API?
Send requests to https://api.haimaker.ai/v1/chat/completions with model "ibm-granite/granite-4.1-8b" using any OpenAI-compatible SDK. Authentication uses a Bearer API key from https://app.haimaker.ai.
Use granite 4.1 8b with the haimaker API
OpenAI-compatible endpoint. Start building in minutes.