Run this model with HF Jobs

Run rwb-ai/BerryLM-OS on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/rwb-ai/BerryLM-OS. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/rwb-ai/BerryLM-OS on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/rwb-ai/BerryLM-OS. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/rwb-ai/BerryLM-OS. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
BerryLM-OS / README.md
DDSV13's picture
yuliya ivanova
mysterious-pie's picture
BerryLM-OS
8fc608b
|
Raw History Blame Contribute Delete
51.8 kB
metadata
license: apache-2.0
language:
  - ru
  - en
pipeline_tag: text-generation
library_name: transformers
tags:
  - berrylm
  - moe
  - hybrid
  - linear-attention
  - thinking
  - russian

BerryLM-OS

Hybrid MoE language model for Russian and English with a thinking mode: 40 decoder layers (three linear-attention layers, then one full-attention layer, repeated), sparse MoE FFN with 128 routed experts (top-8) plus a shared expert, Gated Block AttnRes depth mixing and KDA forget gates on the linear-attention layers. ~3.2B active / ~18.3B total parameters (bf16, 36.6 GB of weights), 180 224-token byte-level BPE vocabulary, 256k context.

Architecture

The stack is on the left, one layer on the right. Every layer first mixes in the residual streams committed at earlier block boundaries (AttnRes, a block is 8 layers), then runs its token mixer (KDA linear attention in three layers out of four, full attention in the fourth) and a sparse MoE feed-forward.

BerryLM-OS architecture: 40 layers in 5 blocks of 8, three KDA linear-attention layers then one full-attention layer; every layer runs Gated Block AttnRes, the token mixer and a sparse MoE feed-forward with 128 experts, 8 of them active, plus a shared expert

Quick start (transformers)

python -m pip install "transformers==5.16.1" accelerate torch

Fused kernels are optional: pip install flash-linear-attention adds the Triton kernels of the linear-attention layers; without it the torch reference path runs (correct, slower on long prompts). causal-conv1d is picked up too when installed; it compiles from source unless a prebuilt wheel matches your torch.

from transformers import AutoModelForCausalLM, AutoTokenizer
m = "rwb-ai/BerryLM-OS"
tok = AutoTokenizer.from_pretrained(m, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(m, dtype="auto", device_map="auto", trust_remote_code=True)
msgs = [{"role": "user", "content": "Объясни, что такое линейное внимание, в трёх предложениях."}]
inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_dict=True, return_tensors="pt", enable_thinking=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=2048, do_sample=True, temperature=0.8, top_p=0.95, top_k=20)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:]))

Thinking is on by default: the reply starts with the reasoning and </think> separates it from the answer. Pass enable_thinking=False to the chat template for direct answers.

Sampling

mode temperature top_p top_k
thinking (default, shipped in generation_config.json) 0.8 (0.6–0.8) 0.95 20
direct answers (enable_thinking=False) 0.7 0.8 20

Serving

vLLM (until vllm-project/vllm#57384 is merged):

git clone https://github.com/vllm-project/vllm.git && cd vllm
git fetch origin pull/57384/head
git checkout -b berrylm 7060026c613db283d70efc250f05ab6bbced9317
VLLM_USE_PRECOMPILED=1 VLLM_PRECOMPILED_WHEEL_COMMIT=cb6458c5ce61632524c0447d49790725c1e1d9a2 pip install -e .
vllm serve rwb-ai/BerryLM-OS --reasoning-parser berrylm --tool-call-parser berrylm --enable-auto-tool-choice

SGLang (until sgl-project/sglang#55435 is merged):

git clone https://github.com/sgl-project/sglang.git && cd sglang
git fetch origin pull/55435/head
git checkout -b berrylm ebedc568181c5290660b3295666382556976ff05
pip install -e "python"
python -m sglang.launch_server --model-path rwb-ai/BerryLM-OS --port 8000 \
  --reasoning-parser berrylm --tool-call-parser berrylm

Installing SGLang from source builds its Rust extensions: have a Rust toolchain installed, or set SGLANG_BUILD_RUST_EXTS=none for the install.

Both servers read the sampling defaults from generation_config.json, split the reasoning into the reasoning / reasoning_content field of the OpenAI-compatible response and parse tool calls (if you render prompts yourself with apply_chat_template, pass the arguments of earlier tool calls as a mapping, not as a JSON string). Thinking is switched per request; both commands above serve on port 8000:

curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
  "model": "rwb-ai/BerryLM-OS",
  "messages": [{"role": "user", "content": "Сколько будет 17 * 23?"}],
  "max_tokens": 4096,
  "chat_template_kwargs": {"enable_thinking": false}
}'

Hardware

bf16 weights take 34 GiB; the KV cache of the full-attention layers costs about 20 KB per token (5 GiB for the whole 256k context) and the linear-attention state 60 MiB per running sequence. vLLM reserves one state block per --max-num-seqs slot (1024 by default). On an 80 GB card the commands above work as written; on a smaller one pass a lower --max-num-seqs and, if the full context does not fit, a lower --max-model-len (vLLM) / --context-length (SGLang). Measured: under a 46 GiB memory cap (a 48 GB card) vllm serve ... --max-model-len 32768 --max-num-seqs 64 starts and serves.

Other formats

  • BerryLM-OS-FP8: block-wise FP8 weights for vLLM and SGLang, 17.8 GiB instead of 34 GiB, within two points of these weights on the thinking benchmarks below.
  • BerryLM-OS-GGUF: Q6_K and Q4_K_M for llama.cpp. They need llama.cpp with BerryLM support, proposed in ggml-org/llama.cpp#30234 and not merged yet.

Evaluation

Pareto plot for averaged scores (all benchmarks)

Pareto of average score against active parameters

Unweighted mean of 25 scores:

  • No-think (12): MMLU-ProX, AA-LCR, WMT24++ en→ru, LIBRA, RULER 32k, RULER 64k, RULER 128k, GSM8K, MATH-500, MGSM ru, WikiWebFacts, HardMultiQA.
  • Think (13): GPQA, AIME 2026, HMMT Feb 2025, DOOM, IFEval, Multi-IF, BFCL v4, RU Arena-Hard, IFBench, MERA v2, HumanEval, MBPP, BigCodeBench.

LFM2.5-2.6B is averaged over 23 scores (no AA-LCR and RULER 128k) and gpt-oss-20b over 24 (no RULER 128k). LFM2.5-2.6B has no no-think mode, so all its scores here and in the table below were measured in think mode.

Pareto plot for averaged scores (Russian benchmarks subset)

Pareto of the average Russian benchmark score against active parameters

Equal-weight mean of the nine Russian benchmark scores: DOOM, RU Arena-Hard, MMLU-ProX ru, WMT24++ en→ru, LIBRA, MGSM ru, WikiWebFacts, HardMultiQA, MERA v2.

Benchmark Mode BerryLM-OS LFM2.5
2.6B*
Qwen3.5
4B
Qwen3.5
9B
Nemotron 3.5
30B-A3B
gpt-oss
20b
Qwen3.5
35B-A3B
Qwen3.6
35B-A3B
Gemma 4
26B-A4B
General knowledge and reasoning
MMLU-ProX en+ru
pass@1
no-think79.264.273.778.174.269.983.083.181.5
GPQA
pass@1
think79.056.677.081.975.471.583.579.079.7
DOOM1
pass@1
think75.045.571.073.863.862.478.372.377.2
Math
AIME 2026
pass@1
think90.065.282.587.787.584.890.290.886.5
HMMT Feb 2025
pass@1
think80.847.971.381.785.471.384.289.279.2
GSM8K
8-shot CoT, exact match
no-think96.289.291.695.389.777.296.496.396.5
MATH-500
4-shot, pass@32
no-think98.498.097.298.885.695.699.499.298.6
MGSM ru
symbolic match
no-think94.082.087.288.880.471.692.092.891.6
Code and agentic
HumanEval
pass@1
think97.384.584.991.695.184.396.697.499.0
MBPP
pass@1
think92.377.169.380.587.689.085.692.796.8
BigCodeBench-Hard
pass@1
think48.231.532.939.849.746.245.450.648.5
BFCL v42
overall
think66.258.654.062.757.532.966.363.360.7
Instruction following
IFEval
prompt-level strict
think93.693.088.389.691.888.590.888.894.8
Multi-IF en+ru
mean of 3 turns
think85.682.079.684.283.281.885.886.188.8
IFBench
strict / loose mean
think73.357.954.461.370.866.565.958.377.3
Russian
RU Arena-Hard3
win rate
think49.25.98.418.116.744.238.166.669.2
WMT24++ en→ru4
COMET
no-think85.475.281.484.075.879.086.085.786.5
WikiWebFacts5
judged accuracy
no-think53.938.137.448.242.446.662.960.960.2
HardMultiQA5
judged accuracy
no-think39.021.822.535.029.534.645.342.644.4
MERA v26
overall
think40.712.09.318.623.927.433.039.145.2
Long context
AA-LCR7
pass@1
no-think44.0—36.836.513.531.557.058.539.3
LIBRA
mean of 21 sets
no-think63.942.659.260.052.654.961.561.262.3
RULER 32k
accuracy
no-think96.767.395.996.597.174.596.596.996.5
RULER 64k
accuracy
no-think95.945.695.296.196.868.096.196.795.0
RULER 128k
accuracy
no-think95.1—94.895.696.5—95.996.391.9

1 DOOM: mean of the math and physics subsets.

2 BFCL v4: overall score without the web-search category.

3 RU Arena-Hard (474 prompts): GLM-4.7-FP8 compares each answer with the fixed DeepSeek-V3.2 baseline answers, in both orders; the score is the win rate against that baseline (the baseline itself would score 50).

4 WMT24++: scored by the XCOMET-XXL metric model, not an LLM judge.

5 WikiWebFacts (1365 questions) and HardMultiQA (670): no comparison model; Qwen3.5-122B-A10B grades each answer against the reference answer as −1, 0 or 1, and the score is the share of answers graded 1.

6 MERA v2: LFM2.5-2.6B, Qwen3.5-4B, Qwen3.5-9B, Qwen3.5-35B-A3B and Qwen3.6-35B-A3B are taken from the official leaderboard; Nemotron 3.5 30B-A3B, gpt-oss-20b, Gemma 4 26B-A4B and BerryLM-OS were run with the official MERA v2 code and scored by the MERA scoring system (the leaderboard has Gemma 4 26B-A4B only in non-reasoning mode).

7 AA-LCR: judged by GLM-4.7-FP8, which checks the answer against the reference.

* LFM2.5-2.6B has no no-think mode: all its scores were measured in think mode.

The other benchmarks are scored without a model, by answer matching or unit tests. Bold: best in the row; —: not measured.

Authors

Danil Smorchkov, Anton Tikhonov, Yulia Ivanova, Matvey Saprykin, Anton Egorov, Yuriy Sofronov, Adel Khalilov, Andrey Yakuboy, Igor Bogdanov, Maria Korshunova, Mikhail Aleshin, Alexander Kostylev, Damir Chanyshev.

License

Released under the Apache License 2.0.