Text Generation
Transformers
Safetensors
GGUF
Russian
English
Chinese
qwen3
russian
on-device
edge
mnn
keyboard
work-in-progress
conversational
text-generation-inference
Instructions to use Rahspide/MNN-Pocket-0.3B-RU with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Rahspide/MNN-Pocket-0.3B-RU with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Rahspide/MNN-Pocket-0.3B-RU") 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("Rahspide/MNN-Pocket-0.3B-RU") model = AutoModelForCausalLM.from_pretrained("Rahspide/MNN-Pocket-0.3B-RU", 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 Rahspide/MNN-Pocket-0.3B-RU 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 Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M # Run inference directly in the terminal: llama cli -hf Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M # Run inference directly in the terminal: llama cli -hf Rahspide/MNN-Pocket-0.3B-RU: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 Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Use Docker
docker model run hf.co/Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use Rahspide/MNN-Pocket-0.3B-RU with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Rahspide/MNN-Pocket-0.3B-RU" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rahspide/MNN-Pocket-0.3B-RU", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
- SGLang
How to use Rahspide/MNN-Pocket-0.3B-RU 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 "Rahspide/MNN-Pocket-0.3B-RU" \ --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": "Rahspide/MNN-Pocket-0.3B-RU", "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 "Rahspide/MNN-Pocket-0.3B-RU" \ --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": "Rahspide/MNN-Pocket-0.3B-RU", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Rahspide/MNN-Pocket-0.3B-RU with Ollama:
ollama run hf.co/Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
- Unsloth Desktop
- Pi
How to use Rahspide/MNN-Pocket-0.3B-RU with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Rahspide/MNN-Pocket-0.3B-RU with Docker Model Runner:
docker model run hf.co/Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
- Lemonade
How to use Rahspide/MNN-Pocket-0.3B-RU with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Run and chat with the model
lemonade run user.MNN-Pocket-0.3B-RU-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Rahspide/MNN-Pocket-0.3B-RU with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Rahspide/MNN-Pocket-0.3B-RU with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "Rahspide/MNN-Pocket-0.3B-RU:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
docs: v1 results, GGUF builds, honest en/zh regression
Browse files
README.md
CHANGED
|
@@ -23,9 +23,9 @@ tags:
|
|
| 23 |
|
| 24 |
# MNN-Pocket-0.3B-RU (work in progress)
|
| 25 |
|
| 26 |
-
> **Status:
|
| 27 |
-
>
|
| 28 |
-
>
|
| 29 |
|
| 30 |
A continued-pretraining run of [`taobao-mnn/MNN-Pocket-0.3B-Base`](https://huggingface.co/taobao-mnn/MNN-Pocket-0.3B-Base)
|
| 31 |
that teaches it Russian while keeping English and Chinese intact. It is a small multilingual continuation
|
|
@@ -42,7 +42,7 @@ continues a typed prefix instead of answering it. English and Chinese are kept a
|
|
| 42 |
| Training tokens | 1.2B (0.9B ru + 0.204B en + 0.096B zh) |
|
| 43 |
| Method | full fine-tune, 1 epoch, no LoRA |
|
| 44 |
| Hardware | single Colab T4 16 GB, 4.8k tok/s, ~69 h total |
|
| 45 |
-
|
|
| 46 |
|
| 47 |
## Why the recipe looks like this: Russian is expensive in this tokenizer
|
| 48 |
|
|
@@ -99,16 +99,19 @@ were used, so the resulting weights stay publishable.
|
|
| 99 |
Per language: perplexity, **bits per character**, and top-1 / top-5 next-token accuracy. Bits/char is the
|
| 100 |
metric that stays comparable across tokenizers, which perplexity is not.
|
| 101 |
|
| 102 |
-
|
| 103 |
|
| 104 |
-
| Lang | ppl | bits/char | top-1 | top-5
|
| 105 |
-
|---|---|---|---|---|
|
| 106 |
-
| ru | 10.42 | 1.625 | 46.2% | 69.3%
|
| 107 |
-
| en | 21.85 | 1.016 | 39.9% | 64.1%
|
| 108 |
-
| zh | 23.95 | 3.274 | 41.9% | 62.0%
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
## Two models, two jobs
|
| 114 |
|
|
@@ -129,6 +132,20 @@ The split exists because the two tasks reward opposite behaviour. Training a sin
|
|
| 129 |
it mediocre at each: a continuation model that starts answering, and an assistant that leaks into
|
| 130 |
completion mode.
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
## Intended use
|
| 133 |
|
| 134 |
- On-device next-word and short-phrase suggestion in a keyboard or IME, Russian first, English and Chinese
|
|
@@ -149,8 +166,8 @@ This checkpoint is the first of several variants, ordered by cost:
|
|
| 149 |
|
| 150 |
| Variant | What | Status |
|
| 151 |
|---|---|---|
|
| 152 |
-
| **v1** | Russian continuation model β this run |
|
| 153 |
-
| **v2** | Russian assistant: instruction tuning (SFT on ChatML) on top of v1
|
| 154 |
| **v3** | Tokenizer extension: ~4β8k extra Cyrillic BPE merges plus an embedding resize, warm-started from v1, cutting Russian tokens per word by roughly half | optional, after v1 |
|
| 155 |
| **v4** | Quantised builds for devices: GGUF Q8_0 / Q4_K_M and MNN INT4, with device-side tok/s measurements | after v1 |
|
| 156 |
|
|
@@ -159,7 +176,6 @@ is then a short SFT on top of it rather than another round of pretraining.
|
|
| 159 |
|
| 160 |
## Limitations
|
| 161 |
|
| 162 |
-
- **Work in progress.** No quality claims until the run finishes and the table above is filled.
|
| 163 |
- Russian is tokenised near character level (see above): slower decoding and a larger effective cost per
|
| 164 |
Russian word than the same model pays for English.
|
| 165 |
- Web text only. Register is mostly written/informal blog Russian; no dialogue corpora, no post-training.
|
|
|
|
| 23 |
|
| 24 |
# MNN-Pocket-0.3B-RU (work in progress)
|
| 25 |
|
| 26 |
+
> **Status: v1 released.** Trained on 1.2B tokens (one epoch), weights in this repository, GGUF builds in
|
| 27 |
+
> `gguf/`. Training log, checkpoints and the evaluation script live in the private repo
|
| 28 |
+
> `Rahspide/mnn-pocket-ru-run`.
|
| 29 |
|
| 30 |
A continued-pretraining run of [`taobao-mnn/MNN-Pocket-0.3B-Base`](https://huggingface.co/taobao-mnn/MNN-Pocket-0.3B-Base)
|
| 31 |
that teaches it Russian while keeping English and Chinese intact. It is a small multilingual continuation
|
|
|
|
| 42 |
| Training tokens | 1.2B (0.9B ru + 0.204B en + 0.096B zh) |
|
| 43 |
| Method | full fine-tune, 1 epoch, no LoRA |
|
| 44 |
| Hardware | single Colab T4 16 GB, 4.8k tok/s, ~69 h total |
|
| 45 |
+
| Training | 36,621 steps Γ 32,768 tokens = 1.2B tokens, ~11 h on one A100 40 GB (25k tok/s), ~35 h on L4 |
|
| 46 |
|
| 47 |
## Why the recipe looks like this: Russian is expensive in this tokenizer
|
| 48 |
|
|
|
|
| 99 |
Per language: perplexity, **bits per character**, and top-1 / top-5 next-token accuracy. Bits/char is the
|
| 100 |
metric that stays comparable across tokenizers, which perplexity is not.
|
| 101 |
|
| 102 |
+
100k held-out tokens per language, identical settings for both models:
|
| 103 |
|
| 104 |
+
| Lang | ppl base β v1 | bits/char base β v1 | top-1 base β v1 | top-5 base β v1 |
|
| 105 |
+
|---|---|---|---|---|
|
| 106 |
+
| **ru** | 10.42 β **5.05** | 1.625 β **1.123** (β31%) | 46.2% β **61.0%** | 69.3% β **80.6%** |
|
| 107 |
+
| en | 21.85 β 41.16 | 1.016 β 1.225 (+21%) | 39.9% β 35.5% | 64.1% β 58.7% |
|
| 108 |
+
| zh | 23.95 β 51.86 | 3.274 β 4.071 (+24%) | 41.9% β 37.7% | 62.0% β 55.6% |
|
| 109 |
|
| 110 |
+
Russian landed well past the target (bits/char 1.123 against a 1.40 gate). English and Chinese regressed
|
| 111 |
+
by 21β24%, i.e. beyond the +10% the recipe aimed for: a 25% replay mix is too thin at 0.36B when the target
|
| 112 |
+
language is tokenised this badly. A second pass with a 50/25/25 mix at lr 5e-5 was started to pull en/zh
|
| 113 |
+
back, and it got through ~50M of the planned 200M tokens before the compute budget ran out β that variant is
|
| 114 |
+
**not** published. Treat v1 as Russian-first, with working but measurably weaker English and Chinese.
|
| 115 |
|
| 116 |
## Two models, two jobs
|
| 117 |
|
|
|
|
| 132 |
it mediocre at each: a continuation model that starts answering, and an assistant that leaks into
|
| 133 |
completion mode.
|
| 134 |
|
| 135 |
+
## GGUF builds
|
| 136 |
+
|
| 137 |
+
| File | Size | Note |
|
| 138 |
+
|---|---|---|
|
| 139 |
+
| `gguf/MNN-Pocket-0.3B-RU-Q8_0.gguf` | 310 MB | near-lossless, the one to use on desktop |
|
| 140 |
+
| `gguf/MNN-Pocket-0.3B-RU-Q4_K_M.gguf` | 223 MB | the size to ship on a phone |
|
| 141 |
+
|
| 142 |
+
Converted with llama.cpp `convert_hf_to_gguf.py` (f16) and quantised with `llama-quantize`. Measured on a
|
| 143 |
+
16-thread x86 CPU: ~78 tok/s generation on Q4_K_M, ~88 tok/s prompt processing β no GPU involved.
|
| 144 |
+
|
| 145 |
+
The base model's tokenizer ships a pre-tokenizer that current llama.cpp does not hash-match, so conversion
|
| 146 |
+
needs the Qwen pre-tokenizer pinned by hand (`qwen2`) and `extra_special_tokens` removed from
|
| 147 |
+
`tokenizer_config.json`. Both are fixed in this repository's copy of the file.
|
| 148 |
+
|
| 149 |
## Intended use
|
| 150 |
|
| 151 |
- On-device next-word and short-phrase suggestion in a keyboard or IME, Russian first, English and Chinese
|
|
|
|
| 166 |
|
| 167 |
| Variant | What | Status |
|
| 168 |
|---|---|---|
|
| 169 |
+
| **v1** | Russian continuation model β this run | **released** |
|
| 170 |
+
| **v2** | Russian assistant: instruction tuning (SFT on ChatML) on top of v1 β see [`MNN-Pocket-0.3B-RU-Chat`](https://huggingface.co/Rahspide/MNN-Pocket-0.3B-RU-Chat) | planned |
|
| 171 |
| **v3** | Tokenizer extension: ~4β8k extra Cyrillic BPE merges plus an embedding resize, warm-started from v1, cutting Russian tokens per word by roughly half | optional, after v1 |
|
| 172 |
| **v4** | Quantised builds for devices: GGUF Q8_0 / Q4_K_M and MNN INT4, with device-side tok/s measurements | after v1 |
|
| 173 |
|
|
|
|
| 176 |
|
| 177 |
## Limitations
|
| 178 |
|
|
|
|
| 179 |
- Russian is tokenised near character level (see above): slower decoding and a larger effective cost per
|
| 180 |
Russian word than the same model pays for English.
|
| 181 |
- Web text only. Register is mostly written/informal blog Russian; no dialogue corpora, no post-training.
|