Lune

EMNLP2023Top-tier venue

Compressing Context to Enhance Inference Efficiency of Large Language Models

Yucheng Li, Bo Dong, Frank Guerin, Chenghua Lin

Abstract

Large language models (LLMs) achieved remarkable performance across various tasks. However, they face challenges in managing long documents and extended conversations, due to significantly increased computational requirements, both in memory and inference time, and potential context truncation when the input exceeds the LLM's fixed context length. This paper proposes a method called Selective Context that enhances the inference efficiency of LLMs by identifying and pruning redundancy in the input context to make the input more compact. We test our approach using common data sources requiring long context processing: arXiv papers, news articles, and long conversations, on tasks of summarisation, question answering, and response generation. Experimental results show that Selective Context significantly reduces memory cost and decreases generation latency while maintaining comparable performance compared to that achieved when full context is used. Specifically, we achieve a 50% reduction in context cost, resulting in a 36% reduction in inference memory usage and a 32% reduction in inference time, while observing only a minor drop of .023 in BERTscore and .038 in faithfulness on four downstream applications, indicating that our method strikes a good balance between efficiency and performance. Code and data are available at https://github.com/ liyucheng09/Selective_Context .

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

90 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Learning to Compress Prompts with Gist Tokens cites Language Models are Few-Shot Learners
  • Mental-LLM: Leveraging Large Language Models for Mental Health Prediction via Online Text Data cites Language Models are Few-Shot Learners
  • Measuring Massive Multitask Language Understanding cites Language Models are Few-Shot Learners
  • MEM1: Learning to Synergize Memory and Reasoning for Efficient Long-Horizon Agents cites Language Models are Few-Shot Learners
  • C3oT: Generating Shorter Chain-of-Thought Without Compromising Effectiveness cites Learning to Compress Prompts with Gist Tokens
  • C3oT: Generating Shorter Chain-of-Thought Without Compromising Effectiveness cites Adapting Language Models to Compress Contexts
  • Adapting Language Models to Compress Contexts cites Learning to Compress Prompts with Gist Tokens
  • Adapting Language Models to Compress Contexts cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers90

  1. Mental-LLM: Leveraging Large Language Models for Mental Health Prediction via Online Text DataXuhai Xu, Bingsheng Yao, Yuanzhe Dong, Saadia Gabriel et al.UbiComp 2024 · 281 citations
  2. MemAgent: Reshaping Long-Context LLM with Multi-Conv RL-based Memory AgentHongli Yu, Tinghong Chen, Jiangtao Feng, Jiangjie Chen et al.ICLR 2026 · 231 citations
  3. MEM1: Learning to Synergize Memory and Reasoning for Efficient Long-Horizon AgentsZijian Zhou, Ao Qu, Zhaoxuan Wu, Sunghwan Kim et al.ICLR 2026 · 223 citations
  4. C3oT: Generating Shorter Chain-of-Thought Without Compromising EffectivenessYu Kang, Xianghui Sun, Liangyu Chen, Wei ZouAAAI 2025 · 162 citations
  5. LightMem: Lightweight and Efficient Memory-Augmented GenerationJizhan Fang, Xinle Deng, Haoming Xu, Ziyan Jiang et al.ICLR 2026 · 162 citations

Builds on5

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. BERTScore: Evaluating Text Generation with BERTTianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger et al.ICLR 2020 · 8,443 citations
  3. Measuring Massive Multitask Language UnderstandingDan Hendrycks, Collin Burns, Steven Basart, Andy Zou et al.ICLR 2021 · 7,905 citations
  4. Learning to Compress Prompts with Gist TokensJesse Mu, Xiang Li, Noah D. GoodmanNeurIPS 2023 · 488 citations
  5. Adapting Language Models to Compress ContextsAlexis Chevalier, Alexander Wettig, Anirudh Ajith, Danqi ChenEMNLP 2023 · 34 citations

Related papers

  1. Dynamic Context Pruning for Efficient and Interpretable Autoregressive TransformersSotiris Anagnostidis, Dario Pavllo, Luca Biggio, Lorenzo Noci et al.NeurIPS 2023 · 95 citations
  2. SCA: Selective Compression Attention for Efficiently Extending the Context Window of Large Language ModelsHuanran Zheng, Wei Zhu, Xiaoling WangEMNLP Findings 2024
  3. Pretraining Context Compressor for Large Language Models with Embedding-Based MemoryYuhong Dai, Jianxun Lian, Yitian Huang, Wei Zhang et al.ACL 2025
  4. Accelerating Inference of Retrieval-Augmented Generation via Sparse Context SelectionYun Zhu, Jia-Chen Gu, Caitlin Sikora, Ho Ko et al.ICLR 2025
  5. Extending Context Window of Large Language Models via Semantic CompressionWeizhi Fei, Xueyan Niu, Pingyi Zhou, Lu Hou et al.ACL Findings 2024 · 20 citations
Dusk over the sea between two cliffs drawn in fine vertical lines