179 questions
No questions match those filters.
You're training a CLIP-style contrastive model from scr...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansFor a standard supervised classifier, batch size is mostly a tool for estimating the gradient and trading off compute efficiency against optimization noise — smaller batches are often fine, sometimes even beneficial as a regularizer. Contrastive objectives like CLIP’s don’t work that way, because the batch itself defines the learning problem. With N image-text pairs in a batch, you get N correct pairings and N² − N incorrect ones to push apart; the loss is essentially “pick the right match out of everything else in this batch.”
If N is small — 64, say — the model only has to distinguish the correct match from 63 alternatives, which is often trivially easy on superficial cues (brightness, aspect ratio, obvious category) rather than the fine- grained semantic alignment you actually want. The model converges fast and looks like it’s training well, while learning almost nothing useful. The original CLIP paper’s very large batch sizes weren’t primarily about throughput — they were necessary to give the contrastive loss enough hard negatives per step to force genuinely discriminative representations.
Practically, this means treating VRAM limits on a single GPU as something to route around, not respect: gather embeddings from every GPU in the node (e.g. via an all-gather) before computing the similarity matrix and loss, so the effective batch — and the negative pool — spans the whole cluster rather than one device. If you can’t reach a batch size in the thousands, techniques like gradient caching or memory banks that simulate a larger effective batch matter more here than in almost any other training setup.