Skip to main content

laya-mnn

Run the Laya System 1 decision model locally on MNN — no PyTorch, no GPU, no API key.

Laya takes a state (email, ticket, JSON) plus typed questions and returns typed answers with calibrated probabilities in one forward pass. It never generates text, so there is nothing to parse and nothing to hallucinate. This package runs a converted Laya checkpoint on Alibaba's MNN runtime.

uvx laya-mnn decide \
  --state "Hi, we were billed twice for March. Please refund the duplicate or we will cancel our plan." \
  --questions '{"department":{"type":"choice","instructions":"Which department should handle this?","criteria":{"billing":"invoices, payments, refunds","technical":"bugs, outages","other":"everything else"}},
                "churn_risk":{"type":"noul","instructions":"Does the user threaten to cancel?"}}'
{
  "model": "laya-mnn",
  "answers": {
    "department": {
      "type": "choice", "choice": "billing",
      "probabilities": { "billing": 0.9631, "technical": 0.0165, "other": 0.0204 },
      "confidence": 0.8067, "action": { "act_probability": 0.9977 }
    },
    "churn_risk": { "type": "noul", "noul": 0.9476, "confidence": 0.9476, "action": { "act_probability": 0.9977 } }
  }
}

Weights download automatically on first use (about 850 MB for fp16).

Question types

type answer use for
choice one of the criteria keys, plus a probability per option routing, intent, classification
score expected value over ordered criteria levels (0-based) severity, urgency, sentiment strength
noul P(true) yes/no judgements

criteria is defined at request time — new schemas do not need retraining. Up to 64 options per question with the shipped checkpoints.

CLI

laya-mnn decide --state S --questions Q [--precision fp16|int8] [--threads N] [--quiet]
laya-mnn download [--precision ...]      # pre-fetch weights
laya-mnn info     [--precision ...]      # cache dir + manifest

--state accepts literal text, inline JSON, or @path. --questions accepts inline JSON or @path.

Python

from laya_mnn import LayaMNN, ensure_model

model = LayaMNN(ensure_model("fp16"), threads=4)
result = model.system_one(
    {"subject": "Duplicate charge", "body": "We were billed twice..."},
    {"department": {"type": "choice", "instructions": "Which department?", "criteria": ["billing", "technical", "other"]}},
)
print(result["answers"]["department"]["choice"], result["answers"]["department"]["probabilities"])

Checkpoints

precision size notes
fp16 846 MB weights stored in half precision; probability deltas vs. the original PyTorch model are below 1e-3
int8 581 MB weight-only 8-bit quantization; larger deltas, check it against your own eval

Both are conversions of convaiinnovations/laya (English, ModernBERT-large backbone, 421M parameters). The model was exported to ONNX (opset 17, eager attention, static 512-token sequence) and converted with the MNN converter 3.6.1.

Hosted on Hugging Face and ModelScope; modelscope is tried first, then Hugging Face (override with HF_ENDPOINT). Set LAYA_MNN_CACHE to change the cache directory (default ~/.cache/laya-mnn).

Notes and limits

  • CPU is the supported backend. The MNN Metal backend was measured to return all-zero logits for this graph in some builds of the 3.6.1 wheel; --backend metal is exposed but not recommended.
  • A 512-token forward pass costs roughly 1.3 s on an Apple Silicon CPU. Shorter states are cheaper — the graph is exported at a fixed 512 tokens, so the CLI pads and masks.
  • Max 64 options per question, 512 tokens of context, English only. The multilingual checkpoint (mmBERT-base) is not converted here.
  • Percentile-latency and calibration in the upstream model card are for the original PyTorch model; quantized results will differ slightly.

License and attribution

Apache-2.0. The model, its prompt format and the calibration scheme come from NandhaKishorM/laya by Convai Innovations (Apache-2.0); this package is an independent MNN port and is not affiliated with or endorsed by them. See NOTICE.

Release files for laya-mnn 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for laya-mnn 0.1.1
File Size Uploaded
laya_mnn-0.1.1.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for laya-mnn 0.1.1
File Interpreter ABI Platform
laya_mnn-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.2 kB

Release files / laya_mnn-0.1.1.tar.gz

Download URL laya_mnn-0.1.1.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e36465149ec9439cdad8fe03d14551c6917c2e0b0141916cc44f84b8b4d40f7a
BLAKE2b-256 checksum
How to use checksums
8f458d956997d8b6351072905d084e67492c8c34adf498926ff578b3d665cf43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / laya_mnn-0.1.1-py3-none-any.whl

Download URL laya_mnn-0.1.1-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ca0fc7658e0f1af26b3ef0e96ae58e4d112d54ba3cda513a3e6cf8b69044e56
BLAKE2b-256 checksum
How to use checksums
2bb2cc0cabe52d1b48dbfa9a82b9d98ebca854d2cfd83cf1261ca107e12fcde5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release 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