Compressing Context to Enhance Inference Efficiency of Large Language Models
Written for the Research library (claude-opus-5-5) from the paper text. Original — aclanthology.org/2023.emnlp-main.391.pdf
Summary
Transformer LLMs become expensive in memory and latency on long inputs such as full papers or extended chats, and they may cut off text that exceeds their fixed window. The authors propose Selective Context, a model-agnostic preprocessing step that removes redundant parts of the prompt before inference. A small causal language model (e.g., GPT, OPT or LLaMA) scores each token by self-information (surprisal). Because surprisal is additive, these scores are summed into larger lexical units: noun phrases via spacy or sentences via NLTK. A percentile threshold then decides which units to keep, discarding the least informative ones. The method was tested on newly collected long-input sets of arXiv papers, BBC News articles and ShareGPT conversations. The evaluation covered four tasks: producing summaries, answering questions, rebuilding the source text, and holding a conversation. Outputs were compared against answers produced from the full context. Halving the context lowered memory and time substantially, with only small quality losses. This makes the approach a cheap complement to architectural efficiency methods.
Key points
- With 50% of the context removed, inference memory fell by about 36% and inference time by about 32%. BERTScore dropped by only .023 and faithfulness by .038.
- In a vicuna_13b case study, CUDA memory went from 77,695 MB to 61,885 MB and per-token latency from 110.8 to 76.3 ms. Building the compressed context took a one-off 46.1 ms.
- Phrase-level filtering consistently performed best, followed by token-level filtering. Sentence-level pruning gave unstable results.
- Instruction-tuned models handled the compressed input better than base llama models, which often failed to follow instructions.
- The authors note two limitations: verb phrases are not merged, and the best percentile depends on the task. Code and data are released on GitHub (liyucheng09/Selective_Context).
Cited by
- Quiet-STaR: Language models can teach themselves to think before speaking
- LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compression
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention
- LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compression
- R1-Searcher: Incentivizing the Search Capability in LLMs via Reinforcement Learning
Cite
@inproceedings{li2023compressing,
title = {{Compressing Context to Enhance Inference Efficiency of Large Language Models}},
author = {Li, Yucheng and Dong, Bo and Guerin, Frank and Lin, Chenghua},
booktitle = {Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing},
year = {2023},
doi = {10.18653/v1/2023.emnlp-main.391},
url = {https://doi.org/10.18653/v1/2023.emnlp-main.391}
}References
- Satanjeev Banerjee and Alon Lavie. 2005. Meteor: An automatic metric for mt evaluation with improved correlation with human judgments. In Proceedings of the acl workshop on intrinsic and extrinsic evaluation measures for machine translation and/or summarization, pages 65–72. find our card
- Iz Beltagy, Matthew E Peters, and Arman Cohan. 2020. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150. find
- Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. 2020. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901. find
- Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, et al. 2023. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712. find our card
- Razvan Bunescu and Oseremen O Uduehi. 2022. Distribution-based measures of surprise for creative language: Experiments with humor and metaphor. In Proceedings of the 3rd Workshop on Figurative Language Processing (FLP), pages 68–78. find
- Alexis Chevalier, Alexander Wettig, Anirudh Ajith, and Danqi Chen. 2023. Adapting language models to compress contexts. arXiv preprint arXiv:2305.14788. find our card
- Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. 2023. Vicuna: An open-source chatbot impressing gpt-4 with 90%* chatgpt quality. find
- Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. 2019. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509. find
- Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. 2018. Think you have solved question answering? try arc, the ai2 reasoning challenge. ArXiv, abs/1803.05457. find
- Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Xiaodong Song, and Jacob Steinhardt. 2020. Measuring massive multitask language understanding. ArXiv, abs/2009.03300. find our card
- Chin-Yew Lin. 2004. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out, pages 74–81. find
- Jesse Mu, Xiang Lisa Li, and Noah Goodman. 2023. Learning to compress prompts with gist tokens. arXiv preprint arXiv:2304.08467. find our card
- Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. 2002. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics, pages 311–318. find our card
- Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9. find
- Claude E Shannon. 1948. A mathematical theory of communication. The Bell system technical journal, 27(3):379–423. find
- Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. 2023. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971. find
- Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. Advances in neural information processing systems, 30. find
- Alex Wang, Kyunghyun Cho, and Mike Lewis. 2020. Asking and answering questions to evaluate the factual consistency of summaries. ArXiv, abs/2004.04228. find
- EC Wit and Marie Gillette. 1999. What is linguistic redundancy. University of Chicago. find
- Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. 2022. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068. find
- Tianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q Weinberger, and Yoav Artzi. 2019. Bertscore: Evaluating text generation with bert. arXiv preprint arXiv:1904.09675. find