Text Classification
Transformers
Safetensors
Laya
Chinese
system-one
calibrated-decisions
rlcd
chinese
classification
routing
scoring
guardrails
non-autoregressive
commercial-license-required
Instructions to use ZichenAI/layazh-zh with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ZichenAI/layazh-zh with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="ZichenAI/layazh-zh")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ZichenAI/layazh-zh", device_map="auto") - Laya
How to use ZichenAI/layazh-zh with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
NovaAI commited on
docs: specific RLCD recipe (reward weights, group/sigma/tau, lr, unfrozen layers); temperature-clamp note
Browse files
README.md
CHANGED
|
@@ -61,7 +61,40 @@ base_model: hfl/chinese-roberta-wwm-ext-large
|
|
| 61 |
| 总参数 | 421M | **352M** |
|
| 62 |
| 上下文 | 512 tokens | 512 tokens |
|
| 63 |
| 选项预算 | `head_max_len = 192` | `head_max_len = 192` |
|
| 64 |
-
| 训练配方 | RLCD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
序列模板与上游完全一致(已用上游 `laya` 包内的 `render_options` / `QTYPES` 做过程序化对齐校验):
|
| 67 |
|
|
@@ -340,6 +373,19 @@ batch 混合了 2 选项与 15 选项的题目,loss 水平主要由构成比
|
|
| 340 |
"noul:2": 0.970277, "score:3-5": 1.034508}
|
| 341 |
```
|
| 342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
> 分桶温度是**由留出数据挑选**出来的,不是默认采用上游做法。
|
| 344 |
> 这一点很重要:同一套分桶在各方案比较中只赢了 0.0137 ECE,
|
| 345 |
> 如果不做留出对比就无从判断它是否真的更好。
|
|
|
|
| 61 |
| 总参数 | 421M | **352M** |
|
| 62 |
| 上下文 | 512 tokens | 512 tokens |
|
| 63 |
| 选项预算 | `head_max_len = 192` | `head_max_len = 192` |
|
| 64 |
+
| 训练配方 | RLCD:log + 0.5·spherical(序数题另加 RPS),REINFORCE + group-mean baseline,多轮 TD(λ=1) | 同配方,实测采用:`rl_weight=8`、`kl_weight=1`、`group=4`、`σ=0.5`、`τ=1.5` |
|
| 65 |
+
|
| 66 |
+
**训练配方的具体做法(同构部分与实测取值)**
|
| 67 |
+
|
| 68 |
+
奖励函数两侧**逐字一致**(我方 `layazh.model.proper_reward` 与上游 `laya.common.proper_reward` 对拍
|
| 69 |
+
确认默认参数相同):
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
reward = log_score + 0.5 × spherical_score # 所有题型
|
| 73 |
+
− 1.0 × ranked_probability_score # 仅序数题 (score)
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
三者都是**严格恰当评分规则**,因此最大化期望奖励的唯一方式就是如实报告概率——
|
| 77 |
+
这是校准性的来源,而不是事后补丁。
|
| 78 |
+
|
| 79 |
+
具体训练设置(我方为实测值;上游的这几项未随 checkpoint 发布,故不臆测):
|
| 80 |
+
|
| 81 |
+
| 项 | 上游 | 本模型(layazh) |
|
| 82 |
+
|---|---|---|
|
| 83 |
+
| 策略梯度估计 | REINFORCE + group-mean baseline(GRPO 风格) | 同 |
|
| 84 |
+
| 探索噪声 | 对选项 logits 加零均值高斯噪声 | `σ = 0.5`,每组采样 `4` 次取组均值作基线 |
|
| 85 |
+
| 采样温度 | 未公开 | `τ = 1.5` |
|
| 86 |
+
| 目标函数 | 策略梯度 + 稠密 masked-KL 辅助项 | `8.0 × PG + 1.0 × KL` |
|
| 87 |
+
| 多轮对话 | TD(λ = 1.0) 于前缀切片 | 同(代码路径一致) |
|
| 88 |
+
| 决策头 lr | 未公开 | `3e-4`(AdamW) |
|
| 89 |
+
| 编码器 lr | 未公开 | `2e-5`(分组,`encoder_lr_scale=0.067`) |
|
| 90 |
+
| 可训练范围 | 全量微调编码器 | **顶部 8/24 层** + 决策头(12 GB 显存约束) |
|
| 91 |
+
| LR 调度 | 未公开 | 线性 warmup 6% + cosine 衰减 |
|
| 92 |
+
| 其他 | — | 选项顺序增强开、grad clip 1.0、gradient checkpointing 开、fp32 |
|
| 93 |
+
|
| 94 |
+
> **诚实说明**:上游只发布了**权重与推理配置**,没有发布 RLCD 的训练超参
|
| 95 |
+
> (`rl_agent_config.json` 里只有 `temperature` 与 `updates: 7313 / hours: 1.96` 这类元数据)。
|
| 96 |
+
> 因此"同配方"指的是**算法与奖励函数相同**,而上表中的具体数值是本项目自行确定并实测的,
|
| 97 |
+
> 不能声称与上游的隐藏设置一致。
|
| 98 |
|
| 99 |
序列模板与上游完全一致(已用上游 `laya` 包内的 `render_options` / `QTYPES` 做过程序化对齐校验):
|
| 100 |
|
|
|
|
| 373 |
"noul:2": 0.970277, "score:3-5": 1.034508}
|
| 374 |
```
|
| 375 |
|
| 376 |
+
> **与上游 SDK 的一处已知差异。** 上游 `laya` 包在加载 checkpoint 时会用
|
| 377 |
+
> `clamp_temperature` 把温度限制在 **[0.5, 5.0]**,而本模型的 `choice:2` 桶
|
| 378 |
+
> 拟合值为 **0.253**(低于下界)。我实测了加这个限幅的影响:
|
| 379 |
+
>
|
| 380 |
+
> | 温度限幅 | ECE(全部 6,244 题) |
|
| 381 |
+
> |---|---|
|
| 382 |
+
> | 不限幅(本模型默认) | **0.2498** |
|
| 383 |
+
> | `[0.5, 5.0]`(上游 SDK 行为) | 0.2799 |
|
| 384 |
+
>
|
| 385 |
+
> 限幅会让 ECE 变差,说明该桶确实需要更强的锐化(模型对 2 选项题过于保守)。
|
| 386 |
+
> 因此本模型**不做限幅**。若你通过上游 `laya` SDK 加载本 checkpoint,
|
| 387 |
+
> 温度会被自动限幅到 0.5,ECE 将为 0.2799 —— 这是可预期的差异,不是 bug。
|
| 388 |
+
|
| 389 |
> 分桶温度是**由留出数据挑选**出来的,不是默认采用上游做法。
|
| 390 |
> 这一点很重要:同一套分桶在各方案比较中只赢了 0.0137 ECE,
|
| 391 |
> 如果不做留出对比就无从判断它是否真的更好。
|