A model trained on 400 million web images may have seen some evaluation images during pre-training. Rather than delete duplicates before training, the CLIP paper measures the overlap and its effect for each dataset: a duplicate detector scores every test example against the training set, a threshold splits the test set, and the accuracy on the two parts is compared. Implement the comparison.
overlap_report(similarity, correct, threshold, confidence=0.995)
similarity[i]: the detector's score of test example i against its nearest training example; correct[i]: 1 if the model classified it correctly, else 0.threshold; Clean holds the rest; All is the whole set."n_all", "n_overlap", "n_clean"; "contamination": n_overlap / n_all;"acc_all", "acc_clean", "acc_overlap" (accuracies as fractions; None for an empty part);"all_minus_clean": acc_all - acc_clean, the estimated inflation (None if Clean is empty);"p_value": the one-sided binomial test of the Overlap accuracy with the Clean accuracy as the null: for , the number correct in Overlap (None if either part is empty);"ci": the exact (Clopper-Pearson) interval for the Overlap accuracy at the given confidence, as [lower, upper] (None if Overlap is empty). With , the lower end is the where (0 if ) and the upper end the where (1 if ).bonferroni(p_values, level=0.05): given one p-value per dataset (None for datasets without a test), return the indices whose p-value is below level / m, where m is the number of p-values that are not None.