Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

Efficient Many-Shot In-Context Learning with Dynamic Block-Sparse Attention

About

Many-shot in-context learning has recently shown promise as an alternative to finetuning, with the major advantage that the same model can be served for multiple tasks. However, this shifts the computational burden from training-time to inference-time, making deployment of many-shot ICL challenging to justify in-practice. This cost is further increased if a custom demonstration set is retrieved for each inference example. We present Dynamic Block-Sparse Attention, a training-free framework for retrieval-based many-shot in-context learning. By combining carefully designed block-sparse attention and retrieval of cached groups of demonstrations, we achieve comparable per-example latency to finetuning while maintaining on average >95% of the best method's accuracy across strong ICL and finetuning baselines. We hope that this will further enable the deployment of many-shot ICL at scale.

Emily Xiao, Chin-Jou Li, Yilin Zhang, Graham Neubig, Amanda Bertsch• 2025

Related benchmarks

TaskDatasetResultRank
Text ClassificationTREC
Accuracy95
179
Intent ClassificationBanking77
Accuracy89
24
Text ClassificationTREC Fine
Accuracy0.88
8
Text ClassificationClinic
Accuracy90
8
Text ClassificationNLU
Accuracy88
8
Inference Efficiency30k Context Length Llama-2-7B
Inference Throughput (QPS)3.4
4
Inference Efficiency30k Context Length (Llama-3.1-8B)
Inference Throughput (QPS)12.8
4
Inference Efficiency90k Context Length Llama-3.1-8B
Throughput (queries/s)7.7
4
Many-shot ICL Efficiency30k Context Length Pool (Llama-3.1-8B)
Inference Latency (Relative)0.1
4
Showing 9 of 9 rows

Other info

Code

Follow for update