Laya for Python
The reference implementation of Laya is the `laya` package on PyPI, maintained by Convai Innovations under Apache 2.0. It ships three checkpoints, a Router that picks one per request by script and language, a CLI, an HTTP server and an optional MCP server.
770 projects
laya-decision-lab
KGFCode
Demonstrates Laya text classification, scoring, and probability analysis with an API and MCP service
laya-demo-0921
2045max
Demonstrates Laya decisions for routing, triage, moderation, RAG filtering, and other tasks
laya-demo
nile1801
Demonstrates typed decisions, calibrated probabilities, and multilingual routing with Laya checkpoints
laya-triage
Mezahir2025
Provides a Laya-based message triage API for Make.com
laya-school-email-triage
nccyber
Demonstrates Laya for routing and assessing urgency in synthetic school emails
laya_api
Anuragggggggg
Serves Laya typed-decision endpoints for generic decisions and candidate routing
laya
henrybit
Demonstrates Laya typed decisions with English and multilingual checkpoints
laya-demo
wuyouxiaobai
Provides a landing page and deployable Gradio demo for Laya typed decisions
laya-decision-playground
hadeas
Provides a Gradio playground for Laya typed decisions with editable schemas and probability outputs
laya-demo
aired
Demonstrates Laya typed decisions for triage, guardrails, filtering, moderation, and routing
laya-prompt-guardrail
Parvathy-2025
Uses Laya to score prompts for jailbreak and injection risk before an LLM call
laya-demo
nickfury6023
Demonstrates Laya typed decisions for triage, guardrails, filtering, moderation, and routing
laya-multilingual-demo
DennisRadix58
Demonstrates multilingual Laya typed decisions for triage, guardrails, moderation, and exploration
viralpilot-laya
khushali678
Analyzes content and scores its potential virality through an AI API
laya-webgpu
ti3x-m
Runs Laya typed-decision checkpoints in the browser using WebGPU or WASM
laya-demo
dungdq1
Demonstrates Laya typed decisions for routing, moderation, guardrails, and retrieval filtering
laya-fp16-parity
xauberer93
Checks FP16 parity for the Laya model on a ZeroGPU lane
Laya-demo
robynsd
Provides an API demo for Laya typed decisions without text generation
laya-trader
antonellof
Uses Laya MLX to paper-trade crypto and stocks with a dashboard and backtesting tools
system-one-reexamined
CodeWithMoin
Benchmarks Laya and Jev against zero-shot NLI and SetFit classifiers
semantic-operators
jasonduncan
Provides Python, CLI, and MCP interfaces for typed judgments using Laya and Jev
laya
byrash
Provides download instructions for the English and multilingual Laya models
laya-shim
bunkerlab-net
Serves Laya or Laya-MLX behind TypeSafe's System One API route
jev-vs-laya
vizakan10
Compares Jev and Laya decision quality and speed by having both models play Wordle
Install
Python 3.10 or newer, per the core README:
python -m pip install laya
Optional extras: laya[serve] (HTTP server), laya[mcp] (MCP server), laya[langchain], laya[onnx] (ONNX Runtime) and laya[fast] (TileLang GPU fast path).
First decision
from laya import Router
router = Router() # downloads a checkpoint on first use
state = "Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan."
questions = {
"department": {"type": "choice", "instructions": "Which department should handle this?",
"criteria": {"billing": "invoices, payments, refunds",
"technical": "bugs, outages, system errors",
"other": "everything else"}},
"urgency": {"type": "score", "instructions": "How urgent is this?",
"criteria": ["not urgent", "soon", "blocking"]},
"churn_risk": {"type": "noul", "instructions": "Does the user threaten to cancel or leave?"},
}
result = router.predict(state, questions)
print(result["answers"]["department"]["choice"]) # billing
print(result["routing"]["model"]) # english
The package also installs a laya command, for example laya "My payment failed twice" --preset triage.
Checkpoints
| checkpoint | encoder | params | context |
|---|---|---|---|
laya |
ModernBERT-large | 421M | 512 |
laya-multilingual |
mmBERT-base | 322M | 1024 (up to 8,192) |
laya-typed-decisions |
ModernBERT-large | 421M | 1024 |
The README reports 32.8 ms for one question with laya-multilingual on a Tesla T4, and 193 to 464 ms per request on CPU with checkpoints preloaded.
Other Python projects
laya-mlx and laya-coreml for Apple Silicon, laya-openvino for Intel CPUs, edgejev for INT8 ONNX on CPU, and laya-mcp for agent tools.
Caveats
The README is direct about limits: the base checkpoints score near chance on its typed-decisions benchmark (0.362 and 0.352), and the 0.766 figure comes from the fine-tuned checkpoint. Temperatures should be refit on your own data before you trust the probabilities. The English checkpoint collapses on non-Latin scripts, which is why the Router exists.
More ways to use Laya