Text Generation
Transformers
Safetensors
English
Chinese
k2_horizon
k2-horizon
0.9b
dense
reasoning
knowledge-distillation
ifm
conversational
custom_code
Instructions to use IFM/K2-Horizon-0.9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IFM/K2-Horizon-0.9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="IFM/K2-Horizon-0.9B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("IFM/K2-Horizon-0.9B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use IFM/K2-Horizon-0.9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "IFM/K2-Horizon-0.9B" # 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-0.9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/IFM/K2-Horizon-0.9B
- SGLang
How to use IFM/K2-Horizon-0.9B 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-0.9B" \ --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-0.9B", "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-0.9B" \ --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-0.9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use IFM/K2-Horizon-0.9B with Docker Model Runner:
docker model run hf.co/IFM/K2-Horizon-0.9B
Commit ·
070513c
1
Parent(s): d9eb85d
docs: update SGLang quickstart (#1)
Browse files- docs: update SGLang quickstart (fec9b26a370afbc43d5a68d00fdf4adee1d6022d)
README.md
CHANGED
|
@@ -338,7 +338,45 @@ print(message.content)
|
|
| 338 |
|
| 339 |
</details>
|
| 340 |
|
| 341 |
-
### Option B -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
The checkpoint can also be loaded directly from the Hugging Face repository.
|
| 344 |
Its `configuration_k2_horizon.py` and `modeling_k2_horizon.py` files are loaded
|
|
|
|
| 338 |
|
| 339 |
</details>
|
| 340 |
|
| 341 |
+
### Option B - SGLang (native architecture support)
|
| 342 |
+
|
| 343 |
+
Native K2 Horizon support is provided by
|
| 344 |
+
[sgl-project/sglang#37654](https://github.com/sgl-project/sglang/pull/37654).
|
| 345 |
+
Use a `lmsysorg/sglang:dev` image built after that PR is merged. Once support is
|
| 346 |
+
included in a tagged SGLang release, use the corresponding versioned image.
|
| 347 |
+
|
| 348 |
+
<details>
|
| 349 |
+
<summary>Show the SGLang serving command</summary>
|
| 350 |
+
|
| 351 |
+
```bash
|
| 352 |
+
docker run --gpus all \
|
| 353 |
+
--shm-size 32g \
|
| 354 |
+
-p 30000:30000 \
|
| 355 |
+
-v ~/.cache/huggingface:/root/.cache/huggingface \
|
| 356 |
+
--ipc=host \
|
| 357 |
+
lmsysorg/sglang:dev \
|
| 358 |
+
python3 -m sglang.launch_server \
|
| 359 |
+
--model-path "IFM/K2-Horizon-0.9B" \
|
| 360 |
+
--revision main \
|
| 361 |
+
--tp 1 \
|
| 362 |
+
--dtype bfloat16 \
|
| 363 |
+
--context-length 8192 \
|
| 364 |
+
--attention-backend fa3 \
|
| 365 |
+
--reasoning-parser k2_horizon \
|
| 366 |
+
--tool-call-parser k2_horizon \
|
| 367 |
+
--mem-fraction-static 0.85 \
|
| 368 |
+
--host 0.0.0.0 \
|
| 369 |
+
--port 30000
|
| 370 |
+
```
|
| 371 |
+
|
| 372 |
+
</details>
|
| 373 |
+
|
| 374 |
+
This uses SGLang's native `K2HorizonForCausalLM` implementation; no
|
| 375 |
+
`--trust-remote-code`, source patch, or external parser plugin is required. The
|
| 376 |
+
8,192-token limit is a conservative starting point; increase it only after
|
| 377 |
+
measuring KV-cache capacity.
|
| 378 |
+
|
| 379 |
+
### Option C - plain Transformers (no vLLM, no container)
|
| 380 |
|
| 381 |
The checkpoint can also be loaded directly from the Hugging Face repository.
|
| 382 |
Its `configuration_k2_horizon.py` and `modeling_k2_horizon.py` files are loaded
|