Laya — Laya is a fast, multilingual decision engine for typed questions over any text, in 33ms.
Analyzed by Sai Pavan Gopularam · AI · Decision Models · View on GitHub
- Stars: 8618
- Forks: 722
- Commits last 30 days: 54
- Health: Active (54 commits this month)
- Language: Python
- License: Apache-2.0
What It Is
Laya is a "System 1" decision engine, meaning it makes lightning-fast, non-autoregressive decisions. Unlike traditional large language models that generate text step-by-step, Laya directly outputs a decision or classification in a single forward pass. Think of it like a reflex action: it processes an input (text, email, JSON) and immediately gives a structured answer, such as a choice from a list, a score, or a yes/no probability.
This approach kills several problems: speed (33ms per decision), multilingual support (100+ languages), and the elimination of hallucinations since it doesn't generate text. It also provides statistically meaningful confidence scores, allowing businesses to automate high-confidence decisions and escalate low-confidence cases to humans, making it ideal for high-volume, real-time applications.
License Verdict
Apache 2.0 License — Build and Sell Freely — Commercial Use Approved • Permissive Open Source
The Apache 2.0 license is highly permissive. You can freely use, modify, distribute, and sell software built with Laya, even for commercial purposes. You must include the original copyright and license notice, and state any significant changes you make to the code.
How to Use It
Install Laya via pip, then use its Router to automatically detect language and dispatch requests to the optimal model. You can define custom questions for classification, scoring, or yes/no probabilities over any input state.
Prerequisites:
- Python 3.8+
Estimated setup time: 5 minutes.
pip install laya
python -c "import laya; from laya import Router; router = Router(preload=True); state = {'body': 'Hello'}; questions = {'intent': {'type': 'choice', 'instructions': 'What is the intent?', 'criteria': {'greeting': 'hello', 'farewell': 'bye'}}}; res = router.predict(state, questions); print(res)"
What I'd Build With This
Real-time Multilingual Support Triage API (micro-saas)
Build an API that takes support tickets or chat messages in any language and instantly classifies them by department, urgency, and sentiment using Laya's capabilities. Sell this API to small e-commerce businesses or SaaS companies struggling with manual ticket routing and multilingual customer bases. They pay per API call for instant, accurate triage, reducing response times.
Effort: 3 Days Build Time · Target: Small-to-Medium SaaS, E-commerce · Pricing: $99/mo for 10,000 calls
AI-Powered Content Moderation & Guardrails Platform (saas)
Develop a SaaS platform that leverages Laya's speed and predefined moderation/guardrail questions to automatically flag or classify user-generated content (comments, posts, reviews) across 100+ languages. Offer real-time protection against toxicity, spam, and prompt injections for online communities, gaming platforms, or social apps. Customers subscribe for enhanced brand safety and compliance.
Effort: 2 Weeks Build Time · Target: Online Communities, Gaming Platforms · Pricing: $499/mo for 1M content checks
Internal LLM Security & Routing Gateway (enterprise)
Offer an on-premise or private cloud solution that acts as a gateway for enterprise-wide LLM usage. This gateway uses Laya to perform ultra-fast prompt guardrailing (detecting PII leaks, jailbreaks) and intelligent routing of user queries to the most appropriate internal LLM or knowledge base, all before the main LLM inference. This provides a critical security and efficiency layer for large organizations adopting AI.
Effort: 1 Month Build Time · Target: Large Enterprises, Government Agencies · Pricing: $5,000+/mo for infrastructure licensing
Sai Pavan Gopularam's Take
Laya's speed and multilingual support for structured decisions are a game-changer, especially for real-time applications where every millisecond counts. Being non-autoregressive means no hallucinations, which is a huge win for trust. You could easily build a micro-SaaS for automated customer support routing, charging $99/month for 10,000 classifications.
Watch Out For
- High-Cardinality Choice Questions: Laya's default settings struggle with choice questions having more than 50 options due to token budget constraints. You'll need to manually increase `head_max_len` in the configuration or implement a hierarchical classification approach for optimal accuracy.
- Calibration Needed for Confidence Scores: Out-of-the-box, Laya's models are over-confident. While confidence scores are statistically meaningful after calibration, you'll need to refit temperature parameters on your specific held-out data to ensure their reliability for automated decision-making.
- Limited Zero-Shot Typed Decision Capability: The base Laya checkpoints perform near chance on zero-shot typed decisions. High accuracy (e.g., 0.766) is achieved with fine-tuned checkpoints for specific tasks. Laya is a fast base to specialize, not a general zero-shot decision engine.
I break down trending repos like Laya every week — join the newsletter.