更快更好的查询(FBQ):从首个生成的词元中学习未来位置探针
摘要
该论文提出了 Faster and Better Query(FBQ),通过在首个生成 token 的嵌入上学习加性位置偏移,构建低成本的伪查询,用于提示词缓存选择,仅需一次前向传播即可在 LongBench 上达到八步 Lookahead Q-Cache 的性能。
查看缓存全文
缓存时间: 2026/11/27 09:32
# Faster and Better Query (FBQ)Learning Future-Position Probes from the First Generated Token
Source: [https://arxiv.org/html/2611.33679](https://arxiv.org/html/2611.33679)
###### Abstract
When a large language model \(LLM\) evicts prompt keys and values at the end of prefill, it must decide what to keep before it sees the queries from subsequent decoding steps\. Generating a draft continuation can approximate those queries at the cost of extra autoregressive steps\. Can we use the embedding of the first output token, already available from the final prefill logits, to construct low\-cost pseudo queries that approximate future decoding queries? We start with FTQ\-8, which places eight copies of the first token ID at consecutive future positions and reads their attention to the prompt in one causal forward pass\. Each copy sees a different prefix, but a generic opening such as*the*offers a poor literal guess for seven successive tokens\. Faster and Better Query \(FBQ\) preserves the first embedding and learns an additive offset at each of the seven remaining positions\. We train these offsets to predict the average prompt attention of a full\-cache continuation\. On LongBench, FBQ performs comparably to eight\-step Lookahead Q\-Cache at the same cache budget, using a single forward pass to compute all probe queries\.
Figure 1:FBQ uses the first output tokenggto select a prompt cache\. FTQ\-8 repeatsE\(g\)E\(g\)at all eight positions\. FBQ learns seven offsets offline from full\-cache continuation attention\. After selection, it discards the probe KV and processesggat its original positionLL\.## 1Introduction
Consider two questions about the same long report: one asks who approved an expenditure, the other asks for the report’s main findings\. A model might begin both answers with*the*\. A cache eviction rule must decide, before either answer unfolds, which parts of the report will still be available when the model generates a name or summarizes a later section\. The first output token is a particularly interesting signal at this point\. Its identity reflects a decision the model has already made using the full prompt\. Its attention query, once computed in the context of the question, can differ across the two requests even when their first token IDs coincide\.
Lookahead Q\-Cache \(LAQ\) estimates the importance of prompt positions from pseudo lookahead queries\([Wang et al\., 2025](https://arxiv.org/html/2611.33679#bib.bib6)\)\. Generating a draft continuation gives the queries plausible lexical context, at the cost of a sequential dependency between draft steps\. We explore how far the first committed output token alone can take this idea\. Our starting point, FTQ\-8, inserts its ID into eight consecutive positions after the prompt on a temporary cache branch\. All eight inputs are available immediately\. With a causal mask, each later copy can attend to a longer prefix of the block, and the model applies the positional encoding for its actual future position\. Thus repeating an ID yields eight contextualized queries, even though the method predicts only one vocabulary item\.
Repetition also imposes a strong lexical assumption\. A model that starts an answer with*this*may next produce a noun, a verb, or a reference to a passage\. FTQ\-8 supplies the embedding of*this*in each case\. We retain the part of FTQ\-8 that is grounded in the model’s own decision and relax the part that extrapolates it\. In Faster and Better Query \(FBQ, Figure[1](https://arxiv.org/html/2611.33679#S0.F1)\), the first position takes the committed token unchanged\. Each later position starts from the same embedding and adds a learned vector\. These offsets can change which prompt evidence a probe attends to without requiring the probe to decode a plausible word\.
An exploratory run first motivated this construction\. Across 16 tasks, eight repeated positions scored 35\.06, compared with 34\.69 for 32 repeated positions in the same result series\. A residual\-probe variant in that series scored 35\.37\. These observations favored investigating the contents of a short probe block over simply lengthening it\. We report that pilot separately from our main LAQ comparison because its full\-cache reference was 38\.72\. In the main experiment, the reference is 48\.07\. All comparisons below specify the result series from which the numbers come\.
## 2From a token ID to future queries
### FTQ\-8\.
Letxxbe a prompt of lengthLLand letggbe the first output token selected from its final prefill logits under the decoding policy\. On a branch of the prompt cache, placeggat positionsL,…,L\+7L,\\ldots,L\+7\(zero\-based\)\. With input embedding tableEE, all eight rows areE\(g\)E\(g\)\. For rowtt, the causal mask exposes the prompt and rows0,…,t0,\\ldots,t\. At row zero the frozen model therefore computes the query that processing the real first output token would produce on the full prompt\. For later rows, the state depends on both the new position and the representations of earlier copies\. They probe subsequent decoding positions in one pass\. The generated answer receives only the committed tokengg\.
### FBQ\.
For embedding dimensiondd, introduce seven vectorsδ1,…,δ7∈ℝd\\delta\_\{1\},\\ldots,\\delta\_\{7\}\\in\\mathbb\{R\}^\{d\}\. The temporary input block is
u0\\displaystyle u\_\{0\}=E\(g\),\\displaystyle=E\(g\),ut\\displaystyle u\_\{t\}=E\(g\)\+δt,1≤t≤7\.\\displaystyle=E\(g\)\+\\delta\_\{t\},\\qquad 1\\leq t\\leq 7\.\(1\)The vectors are shared across requests and initialized to zero, which recovers the FTQ\-8 inputs exactly\. The base embedding changes withggand every row still attends to the particular prompt\. For two requests with the same opening token, the input blocks coincide but their queries can differ\. The causal mask also prevents any learned offset from altering the first query\. This gives the scorer one unchanged observation of the actual decoding trajectory throughout training\.


Figure 2:Query diagnostics on a GovReport example with Qwen2\.5\-7B\-Instruct\. Left: a joint t\-SNE of post\-RoPE queries at eight future positions for layer 13, head 0\. Matching outline markers reuse the queries before reranking\. Right: parallel and orthogonal errors relative to the corresponding FullKV query, normalized by its norm, for 16 layer/head pairs at eight positions each\. Each point’s radius equals its original relative error\.
### A query\-level observation\.
Figure[2](https://arxiv.org/html/2611.33679#S2.F2)compares queries with those from a continuation generated using the full prompt cache\. The repeated\-ID construction yields distinct queries at successive positions in the head shown\. To quantify alignment, we pair each probe query with the full\-cache query at the same layer, head and position and measure relative Euclidean distance in the original 128\-dimensional space\. Across 128 such pairs on this example, the mean is 0\.596 for FTQ\-8, 0\.565 for the residual probes and 0\.754 for the DapQ8 content\-reconstruction control\. The residual reduces the mean distance by 0\.031, about 5\.2% relative to FTQ\-8\. These are measurements within one prompt\. The 128 pairs share that prompt, and their distances measure query alignment rather than task accuracy\.
### What the offsets learn\.
Offline, the full\-cache model generates a continuation\. Its first 32 decoding positions provide a teacher map of attention to the prompt\. For a fixed layer and head, writeat\(i\)a\_\{t\}\(i\)for a probe’s attention to prompt positionii\. The softmax includes prompt keys and causally visible probe keys\. We take the prompt slice of the resulting probabilities and apply a width\-five average pool along the prompt after averaging over the eight rows:
sδ\(i\)=Pool5\[18∑t=07at\]\(i\)\.s\_\{\\delta\}\(i\)=\\operatorname\{Pool\}\_\{5\}\\\!\\left\[\\tfrac\{1\}\{8\}\\textstyle\\sum\_\{t=0\}^\{7\}a\_\{t\}\\right\]\(i\)\.\(2\)We constructs⋆s^\{\\star\}analogously using the teacher’s 32 genuine continuation positions\. For each document, we average\(sδ\(i\)−s⋆\(i\)\)2\(s\_\{\\delta\}\(i\)\-s^\{\\star\}\(i\)\)^\{2\}over prompt positions, heads and layers, then average over documents\. Gradients pass through the frozen transformer to the seven offsets\. The teacher supplies attention targets offline\. At inference, the response prefix required to construct the probes consists solely ofgg\.
### Selecting and using the cache\.
After fitting the offsets, we freeze them and calibrate a linear scorer against membership in the teacher’s top\-BBprompt positions\. The scorer uses both the pooled meansδs\_\{\\delta\}and the pooled attention of row zero\. Each map supplies a rank percentile and a log score relative to its head mean\. Normalized prompt position and a bias give six features in total\. This combination lets the scorer preserve evidence favored by the first genuine query even when averaging the block lowers its rank\. We keep theBBhighest\-scoring prompt positions for each layer and query head, restore their original order, discard the temporary branch, and continue decoding from the retained prompt cache with the committed first token\. Generated tokens subsequently add their own cache entries\.
### Cost of the probe\.
For a prompt of lengthLL, one head evaluates8L8Lprompt\-query dot products for the probe block, as well as attention within the short causal suffix\. Batching changes the sequential dependence of these computations\. All eight embeddings are specified by Eq\.[1](https://arxiv.org/html/2611.33679#S2.E1)before the first layer runs\. In a draft that chooses each subsequent token from the previous step’s logits, those token choices serialize the corresponding forwards\. FBQ still incurs a post\-prefill forward and reads the prompt cache to score it\. Wall\-clock savings depend on how the implementation handles these reads and the temporary branch\.
## 3Experimental results
We evaluate on the 16\-task English and code subset of LongBench\([Bai et al\., 2024](https://arxiv.org/html/2611.33679#bib.bib2)\)\. It covers single\- and multi\-document question answering, summarization, few\-shot learning, synthetic tasks and code completion\. The main comparison uses Mistral\-7B v0\.3 and a history budget of 128 prompt positions per head for the compressed methods\. Each method covers 3,750 examples\. We report the arithmetic mean of the 16 task scores, giving each task equal weight\. FullKV retains the entire prompt\. LAQ\-2 and LAQ\-8 use two and eight lookahead steps\. We show all three evaluated residual checkpoints so that the spread across training epochs is visible\.
Table 1:LongBench results on Mistral\-7B v0\.3, grouped by task family\. The upper block reproduces the Mistral\-7B\-Instruct\-v0\.3 results of[Liu et al\. \(2025\)](https://arxiv.org/html/2611.33679#bib.bib5)\(Table 2\)\. The lower block gives our runs\. Each FullKV row is the uncompressed reference for its block\. Bold marks the highest displayed score among compressed methods within each block, including ties\. Avg\. is the 16\-task mean reported by the corresponding source\.### Within\-protocol comparison\.
FBQ reaches 45\.73 at epochs three and four, 0\.85 above LAQ\-2 and 0\.07 above LAQ\-8 at the reported precision \(Table[1](https://arxiv.org/html/2611.33679#S3.T1)\)\. Epoch two is 0\.15 below LAQ\-8\. The means place the later checkpoints close to LAQ\-8, with a substantial gap still remaining to full\-cache performance\. Descriptive wins also depend on the task\. Epoch three scores higher than LAQ\-8 on nine tasks and lower on seven\. Epoch four scores higher on nine, ties on one and scores lower on six\.
The largest gain occurs on PassageCount, where both methods have low absolute scores\. The largest decline occurs on LCC, whereas RepoBench\-P, the other code task, improves by 0\.39\. Even within a broad category, changing the query construction can favor different examples or tasks\. Identical displayed means for epochs three and four likewise conceal changes in individual tasks\.
### Published baselines at budget 128\.
Table[1](https://arxiv.org/html/2611.33679#S3.T1)places our evaluation alongside the Mistral results reported by[Liu et al\. \(2025\)](https://arxiv.org/html/2611.33679#bib.bib5)\. Judge Q improves on the other four eviction methods in that experiment\. Its score of 42\.38 is 3\.63 below its full\-cache reference\. Our corresponding gap is 2\.34\. The full\-cache references already differ by 2\.06 points across evaluations\. For example, the published full\-cache RepoBench\-P score is 46\.28, compared with 62\.56 in our run\. Nominal agreement on the backbone and budget therefore leaves appreciable protocol variation\. A direct estimate of the gain over Judge Q requires evaluating its checkpoint with the same prompt processing, generation and scoring pipeline\.
## 4Why the quality curves can meet
The probe learns real\-valued scores, whereas the decoder receives a set of retained positions\. Consider a single head and letssbe a reference vector of final selection scores, in decreasing order\. Denote the gap at the budget boundary byγ=s\(B\)−s\(B\+1\)\\gamma=s\_\{\(B\)\}\-s\_\{\(B\+1\)\}\. For any estimates^\\hat\{s\}, the sufficient condition
2‖s^−s‖∞<γ2\\\|\\hat\{s\}\-s\\\|\_\{\\infty\}<\\gamma\(3\)preserves the selected set\. Indeed, for every retainediiand discardedjj, their estimated difference is at leastγ−2‖s^−s‖∞\>0\\gamma\-2\\\|\\hat\{s\}\-s\\\|\_\{\\infty\}\>0\. Consequently two estimators can disagree on attention scores and still pass exactly the same cache to decoding\. With identical caches at all heads and layers and identical deterministic decoding, their generated answers coincide\.
Equation[3](https://arxiv.org/html/2611.33679#S4.E3)helps interpret the small mean difference between LAQ\-8 and FBQ\. It gives a mechanism by which further improvements in score estimation can leave answers unchanged\. Applying it empirically requires measuring the final selection scores after calibration\. A small training MSE averaged over thousands of positions can coexist with a large error on the token ranked 128th\. Equal task means can also arise from different answers and opposite gains across tasks, as Table[1](https://arxiv.org/html/2611.33679#S3.T1)illustrates\. The condition makes no assumption that LAQ achieves the best possible ranking\.
## 5Related work
StreamingLLM retains the initial attention sinks and a recent token window\([Xiao et al\., 2024](https://arxiv.org/html/2611.33679#bib.bib7)\)\. H2O keeps recent tokens alongside earlier tokens with high accumulated attention\([Zhang et al\., 2023](https://arxiv.org/html/2611.33679#bib.bib8)\)\. At prefill, SnapKV uses queries from the end of the prompt to select positions for each head\([Li et al\., 2024](https://arxiv.org/html/2611.33679#bib.bib4)\)\. PyramidKV assigns larger cache budgets to lower layers, where attention is more widely distributed\([Cai et al\., 2025](https://arxiv.org/html/2611.33679#bib.bib3)\)\.
LAQ uses pseudo lookahead queries to estimate which cached positions will matter during decoding\([Wang et al\., 2025](https://arxiv.org/html/2611.33679#bib.bib6)\)\. Judge Q trains soft tokens to match the prompt attention of actual response tokens\([Liu et al\., 2025](https://arxiv.org/html/2611.33679#bib.bib5)\)\. LookaheadKV combines learned lookahead tokens with low\-rank adapters to estimate future attention without draft generation\([Ahn et al\., 2026](https://arxiv.org/html/2611.33679#bib.bib1)\)\. FBQ studies a narrower parameterization: a prompt\-dependent lexical base drawn from the model’s own output, an unchanged first query, and seven shared offsets applied at distinct future positions\. The zero\-offset construction gives a concrete control for learning in this family\.
## 6Conclusion
FTQ\-8 turns the first output ID into a block of contextualized future queries\. FBQ retains the first query and learns how the remaining seven inputs should deviate from literal repetition\. In our Mistral runs, this one\-block construction reaches 45\.73 against 45\.66 for eight\-step LAQ\. The remaining gap to FullKV and the opposing task\-level changes identify where a closer study of the retained evidence is warranted\.
## Limitations
The main comparison covers one model family and one budget\. A matched zero\-offset run under the main evaluation protocol is needed to isolate the gain due to residual training\. The pilot motivates the design but uses a different full\-cache reference\. The examples*the*and*this*illustrate the motivation\. Establishing a specific benefit on generic openings requires stratifying examples by first token and comparing FTQ\-8 with FBQ within each group\. The reported task aggregates do not provide a paired uncertainty interval for the 0\.07\-point difference\.
Our preliminary system measurements favor FBQ over LAQ in peak memory, time to first token and time per output token\. Quantitative claims about the size of these gains require timings and memory measurements for the same checkpoint, hardware, workload and token\-emission convention\. In particular, a server can emit the committed first token either before or after cache selection, which changes which part of the probe cost appears in first\-token latency\.
## References
- Ahn et al\. \(2026\)Jinwoo Ahn, Ingyu Seong, Akhil Kedia, Junhan Kim, Hyemi Jang, Kangwook Lee, and Yongkweon Jeon\. 2026\.[LookaheadKV: Fast and accurate KV cache eviction by glimpsing into the future without generation](https://openreview.net/forum?id=RVLMGPXt2i)\.In*International Conference on Learning Representations*\.
- Bai et al\. \(2024\)Yushi Bai, Xin Lv, Jiajie Zhang, Hongchang Lyu, Jiankai Tang, Zhidian Huang, Zhengxiao Du, Xiao Liu, Aohan Zeng, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li\. 2024\.[LongBench: A bilingual, multitask benchmark for long context understanding](https://doi.org/10.18653/v1/2024.acl-long.172)\.In*Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\)*, pages 3119–3137\. Association for Computational Linguistics\.
- Cai et al\. \(2025\)Zefan Cai, Yichi Zhang, Bofei Gao, Yuliang Liu, Yucheng Li, Tianyu Liu, Keming Lu, Wayne Xiong, Yue Dong, Junjie Hu, and Wen Xiao\. 2025\.[PyramidKV: Dynamic KV cache compression based on pyramidal information funneling](https://openreview.net/forum?id=ayi7qezU87)\.In*Second Conference on Language Modeling*\.
- Li et al\. \(2024\)Yuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acyr Locatelli, Hanchen Ye, Tianle Cai, Patrick Lewis, and Deming Chen\. 2024\.[SnapKV: LLM knows what you are looking for before generation](https://doi.org/10.52202/079017-0722)\.In*Advances in Neural Information Processing Systems*, volume 37, pages 22947–22970\. Curran Associates, Inc\.
- Liu et al\. \(2025\)Yijun Liu, Yixuan Wang, Yuzhuang Xu, Shiyu Ji, Yang Xu, Qingfu Zhu, and Wanxiang Che\. 2025\.[Judge Q: Trainable queries for optimized information retention in KV cache eviction](https://arxiv.org/abs/2509.10798)\.arXiv:2509\.10798\.
- Wang et al\. \(2025\)Yixuan Wang, Shiyu Ji, Yijun Liu, Yuzhuang Xu, Yang Xu, Qingfu Zhu, and Wanxiang Che\. 2025\.[Lookahead Q\-cache: Achieving more consistent KV cache eviction via pseudo query](https://doi.org/10.18653/v1/2025.emnlp-main.1732)\.In*Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing*, pages 34158–34174\. Association for Computational Linguistics\.
- Xiao et al\. \(2024\)Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis\. 2024\.[Efficient streaming language models with attention sinks](https://proceedings.iclr.cc/paper_files/paper/2024/file/5e5fd18f863cbe6d8ae392a93fd271c9-Paper-Conference.pdf)\.In*International Conference on Learning Representations*\.
- Zhang et al\. \(2023\)Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, Zhangyang Wang, and Beidi Chen\. 2023\.[H2O: Heavy\-hitter oracle for efficient generative inference of large language models](https://doi.org/10.52202/075280-1506)\.In*Advances in Neural Information Processing Systems*, volume 36, pages 34661–34710\. Curran Associates, Inc\.相似文章
信号与查询:高效利用词元的智能体上下文发现
该论文介绍了 Signals and Queries(S&Q),这是一种用于 Parlant 4.0 的轻量级第一阶段相关性过滤器。它采用在大语言模型生成的样本上离线训练的逻辑回归分类器,在保持高召回率的同时,每轮筛除至少 30% 的候选行为策略,性能优于 top-K 检索和余弦相似度阈值检索。
LazyAttention:通过延迟位置编码实现高效检索增强生成
LazyAttention 提出了一种新颖的注意力机制,通过延迟位置编码来实现跨多个请求的零拷贝、位置无关的 KV 缓存复用。在文档分布倾斜的 RAG 场景下,该方法与 Block-Attention 相比,首 token 生成时间缩短至原来的 1/1.37×,推理吞吐量提升 1.40×。
ZoAQ: 基于查询重用耦合的自适应零阶查询
ZoAQ 提出了一种自适应零阶优化方法,通过重用过去的查询来减少评估次数,在合成任务中节省了43-48%的查询,并在黑盒攻击中实现了高成功率。
KVFetch:面向 KV Cache 压缩所缺失的另一半的时序预取
论文提出了 KVFetch,一个无需训练的框架,通过在基于评分的 KV cache 压缩器中加入时序召回通道,解决压缩导致的"序列遗忘"问题(即压缩后逐字复制能力失效),将复制性能从 0.8 恢复至 78.4,并在相同预算下将 RULER-16K 平均得分提升 +8.4。
在查询关注之处分配比特:具有注意力保持变换的KV缓存向量量化
本文提出NOVA-KV,一种用于KV缓存量化的变换编码方法,它利用注意力保持变换在查询实际关注的位置分配比特,与先前方法相比,在低比特率下提高了长上下文检索精度。