Mixture of In-Context Experts Enhance LLMs' Long Context Awareness

Hongzhan Lin, Ang Lv, Yuhan Chen, Chen Zhu, Yang Song +2 more
2/3/2026

No official code found. Best implementation: p1nksnow/MoICE (14 stars, last commit 2025-01-07).

Abstract

Many studies have revealed that large language models (LLMs) exhibit uneven awareness of different contextual positions. Their limited context awareness can lead to overlooking critical information and subsequent task failures. While several approaches have been proposed to enhance LLMs' context awareness, achieving both effectiveness and efficiency remains challenging. In this paper, for LLMs utilizing RoPE as position embeddings, we introduce a novel method called"Mixture of In-Context Experts"(MoICE) to address this challenge. MoICE comprises two key components: a router integrated into each attention head within LLMs and a lightweight router-only training optimization strategy: (1) MoICE views each RoPE angle as an `in-context' expert, demonstrated to be capable of directing the attention of a head to specific contextual positions. Consequently, each attention head flexibly processes tokens using multiple RoPE angles dynamically selected by the router to attend to the needed positions. This approach mitigates the risk of overlooking essential contextual information. (2) The router-only training strategy entails freezing LLM parameters and exclusively updating routers for only a few steps. When applied to open-source LLMs including Llama and Mistral, MoICE surpasses prior methods across multiple tasks on long context understanding and generation, all while maintaining commendable inference efficiency.

View on arXivView PDF

Code Implementations(1)

p1nksnow/MoICECommunity100%

Official implementation for "Mixture of In-Context Experts Enhance LLMs’ Awareness of Long Contexts" (Accepted by Neurips2024)

143Shell, PythonMay 20, 20241 years ago

Similar Papers

Cite this paper

@article{lin2026mixture,
  title  = {Mixture of In-Context Experts Enhance LLMs' Long Context Awareness},
  author = {Hongzhan Lin and Ang Lv and Yuhan Chen and Chen Zhu and Yang Song and Hengshu Zhu and Rui Yan},
  year   = {2026},
  eprint = {2406.19598},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2406.19598},
  url    = {https://arxiv.org/abs/2406.19598},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2406.19598.svg)](https://codeofpaper.com/paper/2406.19598)

Discussion