Basics Prompt Templates Distractor Dilution q8 Β· 24.28 MB WASM

Basics: Inside TinyCLIP β€” Prompt Templates & Distractor Dilution

CLIP classifies by comparing an image vector to text prompt vectors inside a softmax. Changing the prompt wrapper shifts cosine alignment, while adding semantically near distractors (like wolf next to dog) dilutes confidence far more than unrelated distractors (like pizza). Run both live below.

1 Β· Model, photo & precision

Loading starter photo…

2 Β· Prompt-template comparison lab

Tests the active candidate concepts (base pair + near/far labels) wrapped in five prompt templates. Compare how wording alters the top-1 softmax margin and cosine alignment.

Consensus top-1–
Template agreement–
Best margin template–
NaN count–
Live classification metrics across 5 prompt templates
Template Top-1 Top-1 % Margin vs #2 Top cosine Entropy (bits) Latency
Load TinyCLIP above to compare prompt templates.
Show the code β€” comparePromptTemplateRuns() aggregation

3 Β· Distractor dilution & softmax entropy experiment

Runs three sequential candidate sets on the exact same image: (A) clean 2-way base pair, (B) base pair + near distractors, and (C) base pair + far distractors. Watch how softmax temperature (logit_scale) concentrates probability when distractors are far versus splitting probability across near neighbors.

Base 2-way target–
+ Near distractors–
+ Far distractors–
Near vs Far penalty–
Fitted logit scale–

A Β· Base pair

B Β· Base + near distractors

C Β· Base + far distractors

Show the code β€” computeDistractorDilution() near vs far penalty
Show the code β€” fitLogitScale() least-squares temperature recovery