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.
Figures & tables
Figure 1. A textual prefix carries document context through embedding retrieval and reranking. Contextual encoders enrich chunk vectors, while the reranker receives only the original chunk text. The upper pipeline supplies a generated prefix and the original chunk to both the embedding model and reranker. The lower pipeline contextualizes vectors but supplies original chunks to the reranker.
Retrieval view
Reranker view
Emb.
Rec.@15
Rer.
Raw
Raw
.5484
.7691
.6483
Prefix + raw
Raw
.6547
.8475
.6924
Raw
Prefix + raw
.5484
.7691
.6940
Prefix + raw
Prefix + raw
.6547
.8475
.7585
PPLX-4B
Raw
.8210
.9387
.7310
PPLX-4B
Prefix + raw
.8210
.9387
.8135
Table 1. Prefix placement analysis on ConTEB using untrained Qwen3.5-2B with Anthropic’s prompt. The first four rows use Qwen3-Embedding-4B for candidate retrieval, and all rows use Qwen3-Reranker-4B. Emb. and Rer. report nDCG@10; Rec.@15 reports candidate recall. All metrics are macro-averaged across the eight tasks.
Method
Ins.
COVID
Geo.
ESG
Football
SQuAD
NQA
MLDR
Overall
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Qwen3-Emb.-4B
.145
.166
.546
.692
.719
.853
.397
.483
.317
.465
.726
.798
.777
.846
.760
.883
.5484
.6483
InSeNT
.451
.394
.360
.538
.831
.885
.230
.466
.252
.367
.684
.790
.667
.793
.719
.872
.5242
.6381
PPLX-0.6B
.997
.333
.561
.700
.898
.880
.461
.541
.714
.650
.789
.838
.842
.861
.867
.885
.7662
.7110
PPLX-4B
1.000
.344
.620
.741
.935
.879
.631
.602
.781
.677
.837
.850
.869
.865
.895
.890
.8210
.7310
Voyage-3
1.000
.348
.547
.695
.928
.880
.574
.571
.796
.728
.826
.850
.818
.861
.896
.900
.7983
.7292
Table 2. ConTEB nDCG@10 for embedding retrieval (Emb.) and reranking (Rer.). Overall reports the macro-average across the eight tasks. Qwen3.5 rows denote untrained models using Anthropic’s prompt. Green bold and underlining indicate the best and second-best scores, respectively.
Method
Ins.
COVID
Geo.
ESG
Football
SQuAD
NQA
MLDR
Overall
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
ConTra-0.8B
.127
.160
.514
.691
.936
.947
.507
.671
.726
.833
.694
.795
.772
.843
.765
.936
.6302
.7346
0.8B −Rrank
.170
.161
.488
.671
.941
.957
.538
.652
.658
.827
.735
.812
.748
.829
.805
.940
.6353
.7311
0.8B −Rfact
.202
.223
.488
.656
.939
.953
.534
.595
.709
.817
.710
.809
.770
.842
.760
.911
.6388
.7257
0.8B −Rlen
.152
.178
.525
.692
.945
.956
.490
.637
.734
.820
.673
.646
.766
.838
.694
.806
.6225
.6966
ConTra-2B
.988
1.000
.518
.694
.922
.942
.515
.730
.649
.825
.766
.841
.785
.851
.832
.937
.7469
.8525
Table 3. Reward ablation results on ConTEB. Emb. and Rer. report embedding and reranked nDCG@10, respectively. ConTra rows use the full reward objective. Green bold and underlining denote the best and second-best scores within each model scale.
Qwen3 0.6B
Qwen3 8B
Method
K=10
K=15
K=20
K=10
K=15
K=20
Raw Qwen3
.5668
.5792
.5880
.6609
.6735
.6777
InSeNT
.5819
.6053
.6065
.6237
.6465
.6526
PPLX-0.6B
.6810
.6649
.6477
.7366
.7295
.7204
PPLX-4B
.7158
.6862
.6661
.7675
.7454
.7299
Voyage-3
.7118
.6839
.6648
.7635
.7445
.7345
Table 4. Eight-task macro final nDCG@10 on full ConTEB across Qwen3 retrieval model sizes and candidate pool sizes without retraining prefix writers.
Collection
Queries
Docs.
Chunks
NQ
5,499
5,181
99,096
TechQA
149
139
1,036
FairytaleQA
1,007
23
342
QMSum
244
35
2,140
FinanceBench
146
84
45,049
Table 5. Sizes of the application collections in RealContextBench .
Application collections
NanoBEIR context
Method
NQ
TechQA
FQA
QMSum
Finance
Orig.
Rand.
Topic.
Overall
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Emb.
Rer.
Qwen3-Emb.-4B
.651
.710
.722
.742
.628
.787
.314
.357
.292
.339
.689
.721
.689
.721
.689
.721
.5845
.6373
InSeNT
.602
.686
.653
.738
.494
.720
.110
.192
.088
.104
.516
.606
.398
.551
.494
.635
.4194
.5291
PPLX-0.6B
.598
.685
.728
.758
.674
.798
.263
.301
.247
.288
.597
.685
.582
.668
.596
.683
.5357
.6083
PPLX-4B
.679
.717
.759
.770
.722
.812
.412
.405
.418
.445
.629
.705
.590
.678
.633
.703
.6051
.6542
Table 6. RealContextBench nDCG@10. FQA and Finance denote FairytaleQA and FinanceBench; Orig., Rand., and Topic. denote original, random, and topical context conditions. Qwen3.5 rows use Anthropic’s prompt. Green bold and underlining mark the best and second-best scores for embedding retrieval and reranking separately.
2B model
4B model
Collection
ConTra
PPLX
ConTra
PPLX
Application collections
NQ
.7486
.7382
.7267
.7161
TechQA
.7649
.7797
.7522
.7834
FairytaleQA
.8092
.8194
.8123
.8234
QMSum
.3811
.4140
.4110
.4286
Table 7. Comparison of candidate retrieval using ConTra versus PPLX-4B, with ConTra prefixes supplied to the reranker in both cases. Reported metrics are reranked nDCG@10. Bold marks the stronger retriever within each generator size.
Figure 2. Case 1: A prefix supplies answer information to a non-gold chunk. Case 2: A prefix highlights relevant information already present in the target chunk. Two vertically stacked bordered cases. The first shows Leo Arnaud's full name added to a neighboring passage. The second shows a passage defining rumination syndrome and a prefix summarizing that passage, with no added surrounding context; its rank improves from 4 to 1 on fixed PPLX candidates.
Method
Long docs.
Short docs.
Qwen3-Emb.-4B
7.92
1.01
PPLX-0.6B
29.97
3.51
PPLX-4B
77.97
8.08
Qwen3.5-9B
268.12
29.02
Qwen3.5-0.8B
53.39
6.20
ConTra-0.8B
38.09
2.70
Table 8. Total indexing time in seconds on a single NVIDIA H100 80GB GPU. Paired Qwen3.5–ConTra runs hold all inference settings identical within each model size.