How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="salgr/SalgrAI_1")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("salgr/SalgrAI_1")
model = AutoModelForCausalLM.from_pretrained("salgr/SalgrAI_1", device_map="auto")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

SalgrAI-v1

Русская версия

A tiny Russian-language chat model (14,997,888 parameters, 6 layers) trained from scratch by one person on a single RTX 3060. It chats in a casual, friend-like style ("lowercase Telegram Russian") and is meant for experiments, demos and learning, not for serious use: it is far too small to be reliably correct.

Please read the Limitations section. The model often replies off-topic, gets facts and arithmetic wrong, and has no profanity or safety filter.

Model summary

Architecture decoder-only Transformer, Llama-style: RMSNorm, RoPE (theta 10000), SwiGLU, no biases, tied input/output embeddings
Size 6 layers, hidden 384, 6 attention heads (head dim 64), FFN 1202, 14,997,888 parameters
Context 1024 tokens
Vocabulary 8192 (byte-level BPE trained on the pretraining text and the dialogs)
Language Russian (some English, digits and symbols)
Format chat: <|user|>...<|assistant|>...<|eos|>
Developed by Salgr

Files

File What it is
model.safetensors weights, float32, Llama layout (loads with transformers, no custom code)
pytorch_model.bin the same weights as a PyTorch state dict
SalgrAI-v1-F16.gguf GGUF, float16, for llama.cpp (quantized variants are not provided)
config.json, generation_config.json Llama config and the recommended sampling settings
tokenizer.json, tokenizer_config.json, special_tokens_map.json tokenizer and chat template
original/ the original code (model.py, common.py), the native checkpoint salgrai_original.pt and chat_example.py

The three weight formats were checked against each other: transformers logits match the original model (max difference ~1e-5), greedy generation is identical, and the GGUF file run in llama.cpp gives the same top token and log-probabilities within 0.002 on the test prompts.

Quick start

Transformers

from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "YOUR-USERNAME/SalgrAI-v1"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)

messages = [{"role": "user", "content": "привет"}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
out = model.generate(**inputs)  # sampling settings come from generation_config.json
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))

llama.cpp (GGUF)

llama-server -m SalgrAI-v1-F16.gguf -c 1024 --port 8080
# then, for example:
curl http://127.0.0.1:8080/completion -d '{"prompt": "<|user|>привет<|assistant|>", "n_predict": 120, "temperature": 0.8, "top_k": 40, "top_p": 0.9, "repeat_penalty": 1.1}'
# or the OpenAI-compatible endpoint (the chat template is embedded in the file):
curl http://127.0.0.1:8080/v1/chat/completions -d '{"messages": [{"role": "user", "content": "привет"}], "max_tokens": 120}'

Generation stops by itself at the end-of-turn token <|eos|>.

Native PyTorch

cd original
python chat_example.py            # needs torch and tokenizers; commands: /reset, /exit

Prompt format

<|user|>message<|assistant|>reply<|eos|><|user|>next message<|assistant|>

The model was trained with the loss on assistant tokens only. The reference code (original/common.py) additionally collapses whitespace, replaces <| in user text with < | (so users cannot inject service tokens) and drops the oldest turns when the context is full; the Hugging Face chat template does none of that. Recommended sampling: temperature 0.8 (0.5-0.6 gives steadier but duller replies), top-k 40, top-p 0.9, repetition penalty 1.1. Note that transformers applies the repetition penalty to the prompt tokens as well, the reference code only to generated tokens.

Training

Everything was trained from random initialization on one RTX 3060 (12 GB) in bf16. No third-party model weights were used.

Tokenizer. Byte-level BPE, 8192 tokens, trained on the pretraining text plus the dialogs.

Pretraining. Shared by v1 and v1.1: a 6-layer model from random initialization on about 500M tokens (7,629 steps x 65,536 tokens) of Russian Wikipedia (wikimedia/wikipedia 20231101.ru, first shards; 140.6M training tokens) and Russian OpenSubtitles (OPUS, first ~300M characters; 103.0M training tokens), sampled 50/50 in 1,024-token windows. AdamW (lr 1e-3 with cosine decay to 1e-4, weight decay 0.1, gradient clipping 1.0). Final validation loss: Wikipedia 2.926 (perplexity 18.7), subtitles 3.016 (perplexity 20.4).

Fine-tuning. Stage 1 (pseudo-dialogs): 300,000 pseudo-dialogs built from adjacent subtitle lines (one line as the user, the next as the assistant), 2 epochs (validation loss 3.472 on 500 held-out). Stage 2 (SFT): 2,850 synthetic dialogs from wave 1, lr 1.5e-4, best epoch picked by validation loss; 150 dialogs held out. Loss only on assistant tokens.

Synthetic dialogs. The fine-tuning dialogs are synthetic: they were generated by Claude Haiku (Anthropic) from written specifications (informal friend-like Russian chat, user/assistant turns, honest "I don't know", short refusals of unsafe requests, the assistant introduces itself as SalgrAI made by Salgr). They were generated in three waves: wave 1 (3,000 dialogs, short, many replies began with "ну"), wave 2 (about 3,000, longer, answers that actually answer, fewer verbal tics) and wave 3 (about 3,000, richer answers, more questions back). The dialogs are not released with the model. If you reuse the model, please also check the terms of the sources below.

Pretraining text sources. Russian Wikipedia (wikimedia/wikipedia, 20231101.ru; CC BY-SA) and Russian OpenSubtitles from OPUS (subtitle copyright belongs to the respective rights holders; check the OPUS terms before any reuse).

Evaluation (informal)

Each model has its own validation set, so the validation losses below are not comparable between versions.

Version Parameters Validation loss on its own held-out dialogs
v1 14,997,888 3.580 (perplexity 35.9), 150 dialogs of wave 1
v1.1 14,997,888 3.076 (perplexity 21.7), 200 dialogs of wave 2
v1.2 24,874,368 2.903 (perplexity 18.2), 250 dialogs of wave 3

A tiny side-by-side probe on the final weights (same sampling settings for all versions): 20 simple factual questions (capital of France, 7 x 8, "what is Python?", ...), 4 samples each = 80 answers; an answer counts as a hit if it contains an expected keyword or number. And 3 greetings ("привет", "здарова", "добрый вечер") x 6 samples = 18 answers; a hit if the reply starts with a greeting.

Version Facts (hits of 80) Greetings (hits of 18)
v1 1 14
v1.1 14 17
v1.2 11 18

With 80 samples the standard error is about 4 percentage points, so the difference between v1.1 and v1.2 on facts is within noise. The probe shows that v1 is far behind on facts and that v1.2 answers greetings most reliably; it does not show that the bigger model knows more.

Intended use, limitations and risks

  • Intended use: hobby experiments, demos, studying how small language models behave, a baseline for tiny Russian chat models.
  • Not for: advice, facts, calculations, moderation, anything where a wrong or rude answer matters.
  • Factual knowledge is unreliable and arithmetic almost never works: with 15-25M parameters and a small amount of Wikipedia text the model mostly learned the style of conversation, not facts. It often sounds fluent while being wrong or meaningless.
  • No safety tuning and no profanity filter. Part of the pretraining text is movie subtitles, so the model can occasionally produce rude language or profanity. If you expose it publicly, add your own filtering.
  • The fine-tuning dialogs are LLM-generated, so the style is narrow (casual, short, lowercase) and carries the biases and habits of the generator; the replies are short (typically around 10 words).
  • Mainly Russian; English is weak. Context is 1024 tokens.
  • Sampled replies differ from run to run (sampling) and slightly between runtimes (the repetition-penalty difference noted above); the weights themselves are numerically equivalent in all formats.

SalgrAI family

Model Parameters Notes
SalgrAI-v1 14,997,888 first release; extra subtitle pseudo-dialog stage, 2,850 SFT dialogs
SalgrAI-v1.1 14,997,888 second wave of dialogs, cleaner style (fewer "ну вот" tics), 4,317 SFT dialogs
SalgrAI-v1.2 24,874,368 grown to 11 layers, more subtitles, third wave of dialogs, 5,878 SFT dialogs
SalgrAI-Decider 25,024,129 not a chat model: picks one of 2-8 options and returns probabilities

Live demo of v1, v1.1, v1.2 (switch at the top): https://salgr.top/freeopus/ - and of the Decider: https://salgr.top/freeopus/decider/

License

Not specified yet (see the note at the top of this file). Also consider the licenses and terms of the training sources listed above.

Downloads last month
61
Safetensors
Model size
15M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including salgr/SalgrAI_1