Image Feature Extraction
Transformers
Safetensors
clip_vitb_mini
feature-extraction
clip
knowledge-distillation
consensus-distillation
vit
custom_code
Instructions to use AbstractPhil/clip-vitb-mini-distilled with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AbstractPhil/clip-vitb-mini-distilled with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="AbstractPhil/clip-vitb-mini-distilled", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AbstractPhil/clip-vitb-mini-distilled", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
cc12m champion release: README.md
Browse files
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**
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
**
|
| 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 |
-
|
| 27 |
-
|
| 28 |
-
| model | zs CIFAR-10 | zs CIFAR-100 | COCO R@1 (iβt) | params |
|
| 29 |
|---|---|---|---|---|
|
| 30 |
-
| teacher CLIP-B/16 LAION-2B |
|
| 31 |
-
| **
|
| 32 |
-
|
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
- **Frame ambiguity
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 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, "
|
| 81 |
-
|
|
|
|
| 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)
|
| 89 |
-
|
| 90 |
-
|
|
|
|
| 91 |
```
|
| 92 |
|
| 93 |
-
Outputs are compatible with the
|
| 94 |
-
|
| 95 |
-
for zero-shot
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
-
|
| 102 |
-
|
| 103 |
-
(
|
| 104 |
-
|
| 105 |
-
-
|
| 106 |
-
|
| 107 |
-
-
|
| 108 |
-
|
| 109 |
-
(
|
| 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 |
-
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 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 |
-
-
|
|
|
|
|
|
|
|
|
|
| 129 |
[AbstractPhil/loss-manifest](https://huggingface.co/AbstractPhil/loss-manifest)
|
| 130 |
-
-
|
| 131 |
-
[AbstractPhil/
|
| 132 |
|
| 133 |
## References
|
| 134 |
|
| 135 |
-
- Radford et al., *Learning Transferable Visual Models From Natural
|
| 136 |
-
Supervision* (CLIP) β https://arxiv.org/abs/2103.00020
|
| 137 |
-
- van den Oord et al., *Representation Learning with Contrastive
|
| 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 |
-
-
|
| 142 |
-
|
| 143 |
-
-
|
| 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*
|
|
|
|
| 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
|