NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

RePair: Turning Retrieval Failures into Counterfactual Hard Pairs

Siyi Liu, Xiaorong Zhu, Enjun Du, Xinyu Zuo, Lisheng Duan, Haijin Liang, Jin Ma, Junfu Pu, Yongqi ZhangarXiv 2026

TL;DR

RePair is a failure-conditioned training framework that improves vision-language retrieval by turning a model's own top-ranked false positives into highly effective training data. By minimally editing the specific detail that caused the retrieval failure, RePair creates perfectly matched hard positive and negative pairs that sharpen the model's decision boundaries, outperforming standard augmentation methods while using 26%–75% less synthetic data.

What Problem Does This Paper Address?

Dual-encoder models like CLIP are excellent at matching high-level visual and textual concepts, but they notoriously stumble on fine-grained semantic distinctions—such as attribute binding, relations, and word order. For example, a retriever might mistakenly rank an image of a girl on a regular red plastic swing highly for the query "A girl in a red shirt is on a tire swing."

To fix these "near misses," researchers typically rely on two strategies:

  1. Hard-negative mining: Selecting confusing candidates from an existing corpus. While this tells the model what to push away, it doesn't provide a matched positive signal showing how to correct the boundary.
  2. Synthetic data augmentation: Generating hard samples using generative models. However, these methods are usually error-agnostic—they generate variations based on predefined templates rather than targeting the specific blind spots of the model being trained, leading to massive data inefficiency.

RePair bridges this gap by directly conditioning data synthesis on the model's actual retrieval failures.

Methods

RePair operates on a simple but powerful insight: a top-ranked false positive is a counterfactual scaffold. It already shares most of the query's semantics (the scaffold) and only differs by a localized, failure-causing detail (the residual).

The framework is guided by three core principles:

  1. Validity (Failure-Driven Mining & Validation): RePair mines the top false positives bidirectionally (Text-to-Image and Image-to-Text). It passes these through an LLM-based semantic auditor to filter out annotation noise or benign alternative matches, ensuring only genuine model confusions are targeted.
  2. Minimality (Counterfactual Editing): An LLM diagnoses the error and generates a minimal edit instruction. A modality-specific editor (an LLM for text, a diffusion model like Flux2-9B for images) executes the edit. To prevent the editor from changing the entire scene, a post-edit quality control step selects the candidate closest to the original false positive in the embedding space.
  3. Locality (Local Hard-Pair Contrastive Training): Instead of mixing these synthetic samples loosely into a giant batch where their relationship is lost, RePair organizes them into structured $3 \times 3$ local confusion grids. The model is trained using a dual-objective framework: a global contrastive loss for the original anchor pairs, and a local grid loss that forces the model to resolve the fine-grained boundary between the anchor, the false positive, and the edited counterfactual.
RePair pipeline overview

Datasets

The authors evaluated RePair on standard vision-language retrieval benchmarks:

  • Flickr30K: Standard dataset with 29K training images.
  • COCO30K: A subset of MS-COCO uniformly sampled to match the 29K image scale of Flickr30K for fair comparison.
  • MS-COCO (Full): Used to evaluate how the method scales with a larger training corpus (113K images).
  • ARO (Attribution, Relation, and Order): A demanding diagnostic benchmark used to evaluate fine-grained compositional reasoning.

Key Insights and Ideas

  • Failures are Data Goldmines: Rather than treating retrieval errors as mistakes to discard, RePair treats them as the most informative anchors for boundary calibration.
  • Precision Over Volume: Generating data blindly wastes compute. Targeting the exact error space of the retriever yields higher-quality supervision, allowing a small amount of targeted data to beat massive, error-agnostic datasets.
  • The Asymmetry of Multimodal Errors: Through failure analysis, the authors discovered that Image-to-Text failures frequently involve hallucinations (36.9% of the time), whereas Text-to-Image failures almost never do (0.5%). This strongly justifies their bidirectional, independent pipeline design, as a unified editing strategy would misallocate synthesis effort.

Key Results

  • Superior Data Efficiency: With only 107K synthetic samples, RePair achieved the highest Recall@1 (R@1) across both Flickr30K and COCO30K, outperforming baselines that used up to 435K samples.
  • Fine-Grained Mastery: On the compositional ARO benchmark, RePair significantly improved attribute binding and ranked first among ten competing systems on three out of four metrics—all without using any pre-defined templates for compositional hard negatives.
Case study of RePair's synthesis on T2I and I2T

Limitations and Future Work

  • Generative Ceiling: RePair relies heavily on external generative models. If the image editor suffers from "scaffold drift" (rewriting the entire image instead of just the target detail), the training signal degrades.
  • Static Snapshot Mining: Currently, failures are mined once from a single model snapshot before training. The authors note that an iterative, multi-round loop—where the model continuously re-mines its own evolving failures during training—is a promising but unexplored extension.
  • Architecture Constraints: The framework was exclusively evaluated on dual-encoder architectures (CLIP); its applicability to cross-attention or late-fusion retrieval models remains untested.

Summary updated

BibTeX
@misc{liu2026repair,
  author = {Siyi Liu and Xiaorong Zhu and Enjun Du and Xinyu Zuo and Lisheng Duan and Haijin Liang and Jin Ma and Junfu Pu and Yongqi Zhang},
  title = {{RePair: Turning Retrieval Failures into Counterfactual Hard Pairs}},
  year = {2026},
  eprint = {2608.29604},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.29604},
}
Figure