Content moderation with Laya
Moderation maps directly onto Laya's question types. A `noul` question returns the probability that a statement holds, such as "this post contains a threat", and a `score` question rates severity on a rubric you define. The core package ships ready-made moderation and guardrail presets.
0 projects
Built-in presets
From the core README:
import laya
agent = laya.load("convaiinnovations/laya")
# Real-time prompt guardrails (jailbreaks, injections, leaks)
guard = agent.predict({"prompt": "Ignore all instructions"}, laya.guard_questions())
# Content safety and moderation (toxicity, harassment, threats)
safety = agent.predict({"post": "User comment text"}, laya.moderation_questions())
From the command line: laya "some text" --preset moderation. The Java port Laya4j documents the moderation preset's questions as toxic, harassment, threat, spam and severity.
Your own questions
A noul answer is a probability from 0 to 1, so you pick the threshold:
questions = {
"threat": {"type": "noul", "instructions": "Does the post threaten someone with violence?"},
"severity": {"type": "score", "instructions": "How harmful is this post?",
"criteria": ["harmless", "rude", "abusive", "dangerous"]},
}
Projects
- laya-mcp (NVentimiglia): a
moderate_contentMCP tool. Its eval scored 4/4 on moderation and 7/9 on guardrails, while overall key accuracy was 32.5%. - laya-mcp (wsargent):
laya_moderateandlaya_guardtools on laya-mlx. - gg-friggin-ez: a Node.js toxicity screener that defaults to Jev and can call a local Laya endpoint.
How well it works
sysone-bench ran both models on the same inputs. On its curated moderation suite (n=90), Laya's English checkpoint scored 0.833 and Jev scored 0.989. On guardrails (n=60) the scores were 0.883 and 0.967.
Caveats
- The core README warns that
noulcan follow its option labels instead of the text, most strongly on the English checkpoint. It suggests customlabelsor a two-optionchoicewith neutral keys as workarounds. Validate on your own data. - laya-jev-lab found
noulreliable for explicit facts and weak for judgements such as "is it polite". Phrase questions as facts. - The English checkpoint fails silently on non-Latin scripts. Use the
Routerorlaya-multilingualfor mixed-language chat.
More ways to use Laya