# AI use cases for Laya (receptron/laya)

Repo: [receptron/laya](https://github.com/receptron/laya) | Use cases: 4 | Page: https://dedupedai.com/use-cases/receptron-laya/

Laya is an open-source System 1 decision model that a Node.js or TypeScript program can run locally through ONNX Runtime to answer typed questions about a state with calibrated probabilities, without generating text.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Route support tickets to teams with probabilities: https://dedupedai.com/use-cases/receptron-laya/route-support-tickets-with-probabilities/
- Auto-act on confident answers and queue the rest: https://dedupedai.com/use-cases/receptron-laya/escalate-low-confidence-decisions-to-humans/
- Bake Laya weights into a container image at build time: https://dedupedai.com/use-cases/receptron-laya/bake-laya-weights-into-a-container-image/
- Export a fresh ONNX bundle from a newer Laya checkpoint: https://dedupedai.com/use-cases/receptron-laya/rebuild-the-onnx-bundle-from-a-newer-checkpoint/

## How to route support tickets to teams with probabilities with Laya

Repo: [receptron/laya](https://github.com/receptron/laya) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Send each ticket to a team, an urgency level and a churn-risk flag in one model call.

**Who it is for:** A support operations engineer whose help desk receives mixed tickets and needs automatic routing to billing, support or sales.

**The problem:** Manual triage is slow, and rule-based routing misses tickets that mention several topics at once.

**The outcome:** Each ticket gets a department choice with a probability per team, an expected urgency score, and a calibrated P(true) for churn risk, all from a single systemOne call.

### Steps

1. Run `npm install @receptron/laya` in your Node.js project.
2. Run `node -e 'import("@receptron/laya").then((m) => m.ensureBundle())'` to fetch the weights before the first ticket arrives.
3. Call `Laya.load()`, then pass the ticket subject and body as the state with your department, urgency and churn_risk questions to `systemOne`.
4. Read `result.answers.department.choice`, `result.answers.urgency.score` and `result.answers.churn_risk.noul` and write them to your ticket record.
5. Call `laya.close()` when the worker shuts down.

### Prompt to paste into your agent

```text
In the receptron/laya repo, write a Node.js script that loads Laya with Laya.load() and calls systemOne on the ticket in <ticket-json-file>, asking which team should handle it with choice options billing, support and sales, plus an urgency score and a churn_risk noul question. Expected output: a printed JSON object with the chosen team, its probability, the urgency score and the churn P(true). Verify that the department probabilities sum to about 1.
```

### Caveat

Laya returns a probability for every option, but the README says the state is truncated to 512 tokens for the English checkpoint, so very long ticket threads lose their oldest text unless the state is a list.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/receptron-laya/route-support-tickets-with-probabilities/

## How to auto-act on confident answers and queue the rest with Laya

Repo: [receptron/laya](https://github.com/receptron/laya) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Gate automated actions on answer_confidence so uncertain items go to a human reviewer.

**Who it is for:** A developer building an automated workflow that should only act when the model is sure, such as an agent that files or closes records.

**The problem:** A single label from a classifier hides how uncertain it was, so low-confidence decisions get acted on as if they were certain.

**The outcome:** Items above a chosen confidence threshold are applied automatically, and everything below it is written to a review queue with the full probability breakdown.

### Steps

1. Run `npm install @receptron/laya` and load the model with `Laya.load()`.
2. Call `systemOne` with your state and a `choice` question whose criteria are your allowed actions.
3. Compare `result.answers.<question>.answer_confidence` against your threshold, using the same threshold for every question type.
4. Apply the action when the value is at or above the threshold, and push the item and its `probabilities` object to a review queue otherwise.
5. Log `result.usage.input_tokens` per call to track cost.

### Prompt to paste into your agent

```text
In the receptron/laya repo, add a function that calls Laya systemOne on <record-file> with a choice question over the actions in <action-list>, and applies the top action only when answer_confidence is at least 0.9, otherwise returning it for review. Expected output: an object with the action, its answer_confidence and a review flag. Verify that a record with a near-even probability split is marked for review.
```

### Caveat

The README warns that confidence on choice and score answers is a different quantity, so gate on answer_confidence only and do not reuse the confidence field.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/receptron-laya/escalate-low-confidence-decisions-to-humans/

## How to bake Laya weights into a container image at build time with Laya

Repo: [receptron/laya](https://github.com/receptron/laya) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Fetch the 1.7 GB ONNX bundle during the image build so containers start without a download.

**Who it is for:** A DevOps engineer deploying a Node.js service that uses Laya and needs fast, predictable container start-up.

**The problem:** The first Laya.load() downloads about 1.7 GB, which can stall or fail a container health check at start-up.

**The outcome:** A build step caches the weights, so a running container loads the model from the local cache and only sends a cheap freshness check.

### Steps

1. Add `npm install @receptron/laya` to the image build.
2. Add `node -e 'import("@receptron/laya").then((m) => m.ensureBundle())'` as a build step so the weights are cached.
3. Set `LAYA_CACHE` to a path that the runtime user can read if you want the cache in a fixed location.
4. Pass `revision` with a commit hash to `Laya.load()` to pin the model version for reproducible results.
5. Start the service and time the first `Laya.load()` call to confirm it reads from the cache.

### Prompt to paste into your agent

```text
In the receptron/laya repo, write a Dockerfile for a Node.js 20 service at <service-dir> that installs @receptron/laya and runs ensureBundle() during the build. Expected output: an image where the first Laya.load() in the container finishes without a network download. Verify by running the container with networking disabled and confirming that the model loads.
```

### Caveat

The README says the weights are about 1.7 GB in fp32 and the model needs roughly 2 GB of RAM, so size the container memory limit above that before deploying.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/receptron-laya/bake-laya-weights-into-a-container-image/

## How to export a fresh ONNX bundle from a newer Laya checkpoint with Laya

Repo: [receptron/laya](https://github.com/receptron/laya) | Difficulty: Advanced | Time: 1 hour 30 minutes | Basis: From the README

Rebuild the ONNX bundle from the Hugging Face checkpoint and check it against PyTorch.

**Who it is for:** A machine learning engineer who needs a bundle from a newer checkpoint or a variant that is not published under receptron/laya-onnx.

**The problem:** The published bundle may lag the upstream checkpoint, and a custom variant cannot be used without an export.

**The outcome:** A local ./onnx folder with the five bundle files, verified to match PyTorch to within about 1e-5 in max logit difference, that Laya.load() can read.

### Steps

1. Run `cd export` and then `uv venv -p 3.12 .venv` in the cloned repo.
2. Run `uv pip install -p .venv/bin/python torch transformers safetensors onnx onnxscript onnxruntime huggingface_hub` to install the export dependencies.
3. Run the `snapshot_download('convaiinnovations/laya', local_dir='model', ...)` command from the README to fetch the checkpoint. (inferred, check the README)
4. Run `.venv/bin/python export_onnx.py model ../onnx` and check that the printed max logit difference is about 1e-5.
5. Call `Laya.load({ modelDir: "./onnx" })` and run `LAYA_MODEL_DIR=./onnx yarn example`.

### Prompt to paste into your agent

```text
In the receptron/laya repo, follow the export section of the README to build an ONNX bundle from convaiinnovations/laya into ../onnx. Expected output: the export script prints a max logit difference against PyTorch that is about 1e-5 and the five bundle files exist. Verify by running `LAYA_MODEL_DIR=./onnx yarn example` and confirming it completes.
```

### Caveat

The README notes that the published bundle uses a different temperature for choice questions with 11 or more options than the upstream checkpoint, so a rebuilt bundle will not match published confidences unless you keep the same calibration values.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/receptron-laya/rebuild-the-onnx-bundle-from-a-newer-checkpoint/
