Text Generation
Transformers
Safetensors
GGUF
Russian
English
qwen3_5
image-text-to-text
mera
russian
math
reasoning
qwen3.5
linear-attention
sub-1b
sft
conversational
Instructions to use RusMiniLM/RusNanoLM-800M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RusMiniLM/RusNanoLM-800M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RusMiniLM/RusNanoLM-800M") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("RusMiniLM/RusNanoLM-800M") model = AutoModelForMultimodalLM.from_pretrained("RusMiniLM/RusNanoLM-800M", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use RusMiniLM/RusNanoLM-800M 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 RusMiniLM/RusNanoLM-800M:F16 # Run inference directly in the terminal: llama cli -hf RusMiniLM/RusNanoLM-800M:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf RusMiniLM/RusNanoLM-800M:F16 # Run inference directly in the terminal: llama cli -hf RusMiniLM/RusNanoLM-800M:F16
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 RusMiniLM/RusNanoLM-800M:F16 # Run inference directly in the terminal: ./build/bin/llama cli -hf RusMiniLM/RusNanoLM-800M:F16
Use Docker
docker model run hf.co/RusMiniLM/RusNanoLM-800M:F16
- Llama new
- LM Studio
- Jan
- vLLM
How to use RusMiniLM/RusNanoLM-800M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RusMiniLM/RusNanoLM-800M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RusMiniLM/RusNanoLM-800M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RusMiniLM/RusNanoLM-800M:F16
- SGLang
How to use RusMiniLM/RusNanoLM-800M 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 "RusMiniLM/RusNanoLM-800M" \ --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": "RusMiniLM/RusNanoLM-800M", "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 "RusMiniLM/RusNanoLM-800M" \ --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": "RusMiniLM/RusNanoLM-800M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use RusMiniLM/RusNanoLM-800M with Ollama:
ollama run hf.co/RusMiniLM/RusNanoLM-800M:F16
- Unsloth Desktop
- Pi
How to use RusMiniLM/RusNanoLM-800M with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf RusMiniLM/RusNanoLM-800M:F16
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": "RusMiniLM/RusNanoLM-800M:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use RusMiniLM/RusNanoLM-800M with Docker Model Runner:
docker model run hf.co/RusMiniLM/RusNanoLM-800M:F16
- Lemonade
How to use RusMiniLM/RusNanoLM-800M with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull RusMiniLM/RusNanoLM-800M:F16
Run and chat with the model
lemonade run user.RusNanoLM-800M-F16
List all available models
lemonade list
- Hermes Agent
How to use RusMiniLM/RusNanoLM-800M with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf RusMiniLM/RusNanoLM-800M:F16
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 RusMiniLM/RusNanoLM-800M:F16
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use RusMiniLM/RusNanoLM-800M with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf RusMiniLM/RusNanoLM-800M:F16
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 "RusMiniLM/RusNanoLM-800M:F16" \ --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"
Release RusNanoLM-800M: weights, tokenizer, model card, MERA benchmark charts
Browse files- .gitattributes +7 -0
- README.md +167 -0
- assets/mera_baseline_progression.png +3 -0
- assets/mera_mamuramu.png +3 -0
- assets/mera_mathlogicqa.png +3 -0
- assets/mera_rumultiar.png +3 -0
- assets/mera_simplear.png +3 -0
- assets/mera_suite_summary.png +3 -0
- chat_template.jinja +154 -0
- config.json +104 -0
- generation_config.json +6 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +48 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
assets/mera_baseline_progression.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
assets/mera_mamuramu.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
assets/mera_mathlogicqa.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
assets/mera_rumultiar.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
assets/mera_simplear.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
assets/mera_suite_summary.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,170 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- ru
|
| 4 |
+
- en
|
| 5 |
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- mera
|
| 8 |
+
- russian
|
| 9 |
+
- math
|
| 10 |
+
- reasoning
|
| 11 |
+
- qwen3.5
|
| 12 |
+
- linear-attention
|
| 13 |
+
- sub-1b
|
| 14 |
+
- sft
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
library_name: transformers
|
| 17 |
+
metrics:
|
| 18 |
+
- accuracy
|
| 19 |
---
|
| 20 |
+
|
| 21 |
+
# RusNanoLM-800M
|
| 22 |
+
|
| 23 |
+
[English](#english-overview) | [Русский](#обзор-на-русском)
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
<a id="english-overview"></a>
|
| 28 |
+
## English Overview
|
| 29 |
+
|
| 30 |
+
**RusNanoLM-800M** is an open-weights **800M parameter bilingual (Russian / English) language model** built on a hybrid Linear Attention architecture (Qwen3.5 with Gated Delta Rule layers). It is evaluated on **MERA**, the Russian language understanding benchmark suite: on RuMultiAR a 0.8B model outperforms Qwen2.5-7B and GigaChat-2-10B.
|
| 31 |
+
|
| 32 |
+
### MERA Results (Pass@1, greedy, chat template)
|
| 33 |
+
|
| 34 |
+
| Benchmark | Tasks | RusNanoLM-0.8B | Qwen3.5-0.8B (baseline) | Δ |
|
| 35 |
+
|---|---|---|---|---|
|
| 36 |
+
| SimpleAR | 1000 | **83.2%** | 48.3% | +34.9 |
|
| 37 |
+
| RuMultiAR | 1039 | **33.5%** | 8.1% | +25.4 (×4.1) |
|
| 38 |
+
| MathLogicQA | 680 | **38.2%** | 33.9% | +4.4 |
|
| 39 |
+
| MaMuRaMu | 285 | **46.0%** | 43.6% | +2.4 |
|
| 40 |
+
| PARus | 500 | **53.4%** | 53.6% | -0.2 |
|
| 41 |
+
| RWSD | 810 | **49.9%** | 52.7% | -2.8 |
|
| 42 |
+
| Strict Constraints JSON | 12 | **58.3%** | - | - |
|
| 43 |
+
|
| 44 |
+
Evaluation date: 2026-11-17. Baseline numbers — official MERA submission of Qwen3.5-0.8B (submit id 16125).
|
| 45 |
+
|
| 46 |
+
### RuMultiAR vs larger models
|
| 47 |
+
|
| 48 |
+
| Model | Params | RuMultiAR |
|
| 49 |
+
|---|---|---|
|
| 50 |
+
| RuadaptQwen-32B | 32B | 43.3% |
|
| 51 |
+
| **RusNanoLM-0.8B (ours)** | **0.8B** | **33.5%** |
|
| 52 |
+
| GigaChat-2-10B | 10B | 31.5% |
|
| 53 |
+
| Qwen2.5-7B | 7B | 30.8% |
|
| 54 |
+
| Meta-Llama-3-8B | 8B | 24.8% |
|
| 55 |
+
| Llama-3.2-1B-Instruct | 1B | 16.2% |
|
| 56 |
+
| Qwen3.5-0.8B (baseline) | 0.8B | 8.1% |
|
| 57 |
+
|
| 58 |
+
### Visual Leaderboards
|
| 59 |
+
|
| 60 |
+
#### MERA Suite Summary
|
| 61 |
+

|
| 62 |
+
|
| 63 |
+
#### Baseline Progression
|
| 64 |
+

|
| 65 |
+
|
| 66 |
+
#### SimpleAR
|
| 67 |
+

|
| 68 |
+
|
| 69 |
+
#### RuMultiAR
|
| 70 |
+

|
| 71 |
+
|
| 72 |
+
#### MathLogicQA
|
| 73 |
+

|
| 74 |
+
|
| 75 |
+
#### MaMuRaMu
|
| 76 |
+

|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
### Quickstart & Inference
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
import torch
|
| 84 |
+
from transformers import AutoModelForImageTextToText, AutoTokenizer
|
| 85 |
+
|
| 86 |
+
MODEL_ID = "itismax0/RusNanoLM-800M"
|
| 87 |
+
|
| 88 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 89 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 90 |
+
MODEL_ID,
|
| 91 |
+
torch_dtype=torch.bfloat16,
|
| 92 |
+
device_map="auto"
|
| 93 |
+
)
|
| 94 |
+
model.eval()
|
| 95 |
+
|
| 96 |
+
messages = [
|
| 97 |
+
{"role": "user", "content": "Реши задачу: в корзине 5 яблок и 7 груш. Сколько всего фруктов?"}
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 101 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 102 |
+
|
| 103 |
+
with torch.no_grad():
|
| 104 |
+
outputs = model.generate(
|
| 105 |
+
**inputs,
|
| 106 |
+
max_new_tokens=512,
|
| 107 |
+
do_sample=False,
|
| 108 |
+
pad_token_id=tokenizer.eos_token_id
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 112 |
+
print(response)
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
---
|
| 116 |
+
|
| 117 |
+
<a id="обзор-на-русском"></a>
|
| 118 |
+
## Обзор на русском
|
| 119 |
+
|
| 120 |
+
**RusNanoLM-800M** — открытая двуязычная (русский и английский) модель на 800 млн параметров, построенная на гибридной архитектуре Qwen3.5 с линейным вниманием (Gated Delta Rule): 24 слоя, каждый четвёртый — полное внимание. Оценивалась на русскоязычном бенчмарке MERA (Pass@1, жадная генерация, chat template).
|
| 121 |
+
|
| 122 |
+
### Результаты MERA
|
| 123 |
+
|
| 124 |
+
| Бенчмарк | Задач | RusNanoLM-0.8B | Qwen3.5-0.8B (baseline) | Δ |
|
| 125 |
+
|---|---|---|---|---|
|
| 126 |
+
| SimpleAR | 1000 | **83.2%** | 48.3% | +34.9 |
|
| 127 |
+
| RuMultiAR | 1039 | **33.5%** | 8.1% | +25.4 (×4.1) |
|
| 128 |
+
| MathLogicQA | 680 | **38.2%** | 33.9% | +4.4 |
|
| 129 |
+
| MaMuRaMu | 285 | **46.0%** | 43.6% | +2.4 |
|
| 130 |
+
| PARus | 500 | **53.4%** | 53.6% | -0.2 |
|
| 131 |
+
| RWSD | 810 | **49.9%** | 52.7% | -2.8 |
|
| 132 |
+
| Strict Constraints JSON | 12 | **58.3%** | - | - |
|
| 133 |
+
|
| 134 |
+
### Главный результат: RuMultiAR против больших моделей
|
| 135 |
+
|
| 136 |
+
На арифметических рассуждениях (RuMultiAR) компактная модель 0.8B обгоняет модели в 8-12 раз тяжелее:
|
| 137 |
+
|
| 138 |
+
- **33.5%** — RusNanoLM-0.8B (наша)
|
| 139 |
+
- 31.5% — GigaChat-2-10B
|
| 140 |
+
- 30.8% — Qwen2.5-7B
|
| 141 |
+
- 24.8% — Meta-Llama-3-8B
|
| 142 |
+
- 8.1% — базовая Qwen3.5-0.8B (рост в 4.1 раза)
|
| 143 |
+
|
| 144 |
+
### Честные ограничения
|
| 145 |
+
|
| 146 |
+
- PARus (-0.2%) и RWSD (-2.8%) — на уровне или чуть ниже baseline: прирост получен за счёт арифметики и рассуждений, общее понимание текста не деградировало, но и не выросло.
|
| 147 |
+
- Strict Constraints JSON — всего 12 задач, выборка мала для сильных выводов.
|
| 148 |
+
|
| 149 |
+
### Графики
|
| 150 |
+
|
| 151 |
+

|
| 152 |
+
|
| 153 |
+

|
| 154 |
+
|
| 155 |
+

|
| 156 |
+
|
| 157 |
+

|
| 158 |
+
|
| 159 |
+

|
| 160 |
+
|
| 161 |
+

|
| 162 |
+
|
| 163 |
+
### Архитектура и параметры
|
| 164 |
+
|
| 165 |
+
- Параметры: 800 млн (0.8B)
|
| 166 |
+
- Внимание: гибридное линейное внимание (Gated Delta Rule), сложность памяти состояния O(1)
|
| 167 |
+
- Слои: 24, каждый четвёртый — полное внимание
|
| 168 |
+
- Требования к видеопамяти: около 1.7 ГБ в формате BF16 (запускается на GPU с 4 ГБ VRAM)
|
| 169 |
+
- Шаблон диалога: ChatML (встроен в tokenizer_config)
|
| 170 |
+
- Лицензия: Apache 2.0
|
assets/mera_baseline_progression.png
ADDED
|
Git LFS Details
|
assets/mera_mamuramu.png
ADDED
|
Git LFS Details
|
assets/mera_mathlogicqa.png
ADDED
|
Git LFS Details
|
assets/mera_rumultiar.png
ADDED
|
Git LFS Details
|
assets/mera_simplear.png
ADDED
|
Git LFS Details
|
assets/mera_suite_summary.png
ADDED
|
Git LFS Details
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 150 |
+
{{- '<think>\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3_5ForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"dtype": "float16",
|
| 6 |
+
"image_token_id": 248056,
|
| 7 |
+
"model_type": "qwen3_5",
|
| 8 |
+
"text_config": {
|
| 9 |
+
"attention_bias": false,
|
| 10 |
+
"attention_dropout": 0.0,
|
| 11 |
+
"attn_output_gate": true,
|
| 12 |
+
"bos_token_id": null,
|
| 13 |
+
"dtype": "float16",
|
| 14 |
+
"eos_token_id": 248044,
|
| 15 |
+
"full_attention_interval": 4,
|
| 16 |
+
"head_dim": 256,
|
| 17 |
+
"hidden_act": "silu",
|
| 18 |
+
"hidden_size": 1024,
|
| 19 |
+
"initializer_range": 0.02,
|
| 20 |
+
"intermediate_size": 3584,
|
| 21 |
+
"layer_types": [
|
| 22 |
+
"linear_attention",
|
| 23 |
+
"linear_attention",
|
| 24 |
+
"linear_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"linear_attention",
|
| 27 |
+
"linear_attention",
|
| 28 |
+
"linear_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"linear_attention",
|
| 31 |
+
"linear_attention",
|
| 32 |
+
"linear_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"linear_attention",
|
| 35 |
+
"linear_attention",
|
| 36 |
+
"linear_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"linear_attention",
|
| 39 |
+
"linear_attention",
|
| 40 |
+
"linear_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"linear_attention",
|
| 43 |
+
"linear_attention",
|
| 44 |
+
"linear_attention",
|
| 45 |
+
"full_attention"
|
| 46 |
+
],
|
| 47 |
+
"linear_conv_kernel_dim": 4,
|
| 48 |
+
"linear_key_head_dim": 128,
|
| 49 |
+
"linear_num_key_heads": 16,
|
| 50 |
+
"linear_num_value_heads": 16,
|
| 51 |
+
"linear_value_head_dim": 128,
|
| 52 |
+
"mamba_ssm_dtype": "float32",
|
| 53 |
+
"max_position_embeddings": 262144,
|
| 54 |
+
"mlp_only_layers": [],
|
| 55 |
+
"model_type": "qwen3_5_text",
|
| 56 |
+
"mtp_num_hidden_layers": 1,
|
| 57 |
+
"mtp_use_dedicated_embeddings": false,
|
| 58 |
+
"num_attention_heads": 8,
|
| 59 |
+
"num_hidden_layers": 24,
|
| 60 |
+
"num_key_value_heads": 2,
|
| 61 |
+
"pad_token_id": null,
|
| 62 |
+
"rms_norm_eps": 1e-06,
|
| 63 |
+
"rope_parameters": {
|
| 64 |
+
"mrope_interleaved": true,
|
| 65 |
+
"mrope_section": [
|
| 66 |
+
11,
|
| 67 |
+
11,
|
| 68 |
+
10
|
| 69 |
+
],
|
| 70 |
+
"partial_rotary_factor": 0.25,
|
| 71 |
+
"rope_theta": 10000000,
|
| 72 |
+
"rope_type": "default"
|
| 73 |
+
},
|
| 74 |
+
"tie_word_embeddings": true,
|
| 75 |
+
"use_cache": true,
|
| 76 |
+
"vocab_size": 248320
|
| 77 |
+
},
|
| 78 |
+
"tie_word_embeddings": true,
|
| 79 |
+
"transformers_version": "5.20.2",
|
| 80 |
+
"video_token_id": 248057,
|
| 81 |
+
"vision_config": {
|
| 82 |
+
"deepstack_visual_indexes": [],
|
| 83 |
+
"depth": 12,
|
| 84 |
+
"dtype": "float16",
|
| 85 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 86 |
+
"hidden_size": 768,
|
| 87 |
+
"in_channels": 3,
|
| 88 |
+
"initializer_range": 0.02,
|
| 89 |
+
"intermediate_size": 3072,
|
| 90 |
+
"model_type": "qwen3_5_vision",
|
| 91 |
+
"num_heads": 12,
|
| 92 |
+
"num_position_embeddings": 2304,
|
| 93 |
+
"out_hidden_size": 1024,
|
| 94 |
+
"patch_size": 16,
|
| 95 |
+
"rope_parameters": {
|
| 96 |
+
"rope_theta": 10000.0,
|
| 97 |
+
"rope_type": "axial"
|
| 98 |
+
},
|
| 99 |
+
"spatial_merge_size": 2,
|
| 100 |
+
"temporal_patch_size": 2
|
| 101 |
+
},
|
| 102 |
+
"vision_end_token_id": 248054,
|
| 103 |
+
"vision_start_token_id": 248053
|
| 104 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": 248044,
|
| 4 |
+
"transformers_version": "5.20.2",
|
| 5 |
+
"use_cache": true
|
| 6 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03b7b98a8d2c7d8017a8d97d1d612d0f3a84856ca175e7650943baf7acbfdbc8
|
| 3 |
+
size 1706030056
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5cd9732badce41de57e6efce8302930ded1c1188c5f81feb2bd6c24c4a1941f
|
| 3 |
+
size 19989339
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"extra_special_tokens": [
|
| 12 |
+
"<|im_start|>",
|
| 13 |
+
"<|im_end|>",
|
| 14 |
+
"<|object_ref_start|>",
|
| 15 |
+
"<|object_ref_end|>",
|
| 16 |
+
"<|box_start|>",
|
| 17 |
+
"<|box_end|>",
|
| 18 |
+
"<|quad_start|>",
|
| 19 |
+
"<|quad_end|>",
|
| 20 |
+
"<|vision_start|>",
|
| 21 |
+
"<|vision_end|>",
|
| 22 |
+
"<|vision_pad|>",
|
| 23 |
+
"<|image_pad|>",
|
| 24 |
+
"<|video_pad|>"
|
| 25 |
+
],
|
| 26 |
+
"image_token": "<|image_pad|>",
|
| 27 |
+
"is_local": true,
|
| 28 |
+
"local_files_only": false,
|
| 29 |
+
"merges_file": null,
|
| 30 |
+
"model_max_length": 262144,
|
| 31 |
+
"model_specific_special_tokens": {
|
| 32 |
+
"audio_bos_token": "<|audio_start|>",
|
| 33 |
+
"audio_eos_token": "<|audio_end|>",
|
| 34 |
+
"audio_token": "<|audio_pad|>",
|
| 35 |
+
"image_token": "<|image_pad|>",
|
| 36 |
+
"video_token": "<|video_pad|>",
|
| 37 |
+
"vision_bos_token": "<|vision_start|>",
|
| 38 |
+
"vision_eos_token": "<|vision_end|>"
|
| 39 |
+
},
|
| 40 |
+
"pad_token": "<|endoftext|>",
|
| 41 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 42 |
+
"split_special_tokens": false,
|
| 43 |
+
"tokenizer_class": "Qwen3_5Tokenizer",
|
| 44 |
+
"unk_token": null,
|
| 45 |
+
"video_token": "<|video_pad|>",
|
| 46 |
+
"vision_bos_token": "<|vision_start|>",
|
| 47 |
+
"vision_eos_token": "<|vision_end|>"
|
| 48 |
+
}
|