AdapShot: Adaptive Many-Shot In-Context Learning with Semantic-Aware KV Cache Reuse

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Ou, Jie, Guo, Jinyu, Guo, Shiyao, Li, Yuang, Wu, Ruiqi, Wang, Zhaokun, Li, Wenyi, Tian, Wenhong
Format: Preprint
Veröffentlicht: 2026
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866917462129246208
author Ou, Jie
Guo, Jinyu
Guo, Shiyao
Li, Yuang
Wu, Ruiqi
Wang, Zhaokun
Li, Wenyi
Tian, Wenhong
author_facet Ou, Jie
Guo, Jinyu
Guo, Shiyao
Li, Yuang
Wu, Ruiqi
Wang, Zhaokun
Li, Wenyi
Tian, Wenhong
contents Many-Shot In-Context Learning (ICL) has emerged as a promising paradigm, leveraging extensive examples to unlock the reasoning potential of Large Language Models (LLMs). However, existing methods typically rely on a predetermined, fixed number of shots. This static approach often fails to adapt to the varying difficulty of different queries, leading to either insufficient context or interference from noise. Furthermore, the prohibitive computational and memory costs of long contexts severely limit Many-Shot's feasibility. To address the above limitations, we propose AdapShot, which dynamically optimizes shot counts and leverages KV cache reuse for efficient inference. Specifically, we design a probe-based evaluation mechanism that utilizes output entropy to determine the optimal number of shots. To bypass the redundant prefilling computation during both the probing and inference phases, we incorporate a semantics-aware KV cache reuse strategy. Within this reuse strategy, to address positional encoding incompatibilities, we introduce a decoupling and re-encoding method that enables the flexible reordering of cached key-value pairs. Extensive experiments demonstrate that AdapShot achieves an average performance gain of around 10% and a 4.64x speedup compared to state-of-the-art DBSA.
format Preprint
id arxiv_https___arxiv_org_abs_2605_03644
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle AdapShot: Adaptive Many-Shot In-Context Learning with Semantic-Aware KV Cache Reuse
Ou, Jie
Guo, Jinyu
Guo, Shiyao
Li, Yuang
Wu, Ruiqi
Wang, Zhaokun
Li, Wenyi
Tian, Wenhong
Artificial Intelligence
Many-Shot In-Context Learning (ICL) has emerged as a promising paradigm, leveraging extensive examples to unlock the reasoning potential of Large Language Models (LLMs). However, existing methods typically rely on a predetermined, fixed number of shots. This static approach often fails to adapt to the varying difficulty of different queries, leading to either insufficient context or interference from noise. Furthermore, the prohibitive computational and memory costs of long contexts severely limit Many-Shot's feasibility. To address the above limitations, we propose AdapShot, which dynamically optimizes shot counts and leverages KV cache reuse for efficient inference. Specifically, we design a probe-based evaluation mechanism that utilizes output entropy to determine the optimal number of shots. To bypass the redundant prefilling computation during both the probing and inference phases, we incorporate a semantics-aware KV cache reuse strategy. Within this reuse strategy, to address positional encoding incompatibilities, we introduce a decoupling and re-encoding method that enables the flexible reordering of cached key-value pairs. Extensive experiments demonstrate that AdapShot achieves an average performance gain of around 10% and a 4.64x speedup compared to state-of-the-art DBSA.
title AdapShot: Adaptive Many-Shot In-Context Learning with Semantic-Aware KV Cache Reuse
topic Artificial Intelligence
url https://arxiv.org/abs/2605.03644