SuperAPI AI Directory

Laya - Open-source non-autoregressive AI decision model, an open-source alternative to Jev

Author: AI小集 · Original source: AI工具集

What is Laya

Laya is an open-source non-autoregressive AI decision model. The model does not perform text generation. Based on the ModernBERT/mmBERT bidirectional encoder, it performs only a single forward pass on a piece of text plus typed questions, outputting structured results and calibrated probabilities in about 33ms. The model has built-in language routing supporting 100+ languages. Compared with closed-source modelsJev, Laya has advantages in accuracy (76.6% vs 72.7%), multilingual support (100+ languages), and cost (free for local deployment).

Laya

Laya's main features

  • Single forward-pass decision: Input a state plus a set of typed questions, and a single forward pass directly returns structured results without text generation, in about 33ms.
  • Three decision primitives: choice selects one from the candidates and gives the probability of each; score rates on an ordered scale and gives a distribution; noul answers yes/no questions and returns a 0–1 probability of being true.
  • Automatic language routing: Router detects the input script and language within <0.5ms and automatically dispatches to the English or multilingual checkpoint, avoiding choosing the wrong model and thereby "confidently answering incorrectly."
  • Confidence gating: Probabilities are statistically meaningful after RLCD training, and high-confidence decisions can be automatically approved while low-confidence ones are escalated to humans based on thresholds.
  • Built-in workflow presets: Provides preset question templates such as model routing, prompt injection protection, content safety moderation, and ticket triage, ready to use out of the box.
  • Local fine-tuning: Comes with a Kaggle notebook that supports the complete fine-tuning process of data generation, RLCD training, temperature fitting, and evaluation using your own data.

Laya's technical principles

  • Bidirectional non-autoregressive architecture: Based on the ModernBERT-large (421M) or mmBERT-base (322M) bidirectional encoder, input tokens can simultaneously see the context before and after; during inference it does not generate text token by token, but instead assigns an independent [MASK] position to each candidate option and outputs the logits for all options in a single forward pass, which are normalized into a probability distribution via Softmax—this is the source of the 33ms-level latency.
  • RLCD reinforcement learning training: Using strictly proper scoring rules such as logarithmic scoring, spherical scoring, and ranked probability scoring as rewards, the model can only obtain a high score when it outputs true posterior probabilities, and its confidence naturally decreases when it is uncertain, avoiding the "blind confidence" problem of traditional large models.
  • Language routing mechanism: Before forward, Router uses pure Python to detect the Unicode character set and language, and selects the checkpoint accordingly; because the English checkpoint will give answers with 0 accuracy at 0.95 confidence on non-Latin scripts, and the confidence itself cannot provide an early warning, the routing decision must be completed before inference.
  • Probability calibration: Factory checkpoints are overconfident, so temperature must be fitted on your own data by (question type, number of options); after fitting, the average ECE can drop from 0.466 to 0.081, at which point the probabilities can be directly used for automatic approval decisions.
Digging GitHub

Follow WeChat and reply "open source" to join theAI open-source project exchange group

How to use Laya

  • Install:pip install laya, PyPI package, updated from 0.1.0 to 0.3.4 within two days, note that the interface is still changing.
  • Load the model:Router(preload=True) preloads three checkpoints to avoid rebuilding the model every time the language is switched during cold start.
  • Preparation state: Assemble the text to be analyzed into a dict, such as {"from": ..., "subject": ..., "body": ...}, supporting any language or JSON structure.
  • Define questions: Write a set of typed questions in JSON, specifying type (choice / score / noul), instructions, and criteria (options or scale).
  • Run prediction: Call router.predict(state, questions), a single forward pass returns all answers; English goes through laya, Hindi etc. automatically go through multilingual.
  • Read results: From res["answers"] get the choice label, score value, or noul probability,res["routing"] will explain why this checkpoint was selected.
  • Confidence gating: For confidence set a threshold (e.g. 0.85), high confidence handled automatically, low confidence escalated to humans—but only after temperature fitting has been done on your own data.

Laya's core advantages

  • Ultra-fast inference: A single forward pass takes about 33ms (T4), with batching as low as 7.2ms/question, about 7.8x faster than the closed-source TypeSafe Jev.
  • Zero hallucination risk: It does not generate text, only outputs structured decisions, with no parsing burden and no issue of fabricating content.
  • Calibratable probabilities: Trained with RLCD strict true scoring rules, confidence is statistically meaningful and can directly drive automatic approval/manual review processes.
  • Leading calibration accuracy: After temperature fitting, ECE is only 0.081, better than Jev's 0.246; typed-decisions accuracy of 0.766 also exceeds Jev's 0.727.
  • Multilingual routing: The built-in Router identifies 100+ languages at sub-millisecond speed and automatically selects a checkpoint, avoiding English models "confidently answering incorrectly" on non-Latin scripts.
  • Fully open source, zero cost: Apache-2.0 license, open weights, self-hostable; compared with Jev's $0.042/million token API cost, long-term usage cost is zero.
  • Typed output: The three primitives choice / score / noul cover the vast majority of structured decision scenarios: classification, scoring, and yes/no judgment.

Laya's project address

  • GitHub repository:https://github.com/NandhaKishorM/laya
  • HuggingFace model library:https://huggingface.co/convaiinnovations/laya

Laya's comparison with similar competitors

Dimension Laya (open source) TypeSafe Jev
License/weights Apache-2.0, weights fully open Closed source, API calls only
Latency (single question) 32.8 ms (measured on T4) 236–276 ms p50 (third-party measured)
typed-decisions accuracy 0.766 (fine-tuned version) 0.727
ECE calibration error 0.081 (after temperature fitting) 0.246
Banking77 high-cardinality classification 0.425 (77 options, weak) 0.870 (72 options, strong)
Language coverage 100+ languages, Router automatic distribution No public multilingual benchmark
Cost Self-hosted $0 $0.042 / 1M tokens
Data privacy Can run fully locally, data does not leave the premises Needs to be uploaded to a third-party API
Soft distribution matching (soft acc) 0.471 0.580 (better fits the teacher distribution)
Out-of-the-box usability The base model's zero-shot performance is close to random; fine-tuning is required Commercial API, usable by default

Laya's application scenarios

  • Automatic customer service ticket triage: Determine department ownership (billing/technical/sales), urgency, user frustration, and churn risk; automatically dispatch tickets with high confidence and escalate to a human with low confidence.
  • Content safety and moderation: Detect toxic, harassing, and threatening content; the noul primitive outputs violation probabilities, making it suitable for real-time moderation on community and UGC platforms.
  • Prompt injection protection (Guardrails): Detect jailbreaks, injections, key leaks, and other attacks at the entry point of Agent systems; 33ms-level latency allows it to be embedded in every request链路.
  • Intelligent model routing: In a hybrid large-model architecture, determine whether a request should go to a small model or a frontier model, completing scheduling decisions at extremely low cost and saving inference expenses.