Downloads · 30 days
0
the-walking-fish/jijun-LM
jijun-LM is a text generation model from the-walking-fish. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
基於語意協議型縮的超小型高效端側工具調用語義模型研究 An Empirical Study on Efficient Tool-Calling Language Models via Semantic Protocol Compression
Downloads · 30 days
0
Access
Public
Updated Oct 15, 2026
Repo size
504 MB
Likes
0
Public
Click a slice to open those files.
.safetensors504 MB · 98%
From the Hugging Face model README
基於語意協議型縮的超小型高效端側工具調用語義模型研究 An Empirical Study on Efficient Tool-Calling Language Models via Semantic Protocol Compression
| 目錄 | 後代 | 協定 | 說明 |
|---|---|---|---|
model-json/ | v4d(2026-10-15) | JSON `< | tool_call |
model-compressed-token/ | v1(2026-08-02) | 特殊 Token 型縮 `<tool_call>[AMT]150[CAT]餐飲…< | tool_result |
v4d 為 continue-SFT 鏈最新一代(v1 → v2(多工具 Protocol v2)→ v4b/v4c(短語強化、金額反先驗)→ v4d(偙親費型字面分類修復)。使用者輸入句中出現的分類名若存在於 system prompt 的 enum 內,即原樣抄寫(例:孝親費10000 → category 孝親費)。
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 提供離線端側的工具呼叫能力。
| 項目 | 數值 |
|---|---|
| 總參數量 | ~58M |
| Transformer 層數 | 12 |
| d_model | 768 |
| Query Heads / KV Heads (GQA) | 8 / 4 |
| SwiGLU 中間層維度 | 1152 |
| 最大序列長度 | 1024 |
| 詞表大小 | 6400 + 6 記帳特殊 Token = 6406 |
| 輸出層架構 | LlamaForCausalLM(可透過 transformers 直接載入) |
輸入為裸 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|>
主要注意事項:
tokenizer.encode(...) 請預留足夠的 max_length(否則預設 512 截斷會切掉 system prompt)。<|im_end|> 與 <|tool_result|>。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)。
dataset/ 子資料夾為 v1 時代語料(4,154 筆 SFT + 80/20 切分),供研究展示;v2–v4d 的訓練語料生成器與評測集在專案內部訓練 repo,未隨本 repo 發布。
jingyaogong/minimind-3 詞表(僅 tokenizer,未使用其模型權重)。@misc{jijunlm2026,
title = {jijun-LM: Efficient Tool-Calling Language Models under 58M Parameters via Semantic Protocol Compression},
author = {ADT109119},
year = {2026}
}
MIT License。