Instructions to use the-walking-fish/jijun-LM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use the-walking-fish/jijun-LM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="the-walking-fish/jijun-LM")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("the-walking-fish/jijun-LM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use the-walking-fish/jijun-LM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "the-walking-fish/jijun-LM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "the-walking-fish/jijun-LM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/the-walking-fish/jijun-LM
- SGLang
How to use the-walking-fish/jijun-LM 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 "the-walking-fish/jijun-LM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "the-walking-fish/jijun-LM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "the-walking-fish/jijun-LM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "the-walking-fish/jijun-LM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use the-walking-fish/jijun-LM with Docker Model Runner:
docker model run hf.co/the-walking-fish/jijun-LM
jijun-LM — 58M 超微型端側工具呼叫語意模型
基於語意協議型縮的超小型高效端側工具調用語義模型研究 An Empirical Study on Efficient Tool-Calling Language Models via Semantic Protocol Compression
版本與目錄 (Versions)
| 目錄 | 後代 | 協定 | 說明 |
|---|---|---|---|
model-json/ |
v4d(2026-10-15) | JSON `< | tool_call |
model-compressed-token/ |
v1(2026-08-02) | 特殊 Token 型縮 `[AMT]150[CAT]餐飲…< | tool_result |
v4d 為 continue-SFT 鏈最新一代(v1 → v2(多工具 Protocol v2)→ v4b/v4c(短語強化、金額反先驗)→ v4d(偙親費型字面分類修復)。使用者輸入句中出現的分類名若存在於 system prompt 的 enum 內,即原樣抄寫(例:孝親費10000 → category 孝親費)。
模型描述 (Model Description)
jijun-LM(內部實作類名 BookkeepingLM)是一個從零開始訓練、約 58M 參數 的 Decoder-only 語言模型,專注於記帳(Bookkeeping)窄域的工具呼叫(Tool Calling)任務。模型以 GQA、RoPE、SwiGLU、Pre-RMSNorm 與 Tied Embedding 等現代小模型設計,透過極小的體積可在瀏覽器(WASM/WebGPU)等端側環境進行離線推理。模型並非任何現成模型的微調版本,僅借用 jingyaogong/minimind-3 的 Llama 相容分詞器詞表並動態註冊記帳特殊 Token。
本模型為記帳 PWA 專案 ADT109119/jijun 提供離線端側的工具呼叫能力。
模型規格 (Model Details)
| 項目 | 數值 |
|---|---|
| 總參數量 | ~58M |
| Transformer 層數 | 12 |
| d_model | 768 |
| Query Heads / KV Heads (GQA) | 8 / 4 |
| SwiGLU 中間層維度 | 1152 |
| 最大序列長度 | 1024 |
| 詞表大小 | 6400 + 6 記帳特殊 Token = 6406 |
| 輸出層架構 | LlamaForCausalLM(可透過 transformers 直接載入) |
快速開始 (Quickstart,v4d / model-json)
輸入為裸 ChatML 拼接(不要使用隨付的 HF chat template,其為 minimind-3 base 版含 think 區塊、與訓練協定不同):
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_id = "the-walking-fish/jijun-LM"
model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="model-json", dtype=torch.float32)
tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="model-json")
model.eval()
system_prompt = (
"今天是 2026-12-01(星期二)。你是一個記帳助理。你被賦予了以下 tools:\n"
'{"name": "add_record", "description": "新增一筆記帳記錄", "parameters": {"type": "object", "properties": {"amount": {"type": "number"}, "category": {"type": "string", "enum": ["飲食", "日常", "交通", "娛樂", "醫療", "教育", "還款", "薪水", "獎金", "零用錢", "兼職", "投資", "利息", "欠款回收", "其他"]}, "account": {"type": "string", "enum": ["現金", "信用卡", "悠遊卡", "一卡通", "街口支付", "LINE Pay", "Apple Pay", "Google Pay", "郵局帳戶", "銀行存款", "外幣帳戶", "加密貨幢", "悠遊付", "icash"]}, "description": {"type": "string"}, "type": {"type": "string", "enum": ["expense", "income"]}, "date": {"type": "string", "description": "ISO 8601 格式日期"}}, "required": ["amount", "category", "account", "type", "date"]}}'
)
prompt = (
"<|im_start|>system\n" + system_prompt + "<|im_end|>\n"
"<|im_start|>user\n早餐 60<|im_end|>\n"
"<|im_start|>assistant\n"
)
input_ids = torch.tensor([tokenizer.encode(prompt, max_length=4096, truncation=True, add_special_tokens=False)])
generated = input_ids
for _ in range(300):
with torch.no_grad():
logits, _ = model(generated)
next_id = torch.argmax(logits[0, -1, :]).unsqueeze(0).unsqueeze(0)
if next_id.item() in (tokenizer.eos_token_id,
tokenizer.encode("<|tool_result|>", add_special_tokens=False)[0]):
break
generated = torch.cat([generated, next_id], dim=-1)
print(tokenizer.decode(generated[0, input_ids.shape[1]:]))
# 預期:<|tool_call|>{"name": "add_record", "args": {"amount": 60, "category": "飲食", "account": "現金", "description": "早餐", "type": "expense", "date": "2026-12-01"}}<|tool_result|>
主要注意事項:
- prompt 內容易超 512 token,
tokenizer.encode(...)請預留足夠的max_length(否則預設 512 截斷會切掉 system prompt)。 - 停止記號建議同時含
<|im_end|>與<|tool_result|>。 - system prompt 中的工具定義(分類/帳戶 enum)會被模型查表:自訂分類名只要出現在 enum 內就會被正確選取(v4d 能力)。
評測 (Evaluation)
v4d / model-json,831 筆分層語料全量自迴歸 Greedy(含日期擺點),與 v4c 同集同 harness 對照:
| 指標 | v4c | v4d |
|---|---|---|
| 格式通過率 | 100% | 100% |
| 金額 | 95.8% | 96.4% |
| 分類 | 73.3% | 72.8% |
| 帳戶 | 98.6% | 98.6% |
| 收支型別 | 88.4% | 89.3% |
| 日期 | 77.1% | 80.6% |
| 專案點名「孝親費10000」型 5 案(純模型、不經前端守門) | 0/5 | 5/5 |
| 類別名回聲測試 echo_test category | 2.3% | 94.4% |
早期 v1 時代(2026-08)的兩協定對比評測數值見 results.tsv(為 model-compressed-token/ 與其同代 JSON 版之歷史數據,並非 v4d)。
訓練流程 (Training,v4d)
- 預訓練:以 Wikipedia 繁體百科與理財口語對話混合(7:3)做無監督預訓練。
- Continue-SFT 鏈:v1 SFT → v2 多工具協定 → v4b 短語增廣 → v4c 金額反先驗 → v4d 偙親費型字面回聲;每代皆以上一代 best checkpoint 為起點(lr 5e-5、4 epochs、bf16),並以遺忘防線(舊回歸集不降)與專項 probe 集雙軌門控。
資料集 (Training Data)
dataset/ 子資料夾為 v1 時代語料(4,154 筆 SFT + 80/20 切分),供研究展示;v2–v4d 的訓練語料生成器與評測集在專案內部訓練 repo,未隨本 repo 發布。
其他 (Notes)
- 訓練方式說明:本模型未基於任何現有 LLM 的權重或其輸出做知識蒸饏;字元/輸入數據集合見專案訓練 repo。
- 窄域設計:僅針對記帳工具呼叫;不適用於對話、通用工具使用或多步推理。
- 資料為合成:SFT 語料由大型模型批次生成並經語義過濾,可能帶入分佈偏差。
- 分詞器借用
jingyaogong/minimind-3詞表(僅 tokenizer,未使用其模型權重)。
引用 (Citation)
@misc{jijunlm2026,
title = {jijun-LM: Efficient Tool-Calling Language Models under 58M Parameters via Semantic Protocol Compression},
author = {ADT109119},
year = {2026}
}
授權 (License)
MIT License。