Skip to main content

Order Sensitivity in LLM Decision Models: The Flashlight That Became a Solar Calculator

· 11 min read
Manu Mishra
Distinguished Solutions Architect, Author & Researcher in AI & Cloud

Same decision, any order—Strands Gemma E2B

Imagine a product team alphabetizes a dropdown and the AI recommendation changes. The available choices are identical. Their meanings are identical. Only their display order moved, yet the model picks something else.

I saw a clean example while evaluating an LLM-based decision model.

Question

Which device directly converts chemical energy to electrical energy?

Choices

  • A solar-powered calculator
  • A wood-burning stove
  • A battery-powered flashlight
  • A wind-powered sailboat

A Strands Gemma E2B checkpoint selected the battery-powered flashlight—the correct answer—with an API-returned probability of 0.5589. I then reversed the same four choices. The checkpoint selected the solar-powered calculator with probability 0.5615.

Semantic optionOriginal orderReversed order
solar-powered calculator0.12240.5615
wood-burning stove0.12290.0967
battery-powered flashlight — correct0.55890.2873
wind-powered sailboat0.19580.0545

These columns are aligned by semantic identity: the solar calculator is compared with the solar calculator, regardless of which row displayed it. This was not an index-mapping error. The selected meaning changed. That flashlight became the starting point for a broader systems question: when choices are conceptually a set, why should display order affect the decision?

The pattern was wider than one model​

I applied the same treatment to four public decision models. Each received the same 3,900 questions twice: first in source order, then in complete reversal, meaning the last choice became first, the next-to-last became second, and so on. The question, context, and choice text stayed unchanged.

Tested modelAnswers changed after reversalOriginal-order accuracy
Laya1,426 / 3,900 (36.56%)49.49%
Strands Hobson839 / 3,900 (21.51%)72.13%
Strands Gemma E2B851 / 3,900 (21.82%)73.00%
Strands Gemma E4B563 / 3,900 (14.44%)79.26%

Before counting a change, the evaluator mapped both responses back to the original semantic choices. It asked whether the winning meaning changed, not whether the winning row number changed. All four models also returned zero failed or invalid responses, so the rates are not inflated by malformed output.

This comparison is evidence about these tested model releases, their native typed-choice interfaces, and the recorded runtime—not a claim that every LLM behaves this way. It also tests one transformation, complete reversal, rather than every possible permutation. Even within that bounded test, every jointly encoded model changed a meaningful share of its decisions. The most accurate model, Strands Gemma E4B, still changed about one answer in seven.

The full protocol and per-task results are in the immutable cross-model order-sensitivity evidence. That cross-model study was published after the v0.1.0 project release; it adds comparative evidence but does not change the released runtime or model components.

Project release: GitHub source, runtime, tests, and evidence (v0.1.0) · Hugging Face model components (v0.1.0)

Why an ordered prompt changes the decision​

The original scorer put every choice into one token sequence. Language models process sequences, so moving a choice changes more than its visual row. Its tokens move to another position, its A/B/C-style label can change, and it gets different neighboring text. The model does not receive “the same set in another order.” It receives a different sequence and can compute different internal features.

That matters because a decision model does not merely write an open-ended response. It chooses among typed alternatives: route this request, select that policy, assign this score, answer yes or no. If presentation leaks into the result, a harmless UI sort or serialization change can become a different business decision.

Prior work has documented order sensitivity in multiple-choice questions, separated position and option-label bias, and studied order alongside token sensitivity. My goal here was narrower and practical: could I repair this behavior around one released Strands Gemma E2B checkpoint without retraining its expensive core?

A retrofit, not a rebuild​

Retrofitting a building means keeping the main structure while changing the parts required for a new need. I followed the same approach with the model. The Gemma language-model torso and inherited Strands adapter stayed frozen; I redesigned the path that presents and scores options.

The retrofit has four parts:

  1. Build one isolated branch for each semantic option.
  2. Place every option at the same logical token position.
  3. Fit a replacement scoring head for those isolated features.
  4. Add a small optional set-based module for decisions that require comparison.

The caller still sends one normal typed request containing every choice. Branching happens inside the runtime, and only the small new scoring components are trained.

Architecture of the Strands Gemma order-stable hybrid

Open or download the editable Excalidraw source.

Here is how to read the diagram. The red path across the top is the original design: all choices enter one ordered prompt, one joint model pass scores them, and reversing the list can move the winner. The green path starts with the same external request but fans it into one internal branch per semantic option. Each branch uses the same frozen model weights and puts its one complete option in the same logical location.

At the bottom, the path splits into two modes. normal reads the independent branch scores directly. compare_choices adds a small position-free correction that compares the option features as a set. Both paths then map results back by semantic identity. The architecture removes display position from scoring, while the zero-change claim still depends on the tested execution route described later.

normal: judge each option on its own​

In normal mode, every option receives the same state, question, and instructions, followed by exactly one complete choice. No sibling choice appears in that branch. There is no generated row number, A/B/C label, “first” marker, or “last” marker. Each option begins at the same logical token position.

For a four-choice request, the runtime performs four complete model passes, one at a time. A small shared scoring head converts each branch representation into a logit, the raw ranking score used before scores become probabilities. The options are then ranked and returned under their semantic identities, not their current rows.

In plain language, normal asks: How well does this option fit the question by itself?

That works well for many classification, routing, and policy-selection tasks. A billing route can be judged against the request without needing to know whether “technical support” appeared before or after it. Isolation also means that moving an option in the external list does not change the content of its branch.

compare_choices: judge relationships too​

Some questions cannot be answered one option at a time:

  • Which plan has the second-lowest price?
  • Which value is unique?
  • Which provider is closest to the group average?

An isolated branch cannot know that its value is second, unique, or closest because those properties exist only relative to the alternatives. For these cases, compare_choices starts with the same isolated scores and features as normal, then applies a small set-based correction.

The same transformations are used for every option. The module can compare content and summarize the active set, but it receives no display index, slot embedding, or first/last indicator. If the input rows are shuffled, the output rows should shuffle with them; after mapping them back to their semantic identities, the aligned scores should match within the tested numerical tolerance.

In plain language, compare_choices adds a second question: How does this option relate to the alternatives?

This is why it is opt-in rather than a blanket upgrade. Use normal when candidates can be judged independently. Use compare_choices when the relationship among candidates defines the answer.

What changed after the retrofit​

The standard evaluation contains 3,900 questions across 13 tasks. Under the supported execution path, both modes produced 0 / 3,900 semantic winner changes after complete reversal.

ModeStandard accuracyReversal winner changes
Original Strands Gemma E2B73.00%851 / 3,900
Retrofit normal72.49%0 / 3,900
Retrofit compare_choices72.46%0 / 3,900

The retrofit removed the measured reversal failure with a small standard-accuracy tradeoff. The broad suite did not favor relational scoring, which supports keeping normal as the default.

The value of comparison appeared on a separate, locked 2,000-question relational test. Accuracy increased from 33.55% with independent scoring to 37.10% with compare_choices: a gain of 3.55 percentage points. A paired bootstrap, which resampled matched results from both modes together, placed the 95% interval at +2.20 to +4.90 points.

The relational path also passed 100,028 / 100,028 mapped permutation checks. Those checks were exhaustive for tested questions with four or five options. For six through eight options, they used deterministic balanced and cyclic selections rather than every possible ordering. This is strong evidence for those test families and that execution path, not proof of invariance across all prompts, transformations, hardware, or serving systems.

The opening probabilities also need careful interpretation. They were rounded by the original API and renormalized by the evaluator, so they show which answer won but are not raw model scores or calibrated confidence. Complete reversal is likewise one useful probe, not a complete measurement of every way an interface can reorder choices.

The serving stack is part of the result​

Isolating choices repeats the question and instructions for every branch, so prefix caching looked attractive. Prefix caching computes the model’s internal state for that shared beginning once, then reuses it while processing each option suffix. In the observed cases, its performance ratio ranged from 0.970× to 7.102× full recomputation: slightly slower in one case, but more than seven times faster in another.

Speed was not enough. The acceptance limits were fixed before the final cache cases were examined. In reduced precision, 8 of 14 required cache cases failed the raw-logit limit, and the largest difference from full recomputation was 0.0716. Probability and mapped-permutation checks passed, but a changed underlying score can still matter on a future near-tie. The release therefore rejected the cache path rather than weakening the gate after seeing the result.

Cross-request batching is a different optimization. It groups unrelated requests into one model call and pads shorter rows so they share a common shape. Those neighboring requests should be semantically irrelevant, yet changing the numerical execution shape changed outcomes: the same requests had no flips when run alone, but produced 26 winner flips across 744 batch placements with unrelated padding companions.

This is why runtime belongs in the claim. A position-free comparison rule can still receive different upstream features when precision, caching, padding, kernels, or batch shape changes. The supported result is for serialized requests, one branch per model call, batch size one, and full recomputation. A new serving optimization is a new conformance target, not an implementation detail that inherits the old evidence automatically.

The decision path is the unit to test​

This work establishes a bounded result. For one released checkpoint, isolated branches removed the measured display-order signal while a set-based correction recovered some value on relational tasks. It does not establish stability under every permutation, paraphrase, prompt template, device, precision, or deployment stack. It also does not make compare_choices universally more accurate.

What it does establish is a practical engineering pattern: preserve the expensive model core, remove list position from each option’s encoding, add comparison only when the task requires it, and validate the complete serving path.

Order stability depends on the full decision path:

  • How options are rendered
  • How semantic identities are preserved
  • How logits are computed
  • Which numerical path executes them
  • Whether requests share caches or batches
  • How the service schedules work

The released implementation and evidence remain available in GitHub v0.1.0, with the matching model components in Hugging Face v0.1.0. The later cross-model comparison broadens the observed context without changing that release boundary.

The next time a UI sorts choices, an evaluator shuffles answers, or a service changes serialization order, the model should not quietly receive a different problem. That is the standard I wanted this retrofit to meet.


Built with Kiro, using AI-assisted development to move from a measured failure to a tested, released system.