Compressing Context to Enhance Inference Efficiency of Large Language Models

Yucheng Li, Bo Dong, Chenghua Lin, Frank Guerin
10/9/2023
cs.CL

No official code found. Best implementation: liyucheng09/Selective_Context (423 stars, last commit 2024-02-12).

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.

View on arXivView PDF

Code Implementations(1)

Compress your input to ChatGPT or other LLMs, to let them process 2x more content and save 40% memory and GPU time.

42325Python, Jupyter NotebookMar 29, 20232 years ago
chatgptllmsnlp

Similar Papers

Cite this paper

@article{li2023compressing,
  title  = {Compressing Context to Enhance Inference Efficiency of Large Language Models},
  author = {Yucheng Li and Bo Dong and Chenghua Lin and Frank Guerin},
  year   = {2023},
  eprint = {2310.06201},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.06201v1}
}

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/2310.06201.svg)](https://codeofpaper.com/paper/2310.06201)

Discussion