OrbitLM-1.8B-Thinking

ai-forever/OrbitLM-1.8B-Thinking

作者
ai-forever
任务
文本生成
下载量
976
点赞数
72
趋势分
21
许可证
apache-2.0
收录时间
2026/11/26

license: apache-2.0 language:

  • ru
  • en library_name: transformers pipeline_tag: text-generation tags:
  • looped-language-model
  • recurrent-depth
  • ouro
  • reasoning
  • russian

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

ArchitectureLooped decoder with the Ouro-1.4B layout: 24 shared layers run 4 times, an exit gate after each pass
Parameters1.86B: 1.23B in the shared layers, 0.62B in the untied embedding and output matrices
Layershidden size 2048, 16 attention heads of size 128 (no grouped KV), SwiGLU MLP of size 5632
TokenizerQwen3, 151,936 tokens
Context32,768 tokens, RoPE base 4,000,000
LanguagesRussian, English
Chat formatChatML 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

StageContextBudgetLearning rate and notes
Pretraining 14K100,000 steps, 419B tokens3e-4 to 3e-5, RoPE base 4e4
Pretraining 24K200,000 steps, 839B tokens1e-4 to 1e-5
Context 16K16K47,684 steps, 200B tokens2e-5 to 2e-6, RoPE base 1e6, document masking
Context 32K32K4,769 steps, 20B tokens1e-5 to 1e-6, RoPE base 4e6, document masking
SFT32K7,000 steps, 14.7B tokens1e-5 to 1e-6, document masking
RL16Kstep 90 of 150GRPO 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.

ModelPretraining tokensMMLU-ProGSM8KMATH-500ruMATH-500AIME 2025AIME 2026OlympiadBenchHumanEval+MBPP+LCBIFEvalBFCL
OrbitLM-1.8B-Thinking1.48T53.191.891.082.266.567.363.678.260.828.271.989.5
Ouro-1.4B-Thinking7.7T65.193.491.671.666.272.965.786.371.242.151.471.5
Qwen3.5-2Bn/a65.684.574.480.839.343.943.062.050.79.179.783.0
SmolLM3-3B11.2T57.891.792.886.071.175.566.581.658.131.368.266.0
Nemotron-Nano-4B~15T48.592.390.071.670.880.771.085.766.736.473.267.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.

内容来源:Hugging Face 模型卡

在 Hugging Face 查看