A free guide by Marino Merlini (@marinoautomates)
Founder of Meet Blaine
The Laya Local Classifier Setup & Anthropic Claude Fine-Tuning Guide
Install Laya locally for 30ms text classification and use Anthropic Claude to generate synthetic training data that boosts accuracy from 36% to 76%.
Running a business? We set this up for you. Book a 30-min call
Part 1: Laya vs. TypeSafe Jev: When to Run Local Classification
Laya is an open-source classification model that runs directly on your machine in 30ms, making it 8.3x faster than the 250ms cloud roundtrip of TypeSafe Jev, according to the Laya GitHub page and TypeSafe Jev documentation. Neither model writes code or long essays; both are built strictly to sort incoming text into fixed categories.
Understand the speed difference
TypeSafe Jev is a closed cloud API priced at $0.042 per 1 million input tokens with free output tokens, and its 250ms average latency includes HTTP network travel across the public internet, per TypeSafe Jev documentation. Laya runs a single forward pass on your own hardware in 30ms to 33ms because zero data leaves your computer, per the Laya GitHub page.
Pick the right checkpoint size
The Laya Hugging Face Model comes in two lightweight versions: a 421M parameter English checkpoint and a 322M parameter multilingual checkpoint, per the Laya Hugging Face Model page. Both fit easily inside standard laptop memory.
Account for the base accuracy gap
Out of the box, the untuned Laya base model scores 36% accuracy on complex multi-intent routing benchmarks, per the Laya Hugging Face Model page. You must fine-tune it on your specific categories to reach the 76% fine-tuned benchmark.
Related guide: The AI Token & Cost Cheat Sheet
Part 2: Clone and Install Laya Locally
You can install Laya from the official NandhaKishorM/laya repository on GitHub and download the weights from the Laya Hugging Face Model page in under five minutes. The project has over 35,600 GitHub stars on its GitHub page and supports Apple Silicon (MPS) as well as NVIDIA GPUs.
Clone the repository
Open your terminal and clone https://github.com/NandhaKishorM/laya to your local machine. Move into the new laya folder before installing packages.
Create an isolated Python environment
Run python3 -m venv .venv and activate it with source .venv/bin/activate on macOS or Linux. Installing requirements inside a virtual environment prevents conflicts with other local AI tools.
Pull the model weights
Install the repository dependencies from requirements.txt, then point your configuration to convaiinnovations/laya from the Laya Hugging Face Model repository. Choose the 421M parameter English model for English-only workflows or the 322M parameter multilingual model if your customers write in multiple languages, per the Laya Hugging Face Model page.
git clone https://github.com/NandhaKishorM/laya.git cd laya python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt
Related guide: 5 Trending GitHub AI Repos: Direct Links + Setup Guide
Part 3: Generate Synthetic Fine-Tuning Data with Anthropic Claude
Fine-tuning Laya on task-specific data lifts routing accuracy from 36% to 76% on typed-decision benchmarks, per the Laya Hugging Face Model page. If you do not have thousands of clean historical tickets, you can use Anthropic Claude to generate a balanced JSONLines dataset in minutes.
Define a strict label list
Write down the exact categories Laya needs to predict, such as billing_issue, technical_bug, refund_request, or feature_inquiry. Keep category names lowercase and concise so the classifier outputs clean strings.
Run the synthetic data prompt in Anthropic Claude
Open Anthropic Claude at anthropic.com and paste the prompt below, swapping in your real business description and label list. Ask for hard edge cases, typos, and frustrated customer phrasing so Laya learns how real humans write.
Save the output as train.jsonl
Copy the raw JSONLines block from Anthropic Claude into a file named train.jsonl inside your laya directory. Repeat the prompt 3 to 5 times with varied instructions until you have several hundred examples per label.
You are a synthetic dataset generator for training a local text classifier called Laya. My business: [DESCRIBE YOUR BUSINESS IN 1 SENTENCE] Allowed labels: ["billing_issue", "technical_bug", "refund_request", "sales_inquiry", "urgent_escalation"] Generate 100 realistic customer messages in valid JSONLines (.jsonl) format, with exactly 20 examples per label. Rules: 1. Every line must be a valid JSON object with two keys: "text" and "label". 2. Include realistic typos, slang, short messages (under 6 words), and confusing multi-sentence messages where one primary intent dominates. 3. Output ONLY raw JSONLines with no markdown commentary before or after.
Part 4: Run the Local Fine-Tune and Benchmark Your Speed
Once your train.jsonl and eval.jsonl files are ready, run the training script included in the Laya repository to adapt the base weights to your categories. After training finishes, test both accuracy and latency on your local hardware.
Score the untuned base model first
Run the evaluation script in the Laya repo against your eval.jsonl file using the raw convaiinnovations/laya checkpoint. Record the baseline percentage, which typically sits around 36% on multi-intent tasks per the Laya Hugging Face Model page.
Execute the fine-tuning script
Point the repository's fine-tuning command at your train.jsonl file and let it train for 3 to 5 epochs. Because the English model is 421M parameters and the multilingual model is 322M parameters per the Laya Hugging Face Model page, training finishes on a single consumer GPU or modern Mac without cloud compute clusters.
Verify the 30ms local response time
Load your newly saved fine-tuned checkpoint and run 100 sample classifications while timing each forward pass. Compare your new accuracy score against the 76% benchmark on the Laya Hugging Face Model page and confirm latency stays near the 30ms local execution figure from the Laya GitHub page.
Related guide: The Nod + n8n Local AI Agent Setup Guide
Part 5: Connect Laya to Your Live Triage Pipeline
A local 30ms classifier works best as the front door of your automation stack, sorting every incoming webhook or message before a heavier model like Anthropic Claude ever runs. This keeps simple routing free and instantaneous.
Wrap Laya in a local HTTP endpoint
Keep the fine-tuned Laya model loaded in memory inside a lightweight local server such as FastAPI on localhost. Keeping the weights warm in RAM ensures every request hits the 30ms forward pass latency reported on the Laya GitHub page instead of reloading from disk.
Route incoming webhooks through Laya first
Send new Zendesk tickets, email webhooks, or website chat payloads to your local Laya endpoint. Have Laya attach the predicted label and confidence score in 30ms.
Escalate only complex tickets to Anthropic Claude
If Laya classifies a message as standard billing or FAQ with high confidence, route it straight to the right team or template. Only send low-confidence or complex messages out to Anthropic Claude for full reasoning and drafting.
Mistakes to avoid
- Deploying the raw base model without fine-tuning: the untuned Laya checkpoint scores 36% on complex multi-intent routing benchmarks per the Laya Hugging Face Model page, so always fine-tune first.
- Asking Laya to write code or long replies: like TypeSafe Jev, Laya is a dedicated classification model built for fast categorization, not text generation.
- Reloading model weights on every request: keep Laya loaded in a persistent local process so you get the 30ms execution speed reported on the Laya GitHub page.
- Downloading the wrong package: confirm the GitHub path is NandhaKishorM/laya and the Hugging Face path is convaiinnovations/laya, not LayaAir or Llama.
Questions people ask
Why is Laya 8.3x faster than TypeSafe Jev?
Laya runs locally on your own hardware in 30ms with zero internet travel, whereas TypeSafe Jev averages 250ms because every request makes an HTTP roundtrip to a cloud server and back, per the Laya GitHub page and TypeSafe Jev documentation.
Which Laya model checkpoint should I download?
Download the 421M parameter English checkpoint for English-only workloads, or the 322M parameter multilingual checkpoint if you process non-English messages, both available on the Laya Hugging Face Model page.
Can I use Laya out of the box without training data?
No, the untuned base checkpoint hits 36% accuracy on complex typed-decision benchmarks, while fine-tuning on task-specific data raises accuracy to 76%, per the Laya Hugging Face Model page.
How much does Laya cost compared to TypeSafe Jev?
Laya is free and open-source on GitHub and Hugging Face, while TypeSafe Jev is a closed cloud API that charges $0.042 per 1 million input tokens with free output tokens, per TypeSafe Jev documentation.
Watch the video
Watch on Instagram
Want this built for you?
If you run a 7, 8, or 9-figure company and want custom AI employees and ultra-fast routing systems plugged directly into the software your team already uses, Meet Blaine handles the entire build, implementation, and ongoing support. Book a quick call to see how it works for your operation.
- You walk us through your week. Where the hours go and what keeps falling through.
- We show you what to hand off first. Which jobs an AI employee can take over, and what stays with you.
- You leave with a clear next step. Whether or not we end up working together.
Calendar not loading? Open it in a new page
Book a 30-min call: api.leadconnectorhq.com