YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

SamAI-PonderNet-DMoE-2B (r12)

基于 MiniCPM-5 2B 架构的 Ponder/DMoE 推理缩进模型:末 8 层(L34–41)8 专家 DMoE + Ponder 自适应思考步(N=8, τ=0.125)+ MTP 深度 2。本仓库为 r12 版(r5b→r11→r12 链式续训),重点修复闲聊停机与英文 OOD 两大 P0 问题。

模型规格

基座 MiniCPM5-2B(42L / hidden 2048 / GQA 16+2 / vocab 130560)
MoE L34–41 × 8 专家(expert intermediate 768),router top-2 融合,active≈1.74
Ponder N=8, τ=0.125,平均思考步 ~2.1
MTP 深度 2(训练辅助)
权重 bf16 单文件 5.08GB;trust_remote_code=True 加载
EOS [1, 130073](`<

推理协议(重要)

遵循 MiniCPM5 官方姿势,两件事必须做对:

  1. 采样do_sample=True, temperature=1.0, top_p=0.95, repetition_penalty=1.0(greedy 不在官方设计姿势内,会显著加剧复读)。generation_config 已按此固化。
  2. 思考协议
    • 标准模式:正常 apply_chat_template,模型自行输出 <think>...</think> 后给答案;
    • think_off(轻聊场景推荐):在 assistant 首部预填空思考段 <think>\n\n</think>\n\n,跳过思考直接作答——闲聊停机率更高(86–90%),响应更快。
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("tchbcb/samai-pnet-dmoe-2b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    "tchbcb/samai-pnet-dmoe-2b", trust_remote_code=True,
    torch_dtype="bfloat16", device_map="auto")

# 标准模式
msgs = [{"role": "user", "content": "你好"}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=512, do_sample=True,
                     temperature=1.0, top_p=0.95, repetition_penalty=1.0)
print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=False))

# think_off 模式(assistant 预填空思考)
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt")
pre = tok("<think>\n\n</think>\n\n", return_tensors="pt").input_ids[:, 1:]
out = model.generate(torch.cat([ids.to(model.device), pre.to(model.device)], dim=1),
                     max_new_tokens=256, do_sample=True,
                     temperature=1.0, top_p=0.95, repetition_penalty=1.0)

r12 验收数据(greedy 口径冻结 CE + 双协议 chat50)

指标 r11 r12
“你好” 停机 (top_f) 0.68 ✗ 0.20 ✓
chat50 首答即停 (bare / think_off) 70% / — 90% / 86%
greeting / self / bye 60/90/100% 100/100/100%
EN OOD (12x8) 干净停机 ✓ (rep3=0) ✓ (rep3=0.0)
chat 3-gram 重复率 0.209 ✗ 0.083 ✓
冻结 CE easy/medium/hard Δ-0.09/+0.05/-0.02 Δ-0.43/-0.18/-0.36(全面改善)
TB2 24 题 9/24 10/24(easy 75%)

已知短板:TB2 medium 桶(sed/python 单行/find 语法)仅 11%,r13 精修中;daily/boundary/simple 停机率 80% 仍在打磨。

训练配方

r5b(CE 锚定)→ r11(agent+chat v2 混合)→ r12(chat_synth_v3 54% + zh_cot 1049 锚保护 + alpaca 中英 + agent,5109 行 ×2ep,LoRA r16 α32,--step-ce-weight 0.5,难度先验 easy:0.7/medium:0.4/hard:0.15)。合并配方:load_trainables → PeftModel.merge_and_unload,L36 q_proj delta>0 断言,generation_config.eos=[1,130073] 断言。

文件

  • model.safetensors — 合并后 bf16 权重
  • modeling_samai_pnet.py / config.json — 远程代码(auto_map: SamaiPnetConfig / SamaiPnetForCausalLM)
  • chat_template.jinja / tokenizer.json / tokenizer_config.json — 与 MiniCPM5 官方模板逐字节一致
  • generation_config.json — 已固化官方采样参数
  • inference.py / serve_contract.json — 服务化参考实现与契约
Downloads last month
75
Safetensors
Model size
3B params
Tensor type
F32
·
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using tchbcb/samai-pnet-dmoe-2b 1