Laya
Open-source System 1 decision engine - typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request. A self-hosted, Jev-compatible alternative.
What is this?
Laya answers questions about text. Not chat, not generation — structured decisions. You give it a piece of text (an email, a ticket, a JSON blob) and a set of typed questions, and it gives you back a choice, a score, or a yes/no probability. One forward pass, ~33ms on a T4, in 100+ languages. 27.5k stars, Apache-2.0.
It's also the open-source answer to Jev (TypeSafe's hosted decision API). Same wire protocol, same response shape, but you host it and it costs nothing per token.
What problem does it solve?
Sometimes you don't need a paragraph of text. You need a decision. Which department handles this ticket? How urgent is it? Is this customer about to churn?
You can ask an LLM that, but you're paying 200ms and a handful of tokens to generate text you then have to parse, validate, and hope the model didn't hallucinate an option that doesn't exist. And if you're doing it at scale — thousands of decisions per second — the cost and latency add up fast.
Laya skips generation entirely. It runs a ModernBERT encoder over your text once and reads the answer off the model's output heads. Nothing to parse, nothing to hallucinate, and every answer comes with a calibrated confidence score you can gate on.
How does it work?
your text + questions
│
▼
┌──────────────────────┐
│ Router │
│ detects the script │
│ and language │
└──────────┬───────────┘
│
┌─────┼──────────────┐
▼ ▼ ▼
laya laya- laya-typed-
(English) multilingual decisions
└─────┬──────────────┘
▼
one forward pass
▼
typed answers + confidence
The router looks at your input, figures out what language it's in, and picks the right checkpoint. English goes to the English model. Everything else goes to the multilingual one. If you've fine-tuned your own checkpoint, that gets used too.
The three question types map to real use cases:
- choice — pick one option from a list (route this ticket, classify this email)
- score — rate something on a scale (how urgent, how satisfied)
- noul — yes/no with a probability (will they churn, is this a refund)
Repository Structure
NandhaKishorM/laya/
├── laya/
│ ├── integrations/ # LangChain, LlamaIndex, CrewAI
│ └── mcp/ # MCP server
├── laya-ts/ # TypeScript / Node / browser version
├── research/ # training scripts, RLCD recipes
├── benchmarks/ # benchmark suites and results
├── docker/ # container images
├── nix/ # Nix packaging
├── scripts/ # CLI and utilities
├── tests/ # test suite
└── notebooks/ # examples
Key Features
- Typed decisions — choice, score, and noul in a single call. No parsing, no prompt engineering.
- 100+ languages — the router picks the right checkpoint automatically based on script detection.
- Fast — 33ms per question on a T4, 7.2ms batched. Independently measured at 6-7x faster than Jev.
- Calibrated — trained with reinforcement learning against strictly proper scoring rules (RLCD). The confidence number is a real probability, not a vibe.
- Jev-compatible —
laya.serveexposesPOST /v1/systemonewith the same payload shape Jev returns. Repoint your existing Jev client's baseUrl and nothing else changes. - Self-hosted — $0 per token. Your data never leaves your machine.
- Fine-tunable — train it on your own labeled decisions. A fine-tuned checkpoint beats Jev by 3.9 points on the typed-decisions benchmark.
- Integrations everywhere — MCP server, LangChain, LlamaIndex, CrewAI, ONNX Runtime, CLI, HTTP server, TypeScript SDK.
What You'll Learn
- How non-autoregressive decision models differ from autoregressive LLMs — and when to use which
- How to make structured, calibrated decisions over text without generation or parsing
- How multilingual routing works in practice
- How to self-host a drop-in Jev replacement
- How to fine-tune a decision engine on your own data
- How to gate agent actions on a calibrated confidence threshold
See it in action
pip install laya
from laya import Router
router = Router()
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["answers"]["churn_risk"]["noul"]) # probability of yes
print(result["routing"]["model"]) # english
The same call works in any of 100+ languages — pass text in Spanish, Chinese, Arabic, whatever, and the router handles it. Try the HF Space demo, the Colab notebook, or read the docs.
One honest caveat: Laya's edge over Jev is real but narrow. It wins on speed, cost, and most accuracy benchmarks. Jev still handles 50+ option questions better out of the box. If your use case is high-cardinality classification, check both.
Need a machine that stays on while yours sleeps?
Self-hosted AI only works if the machine never sleeps. A cheap VPS runs your models, agents and APIs 24/7 — setup takes minutes and costs less than lunch per month.
See Hostinger VPS dealsDisclosure: some links on this page are partner links. If you sign up through them, we may earn a commission at no extra cost to you.
A developer cloud VM in under a minute
The developer-favorite cloud for side projects: spin up a droplet, deploy your self-hosted stack, predictable pricing with no surprise bills.
Try DigitalOceanDisclosure: some links on this page are partner links. If you sign up through them, we may earn a commission at no extra cost to you.
Want to learn more about this project?
Have questions or want to understand this technology more deeply? Send me a message.
Related Projects
OpenDots: AI Agent Workspace
OpenDots is a MIT-licensed template for persistent AI agents that each get their own computer, workspace and permissions. 5,579 stars. Covers per-Dot sandboxing, human-in-the-loop approval gates, MCP and Composio tools, voice calls and Slack.
The Ultimate Guide to Ghidra
Ghidra is the NSA's free, Apache-2.0 open-source software reverse engineering framework. 89,844 stars. Learn how to set it up, analyse binaries, decompile code and compare it against IDA Pro and AI agent tooling.
Reverse Engineer Anything (REA)
Reverse Engineer Anything (REA) is a viral open-source MCP server with 195,625 stars that connects Claude Code, Codex and Cursor to Ghidra, Hopper and IDA Pro. Learn how to decompile software with AI, connect Ghidra to Claude Code via MCP, and analyze ELF, PE, Mach-O, APK, Electron and WASM targets.
Discussion
Loading comments...