Laya for Python

The reference implementation of Laya is the `laya` package on PyPI, maintained by Convai Innovations under Apache 2.0. It ships three checkpoints, a Router that picks one per request by script and language, a CLI, an HTTP server and an optional MCP server.

768 projects

laya-example

lim6112j

Demonstrates typed-question routing with Laya checkpoints and startup optimizations

0·GitHub repo

laya-dino

JakkNaj

A fine-tuned Laya model plays Chrome Dino using a Python backend and TypeScript frontend

0·GitHub repo

laya-serve

ouijan

Serves Laya decisions over HTTP with a typed TypeScript client

0·GitHub repo

laya-duum

Hadlock

Uses the Laya Core ML decision model to play the Duum game from semantic state

0·GitHub repo

laya-api

yrodrigez

A FastAPI service loads the Laya model and serves typed-decision predictions

0·GitHub repo

laya-demo

clonekim

Provides a local server and browser interface for classifying text with Laya

0·GitHub repo

laya-server

r2d-ai

Serves Laya's multilingual checkpoint through CUDA-backed REST and MCP interfaces

0·GitHub repo

laya-service

xiaobai1017

Exposes Laya through a FastAPI service with a Jev-compatible System One API

0·GitHub repo

oido-laya

Djancyp

Wraps the Laya decision model in a Dockerized HTTP API for typed predictions

0·GitHub repo

laya-memory

ganeshdipdumbare

A local Laya classifier selects relevant durable memories for coding agents across sessions

0·GitHub repo

agentify-laya

hongyaok

Serves local Laya classifications through an OpenAI-shaped HTTP API and usage dashboard

0·GitHub repo

laya-snapdragon

piffie

Runs Laya typed decisions on Snapdragon X NPUs through ONNX Runtime and Qualcomm QNN

0·GitHub repo

laya-adblock

Samuel-Ku

Uses a local MLX Laya model to identify and remove likely ads from web pages

0·GitHub repo

laya-agents

lesterppo

Integrates local Laya typed-decision tools into Hermes Agent and Muse for classification and routing

0·GitHub repo

laya-kit

FrancyJGLisboa

Provides a local Python interface for Laya typed judgements and confidence calibration

0·GitHub repo

laya-quiz

Aryamanironman

Uses Laya to adapt trivia categories and difficulty to each player's performance

0·GitHub repo

laya-tetris

kuchris

Runs Laya as a Tetris placement decision-maker with a heuristic safety guard

0·GitHub repo

laya-torch

Shivay00001

Ports the Laya typed-decision model to PyTorch for CPU and GPU inference

0·GitHub repo

laya-jv

TimTan1234

Packages a self-hosted Laya decision model as a Docker HTTP service for Luna

0·GitHub repo

laya-server

noahbclarkson

Runs Laya behind a local TypeSafe System One API for compatible clients

0·GitHub repo

Laya_TESTSUITE

sirwari

Provides Laya tests, demos, routing examples, and MLX setup guidance

0·GitHub repo

Laya_Demo

zhangfanxp

Uses the local Laya model to choose maze branches and trace a route to the exit

0·GitHub repo

laya-server

MrLYC

Provides an authenticated CPU-based HTTP service and decision console for Laya models

0·GitHub repo

Laya_Playground

jonas050210

Runs local Laya decision demos, games, and a raw playground through a browser interface

0·GitHub repo

Install

Python 3.10 or newer, per the core README:

python -m pip install laya

Optional extras: laya[serve] (HTTP server), laya[mcp] (MCP server), laya[langchain], laya[onnx] (ONNX Runtime) and laya[fast] (TileLang GPU fast path).

First decision

from laya import Router

router = Router()  # downloads a checkpoint on first use

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["routing"]["model"])                 # english

The package also installs a laya command, for example laya "My payment failed twice" --preset triage.

Checkpoints

checkpoint encoder params context
laya ModernBERT-large 421M 512
laya-multilingual mmBERT-base 322M 1024 (up to 8,192)
laya-typed-decisions ModernBERT-large 421M 1024

The README reports 32.8 ms for one question with laya-multilingual on a Tesla T4, and 193 to 464 ms per request on CPU with checkpoints preloaded.

Other Python projects

laya-mlx and laya-coreml for Apple Silicon, laya-openvino for Intel CPUs, edgejev for INT8 ONNX on CPU, and laya-mcp for agent tools.

Caveats

The README is direct about limits: the base checkpoints score near chance on its typed-decisions benchmark (0.362 and 0.352), and the 0.766 figure comes from the fine-tuned checkpoint. Temperatures should be refit on your own data before you trust the probabilities. The English checkpoint collapses on non-Latin scripts, which is why the Router exists.

More ways to use Laya