Text Classification
Transformers
Safetensors
Laya
system-one
calibrated-decisions
rlcd
classification
routing
scoring
guardrails
moderation
reinforcement-learning
commercial-use
Instructions to use convaiinnovations/laya with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use convaiinnovations/laya with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="convaiinnovations/laya")# pip install -U transformers accelerate # Load model directly from transformers import LayaTypedDecisions model = LayaTypedDecisions.from_pretrained("convaiinnovations/laya", device_map="auto") - Laya
How to use convaiinnovations/laya with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Inference
- Notebooks
- Google Colab
- Kaggle
docs: hub card for the three checkpoints, measured benchmarks, honest limits
Browse files
README.md
CHANGED
|
@@ -1,126 +1,166 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
library_name: transformers
|
| 4 |
-
|
|
|
|
| 5 |
---
|
| 6 |
|
| 7 |
# Laya
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
This
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|---|---|
|
| 15 |
-
| `choice` |
|
| 16 |
-
| `score` |
|
| 17 |
-
| `noul` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
## Architecture
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
## Training
|
| 26 |
-
Trained with **RLCD (Reinforcement Learning for Calibrated Decisions)**: the policy reports a probability distribution, exploration adds zero-mean Gaussian noise to the logits, and the reward is a strictly proper scoring rule (log score + spherical score, plus ranked probability score for ordinal score questions). The maximum expected reward is achieved only when the model outputs true, calibrated probabilities.
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
##
|
| 34 |
|
| 35 |
-
|
| 36 |
-
<img src="eval/benchmark_comparison.png" alt="Laya Benchmark Comparison" width="900" />
|
| 37 |
-
</div>
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|---|---|---|---|
|
| 41 |
-
| **P50 Latency (1 Question)** | ~400 ms avg (70 to 500 ms, 150 ms best) | **38.4 ms** (p95: 42.1 ms) | **Laya is ~10.4x faster on avg (4x faster than Jev best-case)** |
|
| 42 |
-
| **Batched Latency (10 Questions)** | ~1,500 ms (serial) / ~400 ms | **156.0 ms** (p95: 158.4 ms) | **Laya evaluates 10 questions in the time Jev answers 1** |
|
| 43 |
-
| **Batched Latency (50 Questions)** | Multi-second / rate-limited | **721.4 ms** | High-throughput parallel mini-batching |
|
| 44 |
-
| **Benchmark Accuracy** | **67.8%** (across 4 production workflows) | **83.8%** in-task macro accuracy | **Laya achieves +16.0% higher overall accuracy** |
|
| 45 |
-
| **Intent & Customer Routing** | ~95 to 98% agreement | **99.1% accuracy** (ECE: 0.009) | Near-zero calibration error on routing |
|
| 46 |
-
| **Moderation & Content Safety** | ~92 to 95% agreement | **96.7% accuracy** (ECE: 0.061) | Clean safety boundary separation |
|
| 47 |
-
| **Inference & Fact Verification** | Not separately reported | **88.3% accuracy** (ECE: 0.054) | Full bidirectional attention captures contradictions |
|
| 48 |
-
| **Instruction-Following Tasks** | Proprietary internal set | **87.8% in-task / 86.3% zero-shot** | Proven generalization across unseen tasks |
|
| 49 |
-
| **Email Triage & Phishing** | Vendor custom workflow | **73.2% accuracy** (ECE: 0.017) | Tailored email cleaning and phishing filters |
|
| 50 |
-
| **Selective Automation (@ 50% Cov)** | Claims human escalation | **92.2% accuracy** (ECE: 0.041) | Safe automated gating (confidence >= 0.85) |
|
| 51 |
-
| **Model Weights & Code** | Closed-source / proprietary API | **100% Open-source Apache 2.0** | Full data sovereignty and transparency |
|
| 52 |
-
| **Inference Cost** | $0.042 / 1M input tokens recurring | **$0.00 / self-hosted** | Runs on commodity GPUs, Mac MPS, or CPU |
|
| 53 |
-
| **Multi-Turn Trajectory Modeling** | Static state snapshots | **TD(lambda = 1.0) prefix modeling** | Real temporal credit assignment |
|
| 54 |
-
| **Deployment Mode** | Cloud-only egress | **Air-gapped / Local / On-Device** | Zero data egress (HIPAA/GDPR compliant) |
|
| 55 |
-
|
| 56 |
-
## Evaluation Results (This Checkpoint)
|
| 57 |
-
- **In-task test sets:** macro accuracy 0.838, macro ECE 0.060
|
| 58 |
-
- **Zero-shot (held-out task families):** macro accuracy 0.651, macro ECE 0.207
|
| 59 |
-
- **Key Task Families:**
|
| 60 |
-
- Intent and routing: accuracy **0.991**, ECE 0.009
|
| 61 |
-
- Moderation and safety: accuracy **0.967**, ECE 0.061
|
| 62 |
-
- Emotion and tone: accuracy **0.906**, ECE 0.018
|
| 63 |
-
- Email triage and phishing: accuracy **0.732**, ECE 0.017
|
| 64 |
-
- Inference and fact checking: accuracy **0.883**, ECE 0.054
|
| 65 |
-
|
| 66 |
-
Detailed results by task family, reliability diagrams, and risk-coverage curves are located in `eval/` in this repository.
|
| 67 |
-
|
| 68 |
-
## Quickstart (`pip install laya`)
|
| 69 |
|
| 70 |
-
```
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
"from": "customer@acme.com",
|
| 78 |
-
"subject": "Duplicate billing on March invoice #4411",
|
| 79 |
-
"body": "Hi team, we were billed twice for March. Please refund the duplicate before Friday or we will cancel our plan."
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
questions = {
|
| 83 |
-
"department": {
|
| 84 |
-
"type": "choice",
|
| 85 |
-
"instructions": "Which department should handle this email?",
|
| 86 |
-
"criteria": {
|
| 87 |
-
"billing": "invoices, payments, refunds",
|
| 88 |
-
"technical": "bugs, outages, integrations",
|
| 89 |
-
"sales": "pricing, contracts, demos",
|
| 90 |
-
"other": "everything else"
|
| 91 |
-
}
|
| 92 |
-
},
|
| 93 |
-
"urgency": {
|
| 94 |
-
"type": "score",
|
| 95 |
-
"instructions": "How urgent is this request?",
|
| 96 |
-
"criteria": ["not urgent", "soon", "critical deadline or blocking issue"]
|
| 97 |
-
},
|
| 98 |
-
"churn_risk": {
|
| 99 |
-
"type": "noul",
|
| 100 |
-
"instructions": "Does the user threaten to cancel or switch to a competitor?"
|
| 101 |
-
},
|
| 102 |
-
"is_phishing": {
|
| 103 |
-
"type": "noul",
|
| 104 |
-
"instructions": "Is this email a phishing or scam attempt?"
|
| 105 |
-
}
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
result = agent.predict(state, questions)
|
| 109 |
-
answers = result["answers"]
|
| 110 |
-
|
| 111 |
-
print("Department :", answers["department"]["choice"], f"(confidence: {answers['department']['confidence']:.2f})")
|
| 112 |
-
print("Urgency :", f"{answers['urgency']['score']:.2f} / 2.0")
|
| 113 |
-
print("Churn Risk :", f"{answers['churn_risk']['noul']:.1%}")
|
| 114 |
-
print("Phishing :", f"{answers['is_phishing']['noul']:.1%}")
|
| 115 |
-
```
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
library_name: transformers
|
| 4 |
+
pipeline_tag: text-classification
|
| 5 |
+
tags: [laya, system-one, calibrated-decisions, rlcd, classification, routing, scoring, guardrails, moderation, reinforcement-learning, commercial-use]
|
| 6 |
---
|
| 7 |
|
| 8 |
# Laya
|
| 9 |
|
| 10 |
+
Open-source, non-autoregressive **System 1 decision model**. Give it a **state** (text, email,
|
| 11 |
+
ticket, or JSON) and **typed questions**; it returns typed answers with calibrated probabilities
|
| 12 |
+
in a single forward pass. It never generates text, so there is nothing to parse and nothing to
|
| 13 |
+
hallucinate.
|
| 14 |
|
| 15 |
+
**This repo holds the English checkpoint** and serves as the hub for the family.
|
| 16 |
|
| 17 |
+
| checkpoint | encoder | params | context | use it for |
|
| 18 |
+
|---|---|---|---|---|
|
| 19 |
+
| **`convaiinnovations/laya`** (this repo) | ModernBERT-large | 421M | 512 | English |
|
| 20 |
+
| [`convaiinnovations/laya-multilingual`](https://huggingface.co/convaiinnovations/laya-multilingual) | mmBERT-base | 322M | 1024 | 100+ languages, ~2x faster |
|
| 21 |
+
| [`convaiinnovations/laya-typed-decisions`](https://huggingface.co/convaiinnovations/laya-typed-decisions) | ModernBERT-large | 421M | 1024 | the typed-decisions workflows |
|
| 22 |
+
|
| 23 |
+
| question type | returns |
|
| 24 |
|---|---|
|
| 25 |
+
| `choice` | selected option, probability per option, confidence |
|
| 26 |
+
| `score` | expected level on your ordinal rubric, distribution, confidence |
|
| 27 |
+
| `noul` | calibrated probability P(true) |
|
| 28 |
+
|
| 29 |
+
## Quickstart
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
pip install laya
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
import laya
|
| 37 |
+
|
| 38 |
+
agent = laya.load("convaiinnovations/laya")
|
| 39 |
+
result = agent.predict(
|
| 40 |
+
{"subject": "Duplicate charge on invoice 4411",
|
| 41 |
+
"body": "We were billed twice for March. Please refund the duplicate."},
|
| 42 |
+
{"department": {"type": "choice", "instructions": "Which team should handle this?",
|
| 43 |
+
"criteria": {"billing": "invoices, payments, refunds",
|
| 44 |
+
"technical": "bugs and outages", "sales": "pricing"}},
|
| 45 |
+
"urgency": {"type": "score", "instructions": "How urgent is this?",
|
| 46 |
+
"criteria": ["not urgent", "soon", "blocking"]},
|
| 47 |
+
"churn_risk": {"type": "noul", "instructions": "Does the user threaten to cancel?"}},
|
| 48 |
+
)
|
| 49 |
+
print(result["answers"]["department"]["choice"])
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
### Routing between the three checkpoints
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from laya import Router
|
| 56 |
+
|
| 57 |
+
router = Router() # lazy-loads only what a request needs
|
| 58 |
+
router.predict({"body": "I was charged twice"}, questions) # -> laya
|
| 59 |
+
router.predict({"body": "मुझसे दो बार शुल्क लिया गया"}, questions) # -> laya-multilingual
|
| 60 |
+
router.predict(state, questions, model="typed-decisions") # explicit
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
`Router` keeps one checkpoint resident by default (`max_loaded`); raise it for mixed-language
|
| 64 |
+
traffic so it does not reload on every language switch.
|
| 65 |
+
|
| 66 |
+
> **If `laya.load()` hangs:** `transformers` probes for TensorFlow at import, and when TF is
|
| 67 |
+
> installed its abseil runtime can deadlock model construction. Run with `USE_TF=0`.
|
| 68 |
|
| 69 |
## Architecture
|
| 70 |
+
|
| 71 |
+
- **Backbone** ModernBERT-large (395M, bidirectional, fully fine-tuned) + a decision head
|
| 72 |
+
trained from scratch: 2 transformer layers, an option-marker scorer, and an act/escalate head.
|
| 73 |
+
421M total.
|
| 74 |
+
- **Option markers** every option is scored at its own `[MASK]` token, then softmaxed over that
|
| 75 |
+
question's options. The answer space is defined at request time, so new schemas need no
|
| 76 |
+
retraining.
|
| 77 |
+
- **Budget** 512 tokens per question (question + options + state).
|
| 78 |
+
- **Batching** every question in a call is answered in one forward pass.
|
| 79 |
|
| 80 |
## Training
|
|
|
|
| 81 |
|
| 82 |
+
**RLCD (Reinforcement Learning for Calibrated Decisions).** The policy reports a distribution;
|
| 83 |
+
exploration adds zero-mean Gaussian noise to the logits; the reward is a strictly proper scoring
|
| 84 |
+
rule (log + spherical, plus ranked probability score for ordinal questions). Expected reward is
|
| 85 |
+
maximised only by reporting honest probabilities. Updates are REINFORCE with a group-mean
|
| 86 |
+
baseline (GRPO-style). Multi-turn conversations use TD(λ=1.0) over prefix slices.
|
| 87 |
|
| 88 |
+
7,313 updates, 1 epoch, ~1.96 h. Fitted temperatures `[1.637, 1.251, 1.983]` with
|
| 89 |
+
per-option-count scaling.
|
| 90 |
|
| 91 |
+
## Benchmarks
|
| 92 |
|
| 93 |
+
Measured on a Tesla T4; every checkpoint answered byte-identical questions in the same run.
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
### Speed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
| questions/call | `laya` | `laya-multilingual` |
|
| 98 |
+
|---|---|---|
|
| 99 |
+
| 1 | 39.5 ms | **32.8 ms** |
|
| 100 |
+
| 10 | 158.6 ms (15.9 ms/q) | **72.3 ms (7.2 ms/q)** |
|
| 101 |
+
| 50 | 771 ms | **337 ms (6.8 ms/q)** |
|
| 102 |
|
| 103 |
+
103–332 questions/sec batched. TypeSafe Jev has been independently measured at 236–276 ms p50
|
| 104 |
+
([AbdelStark](https://github.com/AbdelStark/jev-benchmarks),
|
| 105 |
+
[nibzard](https://github.com/nibzard/decision-model-benchmark)), so Laya answers a single
|
| 106 |
+
question roughly **6–7× faster**.
|
| 107 |
|
| 108 |
+
### Against Jev
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
Jev figures are **published by third parties, not measured here** — no TypeSafe API access.
|
| 111 |
+
Sample sizes and prompts differ; treat as indicative, not a controlled head-to-head.
|
| 112 |
|
| 113 |
+
| dataset | Jev | Laya |
|
| 114 |
+
|---|---|---|
|
| 115 |
+
| AG News (4 labels) | 0.910 | **0.947** |
|
| 116 |
+
| DAIR Emotion (6) | 0.480 · Brier 0.846 · NLL 5.588 | **0.573** |
|
| 117 |
+
| typed-decisions (2,000 decisions) | 0.727 | **0.766** (fine-tuned checkpoint) |
|
| 118 |
+
| ECE | 0.246 | **0.081** (after temperature fitting) |
|
| 119 |
|
| 120 |
+
On DAIR Emotion, Jev assigned zero probability to the true label on 16% of examples.
|
| 121 |
+
|
| 122 |
+
### English tasks
|
| 123 |
+
|
| 124 |
+
| task | `laya` | `laya-multilingual` | |
|
| 125 |
+
|---|---|---|---|
|
| 126 |
+
| AG News | **0.947** | 0.937 | in training mix |
|
| 127 |
+
| BoolQ | **0.830** | 0.787 | in training mix |
|
| 128 |
+
| DAIR Emotion | **0.573** | 0.513 | held out |
|
| 129 |
+
| prompt-injections | **0.698** | 0.578 | held out, n=116 |
|
| 130 |
+
| SST-5 (ordinal) | 0.372 | 0.282 | held out |
|
| 131 |
+
|
| 132 |
+
### Languages — use `laya-multilingual` outside English
|
| 133 |
+
|
| 134 |
+
Across 51 languages on MASSIVE intent (20 options, random = 0.050), this checkpoint
|
| 135 |
+
macro-averages **0.227** with macro ECE **0.733**, clearing 3× random on only 23 of 51.
|
| 136 |
+
Khmer scores **0.000 accuracy at 0.952 confidence**.
|
| 137 |
+
|
| 138 |
+
| | `laya` | `laya-multilingual` |
|
| 139 |
+
|---|---|---|
|
| 140 |
+
| MASSIVE intent, English | **0.783** | 0.657 |
|
| 141 |
+
| MASSIVE intent, 13 others | 0.306 | **0.451** |
|
| 142 |
+
| XNLI, English | **0.860** | 0.843 |
|
| 143 |
+
| XNLI, 14 others | 0.521 | **0.731** |
|
| 144 |
+
|
| 145 |
+
The confidence score gives no warning when the input is unreadable, so the choice has to be made
|
| 146 |
+
before the forward pass — that is what `Router` is for.
|
| 147 |
+
|
| 148 |
+
## Limits
|
| 149 |
+
|
| 150 |
+
- **Near chance on typed-decisions zero-shot** — 0.362 here and 0.352 for multilingual, against a
|
| 151 |
+
0.318 random and 0.461 majority-class baseline. The 0.766 belongs to the checkpoint fine-tuned
|
| 152 |
+
on that benchmark's own training split. Laya is a fast base to specialise, not a zero-shot
|
| 153 |
+
decision engine.
|
| 154 |
+
- Ordinal `score` questions are the weakest primitive (SST-5 0.372).
|
| 155 |
+
- Ships over-confident: refitting one temperature per (question type, option count) moves mean
|
| 156 |
+
ECE **0.466 → 0.081**. Do this on your own data before trusting the probabilities.
|
| 157 |
+
- English only. Use `laya-multilingual` for anything else.
|
| 158 |
+
|
| 159 |
+
## Links
|
| 160 |
+
|
| 161 |
+
- **GitHub** https://github.com/NandhaKishorM/laya
|
| 162 |
+
- **PyPI** https://pypi.org/project/laya/
|
| 163 |
+
- **Demo** https://huggingface.co/spaces/convaiinnovations/laya-demo
|
| 164 |
+
- **Write-up** [dev.to](https://dev.to/nandakishor_m_6cc0adfde9f/i-built-non-autoregressive-decision-models-a-year-ago-then-a-frontier-lab-called-it-a-18me)
|
| 165 |
+
|
| 166 |
+
Apache 2.0 · Convai Innovations
|