Abstract
Large Language Models (LLMs) are inherently sensitive to token order, which can lead to inconsistent performance in tasks where the sequence of items is semantically irrelevant, such as document retrieval or multiple-choice questions. We present RoToR, a zero-shot approach that ensures order-invariance through a stable global sorting strategy and circular position ID assignment. RoToR maintains model performance by staying close to the training distribution and introduces a "Selective Routing" mechanism to handle mixed order-sensitive and order-invariant tasks. Experimental results demonstrate that RoToR is significantly faster and more computationally efficient than previous methods while achieving state-of-the-art robustness.
Introduction: The Challenge of Positional Bias
Language models are trained on sequential human language, making them naturally sensitive to word order. However, many real-world applications involve data where order should not matter—such as rows in a database, a list of retrieved documents in a Retrieval-Augmented Generation (RAG) system, or options in a multiple-choice exam.
LLMs often exhibit positional bias, such as the "lost-in-the-middle" phenomenon, where models struggle to retrieve information located in the center of a long context. While previous zero-shot methods like PINE attempted to address this by dynamically re-assigning position IDs based on query relevance, they often introduced distribution mismatches that hurt performance and significantly increased computational overhead.
Methodology: RoToR and Selective Routing
RoToR introduces two primary innovations to achieve robust order-invariance without sacrificing efficiency.
1. Rotary Position ID Assignment (RoToR)
Instead of re-calculating the optimal order for every token, RoToR employs a global sorting strategy (e.g., lexical sorting of text segments) that remains fixed during processing. To simulate bidirectional understanding within a standard causal (left-to-right) model, RoToR uses circular assignment, giving each segment a turn at being "at the end" of the sequence through circular shifts of position IDs.
This approach ensures stability and prevents "position ID collisions," where different items are mistakenly assigned the same ID. By keeping the input structure closer to the model's training data, RoToR preserves pre-trained reasoning capabilities.
2. Selective Routing
Real-world tasks are often "mixed," containing both order-sensitive and order-invariant components. For instance, a multiple-choice question might include an option like "None of the above," which must remain at the end. RoToR addresses this via an adaptive framework:
- The input is processed by both a standard model and the RoToR-enhanced model.
- The system compares the confidence scores (output probabilities). If the original model shows high confidence, it likely captured an order-sensitive nuance, and its output is used. Otherwise, the system routes the request to the more robust RoToR branch.
Evaluation and Key Results
The researchers evaluated RoToR across three benchmarks: Lost in the Middle (LitM), Knowledge Graph QA (KGQA), and MMLU.
- Efficiency and Speed: RoToR is significantly faster than PINE. On the LitM benchmark with 30 documents, it achieved a 43% reduction in total runtime. For large-scale models like Qwen-72B, RoToR reduced the additional FLOPs required for invariance by up to 98%.
- Robustness: While standard models experienced performance drops when input segments were shuffled (e.g., a 2.8 point drop on MMLU for Llama-3.1-8B), RoToR’s performance remained statistically stable.
- Zero Collisions: By using lexical sorting, RoToR achieved a 0% collision rate, ensuring every segment remains uniquely identifiable to the model.
Key Insights
A major takeaway from this work is that "less is more." Simple, query-agnostic global sorting performs better than complex, query-dependent attention-based sorting because it provides a stable signal that doesn't disrupt the model's internal activations. Previous methods failed by pushing LLMs too far out of their "comfort zone" (training distribution), whereas RoToR’s minimal modifications preserve reasoning performance.
Limitations and Future Work
Currently, RoToR assumes a "Prefix + Parallel Segments + Suffix" structure, which may need adaptation for more complex, interleaved formats. Future work may explore more sophisticated deterministic sorting algorithms and the integration of specialized kernels like FlashAttention to scale RoToR to massive contexts exceeding 100k tokens.
Summary updated