MPE preprint version
Summary
This PR adds Multi-Prefix Embedding (MPE) support for long-document dense retrieval in Tevatron, together with reproduction scripts for the preprint experiments.
The main idea is to represent a long passage with multiple prefix embeddings extracted at EOS-separated chunk boundaries, then score query-document relevance with MaxSim over the passage prefixes.
Main changes
-
Add chunking-related data arguments:
passage_chunk_sizepassage_chunk_size_rangepassage_chunk_size_variablepassage_chunk_independentencode_use_pre_chunked
-
Extend training and encoding collators to support:
- fixed-size chunking,
- deterministic random chunking,
- pre-chunked input,
- independent chunk encoding,
- EOS position tracking for prefix embedding extraction.
-
Extend
DenseModelto support chunked passage representations:- extract passage embeddings at EOS positions,
- return
[num_passages, max_chunks, hidden_dim]pluschunk_mask, - support independent chunk encoding,
- synchronize chunk dimensions across DDP ranks.
-
Update trainer logic to:
- pass EOS positions / chunk counts into the model,
- gather chunked representations safely under DDP,
- compute document-level MaxSim similarity for contrastive training.
-
Update search logic to:
- detect chunked passage embeddings,
- retrieve over chunk embeddings,
- aggregate chunk-level scores back to document-level scores using MaxSim.
-
Add
examples/mpereproduction scripts for:- data preparation,
- MLDR-EN training,
- MLDR-EN evaluation,
- BrowseComp-Plus evaluation,
- LongEmbed evaluation,
- result collection.
Methods covered by the reproduction scripts
The scripts compare:
- Single-Vector
- MaxP
- MaxP-Train
- MPE Fixed-64
- MPE-Rand-32to1024
Notes for reviewers
This PR touches both core retriever code and paper reproduction scripts. The core change is the chunked passage representation path; the scripts under examples/mpe are included to reproduce the preprint results.
Areas worth reviewing carefully:
- Whether MPE-specific code paths are sufficiently gated and do not affect standard dense retrieval.
- Whether debug prints/logging should be removed or downgraded.
- Whether the DDP shape synchronization and gather logic is robust.
- Whether random chunking behavior should be further documented.
- Whether reproduction scripts should remain in this PR or be split from the core library changes.
AI generated