Instructions to use TreeLoys/microRL-20M-ru-en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TreeLoys/microRL-20M-ru-en with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TreeLoys/microRL-20M-ru-en")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TreeLoys/microRL-20M-ru-en") model = AutoModelForCausalLM.from_pretrained("TreeLoys/microRL-20M-ru-en", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TreeLoys/microRL-20M-ru-en with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TreeLoys/microRL-20M-ru-en" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TreeLoys/microRL-20M-ru-en", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TreeLoys/microRL-20M-ru-en
- SGLang
How to use TreeLoys/microRL-20M-ru-en with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "TreeLoys/microRL-20M-ru-en" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TreeLoys/microRL-20M-ru-en", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "TreeLoys/microRL-20M-ru-en" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TreeLoys/microRL-20M-ru-en", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TreeLoys/microRL-20M-ru-en with Docker Model Runner:
docker model run hf.co/TreeLoys/microRL-20M-ru-en
microRL-20M-ru-en
A 20M-parameter bilingual (Russian + English) decoder-only language model, trained from scratch on a single consumer GPU: an NVIDIA P106-100 (2017), the mining variant of the GeForce GTX 1060, Pascal architecture, 6 GB. Total training time for this stage: about 14 hours (27 000 steps). No cloud, no multi-GPU, no framework — a plain PyTorch loop.
This is the second checkpoint of the microRL project. It continues TreeLoys/microRL-20M-TinyStories, which was English-only: that model scored ≈12 nats/token on Russian text (it could not read Russian at all). This one reads Russian at 2.2 nats/token on held-out web text, while keeping nearly all of its English (1.70 vs 1.62 nats/token on the TinyStories validation set).
Status: research artefact and RL testbed. It is small and undertrained — it produces grammatical, topical text that loses coherence over a few sentences. It has no factual knowledge.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("TreeLoys/microRL-20M-ru-en")
tok = AutoTokenizer.from_pretrained("TreeLoys/microRL-20M-ru-en")
ids = tok("Жил-был в одном селе кузнец, и был у него сын, который", return_tensors="pt")
out = model.generate(**ids, max_new_tokens=70, do_sample=True, temperature=0.6, top_k=40)
print(tok.decode(out[0], skip_special_tokens=True))
No trust_remote_code needed: the weights are a native LlamaForCausalLM.
Architecture
Identical to the base model.
| Type | decoder-only Transformer, Llama-style |
| Attention | causal, RoPE (theta 10 000), 8 heads × 32 dims |
| FFN | SwiGLU, intermediate 704 |
| Norm | RMSNorm (eps 1e-5), pre-norm |
| Layers | 18 |
| Hidden size | 256 |
| Context length | 512 |
| Vocabulary | 20 000 byte-level BPE, trained from scratch |
| Embeddings | input and output tied |
| Parameters | 19.58M total, 14.46M without embeddings |
Special tokens: [BOS] [EOS] [UNK] [PAD] <|user|> <|bot|>.
Training data
Mixed corpus of 348M tokens, built locally and tokenized once; the model saw about 442M tokens (≈1.3 epochs).
| Source | Tokens | Language | Note |
|---|---|---|---|
HuggingFaceFW/fineweb-2, rus_Cyrl subset, first shard |
190M | ru | cleaned web text |
| A private book collection (textbooks, engineering notes, fiction), OCR text | 70M | ru, en | not public |
| roneneldan/TinyStories V2 (GPT-4 curated) | 60M | en | replayed to keep English |
| OpenAssistant/oasst1 | 13M | multi | conversations |
| SteemNova: private in-game messages between LLM characters | 15M | ru | 1.4M unique tokens repeated ×11 |
The earlier books-only experiment (see project notes) caused catastrophic forgetting of English; mixing TinyStories back in fixed that.
Training
| Hardware | 1 × NVIDIA P106-100, 6 GB (Pascal, sm_61) |
| Software | PyTorch 2.7.1 + CUDA 11.8, driver 472.12, mixed fp16 (Pascal has no bf16), attention and softmax in fp32 |
| Batch | 32 sequences × 512 tokens (8 per pass × 4 gradient accumulation) |
| Optimizer | AdamW, lr 1.5e-3, betas (0.9, 0.95), weight decay 0.1, 200 warm-up steps, cosine decay |
| Steps | 27 000 (24 000 + 3 000) |
| Time | 746 + 93 = 839 minutes (≈14 h), ~8 900 tokens/s, 1.85 s per step |
| Peak GPU memory | 2.8 GB |
| Initialisation | weights of an intermediate books-only checkpoint, itself started from microRL-20M-TinyStories |
Training loss of the three runs of the project: TinyStories pretraining, the books-only fine-tune (no replay) and this mixed run.
Benchmarks
Loss in nats per token (lower is better). Documents are scored whole, each starting with [BOS], the same protocol as for the base model; web text is scored in 300-token chunks without preceding context, so its absolute numbers are not comparable with the document rows. "Held-out" means the model never saw the text.
| Domain | TinyStories base | ru-en (this) |
|---|---|---|
| Russian web, held-out (end of the FineWeb-2 shard) | 12.23 | 2.20 |
| WikiText-2 test, held-out (English) | 9.12 | 6.80 |
| TinyStories valid, held-out (English) | 1.62 | 1.70 |
| SteemNova messages, seen ×11 | 11.87 | 1.74 |
Same-text comparison with the official TinyStories models and the community leaderboard (bits per byte, lower is better; see the base model card for the full table):
| Model | Params | TinyStories V1 | TinyStories V2 |
|---|---|---|---|
| microRL-20M-TinyStories | 19.6M | 0.491 | 0.500 |
| microRL-20M-ru-en | 19.6M | 0.508 | 0.524 |
| TinyStories-8M (official) | 19.7M | 0.355 | 0.422 |
The price of Russian is a small loss on English children's stories (1.62 → 1.70 nats/token, +5%); the gain everywhere else is large. Raw numbers: ru_en_bench.json.
Generations
Russian (temperature 0.6, top-k 40):
Для измерения индуктивности катушки необходимо учитывать, что с помощью инструментальных усилителей можно использовать различные виды измерительных приборов.
Жил-был в одном селе кузнец, и был у него сын, который я отказался от них. Последняя свидания сейчас всплывает в одном месте, и я стал его коллегами.
The first is coherent technical prose; the second shows the failure mode — grammatical words, broken agreement and no storyline.
English (temperature 0.6, top-k 40):
Once upon a time, there was a little girl named Lily. She was very independent. She liked to do things by herself. One day, she went to the park to play. At the park, Lily saw a big, scary dog. The dog wanted to catch the little girl.
Negative results and pitfalls
Everything below was tried on this model during the project and did not work. It is recorded so that nobody repeats it.
1. Fine-tuning the whole model on one character made it worse. The original goal of this run was a model that writes in-game letters as one of 17 characters (784 messages, ~170k tokens). Full fine-tuning on those turns was tested from two bases at learning rates from 3e-4 down to 2e-5. In every case the loss on held-out turns (the latest 15% of the character's messages by time) rose from the first optimizer step, while the training loss fell to 0.19:
| Base | Before | After (best / worst lr tried) |
|---|---|---|
| books-only intermediate | 4.35 | 5.9 (lr 2e-5) / 16.2 (lr 3e-4) |
| this model | 2.16 | 4.4 (lr 3e-5) / 6.6 (lr 1e-4) |
A 20M model memorises a few hundred examples instead of learning a style, and loses general language ability in the process.
2. Prompting did not substitute for it. Adding the character card and 4–8 real letters as few-shot examples changed the held-out loss by ±0.005. Naming the recipient in the prompt did not fix the openings (the model writes "юноши," where the real letters start with "Святая матушка,"). Sampling advice: greedy decoding loops, temperature 0.7 falls apart, 0.4 with top-k 40 is the least bad.
3. Fine-tuning on one domain without replay causes forgetting. An earlier run fine-tuned the base model on a book collection only (83M tokens, 0.6 epoch). Russian improved (loss 11.7 → 2.8), but TinyStories went from 1.65 to 4.40 and English prose degraded. The fix used here is replay: the target corpus is mixed with a share of the original data (TinyStories 60M of 348M tokens in this mixture).
4. More steps on the same mixture gave nothing. 3 000 extra steps after the main run changed the loss by at most 0.01 on every domain. The model is at its plateau for this data and size; progress needs different data or a larger model.
5. Evaluation mistakes that produced false success. Two bugs made a broken model look perfect: (a) the fine-tuning loss was computed with a one-position shift between logits and targets, so the model was asked to predict a token it had already seen — hold-out loss read 0.003; (b) the character's messages were included in the pretraining mixture, so this base has no clean hold-out on the game dialogs — the 1.74 nats/token above measures memory as much as generalisation. When a metric looks too good, inspect one example by hand.
Intended use and limitations
- Intended: a cheap bilingual base for RL experiments, teaching, tokenizer/architecture tests on consumer hardware.
- Not intended: any factual or general-purpose use, or production text generation.
- Russian is fluent at the phrase level and incoherent at the level of a paragraph.
- The model saw private in-game messages and a private book collection. A probe found no verbatim recall (1.8 nats/token on average over single seen letters, minimum 0.79; verbatim recall would sit close to zero), but style and phrases from those sources can resurface.
- 20 000-token vocabulary; only about half of it is exercised by this data.
Licence
Released for research use. The weights carry influences from sources with different terms: TinyStories (CDLA-Sharing-1.0), FineWeb-2 (ODC-By 1.0), OpenAssistant (Apache 2.0), plus private texts. No license is granted for the private data.
Citation
The first-stage data and baseline models come from:
@article{eldan2023tinystories,
title = {TinyStories: How Small Can Language Models Be and Still Speak Coherent English?},
author = {Eldan, Ronen and Li, Yuanzhi},
journal = {arXiv preprint arXiv:2305.07759},
year = {2023}
}
- Downloads last month
- -
Model tree for TreeLoys/microRL-20M-ru-en
Base model
TreeLoys/microRL-20M-TinyStories