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, fp32 compute. The Metal backend and MNN's reduced-precision CPU path both return all-zero logits for this graph in MNN 3.6.1, which shows up as uniform probabilities instead of an error, so neither is reachable from this package.
  • 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.3

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.3
File Size Uploaded
laya_mnn-0.1.3.tar.gz 15.8 kB Details

Built distribution (wheel)

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

Total release size: 31.2 kB

Release files / laya_mnn-0.1.3.tar.gz

Download URL laya_mnn-0.1.3.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2077c7439f0a235776e565853a8f1ba87f53736cd420dfbb887e4346b8731028
BLAKE2b-256 checksum
How to use checksums
d92734405f116a3e5e91a93f712b3a971d823fb9abf35a31def70761347da873
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.3-py3-none-any.whl

Download URL laya_mnn-0.1.3-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca88272af089b62d312d3d611b4e4247cb1687ad070ba90dee6c6c6b7a8ad105
BLAKE2b-256 checksum
How to use checksums
e506d81e028f7ee016d0efeb110c91d9599c7d6c035c2f3b7f5a6a7a14b307ba
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

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

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