Kroha-base
Kroha is a 71.69M-parameter multilingual base model with a looped Gated DeltaNet/GQA decoder. It was trained on 36 billion tokens of text, Python, mathematics, scientific prose and DNA, extending context from 2,048 to 4,096, then 16,384 tokens.
| Property | Value |
|---|---|
| Decoder parameters | 71,685,712 |
| Unique active parameters across both passes | 58.71M–63.03M per token |
| Additional MTP training parameters | 3,939,968 |
| Parameters during MTP training | 75,625,680 |
| Hidden size | 512 |
| Decoder blocks | 10 physical blocks, 18 block applications |
| Core | 8 shared blocks, 2 loop iterations |
| Core sequence mixer | Alternating Gated DeltaNet v1 and GQA |
| GQA heads | 8 query heads, 2 key/value heads, head dimension 64 |
| Routed experts | 8 per core block, top-2 per token and pass |
| Routed latent / expert hidden size | 256 / 352 |
| Shared expert hidden size | 256 |
| Block AttnRes group size | 4 sublayer outputs |
| Vocabulary | 69,650 token IDs, tied embedding and LM head |
| Final training context | 16,384 tokens |
Each core block runs twice and selects two to four distinct routed experts in total. Active counts include the tied embedding/LM head and count shared weights once.
Quick start
Reference environment: Python 3.12, PyTorch 2.11.0 and Transformers 5.17.0.
python -m pip install "torch==2.11.0" "transformers==5.17.0"
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "d0rj/Kroha-base"
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" else torch.float32
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
attn_implementation="sdpa",
dtype=dtype,
).to(device).eval()
inputs = tokenizer("Маленькие языковые модели интересны тем, что", return_tensors="pt")
inputs = inputs.to(device)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=64,
do_sample=False,
use_cache=True,
)
continuation = output[0, inputs["input_ids"].shape[1]:]
print(tokenizer.decode(continuation, skip_special_tokens=True))
Keep the prompt and generated continuation within config.max_position_embeddings,
the trained context limit. model_id can also point to a local export directory.
For CUDA GDN1 kernels, install fla-core==0.5.2. GQA supports
attn_implementation="flash_attention_4" with a compatible FlashAttention
installation; training used FlashAttention 4.0.0b35. CPU inference uses PyTorch
and Transformers. Router scores and recurrent decay parameters remain FP32 when
loading BF16 weights.
Architecture
Token embedding
↓
GQA + dense FFN
↓
Shared core, pass 1
↓
Shared core, pass 2
↓
GQA + dense FFN
↓
Final normalization → tied LM head
Each core pass = [GDN1 + MoE → GQA + MoE] × 4
Hybrid sequence mixing. GDN1 (Gated Delta Networks)
maintains a recurrent state with a gated delta rule. GQA uses causal attention and RoPE with
theta=10,000. Each block application keeps a separate inference state, even
when weights are shared.
Pass-specific adapters. The second core pass adds rank-16 Q/V adapters, separate normalization weights and learned sublayer gains, inspired by Relaxed Recursive Transformers.
Latent MoE and SharedGate. Each core FFN projects from 512 to 256 dimensions, applies two routed experts, combines their weighted outputs, applies RMSNorm and projects back to 512 dimensions. A separate shared expert processes every token, with a learned sigmoid gate controlling its contribution. Routed and shared experts use SwiGLU clipped at 10.
HeadGate and Block AttnRes. Learned gates scale GQA heads before the output projection. Block AttnRes mixes earlier representations per token, grouping four sublayer outputs at a time, following Attention Residuals.
The Hugging Face model is self-contained in configuration_kroha.py and modeling_kroha.py,
including the DNA codec. It uses PyTorch and Transformers for RoPE, RMSNorm,
attention dispatch, hybrid caching and generation.
Training
Training used three stages with a global batch of 262,144 token positions. Final partial batches follow the stored corpus boundaries.
| Stage | Source tokens | Context | Global sequences | Microbatch × accumulation | Optimizer steps | Peak LR |
|---|---|---|---|---|---|---|
| Pretrain | 30B | 2,048 | 128 | 32 × 4 | 114,442 | 1e-3 |
| Powerup 2× | 3B | 4,096 | 64 | 16 × 4 | 11,446 | 1e-4 |
| Powerup 8× | 3B | 16,384 | 16 | 4 × 4 | 11,448 | 1e-4 |
All stages use BF16 on one NVIDIA RTX 5070 Ti with 16 GB VRAM. Hidden and expert
matrices use Muon; routers, the tied embedding/LM head, norms and other groups
use AdamW. Each stage has 1% warmup and cosine decay to 10% of its peak LR.
Weight decay is 0.1, AdamW betas are (0.9, 0.95) and gradient-norm clipping is 1.0.
Training uses isolated document packing, buffered global load balancing, SonicMoE/Quack expert kernels, FlashAttention 4, core activation checkpointing and regional compilation. Document boundaries reset positions, attention, convolution and recurrent state. Prediction targets crossing those boundaries are masked. Source-token budgets include document EOS and exclude padding.
Multi-token prediction. An auxiliary GQA/SwiGLU block predicts t+2, using
the backbone state and the ground-truth t+1 embedding. It shares the main
embedding and LM head. The objective is CE(t+1) + 0.3 × CE(t+2), plus the router
balancing loss. Each prediction depth is normalized over its valid targets in
the global batch. This is adapted from the sequential MTP construction in
DeepSeek-V3.
HF generation uses the next-token head. The companion Kroha-base-dev archive pairs the same HF model with full training checkpoints: MTP weights, optimizer/scheduler and RNG states, data cursors, TensorBoard logs, configuration and original training code.
Data
The corpus covers English, Russian and 34 other natural-language quota groups, plus Python, mathematics, scientific prose and DNA. Language exposure varies widely; the lowest-resource groups have very small allocations.
alt atv bak bel bxr che chv eng kaz kbd kca kir kjh koi kpv krc krl kum
lez lud mdf mhr mns mrj myv nog olo rus sah tat tyv udm ukr uzn vep xal
Source-token shares from the stage manifests, rounded to two decimals:
| Domain | Pretrain | Powerup 2× | Powerup 8× |
|---|---|---|---|
| General text | 74.42% | 58.00% | 47.22% |
| Python | 11.58% | 17.00% | 21.59% |
| Mathematics | 11.00% | 17.50% | 21.59% |
| Scientific prose | 1.35% | 3.38% | 4.32% |
| DNA | 1.65% | 4.13% | 5.28% |
General text includes SNeG, Cultura RU Edu, FineWeb-Edu, FineWeb2-HQ, FinePDFs-Edu, DCLM, Wikipedia, HPLT and regional-language corpora. SNeG has priority during deduplication and contributes about 2.80B selected tokens across the curriculum. Corpus provenance records retain source metadata and revision pins.
Python comes from CodeParrot and UltraData-Code; mathematics comes from FineMath and UltraData-Math. Scientific prose includes Dolmino science web, FineDNA biology text and Russian scientific articles. DNA comes from FineDNA sequence subsets.
Stages use disjoint selected token intervals. Filtering includes exact-text, paragraph, Python-AST and DNA-body checks. Benchmark decontamination and biological homology analysis are pending.
Tokenizer and DNA
B64 + DNA6 v3 combines a 65,536-ID multilingual byte-level BPE tokenizer with 4,114 DNA IDs. Numbers are split into individual digits. A chat template and markers for tool calls, reasoning and fill-in-the-middle are provided for later instruction tuning.
DNA mode is selected explicitly. Its 4,096 canonical tokens cover all uppercase
ACGT 6-mers. Sixteen single-symbol tokens and the BPE vocabulary provide lossless
fallback for short tails, ambiguous bases, lowercase letters and formatting.
Ordinary text uses BPE; DNA uses the codec in modeling_kroha.py.
import importlib
model_module = importlib.import_module(type(model).__module__)
codec = model_module.DNACodec(tokenizer)
sequence = "ACGTACGTACGTNNu\n"
encoded = codec.encode_sequence(sequence)
assert codec.decode_sequence(encoded["input_ids"]) == sequence
Pass encoded["input_ids"] to the model as token IDs for a sequence prompt.
For mixed text and DNA, use codec.encode_document(text, dna_mode=True) with
<dna>...</dna> spans. The tokenizer decodes DNA token IDs; </dna> closes a
DNA span so generation can continue afterwards.
Evaluation
Open SLM Leaderboard (Base)
| Benchmark | Leaderboard verified | Local two passes | Local + LoopCD |
|---|---|---|---|
| Intelligence Index | 8.3903 | 8.4783 | 8.5160 |
| Avg | 37.0839 | 37.1286 | 36.8697 |
| HellaSwag | 29.4563% | 29.4463% | 29.2571% |
| ARC-Easy | 36.7845% | 36.8266% | 36.8687% |
| ARC-Challenge | 22.1843% | 22.6109% | 22.0990% |
| PIQA | 55.4951% | 55.5495% | 56.6376% |
| ArithMark-3 | 33.9000% | 33.8000% | 32.1000% |
| ArithMark-2 | 32.7600% | — | — |
The leaderboard column reports the organizers' verified results. The local comparison uses full zero-shot splits, the same weights, and vLLM BF16. Leaderboard · Scoring rules
Inference depth and LoopCD
| Inference mode | Mean26 | Mean50 | WikiText-2 word perplexity ↓ |
|---|---|---|---|
| One pass | 24.5142 | 27.9705 | 24,395.28 |
| Two passes | 30.5285 | 32.3743 | 60.73 |
| Two passes + LoopCD-Logits (ω = 0.3) | 30.5986 | 32.8040 | 76.94 |
All modes share the same checkpoint. LoopCD added 0.43 points on Mean50 and reduced generation throughput by 7–10% on RTX 5070 Ti in vLLM eager mode (256 input and 32 output tokens). LoopCD paper
| Evaluation slice | Tasks | Kroha-base · 71.69M | cRia-75M (benchmark-adapted) | GPT-X3-150M | Supra2-100M-Base | GPT-2 Small 124M |
|---|---|---|---|---|---|---|
| Mean50 | 50 | 32.3743 | — | — | — | — |
| Russian | 23 | 35.3759 | — | — | — | — |
| English | 27 | 29.8174 | — | — | — | — |
| Original Mean26 | 26 | 30.5285 | 34.9430 | 36.6805 | 32.6863 | 30.3616 |
| English/Russian suite | 26 | 33.6887 | — | — | — | — |
| Benchmark | Lang. | Primary metric / filter | Shots | Examples | Kroha-base · 71.69M | cRia-75M (benchmark-adapted) | GPT-X3-150M | Supra2-100M-Base | GPT-2 Small 124M |
|---|---|---|---|---|---|---|---|---|---|
arc_challenge | EN | acc_norm,none | 0 | 1,172 | 22.6109 | 30.4608 | 31.6553 | 24.5734 | 22.5256 |
arc_easy | EN | acc_norm,none | 0 | 2,376 | 36.8266 | 58.3333 | 59.5539 | 47.7273 | 39.6465 |
arithmark3 | EN | acc_norm,none | 0 | 1,000 | 33.8000 | 37.1000 | 51.6000 | 37.5000 | 35.6000 |
balanced_copa | EN | acc,none | 0 | 1,000 | 52.7000 | 58.7000 | 60.1000 | 57.8000 | 55.4000 |
blimp | EN | acc,none | 0 | 67,000 | 74.4164 | 80.3806 | 79.8060 | 80.9075 | 83.3373 |
boolq | EN | acc,none | 0 | 3,270 | 60.5505 | 53.9755 | 58.3180 | 61.7125 | 49.9388 |
commonsense_qa | EN | acc,none | 0 | 1,221 | 20.6388 | 20.4750 | 21.2940 | 21.2940 | 19.5741 |
hellaswag | EN | acc_norm,none | 0 | 10,042 | 29.4463 | 39.0161 | 45.9669 | 35.9988 | 31.2189 |
lambada_openai | EN | acc,none | 0 | 5,153 | 25.9266 | 38.3272 | 36.7553 | 35.6491 | 30.6229 |
mmlu_continuation | EN | acc,none | 0 | 14,042 | 24.6689 | 26.6629 | 28.6498 | 26.9833 | 25.2101 |
openbookqa | EN | acc_norm,none | 0 | 500 | 26.0000 | 33.8000 | 34.4000 | 32.0000 | 27.0000 |
piqa | EN | acc_norm,none | 0 | 1,838 | 55.5495 | 64.6899 | 71.1099 | 65.1251 | 63.4385 |
sciq | EN | acc_norm,none | 0 | 1,000 | 68.7000 | 89.9000 | 80.1000 | 70.8000 | 63.9000 |
truthfulqa_mc2 | EN | acc,none | 0 | 817 | 43.0944 | 41.7106 | 40.0322 | 40.7490 | 40.6980 |
winogrande | EN | acc,none | 0 | 1,267 | 50.7498 | 52.5651 | 53.7490 | 51.2234 | 50.8287 |
bananamind_base | EN | raw_accuracy,none | 0 | 350 | 52.0000 | 60.5714 | 66.2857 | 56.5714 | 51.4286 |
social_iqa | EN | acc,none | 0 | 1,954 | 36.7963 | 40.6346 | 38.9969 | 38.3828 | 36.5404 |
race | EN | acc,none | 0 | 1,045 | 26.2201 | 30.7177 | 33.5885 | 30.1435 | 29.6651 |
mmlu | EN | acc,none | 5 | 14,042 | 26.2641 | 25.5804 | 25.3169 | 25.1389 | 26.2926 |
triviaqa | EN | exact_match,remove_whitespace | 0 | 17,944 | 0.3511 | 4.8373 | 2.2849 | 1.1313 | 0.3622 |
gsm8k | EN | exact_match,flexible-extract | 5 | 1,319 | 1.8196 | 1.9712 | 4.9280 | 1.1372 | 1.2130 |
hendrycks_math500 | EN | exact_match,none | 0 | 500 | 0.2000 | 0.0000 | 1.6000 | 0.4000 | 0.2000 |
bbh | EN | exact_match,get-answer | 3 | 6,511 | 20.4884 | 17.9082 | 23.5141 | 6.8960 | 4.7612 |
humaneval | EN | pass@1,create_test | 0 | 164 | 3.6585 | 0.0000 | 1.8293 | 0.0000 | 0.0000 |
mbpp | EN | pass_at_1,none | 3 | 500 | 0.0000 | 0.2000 | 1.2000 | 0.0000 | 0.0000 |
mbpp_plus | EN | pass_at_1,none | 3 | 378 | 0.2646 | 0.0000 | 1.0582 | 0.0000 | 0.0000 |
mmlu_pro_mc0 | EN | acc,none | 0 | 12,032 | 11.3281 | — | — | — | — |
global_mmlu_full_ru | RU | acc,none | 5 | 14,042 | 26.4706 | — | — | — | — |
mmlu_prox_ru_mc0 | RU | acc,none | 0 | 11,759 | 11.3190 | — | — | — | — |
mera_rummlu_mc0 | RU | acc,none | 0 | 14,012 | 23.1088 | — | — | — | — |
include_base_44_russian | RU | acc,none | 0 | 552 | 28.0797 | — | — | — | — |
rublimp_sum_ll | RU | acc,none | 0 | 45,000 | 91.9889 | — | — | — | — |
rucola_dev | RU | mcc,none | 0 | 2,787 | 0.2638 | — | — | — | — |
sberquad_dev | RU | f1,none | 0 | 5,036 | 7.8481 | — | — | — | — |
rsg_danetqa | RU | acc,none | 0 | 821 | 48.9647 | — | — | — | — |
rsg_parus | RU | acc,none | 0 | 100 | 64.0000 | — | — | — | — |
rsg_rcb | RU | acc,none | 0 | 220 | 32.2727 | — | — | — | — |
rsg_russe | RU | acc,none | 0 | 8,505 | 38.5068 | — | — | — | — |
rsg_rwsd | RU | acc,none | 0 | 204 | 51.4706 | — | — | — | — |
rsg_terra | RU | acc,none | 0 | 307 | 48.5342 | — | — | — | — |
belebele_rus_Cyrl | RU | acc,none | 0 | 900 | 24.8889 | — | — | — | — |
xnli_ru | RU | acc,none | 0 | 2,490 | 39.7590 | — | — | — | — |
xquad_ru | RU | f1,none | 0 | 1,190 | 2.6521 | — | — | — | — |
xwinograd_ru | RU | acc,none | 0 | 315 | 54.6032 | — | — | — | — |
xstorycloze_ru | RU | acc,none | 0 | 1,511 | 52.0847 | — | — | — | — |
mgsm_native_cot_ru | RU | exact_match,flexible-extract | 8 | 250 | 1.6000 | — | — | — | — |
arc_ru | RU | acc_norm,none | 0 | 1,169 | 24.4654 | — | — | — | — |
hellaswag_ru | RU | acc_norm,none | 0 | 9,272 | 29.2278 | — | — | — | — |
truthfulqa_ru_mc2 | RU | acc,none | 0 | 788 | 47.5370 | — | — | — | — |
global_piqa_completions_rus_cyrl | RU | acc_norm,none | 0 | 100 | 64.0000 | — | — | — | — |
Inference and compatibility
The HF implementation supports cached generation, inputs_embeds, hidden-state
outputs, gradient checkpointing and standard linear projections for LoRA.
Install the vLLM or SGLang adapter in a separate environment, following its README.
To enable LoopCD-Logits in the vLLM adapter, add "kroha_loopcd_weight":0.3 to --additional-config. Adapter instructions
Prefix reuse, quantization, speculative decoding and CUDA graphs are untested.