跳到主内容
@wquguru
精选88r/LLMDevs(Reddit)技巧与观点

CacheVerifier:利用次近邻相似度提升缓存命中率

CacheVerifier: checking the 2nd closest cache match gave us +3.5 to 5 points hit rate at the same error rate, and AUC said it got worse

原文
发到 X
推荐理由

做LLM推理优化的同学必看,这个利用次近邻距离差过滤模糊匹配的 trick 非常实用,能直接提升缓存命中率且开销极小,建议在你的检索链路中复现验证。

So in CacheVerifier when a query lands in the gray zone, a small verifier decides if the cached answer is reusable. we only ever looked at the top match. turns out the runner up says a lot.

因此,在 CacheVerifier 中,当查询落入灰色区域时,一个小型验证器会判断缓存答案是否可复用。我们之前只查看了最佳匹配。结果发现,次佳匹配也提供了大量信息。

its basically Lowe's ratio test from SIFT. if the top match is way closer than the 2nd one, its probably the same question. if the two are nearly tied you're in a crowded spot full of similar but different prompts, and reuse is riskier. so we added gap = top1 sim minus top2 sim as one more feature. costs one extra neighbor in the vector query.

这本质上是 SIFT 中的 Lowe's ratio test(洛氏比率测试)。如果最佳匹配比第二匹配近得多,那很可能是同一个问题。如果两者几乎打平,你就处于一个充满相似但不同提示词的拥挤区域,此时复用的风险更高。因此,我们将 gap = top1 sim - top2 sim 作为另一个特征加入。这需要向量查询中多检索一个邻居。

On LmArena with gray zone error held at 2%, hit rate went up 3.46 points, and 5.31 when only 5% of hits get audited labels. +2.8 to +4.8 across 6 warm up settings. Quora +0.3, SearchQueries basically nothing.

在 LmArena 上,将灰色区域错误率控制在 2% 时,命中率提升了 3.46 个百分点;当仅有 5% 的命中获得审计标签时,提升幅度为 5.31 个百分点。在 6 种预热设置下,提升范围为 +2.8 到 +4.8。Quora 数据集提升 +0.3,SearchQueries 数据集基本无变化。

Funny part. AUC went down (0.760 to 0.751) so our own AUC check refused to enable it lol. the gain sits at the strict low error end, AUC just averages it away.

有趣的部分是:AUC 下降了(从 0.760 降至 0.751),所以我们自己的 AUC 检查机制拒绝启用它,哈哈。收益集中在严格低错误率的末端,而 AUC 只是将其平均化了。

Caveat: part of the LmArena gain is the cache changing shape (fewer writes), not just better calls.

注意:LmArena 的部分增益源于缓存形态的改变(写入减少),而不仅仅是调用效果更好。

Anyone else using runner up scores to gate retrieval?

还有其他人使用次佳匹配分数来过滤检索结果吗?

CacheVerifier repo: https://github.com/imxinchengyou/CacheVerifier

CacheVerifier 仓库:https://github.com/imxinchengyou/CacheVerifier

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件