The online triplet mining strategy is more efficient than the offline one. It implies "getting a batch of n samples and their associated labels, and form triplets on the fly." About Triplet vs. Contrastive Loss comparison and its efficient implementation. <a href="https://qdrant.tech/articles/triplet-loss/" rel="nofollow">https://qdrant.tech/articles/triplet-loss/</a>