AbstractPhil commited on
Commit
f04f5f0
Β·
verified Β·
1 Parent(s): a403c2d

cc12m champion release: README.md

Browse files
Files changed (1) hide show
  1. README.md +87 -102
README.md CHANGED
@@ -5,6 +5,7 @@ pipeline_tag: image-feature-extraction
5
  tags:
6
  - clip
7
  - knowledge-distillation
 
8
  - infonce
9
  - vit
10
  - research
@@ -12,63 +13,51 @@ tags:
12
 
13
  # clip-vitb-mini-distilled
14
 
15
- An **8.66M-parameter ViT-Ti-class student** distilled from **CLIP ViT-B/16
16
- (LAION-2B)** pooled image features on **COCO-2017 train only** (118,287
17
- images, ~17 epochs) β€” a controlled, budget-scoped experiment in CLIP
18
- distillation objectives, shipped with its full ledger set and a negative
19
- headline honestly stated.
20
 
21
- **This is a research artifact, not a production model.** At this data budget
22
- the student reaches **~21% of the teacher's zero-shot capability** (CIFAR-10 +
23
- CIFAR-100 mean). The interesting cargo is the *comparative loss study* and the
24
- **frame-ambiguity finding** below.
25
 
26
- ## Headline numbers (test-time, deterministic eval)
27
-
28
- | model | zs CIFAR-10 | zs CIFAR-100 | COCO R@1 (i→t) | params |
29
  |---|---|---|---|---|
30
- | teacher CLIP-B/16 LAION-2B | 0.946 | 0.759 | 0.417 | 86M (image tower) |
31
- | **this student (InfoNCE, seed 0)** | **0.267** | **0.094** | **0.058** | **8.66M** |
32
- | random-init floor | 0.100 | 0.007 | 0.000 | 8.66M |
33
-
34
- Zero-shot uses the **teacher's text tower** (the student lives in the
35
- teacher's 512-d projection space). CIFAR images are bicubic-upscaled to the
36
- student's 160px input; the teacher is judged at its native 224px in the same
37
- harness.
38
-
39
- ## The loss matrix (6 objectives Γ— 2 seeds, 8000 steps, batch 256)
40
-
41
- | arm | zs C10 (s0/s1) | zs C100 | COCO R@1 | teacher-agree | eff. rank |
42
- |---|---|---|---|---|---|
43
- | feature MSE (mimicry) | .269 / .266 | .062 | .025 / .026 | **.714 / .718** | 122 |
44
- | **InfoNCE (ship arm)** | .267 / .231 | **.094 / .085** | **.058 / .054** | .404 / .401 | **184** |
45
- | SigLIP pairwise | .221 / .253 | β€” | .043 / .040 | β€” | 150 |
46
- | affinity KL | .109 / .111 | β€” | .000 | βˆ’.02 (see below) | 175 |
47
- | InfoNCE + geometric terms | .248 / .253 | .084 / .072 | .057 / .051 | .404 | 185 |
48
- | 5-teacher consensus MSE | .154 / .161 | β€” | .004 / .006 | .29 (see below) | 108 |
49
-
50
- Findings, each 2/2 seeds unless noted:
51
-
52
- - **The gauge split.** Feature-MSE mimicry wins *coarse* zero-shot and
53
- teacher agreement; InfoNCE wins *fine-grained* zero-shot (+3.2/+2.2 pts
54
- CIFAR-100), retrieval (2.2Γ—), and effective rank (184 vs 122). Pick your
55
- objective by the gauge you will be judged on.
56
- - **Frame ambiguity (the campaign's main finding).** The affinity-KL arm
57
- scores at floor on every absolute gauge while its embedding cosine to the
58
- teacher is **βˆ’0.02** β€” orthogonal, not absent. One orthogonal Procrustes
59
- rotation fitted on 2,500 held-in pairs recovers agreement to **0.50** and
60
- zero-shot from 0.109 to **0.240** β€” replicated on both seeds with
61
- post-rotation agreements matching to 0.004 (`ledgers/frame_check.json`,
62
- `ledgers/frame_check_s1.json`). The 5-teacher consensus arm tells the same
63
- story: rotated agreement
64
- **0.713 equals direct mimicry's 0.714**. Losses without a cross-space
65
- anchor learn the geometry *with the global frame free* β€” evaluate them
66
- through a fitted rotation or they read as false floors.
67
- - **Coupling wins retrieval.** Batch-coupled InfoNCE beats the decoupled
68
- SigLIP-style pairwise loss on retrieval 2/2 at batch 256 (single batch
69
- size tested β€” disclosed confound).
70
- - **Geometric add-on terms were inert** here: InfoNCE alone already lands the
71
- embedding-spread band the extra terms target.
72
 
73
  ## Usage
74
 
@@ -77,72 +66,68 @@ import torch
77
  from huggingface_hub import hf_hub_download
78
 
79
  repo = "AbstractPhil/clip-vitb-mini-distilled"
80
- ckpt = hf_hub_download(repo, "student_infonce_s0.pt")
81
- ldr = hf_hub_download(repo, "loader.py")
 
82
 
83
  import importlib.util
84
  spec = importlib.util.spec_from_file_location("loader", ldr)
85
  loader = importlib.util.module_from_spec(spec)
86
  spec.loader.exec_module(loader)
87
 
88
- model = loader.load_model(ckpt) # eval mode, cuda if available
89
- x01 = torch.rand(4, 3, 224, 224) # any [0,1] images
90
- emb = loader.embed_images(model, x01) # (4, 512) L2-normalized
 
91
  ```
92
 
93
- Outputs are compatible with the teacher's text tower
94
- ([laion/CLIP-ViT-B-16-laion2B-s34B-b88K](https://huggingface.co/laion/CLIP-ViT-B-16-laion2B-s34B-b88K))
95
- for zero-shot classification and retrieval.
96
-
97
- ## Training recipe
98
-
99
- - Student: ViT d=240, depth 12, heads 4, patch 16, input 160px, CLS readout,
100
- linear head to the teacher's 512-d projection space.
101
- - Targets: precomputed pooled projection-space features from
102
- [AbstractPhil/bulk-coco-features](https://huggingface.co/datasets/AbstractPhil/bulk-coco-features)
103
- (L2-normalized at load), teacher preprocessing verified to cosine 1.00000
104
- against the live tower before any training.
105
- - Objective (ship arm): symmetric InfoNCE student↔teacher, temperature 0.07,
106
- in-batch negatives, batch 256.
107
- - Optimizer: pure Adam (no weight decay), fp32, TF32 off, fixed CRC-derived
108
- seeds; 8000 steps β‰ˆ 17.3 epochs; peak 4.83 GB on one consumer GPU
109
- (~37 min per run).
110
- - Full per-run ledgers in `ledgers/` (JSONL; `agree_cos` is cosine to the
111
- teacher target; `eval_only` rows are deterministic re-evaluations, which
112
- reproduce the training-run numbers to 4 decimal places).
113
 
114
  ## Caveats
115
 
116
- - COCO-only data budget. The viability bar preregistered for this experiment
117
- (β‰₯40% of teacher zero-shot at ≀10% params) was **refuted** β€” treat this as
118
- a measured data point on the distillation-data curve, not a usable
119
- general-purpose encoder.
120
- - Zero-shot numbers come from 160px students judging 32px CIFAR upscales;
121
- absolute values are harness-scoped (floor/ceiling in the same harness
122
- bracket them).
123
- - Single training configuration per arm (2 seeds); batch-size sensitivity of
124
- the contrastive comparisons untested.
125
 
126
  ## Related
127
 
128
- - The loss-objective survey this experiment extends:
 
 
 
129
  [AbstractPhil/loss-manifest](https://huggingface.co/AbstractPhil/loss-manifest)
130
- - Teacher feature bank:
131
- [AbstractPhil/bulk-coco-features](https://huggingface.co/datasets/AbstractPhil/bulk-coco-features)
132
 
133
  ## References
134
 
135
- - Radford et al., *Learning Transferable Visual Models From Natural Language
136
- Supervision* (CLIP) β€” https://arxiv.org/abs/2103.00020
137
- - van den Oord et al., *Representation Learning with Contrastive Predictive
138
- Coding* (InfoNCE) β€” https://arxiv.org/abs/1807.03748
139
  - Yang et al., *CLIP-KD: An Empirical Study of CLIP Model Distillation* β€”
140
  https://arxiv.org/abs/2307.12732
141
- - Wu et al., *TinyCLIP: CLIP Distillation via Affinity Mimicking and Weight
142
- Inheritance* β€” https://arxiv.org/abs/2309.12314
143
- - Zhai et al., *Sigmoid Loss for Language Image Pre-Training* (SigLIP) β€”
144
- https://arxiv.org/abs/2303.15343
145
- - Lin et al., *Microsoft COCO: Common Objects in Context* β€”
146
- https://arxiv.org/abs/1405.0312
147
  - Cherti et al., *Reproducible scaling laws for contrastive language-image
148
- learning* (OpenCLIP / LAION-2B) β€” https://arxiv.org/abs/2212.07143
 
5
  tags:
6
  - clip
7
  - knowledge-distillation
8
+ - consensus-distillation
9
  - infonce
10
  - vit
11
  - research
 
13
 
14
  # clip-vitb-mini-distilled
15
 
16
+ An **8.66M-parameter ViT-Ti-class student** (~10% of a CLIP-B/16 image
17
+ tower) distilled for CLIP-style zero-shot and retrieval β€” now at its
18
+ **CC12M generation**: trained on 10.97M images against a **five-teacher
19
+ consensus target**, shipped with the small frozen rotation that places it
20
+ in the deployment frame.
21
 
22
+ **Headline (CIFAR-10 / CIFAR-100 zero-shot, COCO R@1, both seeds):**
 
 
 
23
 
24
+ | model | zs C10 | zs C100 | R@1 | R@5 |
 
 
25
  |---|---|---|---|---|
26
+ | teacher CLIP-B/16 LAION-2B (86M) | .946 | .759 | .417 | .669 |
27
+ | **champion: consensus + rotation (s1)** | **.5708** | **.2487** | **.1360** | **.3300** |
28
+ | champion seed 0 | .5412 | .2210 | .1322 | .3140 |
29
+ | best single-teacher student (InfoNCE, s0) | .5208 | .1958 | .1252 | .2968 |
30
+ | previous release (COCO-budget InfoNCE) | .2668 | .0939 | .0580 | .1664 |
31
+
32
+ The champion reaches **~48% of the teacher's zero-shot capability at 10%
33
+ of its parameters** β€” up from 21% one data-generation earlier, with the
34
+ data-scaling curve still unbent.
35
+
36
+ ## The finding this model embodies
37
+
38
+ **Don't distill against your serving teacher β€” distill against a
39
+ consensus of teachers, and ship a rotation.** The champion was trained
40
+ with a composite objective (symmetric InfoNCE + per-sample MSE) against
41
+ the *generalized Procrustes mean* of five CLIP towers (two B/16, three
42
+ B/32; LAION-2B, OpenAI, DataComp-XL pretrainings), not against the
43
+ deployment teacher. Its raw outputs live in the consensus frame; one
44
+ **frozen 512Γ—512 orthogonal rotation** (0.5MB, fitted offline on 2,500
45
+ COCO-val pairs) maps them into the CLIP-B/16-LAION-2B frame β€” where it
46
+ **beats the student trained directly against that teacher on every task
47
+ gauge, both seeds**, at identical training cost.
48
+
49
+ Two related phenomena, measured across the full 9-objective Γ— 2-seed
50
+ matrix and shipped in the ledgers:
51
+
52
+ - **Frame ambiguity**: consensus/relational objectives learn geometry
53
+ with the global frame unpinned; absolute gauges misread them as
54
+ failures until a fitted rotation is applied. Absolute-target consensus
55
+ retains *all* its geometry (rotation recovers everything and more);
56
+ purely relational similarity-matching degrades absolutely at scale.
57
+ - **The anchor dial**: across recipes, anchor (MSE) weight trades
58
+ teacher-agreement against retrieval monotonically; the composite sits
59
+ at the sweet point, and its InfoNCE term is what buys retrieval
60
+ (pure-MSE consensus, even rotated, reaches only R@1 β‰ˆ .05).
 
 
 
 
 
 
 
61
 
62
  ## Usage
63
 
 
66
  from huggingface_hub import hf_hub_download
67
 
68
  repo = "AbstractPhil/clip-vitb-mini-distilled"
69
+ ckpt = hf_hub_download(repo, "cc12m/consensus_nce_mse_s1_t88000.pt")
70
+ rot = hf_hub_download(repo, "cc12m/rotation_s1.pt")
71
+ ldr = hf_hub_download(repo, "loader.py")
72
 
73
  import importlib.util
74
  spec = importlib.util.spec_from_file_location("loader", ldr)
75
  loader = importlib.util.module_from_spec(spec)
76
  spec.loader.exec_module(loader)
77
 
78
+ model = loader.load_model(ckpt)
79
+ R = loader.load_rotation(rot)
80
+ x01 = torch.rand(4, 3, 224, 224) # any [0,1] images
81
+ emb = loader.embed_images(model, x01, rotation=R) # (4, 512), LAION frame
82
  ```
83
 
84
+ Outputs (with the rotation) are compatible with the
85
+ [LAION B/16 text tower](https://huggingface.co/laion/CLIP-ViT-B-16-laion2B-s34B-b88K)
86
+ for zero-shot and retrieval. The single-teacher alternate
87
+ (`cc12m/infonce_s0_t88000.pt`) needs no rotation. The original
88
+ COCO-budget model (`student_infonce_s0.pt`) remains for provenance.
89
+
90
+ ## Training
91
+
92
+ - Data: CC12M (10,968,539 images), 88,000 steps at batch 256 β‰ˆ 2.05
93
+ epochs; precomputed teacher targets from
94
+ [bulk-cc12m-features](https://huggingface.co/datasets/AbstractPhil/bulk-cc12m-features)
95
+ (zero teacher inference during training).
96
+ - Champion objective: symmetric InfoNCE (t=0.07) + per-sample MSE against
97
+ the five-tower GPA consensus; pure Adam 3e-4, no weight decay, fp32.
98
+ - Every number above is deterministic: evaluation re-runs reproduce to 4
99
+ decimal places, and the shipped loader reproduces the training-harness
100
+ numbers exactly (verified cross-machine before this release).
 
 
 
101
 
102
  ## Caveats
103
 
104
+ - Research miniature: ~48% of teacher zero-shot, not a production
105
+ encoder. The scaling trend (21% β†’ 42% β†’ 48% across data generations)
106
+ is the point.
107
+ - CIFAR evals upscale 32px images through the student's 160px input;
108
+ floor/ceiling brackets in the same harness contextualize them.
109
+ - Two seeds per objective; single batch size (256).
 
 
 
110
 
111
  ## Related
112
 
113
+ - Teacher feature banks (two towers, viewer-ready):
114
+ [AbstractPhil/bulk-cc12m-features](https://huggingface.co/datasets/AbstractPhil/bulk-cc12m-features)
115
+ Β· COCO companion: [AbstractPhil/bulk-coco-features](https://huggingface.co/datasets/AbstractPhil/bulk-coco-features)
116
+ - The loss-objective genealogy this line extends:
117
  [AbstractPhil/loss-manifest](https://huggingface.co/AbstractPhil/loss-manifest)
118
+ - Consensus encoder line (COCO scale):
119
+ [AbstractPhil/geolip-vit-captionbank-coco](https://huggingface.co/AbstractPhil/geolip-vit-captionbank-coco)
120
 
121
  ## References
122
 
123
+ - Radford et al., *Learning Transferable Visual Models From Natural
124
+ Language Supervision* (CLIP) β€” https://arxiv.org/abs/2103.00020
125
+ - van den Oord et al., *Representation Learning with Contrastive
126
+ Predictive Coding* (InfoNCE) β€” https://arxiv.org/abs/1807.03748
127
  - Yang et al., *CLIP-KD: An Empirical Study of CLIP Model Distillation* β€”
128
  https://arxiv.org/abs/2307.12732
129
+ - Gower, *Generalized Procrustes Analysis* β€”
130
+ https://doi.org/10.1007/BF02291478
131
+ - Changpinyo et al., *Conceptual 12M* β€” https://arxiv.org/abs/2102.08981
 
 
 
132
  - Cherti et al., *Reproducible scaling laws for contrastive language-image
133
+ learning* β€” https://arxiv.org/abs/2212.07143