Below is a set of strategies and considerations that can help refine your mining approach and mitigate the issue of false negatives while still encouraging effective retrieval behavior:
1. Adjust In-Batch Sampling
-
Balanced Positive Inclusion:
You’re already ensuring each batch has the anchor plus at least m positives. This is key in supervised contrastive settings. Double‐check that the positives you choose are as diverse as possible (e.g., varied views or appearance types) so that the anchor’s representation is not “narrow” and confused during retrieval.
-
Exclude Likely False Negatives:
If there’s domain knowledge (say, a label hierarchy or metadata) that suggests that some items in the batch share similarities with the anchor—even if they are not one of its designated positives—dynamically ignore them as negatives in the loss computation. This targeted “masking out” of false negatives can help the model focus on true negatives.
2. Mining Hard Positives and Negatives
-
Hard Positive Mining:
Identify which positives are “hard” (i.e., whose embeddings are farther away from the anchor than expected) and give them higher weight. This can help the network learn more robust representations. For example, you might adjust sampling probabilities or loss weighting to emphasize those positive pairs that are borderline.
-
Hard Negative Mining:
Instead of relying solely on all in-batch negatives, mine “hard negatives” that are close to the anchor in embedding space but are known (or highly likely) to be semantically different. This many-times helps the network pull apart near-duplicates. However, be cautious not to introduce false negatives—this approach works best if you have a mechanism (like a similarity threshold or metadata) to decide which negatives are safe.
-
Semi-Hard Negative Mining:
Another common strategy is to consider negatives that are not the hardest (which might be false negatives) but are moderately challenging. This “semi-hard” approach often stabilizes training and reduces the risk of collapse into monotonic retrieval behavior.
3. Leverage a Memory Bank / Momentum Encoder
-
Memory Bank (or MoCo style queue):
Instead of using only the current batch as negatives, you can store a larger set of negatives in a memory bank that gets updated slowly (or use a momentum encoder). This expanded pool tends to be more diverse and can be pruned using additional criteria (e.g., time stamps, known categories) to avoid pulling in potential false negatives.
-
Decoupled Negative Sampling:
Separating the anchor-positive computation from the negative set can help if you design the memory bank to only contain items confidently distinct from the current anchor’s class or domain. This improved negative sampling can enhance the discrimination of the learned representation.
4. Consider Alternative Loss or Proxy Approaches
-
Proxy-based Methods:
When your positive set is large and in-batch negatives are noisy, consider using proxy losses (such as Proxy-NCA or similar variations). These methods learn “proxy” representations per class (or per domain, e.g., sticker vs. photo) and can sidestep some of the pitfalls of negative sampling by comparing against learned centers rather than raw instances.
-
Hybrid Loss Formulations:
You might also combine SupConLoss with other objectives that promote inter-class separability (such as a classification loss on a subset of the data) to help guide the model during the early stages of training.
5. Regularize and Monitor Retrieval Behavior
-
Diversity Regularization:
Monotonic retrieval behavior might indicate that the model’s latent space is collapsing into a too-ordered system. Adding an entropy or diversity regularization term (or simply using diverse augmentations for positives) can help spread the embeddings out appropriately.
-
Curriculum Mining:
Start training with easier negatives (or fewer in-batch negatives) and gradually increase difficulty as the model learns. A curriculum learning approach can help the model avoid getting trapped in local minima caused by early false negative influence.
Summary
Best Practice Recommendation:
Use a combination of carefully balanced batch sampling that excludes or downweights likely false negatives, and incorporate hard (or semi-hard) mining strategies that select negatives based on embedding distances while leveraging domain/label information to filter out dangerous matches. Additionally, consider supplementing in-batch negatives with a memory bank or proxy-based objectives to stabilize the learning dynamics, and finally, monitor the embedding distribution and retrieval diversity to adjust the mining strategy over time.
This multi-pronged approach should mitigate the risk of false negatives and help avoid overly monotonic retrieval behavior, leading to a more robust, discriminative embedding space for both photos and stickers.