Sunny’s Blog

One Forward Pass: Rebuilding Jev's Architecture Bidirectionally

Contents

A decision model is a strange, useful thing. You hand it a state — a support ticket, a contract clause, a board position — and a set of questions over that state, and it hands back calibrated probabilities. It never writes a sentence. There is no sampling, no temperature at decode, no parsing a JSON blob out of prose. One forward pass, one distribution per question, done in tens of milliseconds.

That framing is worth taking seriously because it inverts the usual economics. Most "classify this with an LLM" systems pay generation costs for an answer that was always going to be one of five tokens, and then pay again in unreliability, because a probability recovered from a generated token is not a probability anyone should threshold on. A decision model gives you the distribution directly, and a distribution you can threshold is what turns a model into automation: route this ticket automatically if p > 0.96, otherwise send it to a human.

What Jev is actually selling

Jev is the system that made this concrete. It emerged from stealth as a "System One model" — explicitly not a chatbot — and what it's selling isn't intelligence. It's a set of properties a generative model can't really offer. Four of them, roughly in the order I'd rank them by how hard they are to copy:

PropertyClaimed / measuredWhat a generative LLM offers
Latency70–500 ms end to endseconds, plus decode variance
Price$0.042 / M input tokens, output free40–400× more, by their arithmetic
Type safetyschema-valid by construction — it cannot emit an invalid answer because it does not emit tokensa parser, a retry loop, and a hope
Calibrationprobabilities you can threshold; ECE ≈ 0.031 on a 1,200-item samplea token log-prob that is not a belief
The vendor's published figures alongside independently measured behaviour. Treat the pricing and speed multiples as marketing arithmetic; the calibration number is someone else's measurement.

At a glance the first three look like an efficiency story. I'd argue the moat is really the fourth row, and the first three are what make it affordable to lean on. A calibrated probability is what converts a model from an assistant into infrastructure: you set an error budget, threshold at it, automate everything above the line, and route the rest to a human. You can't really build that loop on a number scraped from a generated token, because that number isn't a belief about the world — it's a belief about the next token. Being fast and cheap is what lets you then call it five thousand times in a request without thinking about the bill.

And "five thousand" isn’t rhetorical. The most striking published property is that the request limit — roughly 65,536 tokens — counts the state once, no matter how many questions you attach to it. An independent black-box investigation (~10,000 API calls) fit a 23,000-token state with 5,000 questions inside that limit, which is only arithmetically possible if the state is not reprocessed per question. Re-encoding would have needed north of 100 million tokens. Adding questions, in the vendor's own words, "barely changes response time."

That one sentence is the whole architecture brief. It says the state is prefilled once and every question branches off the cached prefix. The same investigation pinned three more behaviours worth building toward: questions are isolated (a fact planted in the shared state reached an unrelated question ~90% of the time; the same fact planted in a sibling question reached it 0% of the time), the options within a question interact before the decision is made, and the billed output_tokens is a pure accounting artifact — it fits a fixed formula, does not vary with the answer, and does not correlate with latency. Nothing is being generated.

So the target is not "a classifier that is good at tickets." It is: one shared state, many isolated questions, options that see each other, no generation, and a probability at the end that someone is willing to put an error budget behind. The rest of this post is an attempt to get all of that out of a 1.7B open model at once — and specifically about one bet I made and then spent several days interrogating: a decision should be a single forward pass, and every candidate answer should be able to see every other candidate answer. That sounds obvious. It is not what the published reference implementations do, and the reasons they don't turn out to be excellent reasons. I'll walk through the mask that makes it possible, the loss that makes the probabilities honest, and the one measurement that still makes me uncomfortable.

The shape of the problem

The contract has three primitives, and every one of them reduces to a distribution over a candidate set:

noul    yes / no                       -> P(yes)
choice  1..255 named options           -> a distribution over options
score   2..255 ordered levels          -> a distribution over levels,
                                          plus expected level and variance

So architecturally there is exactly one job: given a state and N candidate strings, produce N scores and softmax them. Everything interesting is in how the candidates get encoded, because that single choice determines the cost, the caching story, and whether the options can influence one another at all.

The obvious implementation — and the one the public pointwise reference uses — is one sequence per candidate. Concatenate the state with candidate i, run the backbone, read a scalar off a marker token, repeat N times, softmax at the end. It is simple, it is trivially order-invariant, and it has two properties that eventually get in the way:

The second one is where this stops being an efficiency argument. The behaviour was measured against the real hosted system: adding a decoy option shifts the log-odds between two unrelated options by a mean of about −0.28, consistently, every time. Under pointwise-scoring-plus-softmax that shift is not merely unlikely, it is mathematically impossible. Whatever the real thing is doing, the options are reading each other inside the network.

A behaviour your architecture assigns probability zero to isn’t a tuning problem — it’s a falsification. The pointwise design is a fine model of many things, and a provably wrong model of this one.

Why I went bidirectional

Here's the awkward bit. The evidence favoured causal attention, and I built bidirectional anyway. Worth being precise about why, because "bidirectional is better" isn't the reason and was never true.

The decisive experiment is a reference-card probe: plant the one fact needed to answer a question inside a single option, and move it around.

Position of the planted factAccuracy
Last option16/16
First option12/16
Middle option11/16
Moved into the shared state48/48
Planted-fact probe against the hosted system. Symmetric attention over options predicts a flat column. This column is not flat.

A model whose options attend to each other symmetrically predicts roughly position-independent accuracy. What was actually observed is a strong monotone gradient — the last option is the best place to hide a fact, which is exactly what you would expect if option i can only see options 1…i−1. That is a causal signature. If your goal is to reconstruct the original, you build the causal variant and stop.

My goal wasn't reconstruction. I wanted the fastest correct listwise scorer that still has the behaviour that matters, and I wanted to know what symmetry is actually worth. So here's what it buys — the one real reason, and two that sound better than they are:

1. Every candidate sees the whole set — this is the real one

Under a causal mask, candidate i sees candidates 1…i−1 only. Candidate 1 sees no siblings at all; it is scored pointwise, no matter how listwise the rest of the design is. The information available to each candidate is a strict function of its position, and only a final readout token positioned after everything sees the whole set.

That’s why causal designs tend to need a pointer head — a learned query at the readout position scoring each option's hidden state — rather than reading a scalar off each option directly. Under symmetry you don't need one, because every candidate's own position has already seen the entire set, so reading a scalar off each candidate is fair. Concretely: a LayerNorm → Linear(2048, 1) head, 6,145 parameters, reused verbatim from the pointwise reference instead of a new pointer mechanism I would have to validate from scratch. Symmetry buys the readout.

2. It removes the structural part of the order bias — but not the bias

Causal makes the handicap architectural and monotone: candidate N is strictly better informed than candidate 1, always, by construction. Symmetry removes that. What it doesn’t remove is RoPE. The candidates still occupy distinct positions in the sequence, so permuting the option list still moves the scores. I'll come back to this one, because it got worse rather than better.

3. It keeps the door to permutation invariance open

Position tricks can buy invariance on top of a symmetric mask. Under causal, no position trick helps — nothing makes candidate 1 see candidate 2 when the mask forbids it. Whether that option is worth its price is still open, and I'll show the measurement where I tried to cash it in and failed.

What I won’t claim is that symmetry is measured to be better here. The clean --regime causal ablation on this stack was dropped, so the value of symmetry in this codebase is argued rather than demonstrated. The defensible version of the claim is narrow, so I'd rather keep it narrow.

The mask is the architecture

Plain bidirectional attention over the whole sequence — the vanilla encoder conversion — has a cost that doesn’t get mentioned much. Once the prefix attends to the candidates, the prefix's hidden states become a function of the candidate set. A cached prefix is no longer reusable, because a different candidate set produces different prefix activations. For the workload this model exists to serve — one large state, many questions over it — that’s a real loss: you’ve given up the biggest optimisation available.

So the default regime is not flat bidirectionality. It is a block mask: the prefix is causal-ish in the only sense that matters (it cannot look down at the candidates), while the candidates attend to the prefix and to each other, symmetrically.

One rule covers both axes (seg 0 = prefix; seg k = candidates of question k) allow(q, k) = is_prefix(k) or seg(q) == seg(k) Truth table — P = prefix, C₁/C₂ = candidates of two different questions query \ key P C₁ C₂ P yes no no C₁ yes yes no C₂ yes no yes

That table is doing three jobs at once. Row P is prefix independence: prefill the state once, branch many times. Row C₁, column C₁ is symmetric set interaction — the thing a pointwise scorer can’t have. And row C₁, column C₂ is question isolation for free: with several questions packed into one sequence, each question becomes its own segment and the same single rule guarantees that a fact planted in one question's options cannot reach another, while a fact in the shared state reaches all of them.

That last property matters more than it looks. It’s the observed behaviour of the hosted system, and it’s what makes a multi-question request useful rather than a source of quiet cross-talk. Two things are asserted in tests rather than assumed:

Positions restart per question, so a question occupies the same positions whether it is asked alone or packed with eleven others. The payoff, measured on a 1,449-token state:

QuestionsPacked tokensSeparateSavingForward
11,4901,4901.00×21.1 ms
31,5824,4702.83×20.2 ms
61,7208,9405.20×23.4 ms
121,99817,8828.95×29.8 ms
Twelve questions for 1.4× the latency of one. The saving is structural, not a kernel trick.

The same structure shows up on the candidate axis. Scaling from 2 to 200 candidates costs 5.3× the latency — 28.5 ms at 2 candidates, essentially unchanged at 50, 146 ms at 200. A pointwise scorer runs N passes, so its curve is roughly 100×.

The loss: score the probability, not the answer

The whole reason to build a decision model rather than a classifier is that you want the probability, not the argmax. So the objective has to be something that is minimised by reporting your true belief. That is the definition of a proper scoring rule (Gneiting & Raftery, 2007), and it rules out most of the things people reach for first.

Log loss — negative log-likelihood of the gold candidate, masked over real slots L_log = − log p_y , p = masked_softmax(z, candidate_mask) Brier — mean squared error against the one-hot target L_brier = ∑ᵢ ( pᵢ − 1[i = y] )² · maskᵢ Soft log loss — cross-entropy against a target *distribution* L_soft = − ∑ᵢ tᵢ · log pᵢ (t from vote counts, teacher distributions, aggregate ratings)

Log loss and Brier are both proper; they differ in how hard they punish a confident mistake. Log loss is unbounded and will happily let one catastrophically confident error dominate a batch; Brier is bounded and gentler on the tail but pushes less hard on the well-calibrated bulk. Neither is the right default for all data, so both are implemented and the choice is recorded in the run config rather than baked into the code. That sounds like a small thing. It means that six months later the model card can say which one produced the checkpoint.

Three details that matter more than the choice between them:

The RL detour, and why it collapses back to the loss

A sibling project in this space trains its decision model with something branded "RL from contrastive distillation — proper-scoring-rule rewards, GRPO-style policy gradient." I read the code, because the phrase "GRPO-style" is doing a lot of work in that sentence. Stripped to its arithmetic, the update is:

What the loop actually computes (G = 4 group samples, σ: 0.4 → 0.1) ε ~ N(0, σ²) , projected zero-mean over options z = logits.detach() + ε ← the "action" is a perturbed logit vector q = softmax(z) r = log-score(q, y) + 0.75 · spherical(q, y) + RPS(q, y) A = ( r − mean(r) ) / ( std(r) + ε₀ ) ← group-mean baseline logp = − ‖z − logits‖² / (2σ²) ← Gaussian log-density loss = − mean(A · logp) + 1.0 · soft_CE(logits, y)

This is Gaussian-smoothed REINFORCE — a score-function / evolution-strategies estimator in logit space with a group-mean baseline. The gradient reduces to E[A · ε] / σ². It is "GRPO-style" only in that the baseline is a group mean: there is no importance ratio, no clipping, no KL to a reference policy, no trust region, and no sequential MDP. One on-policy group per update.

And here is the thing that matters, which has nothing to do with branding: the reward is differentiable. q = softmax(logits + noise) and the reward is a closed-form scoring rule over q. You can backpropagate through it exactly. The RL estimator is computing a strictly noisier version of the same gradient at four times the reward evaluations. Add that the supervised term in the same loss is soft cross-entropy at weight 1.0, and that the log-score component of the reward is cross-entropy, and the RL branch is contributing a noisy duplicate of a signal already present, plus two extra scoring terms.

The general rule here is easy to get backwards while RL is fashionable: a policy-gradient estimator buys you exactly one thing — the ability to optimise a reward you cannot differentiate through, or an action space that is sequential. When the reward is a closed-form function of your own softmax, you have neither problem. You have a loss function.

Where the loss is genuinely wrong: the ordinal gap

The clearest weak spot in the current checkpoint is the score primitive. Two families sit far below the rest — relevance at 0.45 accuracy against the pointwise reference's 0.6725, and a rubric-grading family at 0.4755 with macro F1 0.2244, collapsing onto one or two levels.

The cause isn’t mysterious. A score question carries level_index and level_order — the levels are ordered, "Completely incorrect" through "Completely correct" — and cross-entropy throws that ordering away entirely. When the truth is "Completely correct," plain CE penalises predicting "Mostly correct" exactly as hard as predicting "Completely incorrect." The model is given no reason to believe the levels lie on a line.

The fix is an ordinal-aware term, and there is a right and a wrong way to write it. The wrong way — the one that is tempting because it is one line — is to add the absolute error of the expected level, |E[level] − y|. That is not a proper scoring rule. It’s minimised by a point mass at the true level no matter how uncertain the model ought to be, so it trains away the calibration that is the whole point. The right way keeps the objective over the distribution:

Ranked probability score — proper, and ordering-aware (F = cumulative distribution) RPS(p, y) = ∑ₖ₋₁..K−₁ ( F_p(k) − F_y(k) )² , F_p(k) = ∑ᵢ≤ₖ pᵢ equivalently: Brier applied to every cumulative threshold "is the level ≤ k?"

RPS is the ordinal generalisation of Brier: it scores the cumulative distribution at each threshold, so predicting an adjacent level costs one threshold's worth of error and predicting the far end costs all of them. It remains proper, so it does not trade calibration for ordering. This is built, not shipped — I am flagging it as the one concrete improvement still on the table rather than claiming it.

Calibration is the product

Everything above is about getting the architecture right. This section is about the thing the architecture is for, and it's where the most useful numbers in the project live.

Accuracy tells you how often the argmax is right. It tells you nothing about whether you can trust the number next to it. Calibration is the gap between "the model said 0.9" and "the model is right 90% of the time when it says 0.9", and it's the only property that lets someone downstream draw a line and automate above it. So it's worth measuring properly, in more than one way, on more than one seed.

Here's the full picture on the locked test split, across two seeds, against the pointwise reference:

MetricSeed 0Seed 1Pointwise ref.
Accuracy0.75310.73810.7375
NLL0.62140.64510.6787
Brier0.32830.35030.3739
ECE(15), untempered0.03990.04090.0534
ECE(15), after temperature0.0399 (T = 1.0)0.0309 (T = 1.08)0.0534 (T = 1.162)
Coverage @ ≤5% error0.49370.44420.1913
Coverage @ ≤10% error0.67100.57740.4763
Two independent runs, locked test split read once each. Lower is better for NLL, Brier and ECE; higher is better for coverage.

Three things I'd pull out of that table.

The accuracy column is flat and the probability columns are not. Seed 1 is actually a shade less accurate than the pointwise reference (0.7381 vs 0.7375, which is a tie), and still beats it by 24% on NLL, 6% on Brier, and 42% on ECE after temperature. The model isn't getting more answers right. It's getting the confidence on those answers right, which is a different and — for this use case — more valuable thing.

Coverage is the version of this that a product person can read. Coverage at a ≤5% error budget is just: sort every decision by confidence, walk down the list, and stop when your running error rate hits 5%. What fraction did you get through? Seed 0 gets through 49.4% of the volume; the pointwise reference gets through 19.1%. Same corpus, same error budget, 2.6× the work automated. Seed 1 is lower at 44.4% but still 2.3×, so the effect survives a seed change even though the margin moves.

Seed 0 needed no temperature at all. The fitted correction was T = 1.0 — the checkpoint came out of training calibrated, which is the outcome you want and not one you can count on. Seed 1 needed a mild T = 1.08 and improved from 0.0409 to 0.0309 (a 24% cut) on the test split, and from 0.0197 to 0.0176 on the calibration split it was fitted on. For reference, the hosted system measures around 0.031 ECE on a public sample, so a 1.7B open model landing in the same neighbourhood is the part of this I find most encouraging.

The temperature that backfired

One detour worth sharing, because the textbook advice led me straight into it.

Post-hoc temperature scaling is the standard trick: fit a single scalar T on a held-out split, divide the logits by it, ship. The default is to fit T by minimising NLL. On this model that default backfired — the search returned T = 3.1857, and applying it took calibration ECE from 0.0439 to 0.1817. Four times worse than doing nothing.

The mechanism is worth understanding, because it'll bite anyone with a similar error profile. NLL is dominated by its worst cases. If you have a heavy confidently-wrong tail, the NLL optimum is reached by flattening everything, including the well-calibrated bulk, which gets dragged into systematic under-confidence. NLL went down. Calibration — the whole reason you're scaling the temperature — went sharply up.

The two objectives disagree, so fit both and let the metric you care about pick T_nll = argmin_T NLL( softmax(z / T), y ) → 1.0555 (seed 1) T_ece = argmin_T ECE₁₅( softmax(z / T), y ) → 1.0802 (seed 1) apply T* = whichever of (T_nll, T_ece, 1.0) gives the lowest calibration-split ECE ← including 1.0, which was the right answer for seed 0

Two practical notes. First, always keep 1.0 in the candidate set — "leave it alone" is a real answer and it won seed 0 outright. Second, ECE is binned and therefore non-convex, so a bracketing search that assumes unimodality is the wrong tool and will settle somewhere arbitrary. A grid is cheap when you're fitting one scalar. And report the fitted value under both objectives, so when they disagree by 0.025 you can see it rather than wonder.

Results

Full fine-tune, two epochs, 1.7B backbone, ~102k decisions from fourteen public sources, one A100. The comparison is against the published pointwise reference on the same corpus construction, with its hyperparameters held fixed so the difference is architectural.

MetricListwise (this)Pointwise reference
Accuracy0.75310.7375CIs overlap
Macro F10.61680.6165even
NLL0.62140.6787−8.4%
Brier0.32830.3739−12.2%
ECE(15)0.03990.0534−25%
Temperature needed1.01.162calibrated as-is
Coverage @ ≤5% error0.49370.19132.6×, non-overlapping
Sequences per decision1N
Latency, 2 → 200 candidates5.32×~100×
IIA mean absolute log-odds shift0.848exactly 0by construction
Locked test split, 1,997 decisions, read once after model selection.

The first row isn’t the interesting one. Accuracy 0.7531 vs 0.7375 is not a result — the 95% intervals are [0.7342, 0.7720] and [0.7054, 0.7686] and they overlap comfortably, and the two corpora differ by 0.085 in their choice/noul mix anyway. I’d rather not quote it as a win.

The row that matters is coverage at a ≤5% error budget: 0.4937 against 0.1913, with non-overlapping intervals. That is the question a decision model is actually asked in production — what fraction of this volume can I automate without exceeding my error budget? — and the answer is 2.6× as much, from a model that is not more accurate. Better-ordered probabilities, not better answers. NLL, Brier and ECE all move in the same direction and say the same thing, and the checkpoint needs no temperature correction at all.

So the defensible claim is: matches the pointwise reference on accuracy, is clearly better calibrated, automates 2.6× the volume at the same error rate, and does it in one forward pass instead of N.

The number I'm not happy about

Permuting the option list flips the argmax 52% of the time. Mean probability delta under permutation went from 0.142 to 0.3868 — it got worse, not better, when I removed the causal mask.

That is the uncomfortable symmetry of this design: order sensitivity and set interaction come from the same mechanism. Letting candidates read each other in-sequence is what produces the IIA violation I wanted, and it is also what lets their positions matter. Removing the causal mask does not remove RoPE.

I tried to cash in the option that symmetry supposedly bought me — per-candidate position restart, so every candidate occupies the same position range and permutation cannot change anything. The invariance was real:

ConfigurationReadout spreadPermutation drift
Continuous positions7.8e-014.1e-02
Position restart, delimiter readout4.8e-07 (collapsed)6.0e-07
Restart + per-candidate offset of 11.0e+00not invariant
Restart + content-token readout3.2e+006.0e-07
Row 2 is the trap: exact permutation invariance, and completely useless.

Row 2 is the most instructive line in this post. Permutation drift 6.0e-07 is float32 epsilon — perfect invariance. It’s also vacuous. With the readout taken at a shared delimiter token, every candidate's readout token has the same token id, the same position after restart, and — under the block mask — the same set of visible keys. An identical query over identical keys returns an identical vector, so candidates of equal token length score exactly the same. Position was the only thing distinguishing those readout tokens, and I’d just removed it.

My test asserted invariance without asserting that the scores stayed distinct. It passed. It was measuring a model that had stopped discriminating. The candidate interaction inside the backbone survived restart perfectly well — a candidate's hidden state still moves by 7.6e-01 when a sibling's text changes — so the collapse is entirely in the readout, which is the only place that is easy to not look at.

An invariance test that does not also test for non-degeneracy will eventually pass on a model that outputs a constant. Every symmetry assertion needs a liveness assertion next to it.

The working combination is row 4: restart plus reading at each candidate's own last content token, whose query genuinely differs per candidate. Exact invariance and distinct scores. The cost is abandoning the reused readout convention and retraining the head — which is why it is deferred rather than shipped, and why the option-order sensitivity is asserted in a test of its own, so that nobody reads the architecture diagram and assumes invariance for free.

Worth noting what this does not mean. A public sibling design gets permutation invariance by keeping candidates in separate sequences and adding a small set-attention head over the pooled per-candidate vectors — invariant by construction, because the set head has no positional encoding. So invariance is not the price of set interaction. It is the price of in-sequence set interaction. That is a narrower and more interesting trade than "you can't have both."

What it adds up to

Four axes, and every real design in this space picks a different corner:

DesignSequences / decisionWhere options interactOption orderState duplication
Pointwise referenceNnowhereinvariant6.7×
Pointwise + set headNpost-hoc, 128-dinvariant~N
Single-sequence, causal1in-backbone, asymmetricsensitive~1
Single-sequence, block-bidirectional1in-backbone, symmetricsensitive (0.52)~1

There is no dominant row. Invariance costs you either in-sequence interaction or N× compute; symmetric interaction costs you order sensitivity and, unless you build the block mask, prefix caching; causal interaction gives you prefix caching for free but makes candidate 1 structurally poorer than candidate N and forces a pointer head to compensate. Picking a corner is the design work. The failure mode is pretending your corner is free — that’s how you end up with a test suite happily certifying a constant function.

What I'd carry into the next one of these: the mask is the architecture, so write it explicitly and assert it rather than inheriting whatever the framework gives you by default. Train on a proper scoring rule and record which one. Reach for a policy gradient only when the reward is genuinely non-differentiable — otherwise you are paying four reward evaluations for a noisier copy of a gradient you could have taken exactly. And pair every invariance assertion with a liveness assertion, because a model that has stopped discriminating satisfies every symmetry you can name.