---
title: ruhui
canonical_url: "https://www.modelscope.cn/models/anyforge/ruhui"
md_url: "https://www.modelscope.cn/models/anyforge/ruhui.md"
repository: anyforge/ruhui
chinese_name: "如晦-System1决策引擎"
last_updated: 2026-09-24
license: "Apache License 2.0"
pipeline_tag: text-classification
tasks:
  - text-classification
parameters: 321.9M
tensor_type:
  - F16
library_name:
  - safetensors
language:
  - multilingual
  - en
  - de
  - fr
  - es
  - pt
  - it
  - nl
  - sv
  - da
  - nb
  - ru
  - pl
  - tr
  - ar
  - he
  - fa
  - ur
  - hi
  - bn
  - ta
  - te
  - kn
  - ml
  - th
  - vi
  - id
  - ms
  - tl
  - ja
  - ko
  - zh
  - el
  - hu
  - fi
  - ro
  - sq
  - sl
  - sw
  - af
  - cy
  - am
  - hy
  - ka
  - km
  - my
  - mn
  - lv
  - is
  - az
  - jv
downloads: 8537
stars: 0
tags:
  - ruhui
  - jev
  - laya
  - multilingual
  - mmbert
  - system-one
  - calibrated-decisions
  - rlcd
  - classification
  - routing
  - guardrails
  - moderation
  - commercial-use
---

# ruhui

> ruhui - anyforge 在 ModelScope 开源的模型。非自回归 System 1 决策引擎（中文/多语言），带校准概率。

anyforge/ruhui 是 ModelScope 魔搭社区上的 321.9M 参数text-classification模型，采用 Apache License 2.0 许可。

- **Repository**: anyforge/ruhui
- **License**: Apache License 2.0
- **Tasks**: text-classification
- **Parameters**: 321.9M
- **Tags**: ruhui, jev, laya, multilingual, mmbert, system-one, calibrated-decisions, rlcd, classification, routing, guardrails, moderation, commercial-use
- **Downloads**: 8537
- **Stars**: 0
- **Last updated**: 2026-09-24

Source: https://www.modelscope.cn/models/anyforge/ruhui

---

# Ruhui · 如晦

**非自回归 System 1 决策引擎（中文/多语言），带校准概率。**

命名取自「房谋杜断」的杜如晦（字克明），「晦」音近「hui」。房玄龄善谋、杜如晦善断——Ruhui 取「断」之意：System 1 快速决策，不生成文本、无可解析输出、因此无幻觉。

架构参照 [Laya](https://github.com/NandhaKishorM/laya)（Apache 2.0），核心差异：

- **中文/多语言底座**：`mmBERT-base`（100+ 语言），而非英语-only 的 ModernBERT
- **中英双语软标签微调**：覆盖 30+ 领域数据集（意图/情感/安全/智能体决策/工具调用等）

---

## 模型信息

| 项 | 值 |
|---|---|
| 参数量 | 322M（mmBERT-base + 决策头）|
| 上下文长度 | 1024 |
| 决策头预算 | 256 |
| 支持语言 | 中文、英文及 100+ 语言 |
| 训练方式 | RLCD（恰当评分规则策略梯度）+ 软蒸馏 + 温度校准 |

---

## 能力

三种决策原语，单次前向传播并行输出：

| 原语 | 输出 | 用途 |
|---|---|---|
| `choice` | top 标签 + 全概率分布 + 置信度 | 意图分类、部门路由、主题归类 |
| `score` | 有序标度上的期望值 | 紧急程度、情绪等级、危害严重度 |
| `noul` | 校准的 P(true) | 垃圾检测、钓鱼识别、越狱检测、流失风险 |

由于概率用严格恰当评分规则训练，**置信度分数是统计上有意义的**，可直接做置信度门控：

```python
if conf >= 0.85:
    route_automatically(dept)   # 高置信自动处理
else:
    escalate_to_human(dept)     # 低置信转人工
```

---

## 快速开始

先安装：

```bash
pip install ruhui
```

然后加载模型做决策。Ruhui **同一份 checkpoint 同时支持中文和英文（100+ 语言）**，无需区分中英文模型：

```python
import ruhui

agent = ruhui.load("anyforge/ruhui")

# 中文输入
result_zh = agent.predict(
    {"message": "我被重复扣款了，请退款"},
    {
        "intent": {
            "type": "choice",
            "instructions": "客户想做什么？",
            "criteria": {"refund": "退款", "technical": "技术问题", "billing": "账单咨询"},
        },
        "churn_risk": {"type": "noul", "instructions": "客户是否威胁要离开？"},
    },
)

# 英文输入 —— 同一个模型，无需切换
result_en = agent.predict(
    {"message": "I was charged twice, please refund me."},
    {
        "intent": {
            "type": "choice",
            "instructions": "What does the customer want?",
            "criteria": {"refund": "money back", "technical": "bug or outage", "billing": "invoice question"},
        },
        "churn_risk": {"type": "noul", "instructions": "Does the customer threaten to leave?"},
    },
)

print(result_zh["answers"])
print(result_en["answers"])
```

---

## 微调（在自己的领域数据上）

```bash
# 1. 软标签数据 → 训练 items
python scripts/prepare_train_data.py --model_dir <底座> --soft_dir <软标签> --out train_items.pt

# 2. 训练（RLCD + 软蒸馏 + 温度校准）
python scripts/train.py --model_dir <底座> --train_items train_items.pt --output_dir output/ruhui --epochs 4

# 3. 评估（对齐 Laya 指标）
python scripts/evaluate.py --model_dir output/ruhui --device cuda
```

详见代码仓库 [anyforge/ruhui](https://github.com/anyforge/ruhui)。

---

## 许可证

Apache 2.0（参照 Laya）。Developed by AnyForge。
