Instructions to use IFM/K2-Horizon-3.7B-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IFM/K2-Horizon-3.7B-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="IFM/K2-Horizon-3.7B-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("IFM/K2-Horizon-3.7B-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use IFM/K2-Horizon-3.7B-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf IFM/K2-Horizon-3.7B-GGUF:BF16 # Run inference directly in the terminal: llama cli -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf IFM/K2-Horizon-3.7B-GGUF:BF16 # Run inference directly in the terminal: llama cli -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf IFM/K2-Horizon-3.7B-GGUF:BF16 # Run inference directly in the terminal: ./llama-cli -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf IFM/K2-Horizon-3.7B-GGUF:BF16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Use Docker
docker model run hf.co/IFM/K2-Horizon-3.7B-GGUF:BF16
- LM Studio
- Jan
- vLLM
How to use IFM/K2-Horizon-3.7B-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "IFM/K2-Horizon-3.7B-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IFM/K2-Horizon-3.7B-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/IFM/K2-Horizon-3.7B-GGUF:BF16
- SGLang
How to use IFM/K2-Horizon-3.7B-GGUF 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 "IFM/K2-Horizon-3.7B-GGUF" \ --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": "IFM/K2-Horizon-3.7B-GGUF", "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 "IFM/K2-Horizon-3.7B-GGUF" \ --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": "IFM/K2-Horizon-3.7B-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use IFM/K2-Horizon-3.7B-GGUF with Ollama:
ollama run hf.co/IFM/K2-Horizon-3.7B-GGUF:BF16
- Unsloth Desktop
- Pi
How to use IFM/K2-Horizon-3.7B-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "IFM/K2-Horizon-3.7B-GGUF:BF16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use IFM/K2-Horizon-3.7B-GGUF with Docker Model Runner:
docker model run hf.co/IFM/K2-Horizon-3.7B-GGUF:BF16
- Lemonade
How to use IFM/K2-Horizon-3.7B-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull IFM/K2-Horizon-3.7B-GGUF:BF16
Run and chat with the model
lemonade run user.K2-Horizon-3.7B-GGUF-BF16
List all available models
lemonade list
- Hermes Agent
How to use IFM/K2-Horizon-3.7B-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default IFM/K2-Horizon-3.7B-GGUF:BF16
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use IFM/K2-Horizon-3.7B-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf IFM/K2-Horizon-3.7B-GGUF:BF16
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "IFM/K2-Horizon-3.7B-GGUF:BF16" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
K2-Horizon-3.7B-GGUF
This repository contains GGUF versions of the IFM/K2-Horizon-3.7B for use with
llama.cpp.The model tensors are stored in their original BF16 precision. The GGUF files include the tokenizer metadata and a
llama.cpp-compatible chat template.Compatibility: These models require a version of
llama.cppcontaining K2 Horizon architecture support. PR to llama.cpp is in progress. MBZUAI-IFM fork of llama.cpp is in https://github.com/MBZUAI-IFM/llama.cpp/tree/model/K2Horizon
K2-Horizon-3.7B is the small dense member of the K2-Horizon family: a 3.7B-core decoder-only model with a 512K context window.
K2-Horizon-3.7B Highlights
- Strong small-model baseline. A dense model evaluated on the same agentic, coding, and reasoning benchmarks as the rest of the family.
- 512K context. Native 524,288-token context from the midtraining stages onward.
- Intermediate checkpoints. Intermediate checkpoints are released so capability changes can be studied across training rather than at a single checkpoint.
- Fully open. Training data and recipe, training code, and evaluation resources are public.
Benchmark Results
The chart at the top of this card shows K2-Horizon-3.7B against selected reference models. The table below lists every comparison model used in the figure.
Full Results
| Open-weight dense models | |||||
|---|---|---|---|---|---|
| K2-Horizon-3.7B | Qwen3.5-4B | G9v3-3B | Granite 4.2-3B | Nemotron 3 Nano-4B | |
| # Params | 3.7B | 4B | 3B | 3B | 4B |
| # Activated params | 3.7B | 4B | 3B | 3B | 4B |
| Architecture | Dense | Dense | Dense | Dense | Dense |
| Math | |||||
HMMT Feb 2026 Competition mathematics | 70.5 | 61.6 | 34.1 | 57.2 | 34.7 |
| Coding | |||||
SWE-bench Verified Software engineering | 68.6 | 41.2 | 16.4 | 32.2 | 1.8 |
| Scientific Reasoning | |||||
GPQA Diamond Graduate-level science QA | 65.4 | 77.1 | 43.8 | 55.9 | 51.3 |
HLE Expert-level reasoning | 12.9 | 9.9 | 4.5 | 6.6 | 4.9 |
| Coding | |||||
SciCode Scientific coding | 25.9 | 16.1 | 17.7 | 24.9 | 16.4 |
Terminal-Bench 2.1 Agentic terminal use | 25.1 | 25.8 | 6.0 | 13.9 | 3.7 |
| Agents | |||||
tau3-Banking Agentic tool use | 17.7 | 6.8 | — | 5.6 | — |
BFCL v4 Function calling | 50.9 | 55.7 | 47.9 | 50.8 | 36.8 |
Scores in %. Bold marks the best score in each row. Baseline protocols may differ;
Quickstart
Serving
vLLM, recipe at recipes.vllm.ai/IFM:
vllm serve IFM/K2-Horizon-3.7B \
--trust-remote-code \
--dtype bfloat16 \
--max-model-len 131072 \
--tensor-parallel-size 1 \
--reasoning-parser k2_horizon \
--enable-auto-tool-choice \
--tool-call-parser k2_horizon
SGLang, this is the recipe validated in the SGLang K2 Horizon cookbook:
sglang serve \
--model-path IFM/K2-Horizon-3.7B \
--revision c177771836a4c460743c00002c22483f6f18d1eb \
--tp 1 \
--dtype bfloat16 \
--attention-backend fa3 \
--reasoning-parser k2_horizon \
--host 0.0.0.0 \
--port 30000
API Usage
Recommended settings:
reasoning_effort="high",temperature=1.0,top_p=0.95, and at least 32,768 output tokens. Reasoning depth is selected per request throughchat_template_kwargs. Thinking is returned inreasoning_contentand the answer incontent.
from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="IFM/K2-Horizon-3.7B",
messages=[{"role": "user", "content": "Explain the result step by step."}],
temperature=1.0,
top_p=0.95,
max_tokens=32768,
extra_body={"chat_template_kwargs": {"reasoning_effort": "high", "tool_call_format": "xml"}},
)
message = response.choices[0].message
print("Reasoning:", getattr(message, "reasoning_content", None))
print("Answer:", message.content)
Our model supports multiple tool calls formats, which can be changed with chat_template_kwargs. The supported values are json, xml, and xml_typed . The default is xml. Keep --tool-call-parser k2_horizon enabled to parse the selected format.
Transformers
Validated with Transformers 5.15.0, PyTorch 2.13.0, Safetensors 0.8.0.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "IFM/K2-Horizon-3.7B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id, device_map="auto", dtype="bfloat16", low_cpu_mem_usage=True, trust_remote_code=True
)
inputs = tokenizer("Explain why long-context evaluation is difficult.", return_tensors="pt").to(model.device)
inputs.pop("token_type_ids", None)
outputs = model.generate(**inputs, max_new_tokens=32768, temperature=1.0, top_p=0.95, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Best Practices
- Reasoning effort: always
high. All reported results use high reasoning effort. Pass{"chat_template_kwargs": {"reasoning_effort": "high"}}on every request;mediumandlowtrade accuracy for speed and are not recommended for evaluation. - Sampling parameters.
temperature=1.0,top_p=0.95. - Output length. Allow at least 32,768 output tokens so reasoning is never cut off. Truncated reasoning is a failed response, not a shorter one.
- Serving. Use the validated SGLang recipe above: BF16, TP=1, FlashAttention-3. Full recipes for every K2-Horizon size, with measured H200 latency and throughput, are in the SGLang cookbook.
- Parsers. Enable the
k2_horizonreasoning parser for chat, and add thek2_horizontool-call parser for agent use. Leave both off for plain completion-style generation. - Revisions. Pin a revision tag when reproducibility matters.
mainis the default checkpoint;base_finaland themid_*_finaltags identify training stages.
Citation
@misc{k2horizon2026,
title = {Introducing K2 Horizon: Frontier Performance, Radically Open},
author = {{IFM Team}},
year = {2026},
url = {https://ifm.ai/blog/k2/},
}
- Downloads last month
- -
16-bit