ConTra 训练框架:用强化学习生成前缀提升上下文检索效果
ConTra: A Training Framework for Effective Contextual Retrieval via Prefix Generation
做 RAG 检索的朋友可以看看这套思路:用 2B 小模型在索引时生成文本前缀,检索和重排序都能用,比 Anthropic 的提示式方案便宜不少,速度还快好几倍。代码和模型都开源了,可以直接拿来跑对比。
Salesforce Research 提出 ConTra(Context That Travels),一个用强化学习训练轻量级前缀生成器的框架,用于改进 RAG 中的上下文检索。其奖励函数综合了冻结的 embedding 模型和 reranker 的反馈,并加入事实校验与长度控制,在索引阶段为每个 chunk 生成一个文本前缀,供向量检索和重排序共用。
配套的 RealContextBench 包含五个应用集合和三种受控条件,用于隔离干扰文本对检索的影响。实验中 ConTra-2B 在 ConTEB 和 RealContextBench 上超过 Anthropic 提示式 9B 方法和 PPLX-4B 上下文编码器,最高领先 3.15 分,索引短文档速度分别快 7.74 倍和 2.15 倍。仅在 ConTEB 上后训练的模型在 RealContextBench 重排序后仍领先各独立方法,对随机和同主题干扰的鲁棒性优于提示式 2B 基线。
ConTra: A Training Framework for Effective Contextual Retrieval via Prefix Generation
Data management systems organize large text collections for tasks such as finding relevant studies and extracting contract clauses. Systems make long documents searchable by splitting them into independently indexed chunks. Chunking can separate text from its identifying details. The indexing challenge is to keep each chunk independently searchable while preserving the context needed to find and rank it. Existing methods either encode that context in chunk vectors or attach it as a text prefix. Context encoded only in vectors is unavailable to text rerankers. Prompted prefixes serve both vector search and reranking, but are costly to generate at indexing time and can underperform contextual encoders. We propose ConTra (Context That Travels), a reinforcement learning framework for training lightweight prefix generators. Its reward combines feedback from frozen embedding and reranking models with factual verification and length control. ConTra generates one prefix per chunk during index construction and stores the augmented text and its embedding for reuse across queries. To evaluate contextual retrieval across workloads and under interference, we introduce RealContextBench, a benchmark with five application collections and three controlled conditions that isolate the effect of distracting text. On ConTEB and RealContextBench, ConTra-2B outperforms the prompted 9B baseline using Anthropic's method and the PPLX-4B contextual encoder, with a margin of up to 3.15 points over their best overall scores, while indexing short documents 7.74 times and 2.15 times as fast as those baselines, respectively. Post-trained only on ConTEB, it leads the standalone methods on RealContextBench after reranking and is less sensitive than the prompted 2B baseline to random and topically similar distractors. Code, datasets, and trained models are available at https://github.com/SStan1/ConTra.
本条情报归属 AITOP「论文」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:ConTra、RAG、上下文检索、Anthropic,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。
信源核验说明:本文原始信息发布自一手权威信源「arXiv: Anthropic」(Tier-1 一手发布),具备高确定性参考价值。