Okapi: Generalising Better by Making Statistical Matches Match

Myles Bartlett, Sara Romiti, Viktoriia Sharmanska, Novi Quadrianto

TL;DR

Okapi is a novel semi-supervised learning (SSL) method that leverages "statistical matching" to help AI models generalize to unseen data, addressing the Out-of-Distribution (OOD) problem. By pairing samples from different domains and enforcing consistency between them using statistical filters, Okapi demonstrates that unlabeled data can significantly boost performance in scenarios where previous SSL methods have failed.

The Out-of-Distribution Generalization Problem

Machine learning models are notoriously brittle when deployed in the real world. A model trained to identify animals in one specific forest might fail miserably in another due to variations in lighting, background foliage, or camera hardware. This vulnerability is known as the Out-of-Distribution (OOD) generalization problem.

In practice, while we often have a limited amount of labeled data, we usually possess mountains of unlabeled data collected from diverse environments. Logically, this unlabeled data should help the model learn to ignore "nuisance" factors (like the time of day) and focus on the core "signal" (the animal itself). However, a major benchmark study (WILDS 2.0) recently suggested that standard semi-supervised learning techniques do not provide a consistent benefit over simple supervised learning for OOD generalization.

The authors of Okapi challenge this finding, arguing that SSL can work effectively—provided you use the right matching strategy to bridge the gap between different domains.

Methods: Introducing Okapi and CaliperNN

The core contribution of the paper is Okapi, a method that introduces a novel matching procedure named CaliperNN.

  1. Statistical Matching: Instead of comparing a sample to an artificially transformed version of itself (as is common in standard SSL), Okapi finds a "match" for a sample in a different domain. For example, it might pair an image of an elephant from "Camera Trap A" with a similar-looking image from "Camera Trap B."
  2. CaliperNN: To ensure these cross-domain matches are actually useful and not misleading, the authors employ "calipers"—statistical filters that prune away poor matches. They use Propensity Scores (the probability that a sample belongs to a specific domain) to ensure the paired samples are statistically comparable. If a match is too far off, it is discarded to avoid corrupting the training signal.
The CaliperNN matching procedure.
  1. Online Learning Architecture: To make this matching process computationally feasible across large datasets, Okapi borrows efficiency tricks from self-supervised learning:
  2. Memory Bank: Stores recent data encodings so the model doesn't have to re-process the entire dataset for every matching step.
  3. Momentum Encoder: A "slow-moving" version of the model that provides stable representation targets for the matching process.
  4. Task & Modality Agnostic: Because Okapi applies its consistency loss to the features (the internal representations) rather than the final output predictions, it is highly versatile. It works seamlessly across classification and regression tasks, as well as different modalities like images and text.

Key Insights

  • Filtering is Key: The critical "aha moment" of Okapi is that not all matches are created equal. By using calipers to drop statistically poor matches, the model avoids learning from noise. This stabilizes training and directly improves OOD performance.
  • Semantic Consistency: Qualitatively, the model learns to match images based on their actual semantic content (e.g., the species of the animal) while successfully ignoring environmental domain differences (e.g., day versus night).
  • Challenging the Status Quo: The paper successfully refutes the idea that unlabeled data is useless for OOD generalization on the WILDS benchmark. It shows that the failure of previous methods was likely due to how they handled domain shifts, not an inherent flaw in using unlabeled data.

Key Results

The authors evaluated Okapi on the WILDS 2.0 benchmark, focusing on three diverse real-world datasets: iWildCam (animal species classification), PovertyMap (predicting wealth indices from satellite imagery), and CivilComments (toxicity classification in text).

Okapi consistently outperformed both standard Empirical Risk Minimization (ERM) and the popular FixMatch algorithm:

Performance comparison on iWildCam and PovertyMap datasets.
  • iWildCam: Okapi achieved a 36.1 macro F1 score on OOD data, outperforming ERM (33.3) and FixMatch (35.2).
  • PovertyMap: Okapi achieved a Pearson correlation of 0.55 and an MSE of 0.33 on OOD data, significantly better than ERM (0.53 correlation / 0.35 MSE). Notably, FixMatch failed to generalize to this regression task entirely.
  • CivilComments: Okapi reached 69.7% worst-group accuracy, surpassing the reproduction of the ERM baseline (68.5%) and approaching the performance of models trained on fully labeled data.

Limitations and Future Work

While highly effective, Okapi has a few limitations. Currently, the "caliper" thresholds are fixed at the start of training; setting these adaptively as the model learns could yield even better results. Additionally, while the memory bank improves efficiency, the nearest-neighbor search still adds computational overhead compared to basic supervised learning.

Future directions include applying Okapi to more complex, dense prediction tasks like object detection and image segmentation, as well as exploring its efficacy in other modalities such as audio.

Summary updated

BibTeX
@inproceedings{bartlett2022okapi,
  author = {Myles Bartlett and Sara Romiti and Viktoriia Sharmanska and Novi Quadrianto},
  title = {{Okapi: Generalising Better by Making Statistical Matches Match}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
}
Figure