How to use from the
Use from the
Transformers library
# 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]:]))
Quick Links

LFM2.5-1.2B-Zhusuan

LoRA-SFT (merged) of LiquidAI/LFM2.5-1.2B-Thinking for abacus-style mental arithmetic (珠算 / 珠心算). Still 1.2B — runs locally.


English

Why this model

Much more accurate integer arithmetic, with a stable expr=result final line. Still 1.2B — no tool calls, pure model.

R4 vs Base — hard 100

Headline (hardest head-to-head): same 100 big-integer problems (test_100.py --hard --seed 628488977, greedy, max_new_tokens=3072):

Op Base (LFM2.5-1.2B-Thinking) Zhusuan R5b Δ
+ 29.2% 100% +70.8
63.0% 92.6% +29.6
× 0.0% 100% +100
÷ 42.9% 100% +57.1
Overall 33.0% 98.0% +65.0

Base collapses on multi-digit multiplication (often copies an operand or invents digits). R5b runs full abacus-style traces (base-1000 chunked mult for ≥10-digit products) and finishes with a parseable expr=result line. Head-to-head numbers above are the R4 release suite (same seed); stratified R5b below is stronger on hard / hard_div / xl.

Stratified suite (greedy, seed=123, eval_math.py; Base from the same harness as our earlier deploy report):

Suite Base Zhusuan R5b Δ
easy (n=100) 96.0% 99.0% +3.0
medium (n=100) 90.0% 98.0% +8.0
hard (n=80) 63.7% 100% +36.3
hard — multiplication only 54.8% (23/42) 100% (40/40) +45.2
hard — division only 83.3% (10/12) 100% (13/13) +16.7
hard_div (large divisors, n=40) 97.5% new stress set
xl_fixed (n=30) 83.3% 100% +16.7
plain_easy (n=50) 98.0% no abacus cue
Overall (easy+med+hard+xl, n=310) 84.5% 99.0% +14.5

R4 vs Base — full chart

Base tends to slip digits on long multiplication, contradict itself, and emit hard-to-parse final lines — real outputs in Demo. Eval is synthetic abacus-style arithmetic (code in sft/); competition word problems are not the target. Repo weight is R5b (chunked big-mult; init R5a → R5b).

Quick start

No system prompt needed — the bundled chat template injects a zhusuan one by default. Ask in any language (用珠算思路算 73×19, Calculate 73×19 …). Use greedy decoding and max_new_tokens ≥ 3072 (long-multiplication traces are long). The answer is the last line after </think>.

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)

messages = [{"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=3072, do_sample=False, pad_token_id=tok.eos_token_id)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Quick test (ground truth computed in plain Python, compared with the model's answer):

python3 test_chat.py   # interactive chat
python3 test_100.py    # random 100 problems -> accuracy report (--seed 42, --hard for big numbers)

License

LFM Open License v1.0 (see LICENSE). Commercial use by entities with annual revenue ≥ USD 10M is not licensed.


中文

为什么用这个模型

整数四则明显更准,末行固定为 式=答。仍是 1.2B,不靠外挂计算器。

R4 vs Base

同题硬核对比test_100.py --hard --seed 628488977,greedy,max_new_tokens=3072):

运算 底座 Base 本模型 R5b Δ
+ 29.2% 100% +70.8
63.0% 92.6% +29.6
× 0.0% 100% +100
÷ 42.9% 100% +57.1
总计 33.0% 98.0% +65.0

底座在大数乘法上几乎全军覆没;R5b 用珠算分步轨迹(≥10 位积走千位分节),大乘/大除都拉到满分档。上表同题硬核为 R4 发布套件;下方分层为 R5b。

分层评测(seed=123,eval_math.py):

套件 底座 本模型 R5b Δ
easy (n=100) 96.0% 99.0% +3.0
medium (n=100) 90.0% 98.0% +8.0
hard (n=80) 63.7% 100% +36.3
hard 仅乘法 54.8% 100% (40/40) +45.2
hard 仅除法 83.3% 100% +16.7
hard_div(大除数 n=40) 97.5% 压测
xl_fixed (n=30) 83.3% 100% +16.7
plain_easy (n=50) 98.0% 不提珠算
总计 (easy+med+hard+xl, n=310) 84.5% 99.0% +14.5

完整对比图

底座常见问题:长乘法串位、末行自相矛盾、答案格式难解析——见 Demo。评测为合成珠算四则(sft/),竞赛应用题不是目标。当前仓库权重为 R5b

怎么用

  • 无需 system prompt:chat template 已内置珠算 system,任意语言提问均可(如 用珠算思路算 73×19
  • greedy 解码,max_new_tokens ≥ 3072(大乘法轨迹很长);答案在 </think> 后的最后一行
  • 随机测试:python3 test_100.py(Python 真值比对并输出正确率;--hard 大数难度,--seed 可复现)
  • 代码示例见英文 Quick start

许可证

LFM Open License v1.0(见 LICENSE);年收入 ≥ 1000 万美元的商业使用不在许可范围内。


日本語

このモデルを選ぶ理由

整数の四則演算が大幅に正確になり、最終行は常に 式=答。パラメータは 1.2B のまま(ツール不使用)。

R4 vs Base

同一 100 問ハード比較test_100.py --hard --seed 628488977):

演算 ベース 本モデル R5b Δ
+ 29.2% 100% +70.8
63.0% 92.6% +29.6
× 0.0% 100% +100
÷ 42.9% 100% +57.1
全体 33.0% 98.0% +65.0

ベースは大きな掛け算でほぼ全滅。R5b は珠算トレース(10 桁以上の積は 1000 進チャンク)で乗除を安定化。上表は R4 公開スイート;下の層別は R5b。

層別評価(seed=123):

スイート ベース 本モデル R5b Δ
easy (n=100) 96.0% 99.0% +3.0
medium (n=100) 90.0% 98.0% +8.0
hard (n=80) 63.7% 100% +36.3
hard 乗算のみ 54.8% 100% (40/40) +45.2
hard 除算のみ 83.3% 100% +16.7
hard_div(大除数 n=40) 97.5% ストレステスト
xl_fixed (n=30) 83.3% 100% +16.7
plain_easy (n=50) 98.0% 珠算ヒントなし
合計 (easy+med+hard+xl, n=310) 84.5% 99.0% +14.5

詳細チャート

ベースの典型的な失敗は桁ずれ・自己矛盾・パース困難な最終行(Demo)。評価は合成の珠算四則(sft/)。リポジトリの現行重みは R5b

使い方

  • system プロンプト不要:chat template がデフォルトの珠算 system を自動挿入します。どの言語でも質問できます(例:珠算の考え方で 73×19 を計算してください。
  • greedy デコード、max_new_tokens ≥ 3072 を推奨(長い乗算の思考は長文になります)。答えは </think> の後の最終行です
  • ランダムテスト:python3 test_100.py(Python の真値と照合して正答率を表示。--hard で大きな数、--seed で再現可能)
  • コード例は英語の Quick start を参照

ライセンス

LFM Open License v1.0LICENSE 参照)。年間売上 1,000 万米ドル以上の主体による商用利用は本契約では許諾されません。


Demo / 示例 / デモ

Real greedy generations. Note: the model always thinks in its trained Chinese abacus trace, even for English/Japanese prompts.(模型无论用什么语言提问,都用中文珠算轨迹思考。どの言語で聞いても中国語の珠算トレースで考えます。)

Calculate 73×19 using abacus-style (珠算) reasoning. — full output

<think>
乘法:逐位取乘数一档,用九九得部分积,再按档错位累加(每步写进位)。
被乘数=73,乘数=19。
— 乘数第1位(权10^0)= 9 —
【一位乘】73×9(从个位向高位,九九口诀+进位):
  第1档: 3×9=27,加进位0 → 27,写7,进2
  第2档: 7×9=63,加进位2 → 65,写5,进6
  最高进位写6
  得 73×9=657
  左移0档,部分积=657
【档位加】累加第1个部分积: 0+657(从个位向高位)
  第1档: 0+7+进0=7 → 写7,进0
  第2档: 0+5+进0=5 → 写5,进0
  第3档: 0+6+进0=6 → 写6,进0
  得 0+657=657
— 乘数第2位(权10^1)= 1 —
【一位乘】73×1(从个位向高位,九九口诀+进位):
  第1档: 3×1=3,加进位0 → 3,写3,进0
  第2档: 7×1=7,加进位0 → 7,写7,进0
  得 73×1=73
  左移1档(×10^1): 73 → 730
【档位加】累加第2个部分积: 657+730(从个位向高位)
  第1档: 7+0+进0=7 → 写7,进0
  第2档: 5+3+进0=8 → 写8,进0
  第3档: 6+7+进0=13 → 写3,进1
  最高进位写1
  得 657+730=1387
验算: 73×19=1387
</think>
73×19=1387。
English translation of the trace (human translation for readability — the model itself always thinks in Chinese)
<think>
Multiplication: take one multiplier digit at a time, build partial products
from the times table, accumulate with digit shifts (record every carry).
Multiplicand=73, multiplier=19.
— Multiplier digit 1 (weight 10^0) = 9 —
[1-digit multiply] 73×9 (units → high, times table + carry):
  Rod 1: 3×9=27, +carry 0 → 27, write 7, carry 2
  Rod 2: 7×9=63, +carry 2 → 65, write 5, carry 6
  Top carry 6
  → 73×9=657
  Shift 0 rods, partial product = 657
[Rod addition] Accumulate 1st partial: 0+657 (units → high)
  Rod 1: 0+7+carry0=7 → write 7, carry 0
  Rod 2: 0+5+carry0=5 → write 5, carry 0
  Rod 3: 0+6+carry0=6 → write 6, carry 0
  → 0+657=657
— Multiplier digit 2 (weight 10^1) = 1 —
[1-digit multiply] 73×1:
  Rod 1: 3×1=3, +carry 0 → 3, write 3, carry 0
  Rod 2: 7×1=7, +carry 0 → 7, write 7, carry 0
  → 73×1=73
  Shift 1 rod (×10^1): 73 → 730
[Rod addition] Accumulate 2nd partial: 657+730
  Rod 1: 7+0+carry0=7 → write 7, carry 0
  Rod 2: 5+3+carry0=8 → write 8, carry 0
  Rod 3: 6+7+carry0=13 → write 3, carry 1
  Top carry 1
  → 657+730=1387
Check: 73×19=1387
</think>
73×19=1387.
日本語訳(読みやすさのための人間による翻訳。モデル自体は常に中国語で思考します)
<think>
乗法:乗数を1桁ずつ取り、九九で部分積を作り、桁ずらしで累加する(各ステップで繰り上がりを記録)。
被乗数=73、乗数=19。
— 乗数の1桁目(重み10^0)= 9 —
【一桁乗算】73×9(一の位から上位へ、九九+繰り上がり):
  第1桁: 3×9=27、繰上0を加算 → 27、7を書き、2を繰上
  第2桁: 7×9=63、繰上2を加算 → 65、5を書き、6を繰上
  最上位の繰上6を書く
  → 73×9=657
  0桁シフト、部分積=657
【桁加算】1つ目の部分積を累加: 0+657(一の位から上位へ)
  第1桁: 0+7+繰上0=7 → 7を書き、繰上0
  第2桁: 0+5+繰上0=5 → 5を書き、繰上0
  第3桁: 0+6+繰上0=6 → 6を書き、繰上0
  → 0+657=657
— 乗数の2桁目(重み10^1)= 1 —
【一桁乗算】73×1:
  第1桁: 3×1=3、繰上0 → 3、3を書き、繰上0
  第2桁: 7×1=7、繰上0 → 7、7を書き、繰上0
  → 73×1=73
  1桁シフト(×10^1): 73 → 730
【桁加算】2つ目の部分積を累加: 657+730
  第1桁: 7+0+繰上0=7 → 7、繰上0
  第2桁: 5+3+繰上0=8 → 8、繰上0
  第3桁: 6+7+繰上0=13 → 3を書き、1を繰上
  最上位の繰上1を書く
  → 657+730=1387
検算: 73×19=1387
</think>
73×19=1387。

Calculate 35937×1774 using abacus-style (珠算) reasoning. — base vs this model

Base burns its thinking budget guessing what 珠算 means, then slips a digit → wrong:

<think> Okay, let's tackle this problem ... Hmm, first, I need to recall what
abacus-style calculation involves. Since the user mentioned using the abacus
and pearls (珠算), which I think refers to the traditional Chinese counting
method ... </think>
... After precise computation, the result is **63,753,238**.

\boxed{63753238}        ← digit slip, WRONG (correct: 63752238)

(Japanese prompt, same story: base calls it the "Jewel Box Suanpan method" and answers 63,753,238.)

This model (EN or JA prompt — identical output) runs the full partial-product trace (abridged) → correct:

<think>
被乘数=35937,乘数=1774。
【一位乘】35937×4=143748 →【档位加】0+143748=143748
【一位乘】35937×7=251559,左移1档 →【档位加】累加=2659338
…(第3、4位同理,逐档进位累加)…
验算: 35937×1774=63752238
</think>
35937×1774=63752238。   ← CORRECT

More real base failures from the same eval run (prompts carried the 用珠算思路算 … wording):

Prompt Correct Base answered What went wrong
19884×19 377796 (unparseable) Right math, but final line = 19884 × (20−1) = … hid the answer
999×999 998001 1000 Truncated mid-\boxed{…; wrong earlier number picked up
64÷8 8 64 Rambled about the "pearl method", never gave a clean answer

Training

  • Base: LiquidAI/LFM2.5-1.2B-Thinking → LoRA SFT (r=16, alpha=32), merged
  • Data: synthetic zhusuan Q&A with <think> traces; R3 round adds 19,666 hard-mined pairs (long ×/÷)
  • Checkpoint: R3 fine, 2.5 epochs, train_loss 0.027 — overall 79.4% → 93.0% vs base; training/eval code in sft/

Citation

Please also cite the base model:

LiquidAI/LFM2.5-1.2B-Thinking
Downloads last month
45
Safetensors
Model size
1B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for itsusony/LFM2.5-1.2B-Zhusuan

Adapter
(13)
this model
Adapters
1 model