Instructions to use salgr/SalgrAI_v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use salgr/SalgrAI_v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="salgr/SalgrAI_v2") 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_v2") model = AutoModelForCausalLM.from_pretrained("salgr/SalgrAI_v2", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use salgr/SalgrAI_v2 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf salgr/SalgrAI_v2:Q4_K_M # Run inference directly in the terminal: llama cli -hf salgr/SalgrAI_v2:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf salgr/SalgrAI_v2:Q4_K_M # Run inference directly in the terminal: llama cli -hf salgr/SalgrAI_v2:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf salgr/SalgrAI_v2:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf salgr/SalgrAI_v2:Q4_K_M
Use Docker
docker model run hf.co/salgr/SalgrAI_v2:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use salgr/SalgrAI_v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "salgr/SalgrAI_v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "salgr/SalgrAI_v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/salgr/SalgrAI_v2:Q4_K_M
- SGLang
How to use salgr/SalgrAI_v2 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 "salgr/SalgrAI_v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "salgr/SalgrAI_v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "salgr/SalgrAI_v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "salgr/SalgrAI_v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use salgr/SalgrAI_v2 with Ollama:
ollama run hf.co/salgr/SalgrAI_v2:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use salgr/SalgrAI_v2 with Docker Model Runner:
docker model run hf.co/salgr/SalgrAI_v2:Q4_K_M
- Lemonade
How to use salgr/SalgrAI_v2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull salgr/SalgrAI_v2:Q4_K_M
Run and chat with the model
lemonade run user.SalgrAI_v2-Q4_K_M
List all available models
lemonade list
- Atomic Chat
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("salgr/SalgrAI_v2")
model = AutoModelForCausalLM.from_pretrained("salgr/SalgrAI_v2", 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]:]))SalgrAI-v2
SalgrAI-v2 is SalgrAI-v2-Full with the vocabulary pruned to Russian: 130.8M parameters instead of 268.1M, the same quality on our tests. It is Gemma 3 270M-it fine-tuned for short, casual, friend-like Russian conversation ("lowercase Telegram Russian") by one person on a single RTX 3060. Meant for experiments, demos and learning, not for serious use.
Why it is smaller: 170M of Gemma 3 270M's parameters are the embedding table for a vocabulary of 262,144 tokens in every script. We kept the 47,544 tokens that Russian text needs and cut the rest. No weights of the transformer layers were changed and nothing was retrained, so the model behaves like SalgrAI-v2-Full, but it can no longer produce Chinese, Arabic or other foreign characters.
Please read the Limitations section. Knowledge is weak, there is no safety filter beyond Gemma's own, and sampled replies sometimes contain non-words.
Model summary
| Base model | google/gemma-3-270m-it, fine-tuned, then vocabulary-pruned |
| Architecture | Gemma 3, decoder-only: 18 layers, hidden 640, 4 heads (1 KV head), FFN 2048, sliding-window + global attention |
| Parameters | 130,754,176 = 100,326,016 in the layers + 30,428,160 in the embedding table (47,544 tokens x 640) |
| Vocabulary | 47,544 tokens (was 262,144): Cyrillic, ASCII (English fragments, digits, symbols), typographic punctuation, emoji, 256 byte tokens, special tokens |
| Language | Russian (English only in fragments, weak) |
| Format | Gemma chat template: <start_of_turn>user ... <end_of_turn><start_of_turn>model ... |
| Developed by | Salgr |
| License | Gemma Terms of Use (see License) |
Files
| File | Size | What it is |
|---|---|---|
model.safetensors |
262 MB | weights, bfloat16 (loads with transformers) |
pytorch_model.bin |
262 MB | the same weights as a PyTorch state dict |
SalgrAI-v2-F16.gguf |
263 MB | GGUF, float16, for llama.cpp |
SalgrAI-v2-Q8_0.gguf |
140 MB | GGUF, 8-bit: recommended for small devices |
SalgrAI-v2-Q4_K_M.gguf |
102 MB | GGUF, 4-bit: smallest, noticeably less exact (see Evaluation) |
config.json, generation_config.json |
config and recommended sampling (temperature 0.5) | |
tokenizer.json, tokenizer.model, tokenizer_config.json, special_tokens_map.json, chat_template.jinja |
the pruned Gemma tokenizer (token ids differ from the original Gemma ids above 107) and chat template | |
chat_example.py |
a minimal chat script | |
NOTICE |
the notice required by the Gemma Terms of Use |
The formats were checked against each other: model.safetensors and pytorch_model.bin give exactly the same logits as the pruned model they were saved from. Against an fp32 reference, the first token of the reply matched on 10 of 10 test prompts for F16 and Q8_0 and on 8 of 10 for Q4_K_M; the whole greedy reply matched on 10, 9 and 3 of 10 prompts respectively. The token ids of the prompt are identical in transformers and llama.cpp.
Quick start
Transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "YOUR-USERNAME/SalgrAI-v2"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16)
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))
Use bfloat16 or float32. Do not run it in float16: Gemma 3 is numerically unstable in fp16.
llama.cpp (GGUF)
llama-server -m SalgrAI-v2-Q8_0.gguf -c 1024 --port 8080
curl http://127.0.0.1:8080/v1/chat/completions -d '{"messages": [{"role": "user", "content": "ะฟัะธะฒะตั"}], "max_tokens": 80, "temperature": 0.5, "top_k": 40, "top_p": 0.9, "repeat_penalty": 1.1}'
The chat template is embedded in the file. In a raw /completion prompt do not write <bos>: llama.cpp adds it itself.
How the vocabulary was pruned
- The original Gemma tokenizer encoded about 150M characters of Russian Wikipedia, 100M characters of Russian OpenSubtitles and all dialogs used for fine-tuning, and every token's frequency was counted.
- Kept: tokens that appear at least 10 times in the corpus or at all in the dialogs; ASCII-only tokens among the first 20,000 ids of the original vocabulary (English fragments, digits, symbols); the 256 byte tokens; the first 108 ids (special and control tokens,
<start_of_turn>,<end_of_turn>, newlines); and, for every kept token, the tokens it is built from by BPE merges. Tokens containing letters of other scripts were dropped. - A new
tokenizer.json(andtokenizer.modelfor GGUF) was built from the kept tokens with the original merge order, and the matching rows were cut from the embedding table (which is also the output layer).
Effect on text the counting never saw (1,600 Russian Wikipedia articles, first 4,000 characters each): the pruned tokenizer needs 0.57% more tokens, and 67% of the texts are tokenized exactly as before; in the rest, rare words are split into smaller pieces. Text in other scripts reaches the model as bytes.
Training
The fine-tuning is the same as for SalgrAI-v2-Full: google/gemma-3-270m-it, full fine-tuning in bf16 with the embedding table frozen, AdamW lr 2e-5, batch 16, 3 epochs, loss on assistant tokens only, best epoch by validation loss (epoch 2). Data: 12,981 short dialogs (about 650K tokens): about 6,700 casual dialogs and about 4,900 more written by Claude Haiku (Anthropic) from a written specification that follows the eight SBB categories (short replies, one persona, no advice, no excuses), plus about 1,400 simple knowledge dialogs generated by a script from small hand-made tables (capitals, authors, arithmetic). Dialogs that repeated an SBB prompt verbatim were removed; 300 dialogs were held out. The dialogs are not released.
Evaluation
SBB V1.0 (SalgrAI Basic Benchmark) is the author's own small benchmark: 100 short Russian messages (80 casual prompts and 20 basic-knowledge questions), one reply each, no history, temperature 0. A reply passes if it contains what is expected, is not an excuse, has no profanity, does not loop and is mostly Russian. The rules look at keywords, not meaning, so conversational scores are somewhat generous.
| Category | Questions | LFM2.5 350M | Gemma 3 270M-it (base) | SalgrAI-v2-Full | SalgrAI-v2 |
|---|---|---|---|---|---|
| Greetings | 12 | 58% | 83% | 92% | 92% |
| How are you / mood | 10 | 40% | 50% | 80% | 80% |
| About itself | 10 | 60% | 70% | 100% | 100% |
| Everyday chat | 14 | 64% | 79% | 100% | 100% |
| Emotions and support | 10 | 20% | 40% | 90% | 90% |
| Simple requests and advice | 12 | 58% | 67% | 67% | 75% |
| Thanks, farewells, reactions | 12 | 33% | 42% | 92% | 92% |
| Basic knowledge | 20 | 10% | 35% | 50% | 50% |
| Total (of 100) | 100 | 41 | 57 | 81 | 82 |
The same benchmark in llama.cpp (one greedy run each, repetition penalty 1.1): F16 83, Q8_0 79, Q4_K_M 82. The spread of a few points between runs is noise: the order does not follow the size, so these runs cannot rank the quantizations. SalgrAI-v2-Lite (25M, from scratch) scores 60 (https://salgr.top/freeopus/sbb/).
Pruning did not change what the model knows or says.
- On 73 facts held out from the training tables, v2 and v2-Full are identical: 47 of 55 new arithmetic questions right, 1 of 14 capitals and 0 of 4 authors that were not in the tables.
- Stray foreign characters in 300 sampled replies (temperature 0.8): 0, against 95 for v2-Full without its vocabulary mask.
How to read it, honestly.
- SBB is in-distribution: the fine-tuning dialogs were written around its eight categories (the 100 prompts themselves are not in the data, but similar phrasings are). The baselines were not tuned for it and the rules punish long and non-Russian replies, which disadvantages general-purpose models. So 82 vs 57 shows that targeted data works for short casual chat, not that the model is generally smarter than Gemma 3 270M-it.
- Knowledge did not grow beyond what was trained: capitals and authors outside the training tables are almost always wrong.
- Sampling noise. At temperature 0.8 about 3.3% of the words in sampled replies were not found in a Russian word list built from Wikipedia and subtitles (a rough proxy for non-words such as "ััะดะพะผัะตะบ"); at 0.5 it was 2.6%, at 0.3 2.5%. The recommended temperature is therefore 0.5.
Intended use, limitations and risks
- Intended use: hobby experiments, demos, studying how small language models behave, a small Russian chat baseline.
- Not for: advice, facts, calculations, moderation, anything where a wrong or rude answer matters.
- Factual knowledge is unreliable; the model sounds fluent while often being wrong or meaningless.
- Russian only. English text is split into small fragments and understood poorly; other scripts are not supported.
- No extra safety tuning. The base model has Gemma's own alignment, which fine-tuning on casual dialogs may have weakened. If you expose it publicly, add your own filtering.
- The fine-tuning dialogs are LLM-generated, so the style is narrow (casual, short, lowercase). The model also mentions "SalgrAI" where it does not fit.
- The byte tokens are kept, so in theory the model can emit an invalid byte sequence; none occurred in our 300 sampled replies.
- Not for float16 inference.
SalgrAI family
| Model | Parameters | Notes |
|---|---|---|
| SalgrAI-v1 / v1.1 / v1.2 | 15M / 15M / 25M | from scratch |
| SalgrAI-v2-Lite | 24,874,368 | from scratch, only casual conversation; SBB 60 |
| SalgrAI-v2-Full | 268,098,176 | Gemma 3 270M-it fine-tuned, full vocabulary; SBB 81 |
| SalgrAI-v2 | 130,754,176 | v2-Full with the vocabulary pruned to Russian; SBB 82 |
| SalgrAI-Decider | 25,024,129 | not a chat model: picks one of 2-8 options |
Live demo: https://salgr.top/freeopus/ - benchmark page: https://salgr.top/freeopus/sbb/
License
This model is a Model Derivative of Gemma and is provided under the Gemma Terms of Use (https://gemma.ai/resources/terms). Whoever uses or redistributes it must follow those terms, including the Gemma Prohibited Use Policy (https://gemma.ai/resources/prohibited_use_policy), must receive a copy of the terms and must keep the NOTICE file. The weights and the tokenizer were modified (fine-tuning and vocabulary pruning). Also consider the terms of the data used to generate the dialogs.
- Downloads last month
- 124
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="salgr/SalgrAI_v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)