Allan-LM Quark 1.1
The chat version of Allan-LM Quark, a small language model trained from
scratch by KEYTRON for the Allan assistant. Quark 1.1 answers in Russian and
English, reasons in a separate block and calls two tools: calc for exact
arithmetic and facts for a reference of countries and chemical elements. The
tools ship with the model and run inside chat.py and the serverless worker.
It is a research model of 283.7M parameters: it follows the formats it was taught well and knows very little beyond them. Read What to expect before using it.
Versions of Allan-LM are named after particles. The base model this one was
tuned from, Allan-LM Quark 1.0, stays in this repo under the tag v1.0.
Model
| Parameters | 283,661,440 total (283.7M), 106.8M active per token (136.2M incl. PLE tables) |
| Breakdown | routed experts 196.6M (8, top-2) · PLE 29.4M · shared expert 24.6M · tied embeddings 23.1M (vocab 36,160) · attention 9.8M |
| Layers | 10, d_model 640, 10 heads (2 KV heads, GQA) |
| Feed-forward | Mixture of Experts: 8 experts, top-2, plus 1 shared expert |
| Per-Layer Embeddings | yes (d_ple 80), in the style of Gemma's E-models |
| Context | trained at 1024 tokens, RoPE positions up to 2048 |
| Tokenizer | own BPE, 32,000 text tokens; the vocabulary (36,160) also holds the chat, reasoning and tool special tokens and reserved audio tokens |
| Weights | fp32 safetensors, tied embeddings |
The architecture is custom (allan_lm/model.py); it does not load with
transformers, llama.cpp or Ollama.
Chat format
<|system|> … <|end|> <|user|> … <|end|>
<|assistant|> <|think|> reasoning <|think_end|> text <|tool_call|> {"name": "calc", "args": {"expr": "17*23"}} <|end|>
<|tool_result|> 391 <|end|>
<|assistant|> … <|end|>
Every marker is a single special token. Tool calls are made only after the
system prompt the model was trained with (allan_lm.agent.SYSTEM); without
it Quark 1.1 answers as a plain chat model.
Training
- Pretraining (= Quark 1.0): ~10B tokens of Russian web text (fineweb-2, ODC-BY), English educational web text (fineweb-edu, ODC-BY) and source code (github-code-clean, per-file licenses).
- Supervised fine-tuning, several stages on RunPod GPUs:
| Source | License | What it teaches |
|---|---|---|
| OpenAssistant/oasst2 | Apache 2.0 | dialogue, written by people |
| CohereLabs/aya_dataset | Apache 2.0 | answers in Russian and English, written by people |
| openai/gsm8k | MIT | word problems, written by people |
| agent tasks generated by code | own | tool calls with real tool output: arithmetic, files, dates, reading --help, checking the user's claims and holding a correct answer under pushback |
| school tasks generated by code | own | equations, fractions, geometry, physics, chemistry step by step through calc; countries and elements through facts |
| Wikidata | CC0 | the facts tables (facts/) |
The generated tasks are built by programs from templates: every number and every tool result comes from really running the tool, so the answers are correct by construction. No text written by any language model (answers, distillations, rewrites) and no machine translation was used at any stage.
Evaluation
| Quark 1.0 | Quark 1.1 | |
|---|---|---|
| Validation CE on the SFT mix (nats/token) | — | 1.574 |
| Agent and school tasks with real tools, 380 tasks | — | 95% |
The 380 tasks are new samples from the same generators (a seed the training
data did not use), solved with real tools. They measure whether the model
uses its tools and formats correctly, not general knowledge. Most kinds
(arithmetic, equations, fractions, facts) score 95–100%; reading --help to
find an option is the weak one at ~50%.
What to expect
- Good: arithmetic and school math through
calc, countries, capitals and elements throughfacts, short factual replies built on a tool result, disagreeing with a wrong claim of the user. - Weak: anything outside those formats. Asked a fact without calling a tool it often invents ("Столица Австралии — Тасмания"); it may misread a correct tool result; open conversation drifts into unrelated text after a few sentences; code it writes does not work.
- Use it to study small models with tools, not as a source of information.
Example (python chat.py, greedy):
>>> What is the capital of Japan?
· Ask the reference about Japan.
→ facts({"query": "Japan"}) = country: Япония / Japan | capital: Токио / Tokyo | continent: Азия / Asia
The capital is Tokyo.
Usage
pip install torch safetensors tokenizers
python chat.py # interactive
python chat.py -p "Посчитай (120 + 45) / 5"
from allan_lm.agent import Agent
agent = Agent(".") # this folder
r = agent.reply([{"role": "user", "content": "Сколько будет 17 * 23?"}])
print(r["content"]) # Получается 391.
print(r["steps"]) # the tool calls and their results
Serverless
serverless/handler.py is a RunPod Serverless worker with an
OpenAI-compatible /v1/chat/completions (streaming included) and
/v1/models. The ready image keytron46/allan-lm-worker:quark-1.1 (Docker
Hub, built from serverless/Dockerfile) has the packages and this repo baked
in; on start serverless/start.sh fetches only the files changed on main
since the build, so each new worker serves the latest weights, and falls back
to the baked copy when the Hub is not reachable. A cold start takes about two
minutes, a warm request one to three seconds.
Without the image, a stock PyTorch image works too (slower start):
image: pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime
command: bash -c 'pip install -q runpod==1.12.0 huggingface_hub==2.2.0 safetensors==0.8.0 tokenizers==0.23.3
&& hf download keytron46/Allan-LM-Quark --local-dir /model && exec python -u /model/serverless/handler.py'
Tool calls come back as reasoning_content, the answer as content.
License
Business Source License 1.1 (see LICENSE): free for personal, academic,
research and evaluation use; commercial use needs a separate agreement with the
licensor. On 2028-10-27 the license changes to MIT.
Русский
Allan-LM Quark 1.1 — чат-версия своей модели Allan-LM, обученной с нуля
(283.7M параметров, 106.8M активных, MoE + PLE). Отвечает по-русски и
по-английски, рассуждает отдельным блоком и сама вызывает инструменты:
calc для точных расчётов и facts — справочник стран и химических
элементов. Дообучена только на текстах, написанных людьми (oasst2, aya,
GSM8K), и на задачах, которые собирает программа с настоящими результатами
инструментов; ответов других нейросетей в данных нет. На 380 задачах с
инструментами — 95%, но за пределами выученных форматов модель слабая и
выдумывает. Базовая модель Quark 1.0 — под тегом v1.0.
Лицензия BSL 1.1: некоммерческое использование свободно, коммерческое — по
договорённости; с 2028-10-27 — MIT.