Moderation

Content Moderation with Laya

Experiment with structured moderation decisions while preserving a human-review fallback for uncertain cases.

Use case

Use typed outputs to separate allow, review, and block paths instead of parsing a free-form moderation answer.

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?

Expected direction

  • moderation_action should lean toward review or block
  • threat should return an elevated P(true)
The Laya upstream benchmark reports weak held-out moderation performance. Treat this recipe as an evaluation pattern, not evidence that the current checkpoint is production-ready for moderation.

Copy the implementation

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();