ibm-granite/granite-4.2-3b
- License
- apache-2.0
- Size
- not mirrored yet
No official torrent yet — requesting it tells the flock what to host next. You cannot seed a catalog-only page.
Cataloged from ibm-granite/granite-4.2-3b
All models by ibm-granite →No official torrent yet — requesting it tells the flock what to host next. You cannot seed a catalog-only page.
Cataloged from ibm-granite/granite-4.2-3b
All models by ibm-granite →Granite is a family of open-source large language models developed by IBM, designed for enterprise and research use. Granite models are built to be versatile, safe, and efficient — covering a range of sizes and capabilities from compact edge-deployable models to large-scale reasoning systems. All Granite models are released under the Apache 2.0 license, enabling unrestricted commercial and academic use.
The Granite 4.2 generation introduces native reasoning (thinking) capabilities, allowing models to perform step-by-step chain-of-thought reasoning before producing final answers. This significantly improves performance on complex math, coding, multi-step logic, and agentic tool-calling tasks.
Granite-4.2-3B is the compact reasoning model in the Granite 4.2 family. Despite its small parameter count, it delivers strong performance on reasoning-intensive tasks by leveraging built-in <think>...</think> chain-of-thought. It supports flexible thinking modes — full thinking (default), non-thinking, and low-effort — allowing users to balance depth vs. latency on a per-query basis.
Key capabilities:
Granite-4.2-3B is built on a decoder-only dense transformer architecture with the following core components:
Granite-4.2-3B is post-trained from Granite-4.1-3B-Base through a rigorous multi-stage pipeline that progressively unlocks reasoning, tool use, and instruction-following capabilities. A full listing of training datasets is available in the Granite 4.2 GitHub repository. The training pipeline consists of three stages:
Granite-4.2-3B builds on Granite-4.1-3B-Base, which was pre-trained on a large-scale English as well as multilingual corpus. For full pre-training details (data composition, training recipe, and infrastructure), refer to our Granite 4.1 Technical Blog.
The SFT stage draws on instruction-following, chain-of-thought, and reasoning data to cultivate the model's reasoning and thinking abilities. For all the three, 3B, 8B and 30B models, the training corpus comprises four sources: (1) publicly available datasets under permissive licenses, (2) internally generated synthetic data targeting reasoning, tool calling, and chain-of-thought capabilities, (3) agentic traces collected across a diverse range of tasks, and (4) a curated selection of human-authored data. Hyperparameters were tuned before training was scaled to all three model sizes. For the 30B model, we conducted a second SFT phase, in which the agentic data was up-sampled while a smaller share of general replay data was retained. This phase trained for a single epoch, starting from a lower learning rate than Phase 1.
The final stage of training applies multi-phase, multi-environment reinforcement learning using Group Relative Policy Optimization (GRPO). Training spans a broad mix of environments including math, code, science, instruction following, tool use, general chat and structured output. Most environments provide verifiable rewards, while open-ended prompts are scored by a generative reward model. Training runs asynchronously: generation and policy updates occupy separate GPU pools rather than proceeding in lockstep, and weights are refreshed in flight.
After the reward-driven phases, a preference-alignment (RLHF) phase tunes helpfulness, conversational quality, and safety. Reinforcement learning is carried out with NeMo RL, and the RL environments run on NeMo Gym.
Infrastructure: We trained the Granite 4.2 Language Models utilizing an NVIDIA GB200 NVL72 cluster hosted in CoreWeave. Intra-rack communication occurs via the 72-GPU NVLink domain, and a non-blocking, full Fat-Tree NDR 400 Gb/s InfiniBand network provides inter-rack communication.
For further details on the post-training methodology, please refer to the Granite-4.2 Technical Blog.
Evaluations are run with an evaluation framework based on NeMo Evaluator SDK.
Important: Use
temperature=1.0andtop_p=0.95across all tasks and serving backends, including general chat, reasoning, and tool calling.
<|im_start|>assistant\n<think>\n, causing the model to reason until it emits </think>, then produce the final answer.<|im_start|>assistant\n<think></think>, bypassing reasoning entirely.{reasoning effort: low} to the user message, signaling shorter reasoning chains.In multi-turn conversations, thinking content from previous assistant turns is automatically stripped (truncate_history_thinking=True by default) to conserve context window space. Only the current generation produces full reasoning. Set truncate_history_thinking=False to preserve full reasoning history.
Granite-4.2-3B is optimized for deployment with vLLM.
Reasoning parser: Use the custom
granite_thinking_parserincluded in this repository (requires vLLM v0.20+). The model also works with the built-innemotron_v3parser, butgranite_thinking_parserprovides better formatting of reasoning output. Native support for granite_thinking_parser will be added to vLLM and SGLang very soon. Tool calling parser: Useqwen3_coder.
Granite-4.2-3B can also be served with SGLang (v0.5.18+) for high-throughput inference.
Reasoning parser: Use
--reasoning-parser auto, which resolves to the built-innemotron_3parser for this checkpoint. It separates the thinking trace intoreasoning_contentand the final answer intocontent, and it handles all three thinking modes (enable_thinking=True/False,low_effort=True) described in Thinking Modes. Tool calling parser: Use--tool-call-parser auto, which resolves toqwen3_coderfor this checkpoint.
For a full deployment recipe (Docker, H200/B200 launch matrix, thinking-mode examples, and benchmark data), see the SGLang Granite 4.2 cookbook.
Granite-4.2-3B can be used as the backbone model for agentic coding tools. Since it supports reasoning and tool calling via the OpenAI-compatible API, it integrates with popular agentic harnesses out of the box. Start the vLLM server as shown in the Serving with vLLM section above, then follow the harness-specific instructions below.
OpenCode is an AI coding agent that runs in your terminal.
Install:
Configure ~/.config/opencode/opencode.json:
Run:
For full documentation, see opencode.ai/docs.
Pi is a minimal agent harness for AI-powered coding that runs in your terminal. It supports custom providers via a models.json configuration file.
Install:
Configure ~/.pi/agent/models.json:
Run:
Then select the granite-4.2-3b model with /model or Ctrl+L in the interactive session.
For full documentation, see pi.dev/docs.
OpenHands is an AI software engineer that can plan, write code, and execute commands.
Install and launch OpenHands following the official installation guide.
Configure the LLM in the OpenHands settings with:
granite-4.2-3bhttp://localhost:8000/v1--api-key valueNote: The
openai/prefix is required when connecting to OpenAI-compatible endpoints like vLLM. Refer to the OpenHands local LLM documentation for detailed setup instructions, troubleshooting, and alternative installation methods.
Granite-4.2-3B supports tool calling with integrated reasoning — the model thinks about which tool to call and why before making the call. Tools are defined using the OpenAI function definition schema.
Granite 4.2 models are primarily finetuned using instruction-response pairs mostly in English, but also multilingual data covering the supported languages listed above. Although this model handles multilingual dialog, its performance may vary compared to English. Few-shot examples can help in such cases.
While aligned for safety, the model may occasionally produce inaccurate, biased, or unsafe responses. The content within <think>...</think> tags represents internal reasoning and may contain unpolished or intermediate thoughts that do not represent final conclusions.
To enhance safety in deployments, we recommend using Granite 4.2 alongside Granite Guardian to detect and flag risks across key dimensions outlined in the IBM AI Risk Atlas.
vllm serve ibm-granite/granite-4.2-3b \ --served-model-name granite-4.2-3b \ --dtype bfloat16 \ --max-model-len 131072 \ --reasoning-parser granite_thinking_parser \ --reasoning-parser-plugin ./granite_thinking_parser.py \ --tool-call-parser qwen3_coder \ --enable-auto-tool-choicefrom openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="unused")
response = client.chat.completions.create( model="granite-4.2-3b", messages=[{"role": "user", "content": "Explain the Riemann hypothesis in simple terms."}], temperature=1.0, top_p=0.95, max_tokens=8192,)
print(response.choices[0].message.content)from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="unused")
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"] } } }]
response = client.chat.completions.create( model="granite-4.2-3b", messages=[{"role": "user", "content": "What's the weather like in Boston right now?"}], tools=tools, temperature=1.0, top_p=0.95, max_tokens=4096,)
print(response.choices[0].message.tool_calls)python3 -m sglang.launch_server \ --model-path ibm-granite/granite-4.2-3b \ --dtype bfloat16 \ --context-length 131072 \ --reasoning-parser auto \ --tool-call-parser autofrom openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="unused")
response = client.chat.completions.create( model="ibm-granite/granite-4.2-3b", messages=[{"role": "user", "content": "Explain the Riemann hypothesis in simple terms."}], temperature=1.0, top_p=0.95, max_tokens=8192,)
print(response.choices[0].message.reasoning_content)print(response.choices[0].message.content)from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="unused")
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"] } } }]
response = client.chat.completions.create( model="ibm-granite/granite-4.2-3b", messages=[{"role": "user", "content": "What's the weather like in Boston right now?"}], tools=tools, temperature=1.0, top_p=0.95, max_tokens=4096,)
print(response.choices[0].message.tool_calls)curl -fsSL https://opencode.ai/install | bash{ "$schema": "https://opencode.ai/config.json", "model": "local/granite-4.2-3b", "provider": { "local": { "npm": "@ai-sdk/openai-compatible", "name": "vLLM (local)", "options": { "baseURL": "http://localhost:8000/v1", "apiKey": "EMPTY" }, "models": { "granite-4.2-3b": { "name": "Granite 4.2 3B", "limit": { "context": 131072, "output": 8192 } } } } }}opencodeopencode run "your task description"curl -fsSL https://pi.dev/install.sh | sh{ "providers": { "vllm": { "baseUrl": "http://localhost:8000/v1", "api": "openai-completions", "apiKey": "EMPTY", "compat": { "supportsDeveloperRole": false, "supportsReasoningEffort": false }, "models": [ { "id": "granite-4.2-3b", "name": "Granite 4.2 3B", "reasoning": true, "input": ["text"], "contextWindow": 131072, "maxTokens": 8192, "samplingParams": { "temperature": 1.0, "top_p": 0.95 }, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 } } ] } }}pipip install torch torchvision torchaudiopip install accelerate transformersimport torchfrom transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "ibm-granite/granite-4.2-3b"tokenizer = AutoTokenizer.from_pretrained(model_path)model = AutoModelForCausalLM.from_pretrained(model_path, device_map="cuda", torch_dtype=torch.bfloat16)model.eval()
messages = [ {"role": "user", "content": "How many r's are in the word 'strawberry'?"},]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad(): output = model.generate(**inputs, max_new_tokens=8192, temperature=1.0, top_p=0.95, do_sample=True)
print(tokenizer.decode(output[0][inputs.input_ids.shape[-1]:], skip_special_tokens=False))<think>Okay, let's see. The problem is to find how many 'r's are in the word 'strawberry'.
First, I need to write out the word: s t r a w b e r r y.
Now, I need to count the number of 'r' letters. Let's list each letter and check for 'r'.
1. s – not r2. t – not r3. r – yes, that's one4. a – no5. w – no6. b – no7. e – no8. r – yes, that's two9. r – yes, that's three10. y – no
Total r's = 3.</think>There are **3** r's in the word "strawberry".<|im_end|>messages = [ {"role": "user", "content": "What is the capital of France?"},]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=2048, temperature=1.0, top_p=0.95, do_sample=True)print(tokenizer.decode(output[0][inputs.input_ids.shape[-1]:], skip_special_tokens=False))<think></think>The capital of France is Paris.<|im_end|>messages = [ {"role": "user", "content": "What is 2 + 2?"},]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True, low_effort=True)inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=4096, temperature=1.0, top_p=0.95, do_sample=True)print(tokenizer.decode(output[0][inputs.input_ids.shape[-1]:], skip_special_tokens=False))<think>Simple answer.</think>2 + 2 = 4.<|im_end|>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"] } } }]
messages = [ {"role": "user", "content": "What's the weather like in Boston right now?"},]text = tokenizer.apply_chat_template(messages, tokenize=False, tools=tools, add_generation_prompt=True, enable_thinking=True)inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=4096, temperature=1.0, top_p=0.95, do_sample=True)print(tokenizer.decode(output[0][inputs.input_ids.shape[-1]:], skip_special_tokens=False))<think>Okay, the user is asking for the weather in Boston right now. Let me check the toolsavailable. There's a function called get_current_weather that takes a city parameter.I need to call that with the city set to Boston.</think><tool_call><function=get_current_weather><parameter=city>Boston</parameter></function></tool_call><|im_end|>messages = [ {"role": "user", "content": "What's the weather like in Boston right now?"}, {"role": "assistant", "content": "<think>\nThe user wants to know the current weather in Boston. I should call get_current_weather.\n</think>", "tool_calls": [{"function": {"name": "get_current_weather", "arguments": {"city": "Boston"}}}]}, {"role": "tool", "content": '{"temperature": "72°F", "condition": "Partly cloudy", "humidity": "65%"}'},]text = tokenizer.apply_chat_template(messages, tokenize=False, tools=tools, add_generation_prompt=True, enable_thinking=True)inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=4096, temperature=1.0, top_p=0.95, do_sample=True)print(tokenizer.decode(output[0][inputs.input_ids.shape[-1]:], skip_special_tokens=False))<think>The tool returned the weather data for Boston: temperature 72°F, partly cloudy, humidity 65%.I need to present this information clearly to the user.</think>The current weather in Boston is 72°F, partly cloudy, with 65% humidity.<|im_end|>messages = [ {"role": "user", "content": "What is 15 * 37?"}, {"role": "assistant", "content": "<think>\nLet me calculate 15 * 37.\n15 * 37 = 15 * 30 + 15 * 7 = 450 + 105 = 555\n</think>\n15 * 37 = 555"}, {"role": "user", "content": "Now divide that by 5"},]
# Default: previous thinking is stripped to save contexttext = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True, truncate_history_thinking=True)
# To preserve full history:text_full = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True, truncate_history_thinking=False)import re
def parse_model_output(text): """Separate thinking content from final answer.""" think_match = re.search(r'<think>(.*?)</think>', text, re.DOTALL) if think_match: thinking = think_match.group(1).strip() answer_start = text.find('</think>') + len('</think>') answer_end = text.find('<|im_end|>', answer_start) answer = text[answer_start:answer_end].strip() if answer_end != -1 else text[answer_start:].strip() else: thinking, answer = "", text.strip() return thinking, answer
thinking, answer = parse_model_output(output_text)