Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Block-Attention for Efficient Prefilling

About

We introduce Block-attention, an attention mechanism designed to address the increased inference latency and cost in Retrieval-Augmented Generation (RAG) scenarios. Traditional approaches often encode the entire context in an auto-regressive manner. Instead, Block-attention divides retrieved documents into discrete blocks, with each block independently calculating key-value (KV) states except for the final block. In RAG scenarios, by defining each passage as a block, Block-attention enables us to reuse the KV states of passages that have been seen before, thereby significantly reducing the latency and the computation overhead during inference. The implementation of Block-attention involves block segmentation, position re-encoding, and fine-tuning the LLM to adapt to the Block-attention mechanism. Experiments on 11 diverse benchmarks, including RAG, ICL, and general domains, demonstrate that after block fine-tuning, the Block-attention model not only achieves performance comparable to that of full-attention models, but can also seamlessly switch between the block and full attention modes without any performance loss. Notably, Block-attention significantly reduces the time to first token (TTFT) and floating point operations (FLOPs) to a very low level. It only takes 45 ms to output the first token for an input sequence with a total length of 32K. Compared to the full-attention models, the TTFT and corresponding FLOPs are reduced by 98.7% and 99.8%, respectively. Additionally, in Appendix A, we elaborate on how Block-attention is applied in Game AI scenario and the substantial potential benefits it entails. We strongly suggest researchers in the gaming field not to overlook this section.

Dongyang Ma, Yan Wang, Lan Tian• 2024

Related benchmarks

TaskDatasetResultRank
Question Answering2WikiMQA--
66
Question AnsweringNarrativeQA
Exact Match (EM)61
5
Question AnsweringTriviaQA
Exact Match (EM)72.3
5
KV Cache EfficiencyTrace-driven simulation 1 GB KV cache budget 100k-doc pool Zipf doc popularity
Low Skewness Hit Ratio1.84
4
KV Cache EfficiencyTrace-driven simulation 5 GB KV cache budget 100k-doc pool Zipf doc popularity
Hit Ratio (Low Skewness)7.67
4
KV Cache EfficiencyTrace-driven simulation 10 GB KV cache budget 100k-doc pool Zipf doc popularity
Low Skewness Hit Ratio10.86
4
KV Cache EfficiencyTrace-driven simulation 50 GB KV cache budget 100k-doc pool Zipf doc popularity
Hit Ratio (Low Skewness)17.46
4
KV Cache EfficiencyTrace-driven simulation No-limit KV cache budget 100k-doc pool Zipf doc popularity
Hit Ratio (Low Skewness)18.55
4
Few-shot classificationAG News Few-shot
TTFT Speedup1
4
Long-Context InferenceLong-context memory-constrained setting 16 docs x 8K tokens, 10 GB KV pool
Time To First Token (TTFT) (s)15.8
2
Showing 10 of 10 rows

Other info

Follow for update