File size: 6,846 Bytes
b355f93
8224179
 
 
b355f93
8224179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b355f93
8224179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9ec967
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8224179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
language:
- ru
- en
license: apache-2.0
tags:
- math
- reasoning
- linear-attention
- sub-1b
- qwen3.5
- cot
- olympiad
- sft
- simpo
pipeline_tag: text-generation
library_name: transformers
metrics:
- accuracy
model-index:
- name: RusNanoMath-800M
  results:
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: MATH-500
      type: HuggingFaceH4/MATH-500
    metrics:
    - type: accuracy
      value: 36.20
      name: MATH-500 Accuracy
    - type: accuracy
      value: 52.42
      name: MATH-500 Algebra Accuracy
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: GSM8K
      type: openai/gsm8k
    metrics:
    - type: accuracy
      value: 52.00
      name: GSM8K Accuracy
---

# RusNanoMath-800M

[English](#english-overview) | [Русский](#обзор-на-русском)

---

<a id="english-overview"></a>
## English Overview

**RusNanoMath-800M** is an open-weights **800M parameter bilingual (Russian / English) mathematical reasoning model**. Built on a hybrid Linear Attention architecture (Qwen3.5 with Gated Delta Rule layers) and aligned via targeted multi-stage SFT and SimPO (Simple Preference Optimization), it demonstrates very strong reasoning performance across competitive mathematics benchmarks, particularly in symbolic algebra.

### Benchmark Visual Leaderboards

#### 1. MATH-500 Overall Leaderboard
![MATH-500 Overall Leaderboard](assets/math500_overall.png)

#### 2. Dedicated Algebra Breakdown (MATH-500: Algebra)
![MATH-500 Algebra Leaderboard](assets/math500_algebra.png)

#### 3. GSM8K Leaderboard
![GSM8K Leaderboard](assets/gsm8k.png)

---

### Highlights

- **Symbolic Algebra (MATH-500 Algebra)**: In the 124 algebra competition problems, RusNanoMath-800M achieves **52.4%**, closely approaching Llama-3.1-8B (53.8%) and surpassing models with 1.5B–3B parameters (Qwen2.5-1.5B at 49.5%, Llama-3.2-3B at 48.0%, Gemma-2-2B at 41.2%).
- **General Competition Math (MATH-500 Overall)**: Across all 500 problems, RusNanoMath-800M reaches **36.2%**, outperforming sub-1B to 2B models (Gemma-2-2B at 35.0%, SmolLM2-1.7B at 21.5%, Llama-3.2-1B at 14.0%).
- **Grade School Arithmetic (GSM8K)**: Achieves **52.0%**, handling multi-step reasoning chains and arithmetic problems.

---

### Quickstart & Inference

```python
import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer

MODEL_ID = "itismax0/RusNanoML-800M"

tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForImageTextToText.from_pretrained(
    MODEL_ID,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
model.eval()

messages = [
    {
        "role": "user",
        "content": "Найдите все действительные корни уравнения x^4 - 5x^2 + 4 = 0. Ответ запишите в \\boxed{}."
    }
]

prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=1024,
        do_sample=False,
        pad_token_id=tokenizer.eos_token_id
    )

response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)
```

### Run with llama.cpp / Ollama (GGUF, full precision)

A full-precision **F16 GGUF** (`RusNanoML-800M-F16.gguf`) is included in this repo — no quantization loss.

```bash
# llama.cpp
llama-cli -hf itismax0/RusNanoML-800M:RusNanoML-800M-F16.gguf --temp 0 -p "Найдите все действительные корни уравнения x^4 - 5x^2 + 4 = 0."
```

**Ollama** (import the GGUF locally):

```bash
echo "FROM RusNanoML-800M-F16.gguf
PARAMETER temperature 0
TEMPLATE \"{{ .Prompt }}\"" > Modelfile
ollama create rusnanoml-800m -f Modelfile
ollama run rusnanoml-800m "Найдите все действительные корни уравнения x^4 - 5x^2 + 4 = 0."
```

> Note: the model uses the Qwen3.5 hybrid linear-attention architecture. llama.cpp builds from `master` (>= b12413) support it; older builds will refuse to load the file.

---

<a id="обзор-на-русском"></a>
## Обзор на русском

**RusNanoMath-800M** — открытая двуязычная (русский и английский) модель на 800 млн параметров для решения математических и логических задач. Архитектура построена на базе Qwen3.5 с гибридным линейным вниманием (Gated Delta Rule), что обеспечивает константную сложность памяти состояния O(1) при генерации. Обучение включает этапы целевого SFT на цепочках рассуждений (CoT) и выравнивание методом предпочтений SimPO (Simple Preference Optimization).

### Графики сравнения с открытыми моделями

#### 1. Общий зачёт: MATH-500
![MATH-500 Overall Leaderboard](assets/math500_overall.png)

#### 2. Раздел алгебры: MATH-500 (Algebra)
![MATH-500 Algebra Leaderboard](assets/math500_algebra.png)

#### 3. Арифметика и текстовые задачи: GSM8K
![GSM8K Leaderboard](assets/gsm8k.png)

---

### Основные показатели

- **Алгебра (MATH-500 Algebra)**: В блоке из 124 задач по алгебре RusNanoMath-800M показывает **52.4%** (65 решённых задач из 124). Модель вплотную приближается к показателям Llama-3.1-8B (53.8%) и превосходит модели большего размера: Qwen2.5-1.5B (49.5%), Llama-3.2-3B (48.0%) и Gemma-2-2B (41.2%).
- **Общий зачёт MATH-500**: По всему набору из 500 олимпиадных задач модель набирает **36.2%** (181 решённая задача), опережая Gemma-2-2B (35.0%), Mistral-7B-Instruct (28.4%), SmolLM2-1.7B (21.5%) и Llama-3.2-1B (14.0%).
- **GSM8K**: На тесте многошаговой арифметики модель показывает **52.0%** (260 решённых задач из 500).

---

### Архитектура и параметры

- Параметры: 800 млн (0.8B)
- Внимание: Гибридное линейное внимание (Gated Delta Rule) со сложностью памяти состояния O(1)
- Требования к видеопамяти: около 1.6 ГБ в формате BF16 (работает на потребительских GPU с 4 ГБ VRAM)
- Контекст: до 32 768 токенов
- Лицензия: Apache 2.0