Set-LLM: A Permutation-Invariant LLM

Beni Egressy, Jan Stühmer · DOI

Abstract

Large Language Models (LLMs) often exhibit significant "position bias," where the order of options in a multiple-choice question influences the model's output. This sensitivity undermines reliability, especially in "LLM-as-a-judge" scenarios. We present Set-LLM, an architectural adaptation that ensures permutation invariance by modifying attention masks and positional encodings. Set-LLM provides mathematically guaranteed consistency across input permutations in a single forward pass, eliminating the need for expensive majority voting while maintaining or improving accuracy.

Introduction: The Order Sensitivity Problem

Standard decoder-only LLMs are notoriously sensitive to the sequence of tokens. In multiple-choice tasks, simply swapping the positions of "Option A" and "Option B" can cause the model to flip its answer. This "order sensitivity" is a critical flaw for automated evaluation pipelines where one model judges others. If a judge-model prefers a candidate simply because it appears first, the evaluation is biased.

Set-LLM addresses the position bias of standard LLMs, ensuring consistent answers regardless of option order.

While techniques like "majority voting" (averaging results over all possible permutations) can mitigate this, they are computationally prohibitive, scaling exponentially with the number of choices ($k!$). Set-LLM solves this at the architectural level, providing a "one-and-done" pass that is provably order-invariant.

Methods: The Set-LLM Architecture

The transformation of a standard LLM into a Set-LLM involves four key architectural modifications designed to remove global sequence dependency while preserving local linguistic structure.

The architectural transition from standard causal models to Set-LLM involves removing global positional encodings and implementing specialized masks and set-based encodings.
  1. Removing Sequential Positional Encoding: Standard global sequence markers (0, 1, 2...) are removed to prevent the model from distinguishing options based on their absolute position in the prompt.
  2. Replacing Causal Masks with Prefix Masks: To allow for richer representations, tokens in the prompt are permitted to attend to each other bidirectionally, moving away from the strictly "look-backward" nature of standard decoders.
  3. Set Position Encoding (SetPE): To maintain the internal word order of an option (e.g., distinguishing "dog bites man" from "man bites dog"), Set-LLM assigns all options in a set the same starting position index. This makes the options order-neutral relative to each other.
  4. Set Attention Mask (SetMask): To prevent information leakage between choices, a custom mask is applied. Tokens within "Option A" can see the prompt but are forbidden from seeing "Option B." This ensures that each choice's representation is independent of its neighbors.

Experimental Setup

Set-LLM was evaluated across several base models, including Gemma (2B, 7B), Llama 3.2 (1B, 3B), and Llama 3.1 (8B). The researchers tested performance on four major multiple-choice reasoning benchmarks:

  • PIQA (Physical interaction)
  • ARC-Challenge (Grade-school science)
  • CommonsenseQA (World knowledge)
  • SIQA (Social intelligence)

Models underwent a small amount of instruction-finetuning using a subset of the UltraFeedback dataset to adapt to the new architectural constraints.

Key Results and Insights

  • Strict Invariance: At 32-bit precision, Set-LLM is empirically proven to produce identical log-probabilities for any permutation of input options.
  • Adversarial Robustness: While standard models often see accuracy drops of over 30% when options are placed in an "adversarial" order, Set-LLM maintains perfectly consistent performance.
  • Performance Gains: Set-LLM frequently outperforms base models even on random-order inputs. For instance, on the ARC-Challenge, a Set-LLM version of Gemma 2B reached ~65% accuracy, compared to the base model's ~55% average.
  • Efficiency: Set-LLM achieves the robustness of exhaustive majority voting with zero runtime overhead compared to a single-pass standard LLM.

Limitations and Future Work

Implementing Set-LLM requires finetuning (e.g., via LoRA) because the shift from causal to prefix/set masks alters the model's fundamental processing logic. Additionally, while the method is mathematically invariant, hardware-level rounding errors in lower precisions (like bfloat16) can introduce minor variations. Future research may extend this framework to Retrieval-Augmented Generation (RAG), ensuring that the order of retrieved documents does not bias the final generated response.

Summary updated

BibTeX
@inproceedings{egressy2025set,
  author = {Beni Egressy and Jan Stühmer},
  title = {{Set-LLM: A Permutation-Invariant LLM}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=Eyis2h3tba},
}
Figure