Instructions to use Squeal-Studio/drakon_58m-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Squeal-Studio/drakon_58m-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Squeal-Studio/drakon_58m-base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Squeal-Studio/drakon_58m-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Squeal-Studio/drakon_58m-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Squeal-Studio/drakon_58m-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Squeal-Studio/drakon_58m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Squeal-Studio/drakon_58m-base
- SGLang
How to use Squeal-Studio/drakon_58m-base 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 "Squeal-Studio/drakon_58m-base" \ --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": "Squeal-Studio/drakon_58m-base", "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 "Squeal-Studio/drakon_58m-base" \ --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": "Squeal-Studio/drakon_58m-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Squeal-Studio/drakon_58m-base with Docker Model Runner:
docker model run hf.co/Squeal-Studio/drakon_58m-base
drakon_58m-base is a compact ~58M parameter language model pretrained from scratch, primarily on Russian-language text (with a small share of English). It uses the Drakon hybrid architecture combining Depthwise Causal Conv, MinGRU, and Full Causal Attention with RoPE — every 3rd block is an attention block.
This is a base model (pretraining only). Instruction-tuned (SFT) version is in progress.
Research and Educational Model. Designed for experimentation and research. Given its size, performance on complex tasks will be limited.
Model Description
- Architecture: Drakon (Depthwise Conv + MinGRU + Causal Attention with RoPE)
- Parameters: ~58M
- Tokenizer: Custom BPE, vocab_size = 24,064
- Context length: 2048 tokens
- Languages: Russian (primary), English (~10% of training tokens)
Architecture Details
| Parameter | Value |
|---|---|
| vocab_size | 24,064 |
| hidden_size | 576 |
| num_layers | 18 |
| num_attention_heads | 9 |
| attention_every_n_layers | 3 |
| num_attention_layers | 6 |
| num_mingru_layers | 12 |
| conv_kernel_size | 4 |
| ffn_ratio | 2.0 |
| dropout | 0.0 |
| max_position_embeddings | 2048 |
| position_embedding | RoPE |
| normalization | RMSNorm (pre-norm) |
| block_pattern | [ConvMinGRU, ConvMinGRU, Attention] x 6 |
Training Details
- Dataset: ~6.32M documents, ~19.2B characters, ~5.06B unique tokens, ~10.1B tokens total (2 epochs)
- Preprocessing: Unicode normalization (NFKC), Cyrillic-ratio filtering, degenerate-repetition filtering, digit/punctuation-ratio filtering, Wikipedia, Fineweb2, cultura paragraph-level chunking, short-utterance grouping, exact deduplication (SHA-256), and approximate deduplication (MinHash/LSH)
- Sequence length: 2048 tokens
- Epochs: 2
- Batch size: 8 per device, gradient accumulation steps 8, 2 GPUs (effective batch size 128 sequences)
- Learning rate: 8e-4 (linear warmup 500 steps, cosine decay to 8e-5, min_lr_ratio = 0.1)
- Weight decay: 0.1 (2D parameters except embeddings; 0.0 for the rest)
- Max grad norm: 1.0
- Steps: 38,643
- Precision: fp16 (mixed precision:
torch.autocast+GradScaler) - Seed: 1337 (validation chunks are selected with a separate fixed seed, 12345)
Sources:
| Source | Documents | Tokens | Characters | Tokens, % | Chars / token |
|---|---|---|---|---|---|
| fineweb2_ru | 2,115,650 | 1,698,478,016 | 6,891,604,708 | 33.54 | 4.06 |
| wikipedia | 1,662,673 | 1,414,341,480 | 4,902,938,113 | 27.93 | 3.47 |
| fineweb_edu_en | 403,122 | 513,906,255 | 1,764,675,193 | 10.15 | 3.43 |
| taiga_proza | 278,519 | 482,585,759 | 1,762,442,320 | 9.53 | 3.65 |
| habr | 349,882 | 479,547,828 | 1,900,452,525 | 9.47 | 3.96 |
| ru_news | 1,018,578 | 402,479,191 | 1,694,226,254 | 7.95 | 4.21 |
| opensubtitles | 491,350 | 73,032,178 | 258,108,908 | 1.44 | 3.53 |
| Total | 6,319,774 | 5,064,370,707 | 19,174,448,021 | 100.00 | — |
Evaluation
| Step | Eval Loss | Perplexity |
|---|---|---|
| 5,000 | 3.1258 | 22.8 |
| 10,000 | 2.9911 | 19.9 |
| 15,000 | 2.9234 | 18.6 |
| 20,000 | 2.8751 | 17.7 |
| 25,000 | 2.8332 | 17.0 |
| 30,000 | 2.7974 | 16.4 |
| 38,500 | 2.7779 | 16.1 |
Training Curve
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "Squeal-Studio/drakon_58m-base"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval().cuda()
# Model was pretrained with <bos> at the start of every sequence
inputs = tok(tok.bos_token + "Однажды в лесу", return_tensors="pt").to("cuda")
inputs.pop("token_type_ids", None)
out = model.generate(
**inputs,
max_new_tokens=150,
do_sample=True,
temperature=0.8,
top_k=50,
repetition_penalty=1.1,
)
print(tok.decode(out[0], skip_special_tokens=True))
# Optional fast CUDA Graph greedy decoding (CUDA only):
out_fast = model.fast_generate(inputs["input_ids"], max_new_tokens=150)
print(tok.decode(out_fast[0], skip_special_tokens=True))
Architecture & Runtime Update (vs drakon_28m-base)
Compared to Squeal-Studio/drakon_28m-base, drakon_58m-base scales both capacity (2.03x total / 2.48x active non-embedding parameters, 2x context length) and introduces a faster runtime implementation in modeling_drakon.py (with PyTorch fallback on CPU / non-Triton environments):
- Triton MinGRU scan (fused gate projections, forward + backward)
- Triton RMSNorm (forward + backward)
- 64-aligned
lm_head+ Triton Cross-Entropy (fp32 softmax on the fly without materializing fp32 logits) DrakonCache(caches MinGRU hidden state, Conv1d state, and RoPE KV cache duringgenerate())model.fast_generate()(CUDA Graph single-token greedy decoding)
GPU Benchmark (Tesla T4 14.6 GB, fp16, PyTorch 2.14.1+cu130, Triton 3.8.0)
| Metric | drakon_28m-base |
drakon_58m-base |
Comparison |
|---|---|---|---|
| Total parameters | 28.48M | 57.78M | 2.03x |
| Active (non-embedding) params | 17.73M | 43.92M | 2.48x |
| Layers / Hidden size | 12 / 448 | 18 / 576 | — |
| Max context | 1024 | 2048 | 2.00x |
Model weights VRAM (fp16) |
54.7 MB | 128.4 MB | 2.35x |
Prefill (1024 tok, bs=1) |
16,584 tok/s (61.7 ms) | 51,246 tok/s (20.0 ms) | 3.09x faster |
generate() (64 + 256 tok) |
35.3 tok/s (7,261 ms) | 43.5 tok/s (5,889 ms) | 1.23x faster |
fast_generate() (CUDA Graph) |
— | 263.5 tok/s (971 ms warm / 1,250 ms cold) | 7.47x faster vs 28M |
| Inference peak VRAM | 77.8 MB | 133.5 MB | 1.72x |
Train step (bs=4, seq=1024, fp16 AMP) |
15,603 tok/s (262.5 ms) | 21,833 tok/s (187.6 ms) | 1.40x faster |
Train peak VRAM (bs=4, seq=1024) |
3,685.3 MB | 2,647.1 MB | 1.39x less (−28.2%) |
CPU Benchmark (fp32, x86_64, 1 thread)
| Metric | drakon_28m-base |
drakon_58m-base |
Comparison |
|---|---|---|---|
Prefill (256 tok, bs=1) |
1,024 tok/s (249.9 ms) | 625 tok/s (409.6 ms) | 0.61x |
generate() (32 + 64 tok) |
11.1 tok/s (5,748 ms) | 22.1 tok/s (2,895 ms) | 1.99x faster |
Train step (bs=1, seq=256) |
231 tok/s (1,108.5 ms) | 138 tok/s (1,855.2 ms) | 0.60x |
Generation Examples
Prompt: Однажды утром я проснулся и
Однажды утром я проснулся и увидел на стене рядом с кроватью письмо, написанное
почерком, который мне не понравился. Я решил, что это чья-то шутка или розыгрыш.
Но, присмотревшись внимательнее, понял, что в письме было написано что-то важное.
В нем говорилось о том, что я должен был уехать из города и
Prompt: Дорогие друзья! Сегодня мы
Дорогие друзья! Сегодня мы рады представить вам новую модель телефона, которая
сочетает в себе передовые технологии, стильный дизайн и доступную цену. Это
устройство разработано с учетом всех современных требований к качеству,
производительности и удобству использования.
Новый телефон оснащен мощным процессором, который обеспечивает быструю и плавную
работу даже самых требовательных приложений. Благодаря
Prompt: Погода сегодня была
Погода сегодня была пасмурная, но дождь так и не пошёл. В итоге я сходил на
тренировку в зал, а потом пошёл домой. На улице было довольно прохладно, поэтому
я оделся потеплее.
Дома я решил посмотреть фильм "Мстители: Война бесконечности". Я уже видел его
раньше, но решил пересмотреть еще раз. Мне очень понравился
Prompt: Когда я был маленьким, мы с бабушкой
Когда я был маленьким, мы с бабушкой часто ходили в лес за грибами. Она всегда
брала с собой большую корзину и говорила: «Вот, смотри, какие красивые грибы!».
Я смотрел на них и не мог понять, почему они такие вкусные. А бабушка смеялась и
говорила, что это потому, что их собирает сама природа.
Однажды
Prompt: В выходные мы поехали на дачу, где
В выходные мы поехали на дачу, где у нас есть свой дом и участок. Мы решили
отдохнуть от городской суеты, подышать свежим воздухом и насладиться природой.
Погода была замечательная: светило яркое солнце, дул легкий ветерок. Мы
прогулялись по лесу, собрали немного ягод и грибов. Вечером мы устроили пикник на
свежем воздухе
Scope & Limitations
- The architecture is still experimental — expect rough edges
- Designed for architectural experiments and educational purposes
- The model hallucinates facts and may produce incoherent or biased text
- Primarily Russian; English ability is limited and incidental
- Context length of 2048 tokens limits long-range coherence
- Not intended for production use
License
Apache 2.0
- Downloads last month
- -
