Instructions to use itsusony/LFM2.5-1.2B-Zhusuan with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use itsusony/LFM2.5-1.2B-Zhusuan with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="itsusony/LFM2.5-1.2B-Zhusuan") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("itsusony/LFM2.5-1.2B-Zhusuan") model = AutoModelForCausalLM.from_pretrained("itsusony/LFM2.5-1.2B-Zhusuan", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use itsusony/LFM2.5-1.2B-Zhusuan with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "itsusony/LFM2.5-1.2B-Zhusuan" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "itsusony/LFM2.5-1.2B-Zhusuan", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/itsusony/LFM2.5-1.2B-Zhusuan
- SGLang
How to use itsusony/LFM2.5-1.2B-Zhusuan 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 "itsusony/LFM2.5-1.2B-Zhusuan" \ --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": "itsusony/LFM2.5-1.2B-Zhusuan", "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 "itsusony/LFM2.5-1.2B-Zhusuan" \ --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": "itsusony/LFM2.5-1.2B-Zhusuan", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use itsusony/LFM2.5-1.2B-Zhusuan with Docker Model Runner:
docker model run hf.co/itsusony/LFM2.5-1.2B-Zhusuan
LFM2.5-1.2B-Zhusuan
LoRA-SFT (merged) of LiquidAI/LFM2.5-1.2B-Thinking for abacus-style mental arithmetic (珠算 / 珠心算).
English
Advantages vs base model
Main benefit: more accurate integer arithmetic and more stable answer format.
Base LFM2.5-1.2B-Thinking |
This model | |
|---|---|---|
| Eval prompt | plain math | zhusuan system + user wording |
| Accuracy (n=100, seed=123) | 72% | 98% (+26 pt) |
| Addition | 67.7% | 96.8% |
| Subtraction | 73.7% | 100% |
| Multiplication | 87.9% | 97.0% |
| Division | 47.1% | 100% |
Other points:
- Higher arithmetic accuracy, especially division/subtraction.
- Structured reasoning in
<think>...</think>(steps / partial products / checks). - Easier parsing: final line often looks like
a×b=result. - Still 1.2B, suitable for local / on-device use.
Eval uses synthetic abacus-style arithmetic; competition word problems are not the main target.
How to use (prompts)
Recommended system prompt:
You are an abacus-style mental arithmetic (珠心算) assistant. First reason step by step inside <think>...</think> using abacus rod positions and abacus formulas, then give a short final answer. Formula names must match the addend/subtrahend correctly, and the arithmetic must be accurate.
(Chinese system prompt below also works well — it matches training distribution more closely.)
Chinese system prompt (recommended for best results):
你是珠算式心算(珠心算)助手。先在 <think>...</think> 里用算盘档位与珠算口诀分步推理,再给出简短最终答案。口诀名称必须与加数/减数对应正确,算术结果必须准确。
Recommended user wording:
用珠算思路算 73×19
用珠算思路算 915+584
用珠算思路算 336÷7
用珠算思路算 256-67
| Case | Recommendation |
|---|---|
| This finetune | Zhusuan system + 用珠算思路算 … |
| Original base model | Plain math prompt (do not force zhusuan wording) |
| Sampling | Prefer do_sample=False / temperature 0 for exact math |
| Where is the answer? | After </think>, last line / expr=number |
Python example:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
repo = "itsusony/LFM2.5-1.2B-Zhusuan"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
repo, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
)
SYSTEM = (
"你是珠算式心算(珠心算)助手。先在 <think>...</think> 里用算盘档位与珠算口诀分步推理,"
"再给出简短最终答案。口诀名称必须与加数/减数对应正确,算术结果必须准确。"
)
messages = [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": "用珠算思路算 73×19"},
]
prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=256, do_sample=False, pad_token_id=tok.eos_token_id)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Expected style:
<think>
1. …
</think>
73×19=1387。
License
LFM Open License v1.0 (see LICENSE). Redistribution of derivatives is allowed with the license attached; commercial use by entities with annual revenue ≥ USD 10M is not licensed under this agreement. See the full LICENSE text.
中文
相对底座的优势
核心收益:整数四则运算更准、格式更稳。
底座 LFM2.5-1.2B-Thinking |
本模型 Zhusuan | |
|---|---|---|
| 评测 prompt | 普通算术(plain) | 珠算 system +「用珠算思路算 …」 |
| 正确率 (n=100, seed=123) | 72% | **98%**(+26 个百分点) |
| 加法 + | 67.7% | 96.8% |
| 减法 − | 73.7% | 100% |
| 乘法 × | 87.9% | 97.0% |
| 除法 ÷ | 47.1% | 100% |
其它特点:
- 算术正确率明显更高,尤其除法、减法。
- 推理痕迹结构化:习惯在
<think>...</think>里分步(档位/口诀/部分积/验算)。 - 输出更易解析:末行多为
a±×÷b=结果。 - 仍是 1.2B,适合本机/边缘部署。
评测为合成珠算四则分布;竞赛应用题不是主优化目标。
怎么用(重点:Prompt)
推荐 System Prompt:
你是珠算式心算(珠心算)助手。先在 <think>...</think> 里用算盘档位与珠算口诀分步推理,再给出简短最终答案。口诀名称必须与加数/减数对应正确,算术结果必须准确。
推荐 User 说法:
用珠算思路算 73×19
用珠算思路算 915+584
用珠算思路算 336÷7
用珠算思路算 256-67
| 场景 | 建议 |
|---|---|
| 本微调模型 | 用上面 珠算 system + 「用珠算思路算 …」 |
| 原版底座 | 用 普通 算术 prompt,不要硬套珠算话术 |
| 采样 | 精确算术建议 do_sample=False / temperature=0 |
| 答案位置 | </think> 之后最后一行,或 表达式=数字 |
Transformers 示例:(同上英文一节代码,system/user 用中文即可)
许可证
继承底座 LFM Open License v1.0(见 LICENSE)。可分发衍生模型,须附带该许可证;年收入 ≥ 1000 万美元 USD 的商业使用有额外限制。
日本語
ベースモデルに対する強み
主な利点:整数の四則演算の精度向上と、答えの形式が安定することです。
ベース LFM2.5-1.2B-Thinking |
本モデル Zhusuan | |
|---|---|---|
| 評価プロンプト | 通常の算数(plain) | 珠算 system +「用珠算思路算 …」 |
| 正答率 (n=100, seed=123) | 72% | **98%**(+26pt) |
| 加算 | 67.7% | 96.8% |
| 減算 | 73.7% | 100% |
| 乗算 | 87.9% | 97.0% |
| 除算 | 47.1% | 100% |
その他:
- 計算精度が明確に高い(特に除算・減算)。
- 思考過程が構造化:
<think>...</think>内で桁・口訣・部分積・検算。 - 答えを抽出しやすい:最終行が
a×b=結果形式になりやすい。 - 1.2B のままローカル/オンデバイス向け。
評価は合成の珠算風四則です。競技数学の文章題は主対象ではありません。
使い方(プロンプトが重要)
推奨システムプロンプト(学習分布に近い中国語を推奨):
你是珠算式心算(珠心算)助手。先在 <think>...</think> 里用算盘档位与珠算口诀分步推理,再给出简短最终答案。口诀名称必须与加数/减数对应正确,算术结果必须准确。
英語 system も可:
You are an abacus-style mental arithmetic (珠心算) assistant. First reason step by step inside <think>...</think> using abacus rod positions and abacus formulas, then give a short final answer. Formula names must match the addend/subtrahend correctly, and the arithmetic must be accurate.
推奨ユーザー文:
用珠算思路算 73×19
用珠算思路算 915+584
用珠算思路算 336÷7
用珠算思路算 256-67
| 場面 | 推奨 |
|---|---|
| 本ファインチューン | 珠算 system + 用珠算思路算 … |
| 素のベースモデル | 通常の算数プロンプト(珠算口調を無理に付けない) |
| サンプリング | 厳密計算は do_sample=False / temperature 0 |
| 答えの位置 | </think> の後の最終行、または 式=数値 |
Python 例: 英語セクションのコードと同じ(SYSTEM と user を上記に)。
期待される出力イメージ:
<think>
1. …
</think>
73×19=1387。
ライセンス
ベースの LFM Open License v1.0(LICENSE 参照)。派生物の配布は可(ライセンス添付必須)。年間売上高が 1,000 万米ドル以上の主体による商用利用は本契約では許諾されません。詳細は LICENSE 全文を確認してください。
Training summary / 训练摘要 / 学習概要
- Base:
LiquidAI/LFM2.5-1.2B-Thinking - Method: LoRA SFT (
r=16,alpha=32) then merge - Data: ~1000 synthetic zhusuan Q&A with
<think> - Early stopping: 10% eval split, patience 3 on
eval_loss - This checkpoint: full retrain Stage1 best (
output_r2_zhusuan/merged, 98%)
Citation
Please also cite the base model:
LiquidAI/LFM2.5-1.2B-Thinking
- Downloads last month
- 28