limloop commited on
Commit
d28e292
·
1 Parent(s): 393f217
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.gguf filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,434 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ pipeline_tag: text-generation
4
+ library_name: transformers
5
+ datasets:
6
+ - wikimedia/wikipedia
7
+ - slon-hk/BooksSummarizationRU
8
+ - common-pile/pre_1929_books
9
+ - Fascinat0r/taiga_corpus_subtitles
10
+ - IlyaGusev/ficbook
11
+ - limloop/fantasy_body_interactions
12
+ - limloop/ru_en_story_pairs
13
+ language:
14
+ - ru
15
+ - en
16
+ tags:
17
+ - mamba
18
+ - mamba2
19
+ - ssm
20
+ - causal-lm
21
  ---
22
+
23
+ # whiff_mamba2-50M-v0.1
24
+
25
+ <details>
26
+ <summary>🇷🇺 Нажмите, чтобы развернуть описание на русском</summary>
27
+
28
+ ## 🧠 Что это такое
29
+
30
+ Это маленькая языковая модель на архитектуре Mamba-2. Всего 50 миллионов параметров. Обучалась несколько месяцев на 8-ядерном CPU, потому что GPU у меня нет, а Mamba жрёт меньше памяти и ресурсов, чем трансформеры.
31
+
32
+ **Коротко:** умеет писать грамматически правильные тексты на русском и английском, вести диалоги, выдавать образные описания. Не умеет отвечать на вопросы, держать связность дольше 100 токенов и не впадать в повторы, если ей скучно.
33
+
34
+ **Длинно:** читайте дальше.
35
+
36
+ ---
37
+
38
+ ## 📐 Архитектура
39
+
40
+ Конфиг — Mamba2Config. Цифры подбирались экспериментально, чтобы влезть в 50M и не умереть от OOM на CPU.
41
+
42
+ | Параметр | Значение | Почему так |
43
+ |:---|:---|:---|
44
+ | vocab_size | 32064 | от [Phi-3.5-mini](https://huggingface.co/microsoft/Phi-3.5-mini-instruct), не пришлось учить свой токенизатор |
45
+ | hidden_size | 512 | маленькие модели — маленькие размерности |
46
+ | num_hidden_layers | 20 | глубокая, но узкая |
47
+ | state_size | 48 | меньше стандартного (128) |
48
+ | num_heads | 8 | для внутреннего внимания в Mamba2 |
49
+ | head_dim | 64 | 512/8 = 64 |
50
+ | conv_kernel | 4 | большое ядро для локальных паттернов, тут решил не экономить |
51
+ | expand | 1 | нет внутреннего расширения → d_inner = 512 |
52
+ | use_conv_bias | True | без него GGUF не конвертировался |
53
+ | tie_word_embeddings | False | с ним safetensors ругался |
54
+
55
+ **Главное:** вся память модели о контексте — это 20 слоёв × 48 состояний = **960 чисел**. Запоминать на 512 токенов это объективно мало, поэтому после 100 токенов модель начинает "забывать", о чём писала.
56
+
57
+ ---
58
+
59
+ ## 📚 На чём обучена
60
+
61
+ **Всего:** 454К примеров, ~230M токенов. Русский + английский, билингва.
62
+
63
+ **Источники (по убыванию объёма):**
64
+ - `wikimedia/wikipedia` — энциклопедия, чистый язык
65
+ - `slon-hk/BooksSummarizationsRU` — пересказы книг
66
+ - `common-pile/pre_1929_books` — старые английские книги (до истечения копирайта)
67
+ - `Fascinat0r/taiga_corpus_subtitles` — субтитры, диалоговая речь
68
+ - `IlyaGusev/ficbook` — фанфики, образность и стили
69
+ - `limloop/fantasy_body_interactions` — просто так
70
+ - `limloop/ru_en_story_pairs` — параллельные тексты, помогает не путать языки
71
+
72
+ ---
73
+
74
+ ## 🏋️ Процесс обучения
75
+
76
+ Одна эпоха, прогрессивное увеличение контекста. Я не мог начать сразу с 512 токенов — модель бы не сошлась, да и я решил сэкономить время обучения. Поэтому 8 этапов, каждый увеличивал либо контекст, либо батч.
77
+
78
+ | Этап | Контекст | Batch size | Что поменялось |
79
+ |:---|:---|:---|:---|
80
+ | 1 | 64 | 64 | старт, есть 40+% Wikipedia и нет story_pairs |
81
+ | 2 | 128 | 64 | удвоил контекст |
82
+ | 3 | 256 | 64 | ещё удвоил |
83
+ | 4 | 256 | 96 | убрал Wikipedia, добавил story_pairs |
84
+ | 5 | 512 | 96 | наконец-то полный контекст |
85
+ | 6 | 512 | 256 | больше батч — стабильнее градиент |
86
+ | 7 | 512 | 360 | еще больше |
87
+ | 8 | 512 | 512 | максимальный батч |
88
+
89
+ **Железо:** Ryzen 7 5700G CPU, DDR4 32GB.
90
+ **Время:** В целом часов 200-300 (8-10 дней) чистого времени обучения.
91
+
92
+ ---
93
+
94
+ ## 📊 Результаты
95
+
96
+ **Цифры:**
97
+ - Train loss: 2.97
98
+ - Eval loss: 3.03
99
+ - Perplexity: exp(3.03) ≈ 20.7
100
+
101
+ **Качество (температура 0.4, оптимальная):**
102
+ - Грамматика на русском почти всегда правильная
103
+ - На английском — правильная, но иногда неидиоматичная ("you're not a doctor" вместо "you're not a doctor, are you?")
104
+ - Диалоги естественные, реплики осмысленные
105
+ - Образность есть (солнце садится, дождь стучит по крыше)
106
+ - Связность держится ~50-100 токенов, дальше начинает плавать
107
+
108
+ **Что не умеет (честно):**
109
+ - Отвечать на фактологические вопросы ("столица Франции" → "the United States")
110
+ - Считать (цифры превращаются в бесконечные последовательности)
111
+ - Следовать инструкциям (это base LM, не instruct)
112
+ - Помнить, что было 150 токенов назад
113
+
114
+ ---
115
+
116
+ ## 🔥 Примеры генерации
117
+
118
+ Все примеры — temperature 0.4, 512 новых токенов. Никакой ручной фильтрации, что сгенерировала модель, то и выложил.
119
+
120
+ <details>
121
+ <summary>🇬🇧 English examples (click)</summary>
122
+
123
+ **Prompt:** `The sun was setting`
124
+
125
+ > The sun was setting 125, and the sun was setting down the sky. Suddenly a familiar silhouette appeared on the threshold - a girl with bright pink hair tied in a white dress.
126
+ > "Hi," he muttered under his breath. "I'm Denis," he said quietly. "You were just sitting here for three years. I've been waiting for you."
127
+ > "No, no, no," Denis shrugged. "And now we're both alone."
128
+ > "I'm not a detective," Denis replied calmly. "It's just... it's like that."
129
+ > "Don't be afraid," Denis whispered, stepping closer. "What are you doing here?"
130
+ > "Oh, just a little girl," Denis chuckled. "But I don't know what to do next."
131
+ > "That's exactly what I found out of my life!" Denis asked. "I'm not your mother."
132
+ > "No, this is impossible," Denis admitted. "It's all right. But I'm always free. And you know how much I've seen him before? Maybe we should have come back then?"
133
+ > "You won't believe what happened to me. You'll never get you out of here."
134
+ > "Maybe I could feel the cold water?" Denis shuddered. "You're in danger. I'm just... I'm not sure. And I'm afraid. I'm not going to work. And I think I'd never forgive. It's just... you're still trying to understand why I'm in love. You're not alone. What would you want to talk about? Why did you come from? And I'm not a doctor. He's not so much. But if I'm not saying anything. But I can't live without being afraid. Maybe I'm just afraid to make yourself alive. Or maybe I'm not afraid. But I'm not ready. I'm not afraid. Afraid that I'm not afraid. That's why I'm not a child. And I'm just afraid of losing you. I'm not a good guy. And I'm not so glad I'm not afraid. Just don't hurt you. I'm not really good. And you're not a
135
+
136
+ **Prompt:** `What is the capital of`
137
+
138
+ > What is the capital of the United States? It was not to be done, but it was a matter that he had to do with this subject. He was a very great man, and he was a man of his own son, who had been in a large part of his country, and he would have been able to come back to the British Government, which was as well as his father's estate. His father was a little boy, and he was a man of about lasting age. He was at the time of the Jewish years, and was one of the most offered manhood, and now that he had been made a good deal of him. He was not an accountant; he was a man of their mother; and he was the best friend of Mrs. D. W. L. C. D. S. M. M. D. M. D. B. N. C. G. R. W. Duff. 2d. He was married in 1843, and had a wife of a young woman, and was married to Dr. J. M. S. Sawyer. She was a very young fellow, and her husband had died in the child's life. Her daughter was a father, and then she was married to Mrs. H. W. H. P. F. A. D. D. D. D. D. D. E. A. D. D. D. D. S. T. T. K. C. D. D. D. D. D. D. D. B. D. D. D. D. M. D. D. D. D. D. M. D. A. C. B. B. M. A. A. D. D. D. D. D. A. A. A. A. A. D. D. D. A. A. A. A. A. A. D. A. D. D. A. A. D. D. D. D. D. A. A. A. A. D. D. A. A. A. A. A. D. A. A. A. A. A. A. D. D.
139
+
140
+ *(Да, модель не умеет отвечать на вопросы. Я предупреждал.)*
141
+
142
+ </details>
143
+
144
+ <details>
145
+ <summary>🇷🇺 Русские примеры (нажми)</summary>
146
+
147
+ **Prompt:** `За поворотом тропинки стоял`
148
+
149
+ > За поворотом тропинки стоял у входа в кафе, сжимая в руках потрепанный шарф и закат. Внезапно кто-то из них открылся, и в комнату вошла молодая женщина в черном ��лаще.
150
+ > — Что это? — прошептала она, не отрываясь от ощущения.
151
+ > — Да, я... Я не знаю, что ты сказал, но мысли не приходили. Но ведь это было уже не то, что теперь надо мной.
152
+ > Они молча сидели, не зная, как говорить, а не друг. Он был прав, только что просто так.
153
+ > — Ты же знаешь, что самое страшное? — спросил он, стараясь, чтобы голос звучал странно.
154
+ > — А ты думаешь, что я должен делать? — спросил он, стараясь, чтобы голос звучал странным.
155
+ > — Нет, — ответил мужчина, чувствуя себя полностью. — Потому что ты всегда будешь готов.
156
+ > — Именно поэтому я сейчас буду рядом. Сейчас же ты меня видел, что это невозможно.
157
+ > — Неужели ты не видишь? — спросил он, подходя ближе.
158
+ > — Знаешь, что я могу быть вместе, — продолжал он, не отрывая взгляда от экрана. — Просто... нужно сделать вид, что всё ещё закончится.
159
+ > — Как вы собираетесь сходить? — спросил он, стараясь, чтобы голос не дрожал.
160
+ > — Да, — ответила девушка, — я не знаю, где ты. Я люблю тебя, давайте поговорим.
161
+ > — Да, — ответил он, глядя на него. — Я не хочу, чтобы ты никогда не понимал, какой именно его.
162
+ > — Может, это была твоя помощь. О том, что ты помнишь, как ты узнал, что
163
+
164
+ **Prompt:** `Почему небо`
165
+
166
+ > Почему небо стояла в кабинете, когда она пошла на кухню. Она была очень тяжелая, но забывала про нее снова. Но ей было не так хорошо. Она уже знала, что это был немного грустный и глупый. Иногда она могла увидеть его. — Ну, конечно же, — тихо сказал он. — Давай, — ответил он, — я не хочу спать, а теперь мы будем вместе. — Как ты? – спросил он. — Что ты делаешь? — Не знаю, — ответила девушка. — Я люблю тебя, — усмехнулся он. — А где же твои родители? — Ага, — вздохнула она. — Смотри, как всегда, — отвечал он, — я вас с тобой не допущу. — Идите, — сказал он, — но... — осторожно прошептал он. — У меня есть возможность быть правдой. — Тогда я могу поговорить с ней, — ответил парень, — а ты не знаешь, что я тебе не нужен. — Вставай, — заявил он, — давайте поговорим, — сказал он, — я бы не знаю, что ты мне не нравишься, но я не буду говорить. — Конечно, — сказал он, — но я не собираюсь никогда не рассказывать об этом. Он сказал, что сейчас, когда я сказал, что он живет рядом, а не потому, что я не слышал. — Если вы не смогли бы придумать, то я не знаю, — сказал он, — я не могу этого не думать, — признаться он. — Или я не могу, — сказал он, — я не скажу тебе. Это не справедливое лицо. Я понимаю, что ответить. И вот, когда я понял,
167
+
168
+ </details>
169
+
170
+ <details>
171
+ <summary>⚠️ Патологические случаи (что идёт не так)</summary>
172
+
173
+ **Зацикливание на английском:**
174
+ > The population is approximately 15,000 people. The city was furnished by the country... 00.00.00 00.00 00.00 00.00.00 00.00 00.00 00.00
175
+
176
+ **Зацикливание на русском:**
177
+ > Для начала нужно: 17 лет, 20 минут, 30 Секунды, 50 Мирата, 40 Как и захочет сделать это...
178
+
179
+ Это происходит, когда модель попадает в "аттрактор" — комбинацию состояний SSM, из которой трудно выйти. Лечится повышением температуры или регенерацией с дру��им seed.
180
+
181
+ </details>
182
+
183
+ ---
184
+
185
+ ## 🚀 Как использовать
186
+
187
+ ```python
188
+ from transformers import AutoModelForCausalLM, AutoTokenizer
189
+
190
+ model = AutoModelForCausalLM.from_pretrained("limloop/whiff-mamba2-50M-v0.1")
191
+ tokenizer = AutoTokenizer.from_pretrained("limloop/whiff-mamba2-50M-v0.1")
192
+
193
+ # Важно: температура 0.4 — сладкая точка
194
+ prompt = "Однажды в лесу"
195
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
196
+ outputs = model.generate(
197
+ **inputs,
198
+ max_new_tokens=512,
199
+ temperature=0.4,
200
+ do_sample=True,
201
+ top_p=0.95
202
+ )
203
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
204
+ ```
205
+
206
+ **Советы по генерации:**
207
+ - Температура 0.3-0.5 — оптимальный диапазон
208
+ - Ниже 0.3 — повторы усиливаются
209
+ - Выше 0.7 — начинается бред
210
+
211
+ ---
212
+
213
+ ## 📉 Ограничения
214
+
215
+ 1. **Не instruct.** Модель не понимает команд "напиши письмо" или "переведи текст". Она только продолжает.
216
+ 2. **Не фактологическая.** На вопрос "кто такой Пушкин" скорее начнёт писать художественный текст про человека в цилиндре.
217
+ 3. **Короткая память.** После 100 токенов детали начинают теряться. После 200 — может забыть имена персонажей.
218
+ 4. **Повторы.** Иногда зацикливается на слове или цифре. Лечится регенерацией.
219
+ 5. **Английский корявый.** Модель билингва, но английский выучен хуже. Фразы грамматически правильные, но неестественные.
220
+ 6. **Не считает.** Цифры для неё — просто токены, без математического смысла.
221
+
222
+ ---
223
+
224
+ ## 🎯 Для кого эта модель
225
+
226
+ - **Исследователи SSM** — посмотреть, как Mamba2 ведёт себя в минималистичной конфигурации
227
+ - **Люди без GPU** — модель работает на CPU
228
+ - **Энтузиасты билингвальных моделей** — русский и английский в одном флаконе
229
+ - **Те, кто хочет дообучить LoRA** — 50M легко дообучается даже на Google Colab
230
+
231
+ </details>
232
+
233
+ ## 🧠 What is this
234
+
235
+ This is a small language model based on the Mamba-2 architecture. Only 50 million parameters. It was trained for several months on an 8-core CPU, because I don't have a GPU, and Mamba consumes less memory and resources than transformers.
236
+
237
+ **In short:** It can write grammatically correct texts in Russian and English, hold dialogues, and produce figurative descriptions. It cannot answer questions, maintain coherence beyond 100 tokens, or avoid repetition when it gets bored.
238
+
239
+ **In long:** Read on.
240
+
241
+ ---
242
+
243
+ ## 📐 Architecture
244
+
245
+ The config is Mamba2Config. The numbers were chosen experimentally to fit into 50M and not die from OOM on the CPU.
246
+
247
+ | Parameter | Value | Why |
248
+ |:---|:---|:---|
249
+ | vocab_size | 32064 | from [Phi-3.5-mini](https://huggingface.co/microsoft/Phi-3.5-mini-instruct), didn't have to train my own tokenizer |
250
+ | hidden_size | 512 | small models — small dimensions |
251
+ | num_hidden_layers | 20 | deep but narrow |
252
+ | state_size | 48 | smaller than standard (128) |
253
+ | num_heads | 8 | for internal attention in Mamba2 |
254
+ | head_dim | 64 | 512/8 = 64 |
255
+ | conv_kernel | 4 | large kernel for local patterns, decided not to skimp here |
256
+ | expand | 1 | no internal expansion → d_inner = 512 |
257
+ | use_conv_bias | True | without it, GGUF wouldn't convert |
258
+ | tie_word_embeddings | False | safetensors complained with it on |
259
+
260
+ **The main thing:** the model's entire memory of the context is 20 layers × 48 states = **960 numbers**. Remembering over 512 tokens is objectively too little, so after 100 tokens the model starts to "forget" what it was writing about.
261
+
262
+ ---
263
+
264
+ ## 📚 What it was trained on
265
+
266
+ **Total:** 454K examples, ~230M tokens. Russian + English, bilingual.
267
+
268
+ **Sources (by decreasing volume):**
269
+ - `wikimedia/wikipedia` — encyclopedia, clean language
270
+ - `slon-hk/BooksSummarizationsRU` — book summaries
271
+ - `common-pile/pre_1929_books` — old English books (pre-copyright expiration)
272
+ - `Fascinat0r/taiga_corpus_subtitles` — subtitles, dialogue speech
273
+ - `IlyaGusev/ficbook` — fan fiction, imagery and styles
274
+ - `limloop/fantasy_body_interactions` — just because
275
+ - `limloop/ru_en_story_pairs` — parallel texts, helps avoid language confusion
276
+
277
+ ---
278
+
279
+ ## 🏋️ Training process
280
+
281
+ One epoch, progressive context increase. I couldn't start with 512 tokens right away — the model wouldn't converge, and I also wanted to save training time. So 8 stages, each increasing either the context or the batch size.
282
+
283
+ | Stage | Context | Batch size | What changed |
284
+ |:---|:---|:---|:---|
285
+ | 1 | 64 | 64 | start, 40+% Wikipedia and no story_pairs |
286
+ | 2 | 128 | 64 | doubled context |
287
+ | 3 | 256 | 64 | doubled again |
288
+ | 4 | 256 | 96 | removed Wikipedia, added story_pairs |
289
+ | 5 | 512 | 96 | finally full context |
290
+ | 6 | 512 | 256 | larger batch — more stable gradient |
291
+ | 7 | 512 | 360 | even larger |
292
+ | 8 | 512 | 512 | maximum batch |
293
+
294
+ **Hardware:** Ryzen 7 5700G CPU, DDR4 32GB.
295
+ **Time:** About 200-300 hours (8-10 days) of pure training time.
296
+
297
+ ---
298
+
299
+ ## 📊 Results
300
+
301
+ **Numbers:**
302
+ - Train loss: 2.97
303
+ - Eval loss: 3.03
304
+ - Perplexity: exp(3.03) ≈ 20.7
305
+
306
+ **Quality (temperature 0.4, optimal):**
307
+ - Grammar in Russian is almost always correct
308
+ - In English — correct, but sometimes non-idiomatic ("you're not a doctor" instead of "you're not a doctor, are you?")
309
+ - Dialogues are natural, responses are meaningful
310
+ - Figurative language exists (sun sets, rain taps on the roof)
311
+ - Coherence holds for ~50-100 tokens, then starts to drift
312
+
313
+ **What it cannot do (honestly):**
314
+ - Answer factual questions ("capital of France" → "the United States")
315
+ - Count (numbers turn into endless sequences)
316
+ - Follow instructions (this is a base LM, not instruct)
317
+ - Remember what happened 150 tokens ago
318
+
319
+ ---
320
+
321
+ ## 🔥 Generation examples
322
+
323
+ All examples — temperature 0.4, 512 new tokens. No manual filtering, what the model generated is what was posted.
324
+
325
+ <details>
326
+ <summary>🇬🇧 English examples (click)</summary>
327
+
328
+ **Prompt:** `The sun was setting`
329
+
330
+ > The sun was setting 125, and the sun was setting down the sky. Suddenly a familiar silhouette appeared on the threshold - a girl with bright pink hair tied in a white dress.
331
+ > "Hi," he muttered under his breath. "I'm Denis," he said quietly. "You were just sitting here for three years. I've been waiting for you."
332
+ > "No, no, no," Denis shrugged. "And now we're both alone."
333
+ > "I'm not a detective," Denis replied calmly. "It's just... it's like that."
334
+ > "Don't be afraid," Denis whispered, stepping closer. "What are you doing here?"
335
+ > "Oh, just a little girl," Denis chuckled. "But I don't know what to do next."
336
+ > "That's exactly what I found out of my life!" Denis asked. "I'm not your mother."
337
+ > "No, this is impossible," Denis admitted. "It's all right. But I'm always free. And you know how much I've seen him before? Maybe we should have come back then?"
338
+ > "You won't believe what happened to me. You'll never get you out of here."
339
+ > "Maybe I could feel the cold water?" Denis shuddered. "You're in danger. I'm just... I'm not sure. And I'm afraid. I'm not going to work. And I think I'd never forgive. It's just... you're still trying to understand why I'm in love. You're not alone. What would you want to talk about? Why did you come from? And I'm not a doctor. He's not so much. But if I'm not saying anything. But I can't live without being afraid. Maybe I'm just afraid to make yourself alive. Or maybe I'm not afraid. But I'm not ready. I'm not afraid. Afraid that I'm not afraid. That's why I'm not a child. And I'm just afraid of losing you. I'm not a good guy. And I'm not so glad I'm not afraid. Just don't hurt you. I'm not really good. And you're not a
340
+
341
+ **Prompt:** `What is the capital of`
342
+
343
+ > What is the capital of the United States? It was not to be done, but it was a matter that he had to do with this subject. He was a very great man, and he was a man of his own son, who had been in a large part of his country, and he would have been able to come back to the British Government, which was as well as his father's estate. His father was a little boy, and he was a man of about lasting age. He was at the time of the Jewish years, and was one of the most offered manhood, and now that he had been made a good deal of him. He was not an accountant; he was a man of their mother; and he was the best friend of Mrs. D. W. L. C. D. S. M. M. D. M. D. B. N. C. G. R. W. Duff. 2d. He was married in 1843, and had a wife of a young woman, and was married to Dr. J. M. S. Sawyer. She was a very young fellow, and her husband had died in the child's life. Her daughter was a father, and then she was married to Mrs. H. W. H. P. F. A. D. D. D. D. D. D. E. A. D. D. D. D. S. T. T. K. C. D. D. D. D. D. D. D. B. D. D. D. D. M. D. D. D. D. D. M. D. A. C. B. B. M. A. A. D. D. D. D. D. A. A. A. A. A. D. D. D. A. A. A. A. A. A. D. A. D. D. A. A. D. D. D. D. D. A. A. A. A. D. D. A. A. A. A. A. D. A. A. A. A. A. A. D. D.
344
+
345
+ *(Yes, the model cannot answer questions. I warned you.)*
346
+
347
+ </details>
348
+
349
+ <details>
350
+ <summary>🇷🇺 Russian examples (click)</summary>
351
+
352
+ **Prompt:** `За поворотом тропинки стоял`
353
+
354
+ > За поворотом тропинки стоял у входа в кафе, сжимая в руках потрепанный шарф и закат. Внезапно кто-то из них открылся, и в комнат�� вошла молодая женщина в черном плаще.
355
+ > — Что это? — прошептала она, не отрываясь от ощущения.
356
+ > — Да, я... Я не знаю, что ты сказал, но мысли не приходили. Но ведь это было уже не то, что теперь надо мной.
357
+ > Они молча сидели, не зная, как говорить, а не друг. Он был прав, только что просто так.
358
+ > — Ты же знаешь, что самое страшное? — спросил он, стараясь, чтобы голос звучал странно.
359
+ > — А ты думаешь, что я должен делать? — спросил он, стараясь, чтобы голос звучал странным.
360
+ > — Нет, — ответил мужчина, чувствуя себя полностью. — Потому что ты всегда будешь готов.
361
+ > — Именно поэтому я сейчас буду рядом. Сейчас же ты меня видел, что это невозможно.
362
+ > — Неужели ты не видишь? — спросил он, подходя ближе.
363
+ > — Знаешь, что я могу быть вместе, — продолжал он, не отрывая взгляда от экрана. — Просто... нужно сделать вид, что всё ещё закончится.
364
+ > — Как вы собираетесь сходить? — спросил он, стараясь, чтобы голос не дрожал.
365
+ > — Да, — ответила девушка, — я не знаю, где ты. Я люблю тебя, давайте поговорим.
366
+ > — Да, — ответил он, глядя на него. — Я не хочу, чтобы ты никогда не понимал, какой именно его.
367
+ > — Может, это была твоя помощь. О том, что ты помнишь, как ты узнал, что
368
+
369
+ **Prompt:** `Почему небо`
370
+
371
+ > Почему небо стояла в кабинете, когда она пошла на кухню. Она была очень тяжелая, но забывала про нее снова. Но ей было не так хорошо. Она уже знала, что это был немного грустный и глупый. Иногда она могла увидеть его. — Ну, конечно же, — тихо сказал он. — Давай, — ответил он, — я не хочу спать, а теперь мы будем вместе. — Как ты? – спросил он. — Что ты делаешь? — Не знаю, — ответила девушка. — Я люблю тебя, — усмехнулся он. — А где же твои родители? — Ага, — вздохнула она. — Смотри, как всегда, — отвечал он, — я вас с тобой не допущу. — Идите, — сказал он, — но... — осторожно прошептал он. — У меня есть возможность быть правдой. — Тогда я могу поговорить с ней, — ответил парень, — а ты не знаешь, что я тебе не нужен. — Вставай, — заявил он, — давайте поговорим, — сказал он, — я бы не знаю, что ты мне не нравишься, но я не буду говорить. — Конечно, — сказал он, — но я не собираюсь никогда не рассказывать об этом. Он сказал, что сейчас, когда я сказал, что он живет рядом, а не потому, что я не слышал. — Если вы не смогли бы придумать, то я не знаю, — сказал он, — я не могу этого не думать, — признаться он. — Или я не могу, — сказал он, — я не скажу тебе. Это не справедливое лицо. Я понимаю, что ответить. И вот, когда я понял,
372
+
373
+ </details>
374
+
375
+ <details>
376
+ <summary>⚠️ Pathological cases (what goes wrong)</summary>
377
+
378
+ **Looping in English:**
379
+ > The population is approximately 15,000 people. The city was furnished by the country... 00.00.00 00.00 00.00 00.00.00 00.00 00.00 00.00
380
+
381
+ **Looping in Russian:**
382
+ > Для начала нужно: 17 лет, 20 минут, 30 Секунды, 50 Мирата, 40 Как и захочет сделать это...
383
+
384
+ This happens when the model falls into an "attractor" — a combination of SSM states from which it is difficult to escape. It can be fixed by raising the temperature or regenerating with a different seed.
385
+
386
+ </details>
387
+
388
+ ---
389
+
390
+ ## 🚀 How to use
391
+
392
+ ```python
393
+ from transformers import AutoModelForCausalLM, AutoTokenizer
394
+
395
+ model = AutoModelForCausalLM.from_pretrained("limloop/whiff-mamba2-50M-v0.1")
396
+ tokenizer = AutoTokenizer.from_pretrained("limloop/whiff-mamba2-50M-v0.1")
397
+
398
+ # Important: temperature 0.4 is the sweet spot
399
+ prompt = "Once upon a time in the forest"
400
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
401
+ outputs = model.generate(
402
+ **inputs,
403
+ max_new_tokens=512,
404
+ temperature=0.4,
405
+ do_sample=True,
406
+ top_p=0.95
407
+ )
408
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
409
+ ```
410
+
411
+ **Generation tips:**
412
+ - Temperature 0.3-0.5 is the optimal range
413
+ - Below 0.3 — repetitions increase
414
+ - Above 0.7 — hallucinations begin
415
+
416
+ ---
417
+
418
+ ## 📉 Limitations
419
+
420
+ 1. **Not instruct.** The model does not understand commands like "write a letter" or "translate text". It only continues.
421
+ 2. **Not factual.** To the question "who is Pushkin" it will likely start writing a fictional text about a man in a top hat.
422
+ 3. **Short memory.** After 100 tokens, details start to get lost. After 200 — it may forget character names.
423
+ 4. **Repetitions.** Sometimes it loops on a word or digit. Fix by regenerating.
424
+ 5. **Clumsy English.** The model is bilingual, but English is learned worse. Phrases are grammatically correct but unnatural.
425
+ 6. **Cannot count.** Numbers are just tokens to it, without mathematical meaning.
426
+
427
+ ---
428
+
429
+ ## 🎯 Who this model is for
430
+
431
+ - **SSM researchers** — to see how Mamba2 behaves in a minimalist configuration
432
+ - **People without a GPU** — the model runs on CPU
433
+ - **Enthusiasts of bilingual models** — Russian and English in one package
434
+ - **Those who want to fine-tune LoRA** — 50M is easy to fine-tune even on Google Colab
bf16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c0442054e3c30c41b47f9636cfdde5d251883cbf0b43bc0f77757412e5968e0
3
+ size 100319872
chat_template.jinja ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|system|>
2
+ ' + message['content'] + '<|end|>
3
+ '}}{% elif message['role'] == 'user' %}{{'<|user|>
4
+ ' + message['content'] + '<|end|>
5
+ '}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>
6
+ ' + message['content'] + '<|end|>
7
+ '}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>
8
+ ' }}{% else %}{{ eos_token }}{% endif %}
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Mamba2ForCausalLM"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "chunk_size": 256,
7
+ "conv_kernel": 4,
8
+ "dtype": "float32",
9
+ "eos_token_id": 32000,
10
+ "expand": 1,
11
+ "head_dim": 64,
12
+ "hidden_act": "silu",
13
+ "hidden_size": 512,
14
+ "initializer_range": 0.2,
15
+ "layer_norm_epsilon": 1e-05,
16
+ "max_position_embeddings": 65536,
17
+ "model_type": "mamba2",
18
+ "n_groups": 1,
19
+ "num_heads": 8,
20
+ "num_hidden_layers": 20,
21
+ "pad_token_id": 32000,
22
+ "rescale_prenorm_residual": false,
23
+ "residual_in_fp32": true,
24
+ "rms_norm": true,
25
+ "state_size": 48,
26
+ "tie_word_embeddings": false,
27
+ "time_step_floor": 0.0001,
28
+ "time_step_limit": [
29
+ 0.0,
30
+ {
31
+ "__float__": "Infinity"
32
+ }
33
+ ],
34
+ "time_step_max": 0.1,
35
+ "time_step_min": 0.001,
36
+ "time_step_rank": 32,
37
+ "transformers_version": "5.3.0",
38
+ "use_bias": false,
39
+ "use_cache": false,
40
+ "use_conv_bias": true,
41
+ "vocab_size": 32064
42
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 32000,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 32000,
8
+ "transformers_version": "5.3.0",
9
+ "use_cache": true
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c29eb6ac7c32ee9583c20bb93738869f8bb20a0c8c76ee5d66d153cd582e039
3
+ size 198856552
q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac5e5d6844bce6f0acd84934a7887f2eea8ebbcfc646000eb2c199cb18bf59d9
3
+ size 53796224
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cb815b904d82b82b25dcd90edd00e71a5ee5443472ad611bcb84f1339300647
3
+ size 3620657
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
3
+ size 499723
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<s>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "<|endoftext|>",
6
+ "is_local": false,
7
+ "legacy": false,
8
+ "model_max_length": 131072,
9
+ "pad_token": "<|endoftext|>",
10
+ "padding_side": "left",
11
+ "sp_model_kwargs": {},
12
+ "tokenizer_class": "TokenizersBackend",
13
+ "unk_token": "<unk>",
14
+ "use_default_system_prompt": false
15
+ }