amitha commited on
Commit
705c468
·
verified ·
1 Parent(s): 43db4a0

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +95 -0
README.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: image-text-to-text
5
+ tags:
6
+ - molmo
7
+ - vision-language-model
8
+ - olmo3
9
+ base_model:
10
+ - allenai/OLMo-3-1025-7B
11
+ - amitha/clip-vit-b16-datacomp-medium
12
+ ---
13
+
14
+ # amitha/molmo-clip-b16-olmo3
15
+
16
+ A Molmo-style vision-language model: a **frozen CLIP ViT-B/16** vision encoder
17
+ (pretrained on **DataComp-medium**, from [`amitha/clip-vit-b16-datacomp-medium`](https://huggingface.co/amitha/clip-vit-b16-datacomp-medium))
18
+ + a trained multimodal connector + the **[OLMo-3-7B](https://huggingface.co/allenai/OLMo-3-1025-7B)**
19
+ language model (`Olmo3ForCausalLM`).
20
+
21
+ The vision encoder was **frozen** during training; only the connector (a SwiGLU image
22
+ projector + a CLS projector) and the language model were trained, following the Molmo recipe.
23
+
24
+ > **Vision weights are referenced, not stored.** This repo ships the connector + LLM weights
25
+ > only. The vision tower is loaded at runtime from [`amitha/clip-vit-b16-datacomp-medium`](https://huggingface.co/amitha/clip-vit-b16-datacomp-medium),
26
+ > so that repo must remain accessible. Loading requires `trust_remote_code=True`.
27
+
28
+ ## Checkpoints
29
+
30
+ Training ran for 4 epochs. The **repo root is the final checkpoint** (`step14392`, 4 epochs).
31
+ Three earlier checkpoints are available as subfolders:
32
+
33
+ | Checkpoint | Subfolder | Notes |
34
+ |---|---|---|
35
+ | `step14392` | *(root)* | final (4 epochs) |
36
+ | `step7196` | `step7196` | 2 epochs |
37
+ | `step13000` | `step13000` | ~3.6 epochs |
38
+ | `step14000` | `step14000` | ~3.9 epochs |
39
+
40
+ Load an earlier checkpoint with `subfolder=`:
41
+
42
+ ```python
43
+ model = AutoModelForImageTextToText.from_pretrained(
44
+ "amitha/molmo-clip-b16-olmo3", subfolder="step13000", trust_remote_code=True)
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ```python
50
+ import torch, PIL.Image, requests
51
+ from transformers import AutoModelForImageTextToText, AutoTokenizer
52
+ from transformers import AutoImageProcessor, AutoProcessor
53
+
54
+ repo = "amitha/molmo-clip-b16-olmo3"
55
+ model = AutoModelForImageTextToText.from_pretrained(
56
+ repo, trust_remote_code=True, dtype=torch.float32).eval()
57
+ processor = AutoProcessor.from_pretrained(repo, trust_remote_code=True)
58
+
59
+ image = PIL.Image.open(requests.get(
60
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg",
61
+ stream=True).raw).convert("RGB")
62
+ inputs = processor(text="Describe this image in detail.", images=[image], return_tensors="pt")
63
+
64
+ with torch.no_grad():
65
+ out = model.generate(**inputs, max_new_tokens=200, do_sample=False)
66
+ print(processor.tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
67
+ ```
68
+
69
+ ### Prompt styles
70
+
71
+ The model was trained with several caption/QA styles. The processor exposes an optional
72
+ `style` argument (default: none) that prepends a `"{style}: "` prefix matching training:
73
+
74
+ ```python
75
+ inputs = processor(text="Describe this image.", images=[image],
76
+ style="long_caption", return_tensors="pt")
77
+ ```
78
+
79
+ Known styles: `long_caption`, `transcript`, `user_qa`, `synthetic_qa`.
80
+
81
+ ## Architecture notes
82
+
83
+ - **Image tokens:** single 224×224 crop, no pooling, CLS token included → 197 image tokens
84
+ (1 CLS + 196 patches) inserted into the text stream.
85
+ - **LLM:** native `Olmo3ForCausalLM` (post-norm, YaRN RoPE), vocabulary padded to 100480;
86
+ the 128 image-placeholder logits are masked during generation.
87
+ - **Image preprocessing:** resize so the short side is 224 (bicubic), center-crop 224,
88
+ normalize with OpenAI CLIP statistics.
89
+
90
+ ## Provenance
91
+
92
+ Converted from native Molmo training checkpoints to the HuggingFace format with a converter
93
+ verified to reproduce the original Molmo inference **bit-for-bit** (identical input ids and
94
+ image token layout; vision features and logits matching to floating-point ordering noise;
95
+ identical greedy generations).