Text Generation
Transformers
Safetensors
English
German
multilingual
k2_horizon
ocean-horizon
3.7b
dense
open-weights
oceanlabs
long-context
reasoning
agentic
custom_code
Instructions to use OceanLabs/Ocean-3.7B-coding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OceanLabs/Ocean-3.7B-coding with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OceanLabs/Ocean-3.7B-coding", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("OceanLabs/Ocean-3.7B-coding", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OceanLabs/Ocean-3.7B-coding with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OceanLabs/Ocean-3.7B-coding" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OceanLabs/Ocean-3.7B-coding", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OceanLabs/Ocean-3.7B-coding
- SGLang
How to use OceanLabs/Ocean-3.7B-coding 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 "OceanLabs/Ocean-3.7B-coding" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OceanLabs/Ocean-3.7B-coding", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "OceanLabs/Ocean-3.7B-coding" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OceanLabs/Ocean-3.7B-coding", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OceanLabs/Ocean-3.7B-coding with Docker Model Runner:
docker model run hf.co/OceanLabs/Ocean-3.7B-coding
Delete README.md
Browse files
README.md
DELETED
|
@@ -1,225 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
pipeline_tag: text-generation
|
| 3 |
-
library_name: transformers
|
| 4 |
-
model_name: K2-Horizon-3.7B
|
| 5 |
-
language:
|
| 6 |
-
- en
|
| 7 |
-
license: apache-2.0
|
| 8 |
-
datasets:
|
| 9 |
-
- IFM/K2-Horizon-Pretrain-Data
|
| 10 |
-
- IFM/K2-Horizon-Midtrain-Data
|
| 11 |
-
tags:
|
| 12 |
-
- k2-horizon
|
| 13 |
-
- 3.7b
|
| 14 |
-
- dense
|
| 15 |
-
- open-weights
|
| 16 |
-
- ifm
|
| 17 |
-
---
|
| 18 |
-
** not finished **
|
| 19 |
-
|
| 20 |
-
# K2-Horizon-3.7B
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
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.
|
| 24 |
-
|
| 25 |
-
<p align="center">
|
| 26 |
-
<img src="assets/k2-horizon-3.7b-benchmarks.png" alt="K2-Horizon-3.7B benchmark results" width="100%">
|
| 27 |
-
</p>
|
| 28 |
-
|
| 29 |
-
## K2-Horizon-3.7B Highlights
|
| 30 |
-
|
| 31 |
-
- **Strong small-model baseline.** A dense model evaluated on the same agentic, coding, and reasoning benchmarks as the rest of the family.
|
| 32 |
-
- **512K context.** Native 524,288-token context from the midtraining stages onward.
|
| 33 |
-
- **Intermediate checkpoints.** Intermediate checkpoints are released so capability changes can be studied across training rather than at a single checkpoint.
|
| 34 |
-
- **Fully open.** Training data and recipe, training code, and evaluation resources are public.
|
| 35 |
-
|
| 36 |
-
## Benchmark Results
|
| 37 |
-
|
| 38 |
-
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.
|
| 39 |
-
|
| 40 |
-
### Full Results
|
| 41 |
-
|
| 42 |
-
<!-- TABLE:START -->
|
| 43 |
-
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;margin:0 auto;padding:8px 0 16px;overflow-x:auto"><table style="display:table;width:100%;table-layout:fixed;border-collapse:collapse;font-size:12px;margin:0"><thead><tr><th style="width:30%;border-bottom:none"></th><th colspan="5" style="padding:6px 4px 2px;text-align:center;font-size:11px;font-weight:600;letter-spacing:0.04em;text-transform:uppercase;opacity:0.65;border-bottom:1px solid rgba(128,128,128,0.25)">Open-weight dense models</th></tr><tr><th style="padding:10px 6px;text-align:left;border-bottom:2px solid #2450D6"></th><th style="padding:10px 3px;text-align:center;font-weight:600;border-bottom:2px solid #2450D6;color:#2450D6;font-size:12.5px;line-height:1.2;width:14%;overflow-wrap:anywhere;background:rgba(36,80,214,0.08);">K2-Horizon-3.7B</th><th style="padding:10px 3px;text-align:center;font-weight:600;border-bottom:2px solid #2450D6;color:#2450D6;font-size:12.5px;line-height:1.2;width:14%;overflow-wrap:anywhere;">Qwen3.5-4B</th><th style="padding:10px 3px;text-align:center;font-weight:600;border-bottom:2px solid #2450D6;color:#2450D6;font-size:12.5px;line-height:1.2;width:14%;overflow-wrap:anywhere;">G9v3-3B</th><th style="padding:10px 3px;text-align:center;font-weight:600;border-bottom:2px solid #2450D6;color:#2450D6;font-size:12.5px;line-height:1.2;width:14%;overflow-wrap:anywhere;">Granite 4.2-3B</th><th style="padding:10px 3px;text-align:center;font-weight:600;border-bottom:2px solid #2450D6;color:#2450D6;font-size:12.5px;line-height:1.2;width:14%;overflow-wrap:anywhere;">Nemotron 3 Nano-4B</th></tr></thead><tbody><tr><td style="padding:7px 4px 7px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;font-weight:600"># Params</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);">3.7B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">4B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">3B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">3B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">4B</td></tr><tr><td style="padding:7px 4px 7px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;font-weight:600"># Activated params</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);">3.7B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">4B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">3B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">3B</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">4B</td></tr><tr><td style="padding:7px 4px 7px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;font-weight:600">Architecture</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);">Dense</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">Dense</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">Dense</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">Dense</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">Dense</td></tr><tr><td colspan="6" style="padding:6px 10px;font-weight:600;font-size:12.5px;color:#2450D6;border-bottom:1px solid rgba(36,80,214,0.25);background:rgba(36,80,214,0.12)">Math</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">HMMT Feb 2026</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Competition mathematics</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>70.5</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">61.6</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">34.1</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">57.2</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">34.7</td></tr><tr><td colspan="6" style="padding:6px 10px;font-weight:600;font-size:12.5px;color:#2450D6;border-bottom:1px solid rgba(36,80,214,0.25);background:rgba(36,80,214,0.12)">Coding</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">SWE-bench Verified</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Software engineering</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>68.6</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">41.2</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">16.4</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">32.2</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">1.8</td></tr><tr><td colspan="6" style="padding:6px 10px;font-weight:600;font-size:12.5px;color:#2450D6;border-bottom:1px solid rgba(36,80,214,0.25);background:rgba(36,80,214,0.12)">Scientific Reasoning</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">GPQA Diamond</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Graduate-level science QA</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>65.4</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">77.1</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">43.8</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">55.9</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">51.3</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">HLE</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Expert-level reasoning</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>12.9</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">9.9</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">4.5</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">6.6</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">4.9</td></tr><tr><td colspan="6" style="padding:6px 10px;font-weight:600;font-size:12.5px;color:#2450D6;border-bottom:1px solid rgba(36,80,214,0.25);background:rgba(36,80,214,0.12)">Coding</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">SciCode</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Scientific coding</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>25.9</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">16.1</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">17.7</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">24.9</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">16.4</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">Terminal-Bench 2.1</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Agentic terminal use</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>25.1</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">25.8</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">6.0</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">13.9</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">3.7</td></tr><tr><td colspan="6" style="padding:6px 10px;font-weight:600;font-size:12.5px;color:#2450D6;border-bottom:1px solid rgba(36,80,214,0.25);background:rgba(36,80,214,0.12)">Agents</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">tau3-Banking</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Agentic tool use</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>17.7</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">6.8</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">—</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">5.6</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">—</td></tr><tr><td style="padding:6px 4px 6px 10px;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle"><div style="font-size:12.5px;font-weight:600;line-height:1.2">BFCL v4</div><div style="margin-top:2px;font-size:10px;opacity:0.65">Function calling</div></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;background:rgba(36,80,214,0.08);"><strong>50.9</strong></td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">55.7</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">47.9</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">50.8</td><td style="padding:6px 2px;text-align:center;border-bottom:1px solid rgba(128,128,128,0.15);vertical-align:middle;font-size:12.5px;line-height:1.2;">36.8</td></tr></tbody></table></div>
|
| 44 |
-
<!-- TABLE:END -->
|
| 45 |
-
|
| 46 |
-
Scores in %. Bold marks the best score in each row. Baseline protocols may differ;
|
| 47 |
-
|
| 48 |
-
## Quickstart
|
| 49 |
-
|
| 50 |
-
### Serving
|
| 51 |
-
|
| 52 |
-
vLLM, recipe at [recipes.vllm.ai/IFM](https://recipes.vllm.ai/IFM):
|
| 53 |
-
|
| 54 |
-
```shell
|
| 55 |
-
vllm serve IFM/K2-Horizon-3.7B \
|
| 56 |
-
--trust-remote-code \
|
| 57 |
-
--dtype bfloat16 \
|
| 58 |
-
--tensor-parallel-size 1 \
|
| 59 |
-
--reasoning-parser k2_horizon \
|
| 60 |
-
--enable-auto-tool-choice \
|
| 61 |
-
--tool-call-parser k2_horizon
|
| 62 |
-
```
|
| 63 |
-
|
| 64 |
-
Use an exact branch name from the inventory with vLLM's `--revision` option. For example, `--revision pretrain_1100000` selects the final checkpoint of Pretraining, at step 1,100,000.
|
| 65 |
-
|
| 66 |
-
SGLang, this is the recipe validated in the [SGLang K2 Horizon cookbook](https://docs.sglang.io/cookbook/autoregressive/IFM/K2-Horizon):
|
| 67 |
-
|
| 68 |
-
```shell
|
| 69 |
-
sglang serve \
|
| 70 |
-
--model-path IFM/K2-Horizon-3.7B \
|
| 71 |
-
--revision 09568bab0d7ee4152a12ee13c21902ca910d15b2 \
|
| 72 |
-
--tp 1 \
|
| 73 |
-
--dtype bfloat16 \
|
| 74 |
-
--attention-backend fa3 \
|
| 75 |
-
--reasoning-parser k2_horizon \
|
| 76 |
-
--host 0.0.0.0 \
|
| 77 |
-
--port 30000
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
-
### API Usage
|
| 81 |
-
|
| 82 |
-
> [!Tip]
|
| 83 |
-
> Recommended settings: `reasoning_effort="high"`, `temperature=1.0`, `top_p=0.95`, and at least 32,768 output tokens.
|
| 84 |
-
> Reasoning depth is selected per request through `chat_template_kwargs`. Thinking is returned in `reasoning_content` and the answer in `content`.
|
| 85 |
-
|
| 86 |
-
```python
|
| 87 |
-
from openai import OpenAI
|
| 88 |
-
|
| 89 |
-
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
|
| 90 |
-
response = client.chat.completions.create(
|
| 91 |
-
model="IFM/K2-Horizon-3.7B",
|
| 92 |
-
messages=[{"role": "user", "content": "Explain the result step by step."}],
|
| 93 |
-
temperature=1.0,
|
| 94 |
-
top_p=0.95,
|
| 95 |
-
max_tokens=32768,
|
| 96 |
-
extra_body={"chat_template_kwargs": {"reasoning_effort": "high"}},
|
| 97 |
-
)
|
| 98 |
-
message = response.choices[0].message
|
| 99 |
-
print("Reasoning:", getattr(message, "reasoning_content", None))
|
| 100 |
-
print("Answer:", message.content)
|
| 101 |
-
```
|
| 102 |
-
|
| 103 |
-
### Transformers
|
| 104 |
-
|
| 105 |
-
Validated with Transformers 5.15.0, PyTorch 2.13.0, Safetensors 0.8.0.
|
| 106 |
-
|
| 107 |
-
```python
|
| 108 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 109 |
-
|
| 110 |
-
model_id = "IFM/K2-Horizon-3.7B"
|
| 111 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 112 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 113 |
-
model_id, device_map="auto", dtype="bfloat16", low_cpu_mem_usage=True, trust_remote_code=True
|
| 114 |
-
)
|
| 115 |
-
|
| 116 |
-
inputs = tokenizer("Explain why long-context evaluation is difficult.", return_tensors="pt").to(model.device)
|
| 117 |
-
inputs.pop("token_type_ids", None)
|
| 118 |
-
outputs = model.generate(**inputs, max_new_tokens=32768, temperature=1.0, top_p=0.95, do_sample=True)
|
| 119 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 120 |
-
```
|
| 121 |
-
|
| 122 |
-
## Training Overview
|
| 123 |
-
|
| 124 |
-
The table below lists the training stages in order and the purpose of each stage.
|
| 125 |
-
|
| 126 |
-
Training steps are counted within each stage or phase. Token budgets cover only the additional training in that stage or phase. For example, the 50B tokens listed for SFT Phase 2 are additional to the 219B tokens in Phase 1, bringing the cumulative budget to 269B tokens by the end of Phase 2. Here, B and T denote billion and trillion tokens, respectively.
|
| 127 |
-
|
| 128 |
-
Each stage or phase continues from the final checkpoint of the preceding stage or phase.
|
| 129 |
-
|
| 130 |
-
Some stages, such as SFT, have multiple phases with slight changes to the data mix while retaining the same overall purpose. During RL, training branches into multiple expert models, which are then merged, as described below.
|
| 131 |
-
|
| 132 |
-
| Training stage | Training steps | Training tokens | Sequence length | Purpose |
|
| 133 |
-
| --- | --- | --- | --- | --- |
|
| 134 |
-
| Pretraining | 1100000 | 22.9T | 8K | Pretraining. |
|
| 135 |
-
| Midtraining — Stage 1 | 55000 | 1.1T | 32K | Context extension. |
|
| 136 |
-
| Midtraining — Stage 2 | 25000 | 498B | 128K | Context extension. |
|
| 137 |
-
| Midtraining — Stage 3 | 5500 | 110B | 512K | Context extension. |
|
| 138 |
-
| Midtraining — Stage 4 | 10000 | 199B | 512K | Continued context extension from Stage 3, with the data mix shifted toward agentic and reasoning SFT data. |
|
| 139 |
-
| RL — Math expert | 2549 | 28.9B | 64K | Math RL from Midtraining Stage 4; common ancestor of the Code and STEM-Code experts. |
|
| 140 |
-
| RL — Code expert | 949 | 15.5B | 64K | Code RL from the Math expert. |
|
| 141 |
-
| RL — STEM-Code expert | 451 | 1.3B | 64K | STEM and code RL from the Math expert. |
|
| 142 |
-
| RL — Merge | — | — | — | ISO merge on self-attention, RAM on the remaining weights; inputs: Midtraining Stage 4 base + Math, Code, STEM-Code experts. |
|
| 143 |
-
| SFT — Phase 1 | 10000 | 199B | 512K | SFT for better domain coverage, starting from the merged RL checkpoint. |
|
| 144 |
-
| SFT — Phase 2 | 2500 | 50B | 512K | SFT on a high-quality subset of the data used in Phase 1, with learning rate decay. |
|
| 145 |
-
|
| 146 |
-
## Release Artifacts
|
| 147 |
-
|
| 148 |
-
The tables below list the release artifacts for **K2-Horizon-3.7B**, their availability, and the expected release dates for remaining items.
|
| 149 |
-
|
| 150 |
-
**Last updated:** 2026-09-11
|
| 151 |
-
|
| 152 |
-
**Status:**
|
| 153 |
-
|
| 154 |
-
- **Available** — fully released for the scope listed;
|
| 155 |
-
- **Partial** — some items are available, with remaining items listed in the notes;
|
| 156 |
-
- **In Progress** — being prepared for release but not yet available.
|
| 157 |
-
|
| 158 |
-
### Artifact Index
|
| 159 |
-
|
| 160 |
-
| Artifact | Link | Status | Remaining items / expected availability |
|
| 161 |
-
| --- | --- | --- | --- |
|
| 162 |
-
| Model card | [Hugging Face](https://huggingface.co/IFM/K2-Horizon-3.7B) | Available | N/A |
|
| 163 |
-
| Training logs | [W&B](https://wandb.ai/llm360/K2-Horizon-3.7B) | Available | N/A |
|
| 164 |
-
| Blog post | [Blog post](https://ifm.ai/blog/k2/) | Available | N/A |
|
| 165 |
-
| Checkpoints | [Checkpoint inventory](#checkpoint-inventory) | Available | N/A |
|
| 166 |
-
| Technical report | Not yet available | In Progress | End of September 2026 |
|
| 167 |
-
| Code repository | [GitHub](https://github.com/ifm-ai/xllm) | In Progress | End of September 2026 |
|
| 168 |
-
|
| 169 |
-
### Checkpoint Inventory
|
| 170 |
-
|
| 171 |
-
**Model repository:** [IFM/K2-Horizon-3.7B](https://huggingface.co/IFM/K2-Horizon-3.7B)
|
| 172 |
-
|
| 173 |
-
Branch names below refer to this repository. Patterns containing `*` group branches by training stage or phase. The `*` is a placeholder for a training-step number, not a literal branch name. Intermediate checkpoint groups exclude the final checkpoint listed separately; a pattern does not imply that a checkpoint is available at every step.
|
| 174 |
-
|
| 175 |
-
For example, `sft_1_10000` is the checkpoint saved at training step 11,000 within SFT Phase 1, and is the final checkpoint of that phase. The numeric suffix is the step within the named stage or phase, not the cumulative step across all training. Thus, `sft_2_2500` refers to step 2,500 within SFT Phase 2.
|
| 176 |
-
|
| 177 |
-
For a partially released group, the available checkpoints and the remaining checkpoints are listed in the notes.
|
| 178 |
-
|
| 179 |
-
| Checkpoint | Branch / repository | Status | Remaining items / expected availability |
|
| 180 |
-
| --- | --- | --- | --- |
|
| 181 |
-
| Pretrain Intermediate Checkpoints | `pretrain_*` | Available | N/A |
|
| 182 |
-
| Pretrain Final Checkpoint | `pretrain_1100000` | Available | N/A |
|
| 183 |
-
| Midtrain Stage 1 Intermediate Checkpoints | `mid_1_*` | Available | N/A |
|
| 184 |
-
| Midtrain Stage 1 Final Checkpoint | `mid_1_55000` | Available | N/A |
|
| 185 |
-
| Midtrain Stage 2 Intermediate Checkpoints | `mid_2_*` | Available | N/A |
|
| 186 |
-
| Midtrain Stage 2 Final Checkpoint | `mid_2_25000` | Available | N/A |
|
| 187 |
-
| Midtrain Stage 3 Intermediate Checkpoints | `mid_3_*` | Available | N/A |
|
| 188 |
-
| Midtrain Stage 3 Final Checkpoint | `mid_3_5500` | Available | N/A |
|
| 189 |
-
| Midtrain Stage 4 Intermediate Checkpoints | `mid_4_*` | Available | N/A |
|
| 190 |
-
| Midtrain Stage 4 Final Checkpoint | `mid_4_10000` | Available | N/A |
|
| 191 |
-
| RL Math Expert Checkpoint | `rl_math` | Available | N/A |
|
| 192 |
-
| RL Code Expert Checkpoint | `rl_code` | Available | N/A |
|
| 193 |
-
| RL Stem Code Expert Checkpoint | `rl_stemcode` | Available | N/A |
|
| 194 |
-
| RL Merged Final Checkpoint | `rl_merged` | Available | N/A |
|
| 195 |
-
| SFT Phase 1 Intermediate Checkpoints | `sft_1_*` | Available | N/A |
|
| 196 |
-
| SFT Phase 1 Final Checkpoint | `sft_1_10000` | Available | N/A |
|
| 197 |
-
| SFT Phase 2 Intermediate Checkpoints | `sft_2_*` | Available | N/A |
|
| 198 |
-
| SFT Phase 2 Final Checkpoint | `sft_2_2500` | Available | N/A |
|
| 199 |
-
|
| 200 |
-
> [!IMPORTANT]
|
| 201 |
-
> Note:
|
| 202 |
-
> - Released K2-Horizon Hugging Face checkpoints (e.g. [Huggingface](https://huggingface.co/IFM/K2-Horizon-375B-A23B/tree/main)) can be used for inference, evaluation, and downstream fine-tuning (including SFT).
|
| 203 |
-
> Training behavior in the bundled Hugging Face implementation may differ from native xLLM, including the auxiliary load-balancing loss.
|
| 204 |
-
> To continue the original pretraining with xLLM's training behavior, use the native xLLM checkpoint and XLLM runtime.
|
| 205 |
-
|
| 206 |
-
## Best Practices
|
| 207 |
-
|
| 208 |
-
1. **Reasoning effort: always `high`.** All reported results use high reasoning effort. Pass `{"chat_template_kwargs": {"reasoning_effort": "high"}}` on every request; `medium` and `low` trade accuracy for speed and are not recommended for evaluation.
|
| 209 |
-
2. **Sampling parameters.** `temperature=1.0`, `top_p=0.95`.
|
| 210 |
-
3. **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.
|
| 211 |
-
4. **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](https://docs.sglang.io/cookbook/autoregressive/IFM/K2-Horizon).
|
| 212 |
-
5. **Parsers.** Enable the `k2_horizon` reasoning parser for chat, and add the `k2_horizon` tool-call parser for agent use. Leave both off for plain completion-style generation.
|
| 213 |
-
6. **Revisions.** Pin a revision tag when reproducibility matters. `main` is the default checkpoint; `base_final` and the `mid_*_final` tags identify training stages.
|
| 214 |
-
|
| 215 |
-
## Citation
|
| 216 |
-
|
| 217 |
-
```bibtex
|
| 218 |
-
@misc{k2horizon2026,
|
| 219 |
-
title = {Introducing K2 Horizon: Frontier Performance, Radically Open},
|
| 220 |
-
author = {{IFM Team}},
|
| 221 |
-
year = {2026},
|
| 222 |
-
url = {https://ifm.ai/blog/k2/},
|
| 223 |
-
}
|
| 224 |
-
```
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|