--- language: - ru - en license: apache-2.0 library_name: transformers pipeline_tag: text-generation datasets: - HuggingFaceFW/fineweb-edu - deepvk/cultura_ru_edu - wikimedia/wikipedia tags: - causal-lm - custom-architecture - gated-deltanet - linear-attention - exact-circuits - tiny-model - base-model - russian ---
Q Project logo

N-Q-26M

A 26M-class Russian/English base model — mini Qwen3.8-Flash-Next, pretrained from scratch on one V100

Parameters Tokens License

Chat model

> [!IMPORTANT] > **This is a research release, not a product.** A plain text-continuation model: grammatical Russian and English, > confident tone, invented facts. For dialogue and exact tool calls use > [N-Q-26M-Chat](https://huggingface.co/q-project/N-Q-26M-Chat). ## Model summary **N-Q-26M** is the base model of the smallest rung of **N-Q**, the Q Project's [MiniMind](https://jingyaogong.github.io/minimind/)-style ladder of small RU/EN models trained from scratch on a single 16GB V100. Architecture: a mini **Qwen3.8-Flash-Next** — Gated DeltaNet linear attention interleaved 3:1 with gated full attention, a 4-stream Gated Residual, and a hashed n-gram embedding — chosen over the ternary Q-164M design by a controlled ablation (see the [chat model card](https://huggingface.co/q-project/N-Q-26M-Chat) for the table). 29.7M backbone parameters + 16.8M n-gram table (46.5M stored), 8,256-token RU+EN byte-level BPE, pretrained on **2.0B tokens** in **6.6 hours** (30,517 steps, 64×1024 tokens/step, WSD schedule, Muon + AdamW, `torch.compile`, 85k tokens/s). 5% of rows were dialogues and `` circuit rows from step 1 (the Q-164M recipe), so even the base model knows the chat and tool formats. ## Results (final checkpoint, step 30,517) | held-out set (never trained on) | loss | perplexity (this tokenizer) | |---|---|---| | FineWeb-Edu (EN) | 2.381 | 10.8 | | Cultura-Ru-Edu (RU) | 2.651 | 14.2 | | Russian Wikipedia | 2.323 | 10.2 | Perplexities are per token of this 8,256-token tokenizer and are **not** comparable to models with other tokenizers. For scale: the same architecture after 0.5B tokens (ablation run) reached a mean loss of 2.616; 2.0B tokens bring it to 2.452. Samples (temperature 0.7): > **Москва — столица** Московской области. Парк расположен в 35 км от Москвы… В годы Великой Отечественной войны город подвергся нападению… > > **Once upon a time,** in ancient times, a small town called Polar, was located on the town of Benedict in Poland. In the 14th century… ## Usage ```python from transformers import AutoModelForCausalLM, AutoTokenizer tok = AutoTokenizer.from_pretrained("q-project/N-Q-26M", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("q-project/N-Q-26M", trust_remote_code=True) ids = tok("Москва — столица", return_tensors="pt") out = model.generate(ids, max_new_tokens=80, temperature=0.7, top_p=0.9, stop_ids=(2,)) print(tok.decode(out[0], skip_special_tokens=True)) ``` The model has its own `generate()` (recurrent Gated DeltaNet state + KV cache). Pass `tokenizer=tok` to switch on the exact `` circuits if you prompt it in the chat format. ## Packed single-file format (`model.qpack`) QPACK1 container (same format as Q-164M / Q-Omni): weights, config, tokenizer and a self-test in one mmap-friendly file, 89 MiB vs 177 MiB safetensors. A folder or repo with `model.qpack` and no `*.safetensors` loads through `AutoModelForCausalLM.from_pretrained(..., trust_remote_code=True)`; `python qpack.py --selftest model.qpack` prints `SELFTEST 5/5`. Matrices fp16, 1-D tensors fp32, n-gram hash tables exact int64. ## Architecture * 8 layers, pattern `LLLA` ×2: Gated DeltaNet (3 key / 6 value heads, dim 64, conv k=4) ×3, then gated attention (8 query / 2 KV heads, dim 64, zero-centred QK-norm, partial RoPE 25% θ=1e6, sigmoid output gate). * hidden 512, SwiGLU 512→704→512, Gated Residual with 4 residual streams, zero-centred RMSNorm, untied output head. * Hashed 3-gram embedding (PLE) after layer 2: 16.8M parameters in prime-sized tables. * Token layout: ids 0–8191 text (0 ``, 1 ``, 2 ``), 8192–8255 control tokens (`` `` `` `` `` `` `` `` `` `` ``, reserved ``…``). ## Limitations - Facts are frequently wrong; thin general knowledge; repetitive under greedy decoding. **No safety tuning.** - Base model: no instruction following beyond the 5% dialogue rows it saw in pretraining. - Research and education only. ## License and data terms Code and weights: **Apache-2.0** (see `LICENSE`). Training data keeps its own terms — check before commercial use: FineWeb-Edu (ODC-By 1.0), Cultura-Ru-Edu, Russian Wikipedia 20231101.ru (CC BY-SA / GFDL); dialogue/circuit rows from SmolTalk, GrandMaster-PRO-MAX, saiga_scored and our own `` corpus.