Reproduce “Block-Attention for Efficient Prefilling” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Dongyang Ma, Yan Wang, Lan Tian

Block-attention, developed by researchers at Tencent, introduces a method to significantly reduce inference latency and computational cost during the prefilling stage of Large Language Models in Retrieval-Augmented Generation scenarios. The approach uses input segmentation, position re-encoding, and targeted fine-tuning to achieve up to a 98.7% reduction in Time To First Token without compromising model accuracy.

Key insights

  • Directly applying a block-attention mechanism to pre-trained LLMs without adaptation causes a substantial drop in performance, highlighting the necessity of targeted fine-tuning.
  • Proper position re-encoding is crucial for maintaining model accuracy and avoiding degradation when reusing cached KV states for blocks whose positions shift within the input context.
  • A hybrid fine-tuning approach that exposes the model to both block-wise and full-attention patterns allows it to efficiently handle structured long contexts while retaining its general-purpose LLM abilities and enabling seamless mode switching.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.