In-Context Former: Lightning-fast Compressing Context for Large Language Model

Xiangfeng Wang, Zaiyi Chen, Zheyong Xie, Tong Xu, Yongyi He +1 more
6/19/2024
cs.CL

No official code found. Best implementation: wonderful9462/IC-Former (21 stars, MIT, last commit 2024-11-21).

Abstract

With the rising popularity of Transformer-based large language models (LLMs), reducing their high inference costs has become a significant research focus. One effective approach is to compress the long input contexts. Existing methods typically leverage the self-attention mechanism of the LLM itself for context compression. While these methods have achieved notable results, the compression process still involves quadratic time complexity, which limits their applicability. To mitigate this limitation, we propose the In-Context Former (IC-Former). Unlike previous methods, IC-Former does not depend on the target LLMs. Instead, it leverages the cross-attention mechanism and a small number of learnable digest tokens to directly condense information from the contextual word embeddings. This approach significantly reduces inference time, which achieves linear growth in time complexity within the compression range. Experimental results indicate that our method requires only 1/32 of the floating-point operations of the baseline during compression and improves processing speed by 68 to 112 times while achieving over 90% of the baseline performance on evaluation metrics. Overall, our model effectively reduces compression costs and makes real-time compression scenarios feasible.

View on arXivView PDF

Code Implementations(1)

MIT

Code for "In-Context Former: Lightning-fast Compressing Context for Large Language Model" (Findings of EMNLP 2024)

212Shell, PythonSep 23, 20241 years agoMIT

Cite this paper

@article{wang2024incontext,
  title  = {In-Context Former: Lightning-fast Compressing Context for Large Language Model},
  author = {Xiangfeng Wang and Zaiyi Chen and Zheyong Xie and Tong Xu and Yongyi He and Enhong Chen},
  year   = {2024},
  eprint = {2406.13618},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2406.13618v2}
}

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

Discussion