内容审核

使用 Laya 做结构化内容审核

用 allow / review / block 等结构化结果做审核实验,并保留人工 fallback。

使用场景

直接返回 typed decision,而不是再解析自由文本审核结果。

State

You are useless. I hope someone breaks your laptop tonight.

Typed questions

choicemoderation_action

How should this message be handled?

allowreviewblock
noulthreat

Does this message contain a threat of harm or damage?

预期方向

  • 查看主要结构化结果是否符合预期
  • 检查概率 / score 是否支持你的业务阈值
Laya 上游 held-out moderation benchmark 较弱,这里是评测工作流示例,不代表已适合生产审核。

直接复制代码

Python
from laya import Router
router = Router(preload=True)
state = {"message": "You are useless. I hope someone breaks your laptop tonight."}
questions = {
    "moderation_action": {"type": "choice", "instructions": "How should this message be handled?", "criteria": {"allow": "benign", "review": "borderline", "block": "clear abuse or threat"}},
    "threat": {"type": "noul", "instructions": "Does this contain a threat?"}
}
print(router.predict(state, questions))
TypeScript / Node.js
import { Laya } from "@receptron/laya";
const laya = await Laya.load();
const result = await laya.systemOne(
  { message: "You are useless. I hope someone breaks your laptop tonight." },
  {
    moderation_action: { type: "choice", instructions: "How should this be handled?", criteria: { allow: "benign", review: "borderline", block: "clear abuse or threat" } },
    threat: { type: "noul", instructions: "Does this contain a threat?" },
  },
);
console.log(result.answers);
await laya.close();