Raising Laya's token budget did not fix long documents.
This page explains, from scratch, what Parswanadh contributed around Laya, an open-source decision model by Nandakishor, and checks every number against the committed data. The headline is a negative result, and it stays one.
Slide the padding and watch the sun
Laya answers a multiple-choice question about a short request hidden at the end of a longer document. More padding in front of the request means a longer document. 200 test items per setting.
Cloud cover is a visual shorthand only: clear at 0.840, fully covered at 0.335, which is what you score by always answering the most common label. The numbers beside each sun are the measurement. Source: experiments/baseline-power-n200/predictions.jsonl, 2,000 rows, one seed (20240924). I recomputed every cell from those rows.
What this analysis found
Everything touching Laya on one developer's laptop was found and read in eight slices. Six items came up. One shipped upstream (two merged pull requests), three are research and engineering Parswanadh ran, and two never went live: a design plan and an explainer site.
| Item | What it is | Status |
|---|---|---|
| Pull requests #696 and #697 | A documentation correction with a regression test, and a benchmark showing accuracy depends on where the evidence sits. | Merged 2026-09-29, shipped in v0.3.22 |
| laya-lab long-context study | A pre-registered study of why Laya fails on long documents and whether three fixes work. Result: none of the architecture changes helped. | Done, public repo. The launch README branch is not pushed. |
| Cross-attention head | A library change adding a zero-initialised cross-attention branch to Laya's decision head. 31 tests pass. | Not submitted, because its own ablation showed it does not change answers. |
| Jadal System-1 integration | Laya wired into a product as a local decision service behind a provider chain, after an evaluation that concluded "use it with limits". | Built, public repo. |
| Vision-fusion design | A written plan for adding image similarity to Laya's scores without editing upstream. | Design only. No code exists. |
Explainer site (laya-site) | A six-page site Parswanadh specified in a design brief. Who wrote the pages is unknown from the files; the speed and style suggest agent drafting. | Never deployed, and it contains errors. See corrections. This page replaces it. |
Attribution matters here and this page does not inflate it. Of 100 commits in laya-lab, 78 carry the name Parswanadh. The other 22 come from AI agent sessions working in the repository under Parswanadh's direction. The tables below say which is which. Neither merged PR carried the research finding: upstream accepted a doc fix, a test and a benchmark.
Laya from scratch
Laya is a small model that reads a piece of text and picks one answer from a list you give it, in a single pass. It never writes sentences.
The problem it solves
A chatbot answers by writing text one word at a time. That is slow, and it can write an answer that is not in your list. Psychologists call fast, instinctive judgement "System 1" and slow, deliberate reasoning "System 2". Laya is built as System 1: one glance, one answer, a probability for every option. It is non-autoregressive, which means no word-by-word loop at all.
What you give it
You give it the state, which is the text to judge, and a set of typed questions. Say the state is "I was billed twice this month" and the question is "Which department?" with options billing, technical, sales, other. There are three question types:
choice(pick one),score(a level, like how urgent) andnoul(a yes/no).How the question becomes tokens
The model reads tokens, which are word-pieces. Laya lays the question out like this, and puts a special
[MASK]token in front of every option:[CLS]choice question: Which department?[SEP] [MASK]billing[MASK]technical[MASK]sales[MASK]other [SEP]I was billed twice this month … (the document goes here)[SEP]Everything before the document is the head. In the multilingual checkpoint a typical four-option question makes a head of 45 tokens. The question and options come first, which is why where the evidence sits in the document turns out to matter.
The encoder reads everything at once
An encoder turns each token into a list of numbers that reflects its context. Laya builds on existing encoders: ModernBERT-large for English (421.29M parameters, 28 layers) and mmBERT-base for the multilingual checkpoint (321.91M parameters, 22 layers). The lab studies the multilingual one.
A small head scores each option
The decision head is a small trained network. It looks only at the vector sitting on each
[MASK]and turns it into one raw score per option, called a logit. The head has about 15M of the model's 322M parameters, so it is cheap to fine-tune while the encoder stays frozen. The lab later exploits exactly that.Scores become probabilities
Softmax converts scores into probabilities that sum to 1. Scores of 2.1, 0.4 and -1.0 become 0.815, 0.149 and 0.037. For a
choicequestion the answer is the largest. Forscoreit is the expected level. Fornoulit is the probability of "true". A fitted temperature divides the scores first, so that a stated 80% is right about 80% of the time. That property is called calibration.The state budget, and why it matters here
The model accepts at most
max_lentokens: 1,024 for the multilingual checkpoint as shipped. After the head is built, the document gets whatever room is left, and the rest is cut off from the end. In the example, a 978-token budget for the document is plenty. Now put the request at the end of a 7,000-token document.head (45 tokens)document kept: first 978 tokens of filler …cut off: remaining filler and the request itselfThe request is gone before the model sees it. Everything in this page that follows starts from that picture.
Two merged upstream pull requests
Both were created on 2026-09-28 and merged by Nandakishor on 2026-09-29 at 17:40:35 UTC, then shipped in v0.3.22 eight minutes later, where the release notes credit it as Parswanadh's first contribution.
#696: the state budget is not what the docs said
The README said the document gets max_len - head_max_len tokens. head_max_len is only a cap on the head, not its real length. Picture a suitcase of fixed size and a maximum-size shoe bag: if the shoes only fill half the bag, the space is still yours. The code measures what is left after the head is built:
room = max(0, max_len - len(ids) - 1) # laya/common.py: after head and options are appended
state = state_ids[:room]
Measured with the shipped tokenizers and the four-option department question:
| Checkpoint | max_len | Real head | Real room | Documented |
|---|---|---|---|---|
| laya (English) | 512 | 48 | 463 | 320 |
| laya-multilingual | 1,024 | 45 | 978 | 768 |
The docs were wrong in both directions. For a short question they understated the room by 143 and 210 tokens. For a question with many options they overstated it, which is the dangerous direction: the library silently cuts a document you sized to fit.
| Options | Head tokens | Real room | Cap-based figure |
|---|---|---|---|
| 46 | 195 | 316 | 320 |
| 47 | 199 | 312 | 320 |
| 77 | 319 | 192 | 320 |
| 100 | 411 | 100 | 320 |
How review went. The first version claimed the cap-based figure is "never an overestimate". An upstream reviewer refuted that, and the table above is the measured counterexample. Parswanadh reproduced it before replying, deleted the false sentence and added tests, including one that parses the README and compares its figures to a live measurement. A second review then asked for more, because the one substantive assertion skips when checkpoints are missing, as they are in CI. That review got no reply and the PR was merged anyway. A later upstream contributor added the stricter checks.
"Passed checks" is not quite right. The merge comment says checks passed, but the first-time-contributor gate left every CI run waiting for approval. The lab's own notes record this accurately.
#697: where the evidence sits changes the answer
Upstream's long-context benchmark always puts the request last, so it changes the document length and the distance to the head at the same time. The #697 script keeps the length fixed and moves the request through the document: 2 lengths × 5 positions × 20 requests, with every prediction saved. At position 1.0 it builds the byte-identical string upstream does.
| Filler tokens | 0.00 | 0.25 | 0.50 | 0.75 | 1.00 |
|---|---|---|---|---|---|
| 4,000 | 0.850 | 0.550 | 0.650 | 0.600 | 0.950 |
| 7,000 | 0.850 | 0.550 | 0.500 | 0.650 | 0.400 |
Paired on the same 20 items, position 1.00 against 0.25 at 4,000 tokens is 0 items fixed and 8 broken (exact p = 0.0078). Position 0.00 against 0.25 at 7,000 is 0 and 6 (p = 0.031). The ordering of the middle cells is not resolvable at n = 20, and the PR says so.
One claim to soften. The PR says position 1.0 at 4,000 tokens "reproduces the published cell (0.950)". Upstream's committed artifact records that cell as 18 of 20, which is 0.90. The two runs also used different devices and library versions. The honest wording is "matches to within one item".
The long-context study
The question: Laya collapses on long documents. Is it the token budget, the attention pattern, or the way the head combines information, and can any cheap fix help?
The lab froze its evaluation protocol before running anything: paired McNemar tests on the same items, Holm correction across a small family of comparisons, bootstrap intervals, raw predictions always saved, and test templates held out from training. Nine steps, in order:
Reproduce upstream first
Upstream's own artifact shows 0.95, 0.65, 0.35, 0.35, 0.35 across 0 to 7,000 padding tokens at the 1,024 budget. The lab's upstream-faithful arm matched all five cells exactly, and four of five at 8,192. The fifth was one item off.
Find out what the 0.35 floor really is
An independent verification (V-001) showed the four padded 1,024-token cells are one measurement repeated four times. The request starts at token 1,000 and only 978 document tokens survive, so zero request tokens reach the model. The floor is not "long context is hard". It is "the question was deleted". This overturned the lab's own earlier headline.
Build a balanced test and measure properly
A synthetic needle-in-a-haystack set with equal labels, 200 items per setting, seed 20240924. Raising the budget to 8,192 helps at every padded setting (all four paired tests survive Holm), but accuracy still falls from 0.840 to 0.420.
Whiskers are 95% bootstrap intervals over the 200 items. At 1,024 the request is kept in 0 of 200 items for every padded setting; at 8,192 it is kept in all 200. The dashed line is the always-the-most-common-label rate, which here is also the position-only oracle. So there are two different failures. At 1,024 the request is truncated away and the model answers a constant. At 8,192 the request is present and used badly. The second is partly better but still 42 points below short-context accuracy. What causes it is not identified: earlier drafts called it "dilution" and the audit retired the word.
Rule out the cheap explanations
Number precision is not it: bf16, fp16 and fp32 all score 0.600 at 4,000 padding. Position matters even with nothing truncated: with the shipped head at 7,000 padding tokens, putting the request at the front scores 0.595 and at the back 0.365 (n = 200 each, four-label pool, chance 0.250). A linear probe on the frozen encoder recovers the label at 0.82 while the shipped head returns 0.30, so the information survives the encoder and is lost in the head's aggregation.
Test the training-free fixes
Widening the sliding attention window has no dose-response and gets worse on the larger set (−0.158, p = 0.0094, n = 120). Making every layer global drops accuracy to 0.000 at 1,000 padding (n = 20) and to the majority rate at 7,000 (n = 120). Each patch was proven live by decoding the attention mask the library actually received, so "no change" could not mean "the patch did nothing". Rescaling the positional encoding was dismissed by reading the code, which shows it is an identity inside the trained length, and was never trained.
Fine-tune the head with the encoder frozen
Train only the roughly 15M-parameter head. It gains +9.0 points at the primary cell (0.365 to 0.455, p = 0.0021). Across three seeds the primary cell spreads only 1.5 points. Mid-document cells gain more but are noisy: one cell spans 11.5 points across seeds. This is the one thing that worked, and it is an adaptation result, not an architecture result.
Try the architecture fix, fairly
The first cross-attention attempt replaced the pre-trained stage with a random one and never learned: its loss stayed at 1.389, which is ln 4, a uniform guess. That is an invalid arm, not a null result. The redesign keeps the shipped head and adds a parallel cross-attention branch whose output layer starts at exactly zero. At step 0 the model is bitwise identical to the baseline: the maximum logit difference is 0.0 over 2,200 items. So any later difference is attributable to learning, not to a lucky start.
The decisive control: switch the branch off
After training, the branch's output layer was set back to zero and the same checkpoint was re-scored. Accuracy did not move.
Primary cell, pad 7,000, max_len 8,192, four balanced labels so chance is 0.250. Never compare across the n = 200 and n = 600 rows without restricting to the same items. The intervals of every fine-tuned arm and the branch overlap. The branch version scores 0.472 against 0.450 for the matching fine-tuned head (n = 600, +2.2 points, p = 0.393), which is no detectable gain. The same trained checkpoint with the branch re-zeroed also scores 0.472: 8 of 600 predictions change, four each way, p = 1.0. The branch is alive during training (its weights grow about twenty-fold) and does not determine the answer. Without that control, the honest-looking sentence would have been "+7.5 points from cross-attention, p = 0.086", a false positive. That is why the cross-attention head stayed on the fork and was never submitted.
Verify independently, then audit the lab's own write-up
Three verification passes re-ran or re-derived the numbers. V-001 reproduced 10 baseline and 13 diagnostic cells exactly. V-002 rebuilt all 2,200 evaluation documents and re-ran two arms end to end with zero prediction mismatches. V-003 (the launch audit) re-derived every README number from raw rows and corrected the lab's own documents in place, including a seed-spread claim that rested on a file a later commit had overwritten. The verdict: the fix is adaptation, not design.
What the study does not show
- The documents are synthetic and repetitive. This is a mechanism probe, not evidence about real long documents.
- Architecture arms have one training seed each, so every architecture null means "not detected at this power".
- Several protocol controls were never implemented: random-chunk and TF-IDF baselines, a random-initialisation arm, a capacity-matched control, and a full n ≥ 200 position sweep.
- Nobody outside the lab has re-run it on a GPU. The audit refuses to call the result reproduced for that reason.
- The two halves of the study use different item pools with different chance rates, 0.335 and 0.250. Never mix them.
Wiring Laya into Jadal
Between 1 and 3 October 2026 Parswanadh took Laya from "interesting model" to a working decision service inside Jadal, an irrigation advisory product for Telugu-speaking farmers, and wrote down exactly where it can and cannot be trusted.
The need
Jadal splits thinking into three tiers. System 2 is a language model holding the conversation. System 1 is a fast reflex that reads a farmer's message and returns an intent (one of seven), an urgency from 0 to 1 and a yes/no for crop stress. The third tier is deterministic water maths. Laya is a candidate for System 1, because it returns a probability per option in one quick pass.
An independent verdict: use it with limits
Before wiring anything, a verdict document separated what was run from what was merely read, and returned five limits:
Limits from docs/research/laya-verdict.md. The probe is four hand-written Telugu messages plus one English control: a smoke test, not an accuracy measurement, and the document says so.Limit Finding Use intent only Intent was right on all five probe messages. But the yes/no "is it release time" fired at 0.814 on an urgent Telugu message and 0.778 on the English control, and urgency never left band 2. Telugu is unvalidated Upstream's own 51-language sweep puts Telugu at 0.220 with 20 options against 0.050 random (rank 42 of 51, 100 items). The lab's test pools contain no Telugu. Keep inputs short Cap messages at 512 tokens; beyond 888 the end of the message is cut, and the end is where the ask usually sits. Real messages are 30 to 47 tokens. Not inside a Worker No ONNX export exists, so Laya needs a Python process beside the app. Refit calibration The multilingual checkpoint ships without fitted temperatures: calibration error 0.314 as shipped, 0.106 after refit. Do not threshold on its probabilities until refit. A local decision service
services/laya/is a small Python HTTP process that loads the checkpoint once and answersPOST /decidewith an intent, urgency band, crop-stress probability and the raw per-question answers.GET /healthreports load state. It counts tokens before inference and refuses to truncate. Every error response has no intent or urgency field, so a failure can never be mistaken for a decision: bad input is 400, too long is 422, model failure is 500, an unmappable answer is 502, and not loaded is 503.A provider chain with fallbacks
In the Cloudflare Worker,
apps/api/src/system1.tstries Laya, then Jev, then keyword rules, and never throws. Each failure advances the chain and is recorded as one of eight reasons, such as timeout, rate limit or malformed JSON. The default timeout is 4 seconds. One honest limit: no live Jev call was ever made, because no API key was present, and the architecture decision record says so.A trust boundary
The rule: Laya may decide the intent and the crop-stress flag. It may not set urgency or the release-time flag, because the probe showed it gets those wrong. The sidecar therefore returns both as null.
Fixes and a self-correction
Three sidecar defects were fixed: a load failure caught
BaseException, so Ctrl-C during loading was recorded as a model failure; the default model was a hardcoded path on one laptop; and an error field was assigned but never declared. Parswanadh also corrected a memory figure in the docs: a mid-load reading of 1,367 MB became a peak of 2,673 MB and a steady 122 MB.Tests and CI
A sub-agent counted 38 Python tests and a further 91 TypeScript test blocks across three files. None were run. The Python suite needs no model: a fake agent returns the real response envelope, and a length-gate test asserts the model is never called.
Known gap, checked on the repository. The trust-boundary change that makes the Worker ignore Laya's urgency (commit 1a3bb6d) lives only on the branch integration/swarm-2026-10-02. It is not an ancestor of main. On main, the Worker still falls back to reading urgency from the raw answers the sidecar echoes. That recovers the same band-2 value the verdict calls untrustworthy. A TypeScript test fixture labelled "the real sidecar body" sets urgency to 0.9 where the real sidecar sends null, which is why the tests stay green.
What is and is not Parswanadh's here. All 16 commits carry Parswanadh's name (13 as Parswanadh, 3 as Parshu through GitHub squash-merges). A branch-only report says an agent harness wrote intermediate checkpoint commits that were later rewritten into conventional ones. So the honest description is developer-directed agent work, committed under Parswanadh's name. The performance numbers (load time 8.33 s, 27 to 43 ms per decision on GPU, 653 to 1,108 ms on CPU) come from a sibling worktree and are reported in the docs, not reproduced here. Whether a deployed Worker can reach a local sidecar at all is still open.
A vision-fusion design that was never built
On 2026-10-10 Parswanadh wrote a 65-line plan for giving Laya an image-similarity term per option, without editing upstream.
The idea: add a learned scalar times an image-text similarity to each option's score, right before the masking step in DecisionModel.forward. The plan makes several sharp observations:
- A constant offset added to every option is unlearnable: softmax ignores it, so it gets zero gradient. Drop it.
- A weight and a fixed scale only matter as their product, so learn one scalar per question type, initialised to zero. That starts the model exactly at stock Laya.
- Do not call the parent
forwardand patch afterwards. The confidence head would then read the unadjusted scores while the answer used the adjusted ones. - The main hazard is option order: the similarity vector must be permuted by the same rule as the markers and the target, or answers go silently wrong.
- Inference has several bypasses, in the fast path, calibration and checkpoint loading, so the plan lists five tests (identity, permutation, order invariance, padding, wiring).
A sub-agent spot-checked 39 line-number citations in the plan against the source snapshot: 35 exact, 4 off by a line or naming the wrong construct. The plan correctly says image support is unverified; the snapshot contains no image path at all. There is no implementation. A separate project, jadal-qa, holds a copy of the plan and says in five places that Laya is not in its pipeline.
Who did what
Git author names record which identity was configured, not who typed. Where the repository cannot tell, I say so.
| Who | What they did | Evidence |
|---|---|---|
| Parswanadh | Both merged PRs and their review replies; the redesigned cross-attention head; the pre-registered hypotheses and the zero-init and ablation design; the audit brief, including "the negative result is the story"; the decision to leave git history unrewritten; the vision-fusion plan; the Laya evaluation and System-1 wiring in Jadal. | 78 of 100 commits in laya-lab; 4 commits in the fork; issues and PR threads. |
| Agent session "engineer" | 18 commits, all the training and evaluation pipeline: the first (failed) cross-attention head, data pools, run orchestration, the learning-rate learnability check. | git log author field. |
| Agent session "launch audit" | 4 commits: the root README, the re-derivation scripts, the red-team log, the Reddit draft, the corrections. | git log; unpushed, 4 commits ahead of the remote. |
| Unknown | Whether two early findings (E-001, E-002) were typed by Parswanadh or by an agent committing under that name. Likewise the pages of the explainer site. | Declared roles in the files differ from the commit author. |
| Nandakishor | Laya itself; merged both PRs and released v0.3.22. | PR pages. |
| Upstream reviewer | Refuted the false bound in #696 and found the weak test. | Public review thread. |
Corrections found while checking
These are errors or stale statements in the existing lab and explainer material. This page does not repeat them. Most are small, and the lab's own audit already caught several.
- PR status. The lab README is current and says both PRs are merged. Older copies are not:
PR-PLAN.mdandprogress.mdsay "both PRs OPEN", theCHANGELOG.md"Verified, not changed" table shows open and unmerged, and one commit message says blocked on CI. - The "0.950 reproduces the published cell" claim. Upstream's artifact says 0.90. It matches to within one item.
- The explainer site says every number is "n = 200 to 600 per cell, balanced". Its central position table is n = 20, and the all-global result is n = 20. It also labels upstream's published calibration figures and the Jev comparison as "we measured", but the lab never measured calibration error, and one figure is attached to the wrong checkpoint. It still says both PRs are open.
- "+9.0 to +16.5 points." The audit replaced this with the primary-cell gain of +9.0 and a warning that mid-document gains are noisy.
- The Reddit draft still uses the retired word "dilution", says "four architectural interventions failed" when three were trained and one dismissed by code reading, and quotes 0.485 against 0.455 as if it were n = 600. That pair is n = 200, and the n = 600 pair is 0.472 against 0.450.
- Three p-values in the README prose (0.011, 0.76, 4e-4) came from a normal approximation. Exact binomial values are 0.0132, 0.822 and 3.0e-4. No conclusion changes.
- The drift gate (
make_figures.py --check) is described as covering the two SVGs. It covers only the three tables. - One lesson lacks an archive. The learning-rate near-miss that would have faked a refutation is real (a sub-agent read the raw log and all four rows match) but its summary file was never committed.
Glossary
- Token
- A word-piece, the unit a model reads. "Refunds" might be one token, "unhappiness" two. Like syllables for a reader.
- Encoder
- The big part that reads the whole text at once and gives each token a context-aware vector. The eyes, not the judgement.
- Decision head
- The small trained part on top that turns vectors into option scores. The steering wheel bolted onto the engine.
- Logit and softmax
- A logit is a raw score. Softmax turns scores into shares that sum to 1, like turning vote counts into percentages.
- Calibration and temperature
- A model is calibrated if its 80% answers are right about 80% of the time. Temperature is one fitted number that softens or sharpens the probabilities, a volume knob.
- Truncation
- Silently cutting off text that does not fit. Like reading only page one of a forty-page report.
- Needle in a haystack
- A controlled test: hide one short request at a known position in neutral filler, so you know exactly where the evidence was.
- Majority-class rate
- The score from always giving the most common label. The student who always answers "C". A model must beat it to show it read the question.
- Position-only oracle
- The same cheat, but allowed to know where the evidence sits. Here it equals the majority rate, so it is not an independent control.
- McNemar test
- A paired test that looks only at items two systems disagree on. Two judges on the same 200 cases: count only the cases they ruled differently.
- Holm correction
- When you run several tests, some look significant by luck. Holm raises the bar test by test so the whole family keeps a 5% false-positive rate.
- Bootstrap interval
- Redraw the items with replacement thousands of times and take the middle 95% of the resulting scores. An error bar that needs no formula.
- Cross-attention
- One set of positions querying another. Here the option markers asking questions of every document token directly, instead of through relayed layers.
- Zero-initialised and init-fair
- A new branch whose last layer starts at zero adds nothing at step 0, so the model starts bit-for-bit as the baseline. Any later difference is learning, not luck.
- Ablation
- Switch one part off and re-measure. Unplug one wire to see whether the lamp still lights. If nothing changes, that part was not doing the work.
- Inference-inert
- Active during training but not changing the final answers. This differs from "unused": the branch's weights grow, yet it moves only 8 of 600 decisions.