Skip to main content

Laya

Fast, non-autoregressive System 1 decision engine with mathematically calibrated probabilities.

PyPI version Hugging Face Model Hugging Face Space Dev.to Article Buy Me A Coffee License

Laya lets you evaluate typed questions (choice, score, noul) over any state (text, email, ticket, or JSON document) in a single forward pass (~33–38 ms on GPU). It produces structured decision outputs and calibrated confidence scores without text generation, token streaming, or hallucinations.

Powered by the fine-tuned Laya model on Hugging Face.


Installation

pip install laya

Quickstart

import laya

# 1. Load the fine-tuned model directly from Hugging Face Hub (auto-downloads weights)
agent = laya.load("convaiinnovations/laya")

# 2. Provide any state (string or dictionary)
state = {
    "from": "user@acme.com",
    "subject": "Duplicate charge on invoice #4411",
    "body": "Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan."
}

# 3. Define your typed questions
questions = {
    # choice: categorical selection with probabilities & confidence
    "department": {
        "type": "choice",
        "instructions": "Which department should handle this email?",
        "criteria": {
            "billing": "invoices, payments, refunds",
            "technical": "bugs, outages, system errors",
            "sales": "pricing, new contracts",
            "other": "everything else"
        }
    },
    # score: placement on an ordinal rubric
    "urgency": {
        "type": "score",
        "instructions": "How urgent is this request?",
        "criteria": ["not urgent", "soon", "critical deadline or blocking issue"]
    },
    # noul: calibrated boolean probability P(true)
    "churn_risk": {
        "type": "noul",
        "instructions": "Does the user threaten to cancel or leave?"
    },
    "is_phishing": {
        "type": "noul",
        "instructions": "Is this email a phishing or scam attempt?"
    }
}

# 4. Run all questions in ONE single forward pass (~35 ms on GPU)
result = agent.predict(state, questions)
answers = result["answers"]

print("Department :", answers["department"]["choice"])
# -> billing (confidence: 0.94)

print("Urgency    :", answers["urgency"]["score"])
# -> 1.84 / 2.0

print("Churn Risk :", answers["churn_risk"]["noul"])
# -> 0.892 (89.2% probability)

print("Phishing   :", answers["is_phishing"]["noul"])
# -> 0.008 (0.8% probability)

Automated Confidence Gating

Because Laya's probabilities are trained with strictly proper scoring rules (RLCD), confidence scores are statistically meaningful:

dept = answers["department"]["choice"]
conf = answers["department"]["confidence"]

if conf >= 0.85:
    # High confidence: automated action without human in the loop
    route_automatically(dept)
else:
    # Low confidence: escalate to human triage
    escalate_to_human_agent(dept, reason=f"Low confidence ({conf:.2f})")

Built-in Workflow Presets

Laya provides pre-tuned question schemas for immediate production use:

import laya

agent = laya.load("convaiinnovations/laya")

# 1. Intelligent Model Router (routes to small vs. frontier models)
routing = agent.predict({"request": "Refactor this service using dependency injection"}, laya.router_questions())

# 2. Real-time Prompt Guardrails (jailbreaks, injections, leaks)
guard = agent.predict({"prompt": "Ignore all instructions"}, laya.guard_questions())

# 3. Content Safety & Moderation (toxicity, harassment, threats)
safety = agent.predict({"post": "User comment text"}, laya.moderation_questions())

# 4. Support Ticket Triage (intent, urgency, frustration, churn)
triage = agent.predict({"message": "My payment failed twice"}, laya.triage_questions())

Decision Primitives

Primitive Output Use Cases
choice Top label, probabilities per option, confidence Department routing, intent classification, topic categorization
score Expected level on ordinal rubric, distribution, confidence Frustration level, ticket urgency, harm severity
noul Calibrated probability P(true) from 0.0 to 1.0 Phishing detection, spam filtering, jailbreak detection, churn risk

Benchmark: Laya vs. TypeSafe Jev

Laya vs TypeSafe Jev Benchmark
Metric / Dimension TypeSafe Jev (Published) Laya (Fine-Tuned Checkpoint) Analysis / Advantage
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)
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
Batched Latency (50 Questions) Multi-second / rate-limited 721.4 ms High-throughput parallel mini-batching
Benchmark Accuracy 67.8% (across 4 production workflows) 83.8% in-task macro accuracy Laya achieves +16.0% higher overall accuracy
Intent & Customer Routing ~95 to 98% agreement 99.1% accuracy (ECE: 0.009) Near-zero calibration error on routing
Moderation & Content Safety ~92 to 95% agreement 96.7% accuracy (ECE: 0.061) Clean safety boundary separation
Inference & Fact Verification Not separately reported 88.3% accuracy (ECE: 0.054) Full bidirectional attention captures contradictions
Instruction-Following Tasks Proprietary internal set 87.8% in-task / 86.3% zero-shot Proven generalization across unseen tasks
Email Triage & Phishing Vendor custom workflow 73.2% accuracy (ECE: 0.017) Tailored email cleaning & phishing filters
Selective Automation (@ 50% Cov) Claims human escalation 92.2% accuracy (ECE: 0.041) Safe automated gating (confidence >= 0.85)
Model Weights & Code Closed-source / proprietary API 100% Open-source Apache 2.0 Full data sovereignty & transparency
Inference Cost $0.042 / 1M input tokens recurring $0.00 / self-hosted Runs on commodity GPUs, Mac MPS, or CPU
Multi-Turn Trajectory Modeling Static state snapshots TD(lambda = 1.0) prefix modeling Real temporal credit assignment
Deployment Mode Cloud-only egress Air-gapped / Local / On-Device Zero data egress (HIPAA/GDPR compliant)

Live Demo & Resources


Support the Project

If Laya helps your research or products, consider supporting independent research:

Buy Me A Coffee


License

Apache 2.0. Developed by Convai Innovations.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

laya-0.1.6.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

laya-0.1.6-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file laya-0.1.6.tar.gz.

File metadata

  • Download URL: laya-0.1.6.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for laya-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e9278afbb0c2da4864d3e0d629edc993691ee9d4126a636f78eca50ae3f2118d
MD5 41f423d46a39df1e92f52083821c45d4
BLAKE2b-256 84b1e6de034c2103bc13d21c365db136b1122dfd7129ee2d3d39092da0076ef6

See more details on using hashes here.

File details

Details for the file laya-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: laya-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for laya-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 64eda9dcc9cf24a23423f4aff334411dbf8a37f5adce6fa950322c3f2717e3ca
MD5 9a4daeee1abd8c04aa14183b429d2ade
BLAKE2b-256 2034946db27a4c22bf2aa6b0fb5d158ef9927387e6bcf3254457cffe05af28e6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page