Instructions to use ai-forever/OrbitLM-1.8B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ai-forever/OrbitLM-1.8B-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ai-forever/OrbitLM-1.8B-Thinking", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ai-forever/OrbitLM-1.8B-Thinking", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ai-forever/OrbitLM-1.8B-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ai-forever/OrbitLM-1.8B-Thinking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ai-forever/OrbitLM-1.8B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ai-forever/OrbitLM-1.8B-Thinking
- SGLang
How to use ai-forever/OrbitLM-1.8B-Thinking 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 "ai-forever/OrbitLM-1.8B-Thinking" \ --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": "ai-forever/OrbitLM-1.8B-Thinking", "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 "ai-forever/OrbitLM-1.8B-Thinking" \ --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": "ai-forever/OrbitLM-1.8B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ai-forever/OrbitLM-1.8B-Thinking with Docker Model Runner:
docker model run hf.co/ai-forever/OrbitLM-1.8B-Thinking
OrbitLM-1.8B-Thinking
OrbitLM-1.8B-Thinking is a looped language model that thinks before it answers. It applies one stack of 24 transformer layers four times to every token, and after each pass an exit gate scores how ready the token is to stop. The model has 1.86B parameters and applies 5.24B of them per generated token, counting each pass of the shared layers.
It was trained from scratch on 1.5T tokens of English and Russian text, then fine-tuned for chat and trained with reinforcement learning on math and code. It answers in English and in Russian, and it can call tools.
The paper is Closing the Loop: Practical Training Recipes for Looped Language Models. The training code, from pretraining to RL, is at ai-forever/OrbitLM on GitHub.
Model details
| Architecture | Looped decoder with the Ouro-1.4B layout: 24 shared layers run 4 times, an exit gate after each pass |
| Parameters | 1.86B: 1.23B in the shared layers, 0.62B in the untied embedding and output matrices |
| Layers | hidden size 2048, 16 attention heads of size 128 (no grouped KV), SwiGLU MLP of size 5632 |
| Tokenizer | Qwen3, 151,936 tokens |
| Context | 32,768 tokens, RoPE base 4,000,000 |
| Languages | Russian, English |
| Chat format | ChatML with a <think> block, thinking on by default |
Each pass keeps its own keys and values, so the KV cache holds 96 layer entries per token: 0.75 MiB per token in bf16, or 24 GiB for one 32K sequence. An FP8 KV cache halves this.
Training
| Stage | Context | Budget | Learning rate and notes |
|---|---|---|---|
| Pretraining 1 | 4K | 100,000 steps, 419B tokens | 3e-4 to 3e-5, RoPE base 4e4 |
| Pretraining 2 | 4K | 200,000 steps, 839B tokens | 1e-4 to 1e-5 |
| Context 16K | 16K | 47,684 steps, 200B tokens | 2e-5 to 2e-6, RoPE base 1e6, document masking |
| Context 32K | 32K | 4,769 steps, 20B tokens | 1e-5 to 1e-6, RoPE base 4e6, document masking |
| SFT | 32K | 7,000 steps, 14.7B tokens | 1e-5 to 1e-6, document masking |
| RL | 16K | step 90 of 150 | GRPO on math and code, loss on every pass weighted by the exit gate, 1e-6 |
The pretraining mixture is mostly English web, math and code text. The Russian share is about 30% in the first stage and about 22% in the second.
During training, the loss of every pass is weighted by the exit gate's probability of stopping there. A KL term toward a uniform exit distribution, with coefficient 0.15, keeps the gate from collapsing onto the early passes. After 1.26T tokens the mean exit probabilities of the four passes were 0.15, 0.25, 0.30 and 0.30, and they changed by less than 0.01 over the next 200B tokens.
Evaluation
All models below were evaluated in one harness. Reasoning uses a 16K token budget with forced closing, and 30K for GPQA and the olympiad tasks. Function calling runs without forcing. AIME uses pass@10, GPQA uses the Diamond subset, LCB denotes LiveCodeBench, and BFCL refers to its parallel category.
| Model | Pretraining tokens | MMLU-Pro | GSM8K | MATH-500 | ruMATH-500 | AIME 2025 | AIME 2026 | OlympiadBench | HumanEval+ | MBPP+ | LCB | IFEval | BFCL |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| OrbitLM-1.8B-Thinking | 1.48T | 53.1 | 91.8 | 91.0 | 82.2 | 66.5 | 67.3 | 63.6 | 78.2 | 60.8 | 28.2 | 71.9 | 89.5 |
| Ouro-1.4B-Thinking | 7.7T | 65.1 | 93.4 | 91.6 | 71.6 | 66.2 | 72.9 | 65.7 | 86.3 | 71.2 | 42.1 | 51.4 | 71.5 |
| Qwen3.5-2B | n/a | 65.6 | 84.5 | 74.4 | 80.8 | 39.3 | 43.9 | 43.0 | 62.0 | 50.7 | 9.1 | 79.7 | 83.0 |
| SmolLM3-3B | 11.2T | 57.8 | 91.7 | 92.8 | 86.0 | 71.1 | 75.5 | 66.5 | 81.6 | 58.1 | 31.3 | 68.2 | 66.0 |
| Nemotron-Nano-4B | ~15T | 48.5 | 92.3 | 90.0 | 71.6 | 70.8 | 80.7 | 71.0 | 85.7 | 66.7 | 36.4 | 73.2 | 67.5 |
Despite using 5.2 times fewer pretraining tokens than Ouro-1.4B-Thinking, OrbitLM-1.8B-Thinking achieves comparable scores on MATH-500, AIME 2025 and GPQA, and comes within about two points on GSM8K and OlympiadBench. It performs better on instruction following and function calling, but trails Ouro on MMLU-Pro, AIME 2026 and code.
Compared with the dense models, OrbitLM-1.8B-Thinking remains competitive on mathematical reasoning, although it applies 5.24B parameters per token, against 1.88B for Qwen3.5-2B and 3.08B for SmolLM3-3B. Ouro-1.4B-Thinking and Ouro-2.6B-Thinking apply 5.03B and 9.97B. These comparisons are not controlled, because the models differ in training data, tokenizers and post-training.
Usage
The model code ships with the weights, so loading needs trust_remote_code=True. Prompts start with
<|endoftext|>, as in training, where that token ended the previous dialogue of a packed sequence. The
recommended sampling is temperature 0.6, top_p 0.95 and top_k 20, which generation_config.json sets.
transformers
Works with transformers 4.56 and later, checked up to 5.23.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "ai-forever/OrbitLM-1.8B-Thinking"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
repo, dtype=torch.bfloat16, trust_remote_code=True, early_exit_threshold=None
).to("cuda")
# PyTorch's cuDNN attention kernel fails on long contexts in some CUDA setups. Without it, SDPA uses
# its flash or memory-efficient kernel, which computes the same attention.
torch.backends.cuda.enable_cudnn_sdp(False)
messages = [{"role": "user", "content": "ะกะบะพะปัะบะพ ะฑัะดะตั 17 ัะผะฝะพะถะธัั ะฝะฐ 23?"}]
prompt = "<|endoftext|>" + tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=True
)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
output = model.generate(**inputs, max_new_tokens=8192)
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
enable_thinking=False answers without a reasoning trace. model.generate(..., exit_at_step=k - 1)
answers from pass k instead of the last one; fewer passes are faster and weaker.
vLLM
vLLM 0.26 and older include the Ouro architecture. vLLM removed it after 0.26, and the small plugin in this repository adds it back. It was checked with vLLM 0.34.
pip install vllm==0.34.0
hf download ai-forever/OrbitLM-1.8B-Thinking --include "vllm_plugin/*" --local-dir orbitlm
pip install ./orbitlm/vllm_plugin
vLLM loads the plugin by itself in every process it starts, so no code has to run first:
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams
repo = "ai-forever/OrbitLM-1.8B-Thinking"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
llm = LLM(repo, trust_remote_code=True, kv_cache_dtype="fp8", max_model_len=32768)
messages = [{"role": "user", "content": "What is 17 times 23?"}]
prompt = "<|endoftext|>" + tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, max_tokens=8192)
print(llm.generate([prompt], params)[0].outputs[0].text)
vllm serve ai-forever/OrbitLM-1.8B-Thinking --trust-remote-code --reasoning-parser qwen3 serves it as well, and the
parser returns the reasoning apart from the answer. The chat endpoint renders the template without the
leading <|endoftext|>. vLLM always runs all four passes. To run fewer, pass
hf_overrides={"total_ut_steps": 3}.
Self-speculative decoding
The model's first pass can draft tokens for the full model, because the draft and the full model share
every weight. vLLM's draft_model method loads the draft as a model of its own and does not apply
hf_overrides to it. The draft is therefore a folder that links to the model's files and holds a copy
of config.json with one pass. The links take no disk space, but vLLM still loads the draft's weights
and gives it a KV cache of its own.
import json
import os
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams
model_dir = snapshot_download("ai-forever/OrbitLM-1.8B-Thinking")
draft_dir = os.path.abspath("orbitlm-draft")
os.makedirs(draft_dir, exist_ok=True)
for name in os.listdir(model_dir):
link = os.path.join(draft_dir, name)
if name != "config.json" and not os.path.lexists(link):
os.symlink(os.path.join(model_dir, name), link)
with open(os.path.join(model_dir, "config.json")) as f:
config = json.load(f)
config["total_ut_steps"] = 1
with open(os.path.join(draft_dir, "config.json"), "w") as f:
json.dump(config, f, indent=2)
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
llm = LLM(
model_dir,
trust_remote_code=True,
kv_cache_dtype="fp8",
max_model_len=32768,
speculative_config={"method": "draft_model", "model": draft_dir, "num_speculative_tokens": 4},
)
messages = [{"role": "user", "content": "What is 17 times 23?"}]
prompt = "<|endoftext|>" + tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, max_tokens=8192)
print(llm.generate([prompt], params)[0].outputs[0].text)
The draft proposes its most likely tokens, and the full model accepts or replaces each of them by rejection sampling. The output therefore follows the full model's own distribution, and the draft only changes the speed. With temperature 0 a run with the draft can still part from a run without it where two tokens tie within bf16 rounding.
On an earlier SFT checkpoint of the same training run, on one H200 with four draft tokens, self-speculative decoding together with an FP8 KV cache decoded 1.73 times faster than bf16 at batch 1 and 16K context, 2.10 times at 16 sequences of 8K and 2.24 times at 8 sequences of 16K, with no change in accuracy on MATH-500 and GSM8K. FP8 alone holds 2.1 times as many tokens in the cache.
License
Apache 2.0.
- Downloads last month
- 138