andreagemelli commited on
Commit
d651d1c
Β·
verified Β·
1 Parent(s): b66671e

Fix generation from the published artifact; rewrite model card

Browse files
Files changed (1) hide show
  1. README.md +25 -66
README.md CHANGED
@@ -27,11 +27,10 @@ text-only reasoning SLM β€” with visual capabilities via the
27
  [InternViT-300M-448px-V2.5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5)
28
  vision encoder and a lightweight MLP projector, for a total of ~628M parameters.
29
 
30
- Trained end-to-end in **~72h on a single H100 (~€219)**. It inherits six European
31
- languages (EN, FR, DE, ES, IT, PL) from the Baguettotron backbone, and β€” unusually β€”
32
- its entire LM pretraining corpus is auditable: Baguettotron was trained on
33
- [SYNTH](https://huggingface.co/datasets/PleIAs/SYNTH), ~58K Wikipedia articles expanded
34
- synthetically, with no scraped web.
35
 
36
  Two checkpoints are published:
37
 
@@ -74,7 +73,7 @@ model = AutoModelForImageTextToText.from_pretrained(
74
  "andreagemelli/baguettotron-internvit-alignment",
75
  trust_remote_code=True,
76
  dtype=torch.bfloat16,
77
- device_map="auto",
78
  )
79
  processor = AutoProcessor.from_pretrained(
80
  "andreagemelli/baguettotron-internvit-alignment",
@@ -91,29 +90,16 @@ inputs = {k: v.to(model.device) for k, v in inputs.items() if v is not None}
91
  print(model.chat(**inputs))
92
  ```
93
 
94
- `chat()` returns the answer as a plain string, already trimmed at the end of the
95
- assistant turn. `max_new_tokens=...` bounds the length.
96
-
97
- ### Apple Silicon and CPU
98
-
99
- The snippet above runs unchanged on `mps` and `cpu` β€” keep `device_map="auto"`, or drop
100
- it and call `.to("mps")` yourself. `dtype=torch.float32` works too. A short answer takes
101
- ~1-3s on `mps` against ~20-25s on CPU, so prefer `mps` on a Mac.
102
-
103
- One caveat handled for you: transformers' repetition-penalty processor corrupts the
104
- first decoding step on MPS, which produced a garbage first token. `chat()` disables the
105
- penalty on that backend automatically.
106
-
107
  ### Example output
108
 
109
- Four COCO images, greedy, `Describe the image concisely.` β€” verbatim:
110
 
111
- | image | output |
112
  |---|---|
113
- | two cats on a couch | `a cat is sleeping on the couch` |
114
- | close-up of a brown bear | `the bear is a good friend.` |
115
- | an upside-down STOP sign | `a sign for a stop sign` |
116
- | a red double-decker bus | `the bus is a red double - decoration` |
117
 
118
  That is the honest range of this checkpoint: it locates the subject and then drifts, which is what 2.7M trained parameters buys. It does not read the text on the sign or the bus.
119
 
@@ -121,59 +107,32 @@ That is the honest range of this checkpoint: it locates the subject and then dri
121
 
122
  Trained on short image captions with no `<think>` traces. The processor emits a bare assistant prefix (`<|im_start|>assistant\n`) and the model completes the caption directly. Keep prompts simple ("Describe the image").
123
 
124
- ## What the evaluation found
125
-
126
- Measured on 6 held-out [RealWorldQA](https://huggingface.co/datasets/xai-org/RealworldQA)
127
- images, judged 1–5 by a vision judge, 244 of 288 cells completed. Thin, and reported as
128
- such β€” full tables and caveats in
129
- [RESULTS.md](https://github.com/andreagemelli/baguettotron-vlm/blob/main/.planning/RESULTS.md).
130
 
131
- - **Short factual questions are its strength** (2.5–3.5), open description its weakest
132
- (~1.5). That inverted our own assumption that this would be a describer.
133
- - **A third checkpoint made things worse.** A reasoning-SFT stage on top of the
134
- instruction-tuned model scored 1.25 against its 2.17, roughly 3 SE. The reasoning
135
- traces are undertrained for imagery and mostly add fluent hallucination, so that
136
- checkpoint is **not published**. It is kept as a recorded negative result.
137
- - **Decoding presets are inside noise** β€” greedy 2.17 vs 1.88 for the other three.
138
 
139
- ### Decoding
140
 
141
- Use **greedy**, which is the default. It is recommended for determinism, not because
142
- it beat anything. Pass `do_sample=True, temperature=...` to `chat()` if you want
143
- sampling anyway.
144
-
145
-
146
- ## Training
147
-
148
- | | |
149
- |---|---|
150
- | Data | LLaVA-CC3M-Pretrain-595K (595K image-caption pairs) |
151
- | Trainable params | ~2.7M (projector only) |
152
- | Frozen | ViT + LLM |
153
- | Effective batch size | 256 |
154
- | Learning rate | 1e-3, cosine, 250-step warmup |
155
- | Precision | bf16 |
156
- | Hardware | 1Γ— H100 SXM (RunPod) |
157
- | Duration | ~5h (~€15) |
158
 
159
  ## Limitations
160
 
161
- - **No stop token.** `<|im_end|>` was masked out of the training loss, so the model
162
- never learned to emit one β€” it spells the turn marker out as ordinary text instead.
163
- `chat()` works around this by stopping on that text (a 512-token call drops from
164
- ~21s to ~1.5s), but the defect is in the weights and needs a retrain to fix.
165
  - **Resolution ceiling.** One 448Γ—448 crop β†’ 256 visual tokens puts document text at
166
  roughly 2–4 px/char. OCR, charts and documents are out of reach by architecture, not
167
  by budget. Neither published checkpoint reads text in an image.
168
  - **Hallucinations**, especially on fine-grained or text-heavy questions.
169
- - **Undertrained for VQA alignment** β€” ~60h of instruction tuning on one H100 is small
170
- relative to the data mixture.
171
  - **Multilingual capability is inherited, not verified.** The backbone covers six
172
  languages; the VLM was never evaluated on non-English benchmarks.
173
- - **Evaluation is thin**: 6 held-out images, one judge, one rubric, 244 judged cells.
174
- Every number here is directional.
175
- - **`transformers` 5.x cannot load this model.** The blocker is upstream in InternViT's
176
- remote code, which predates v5's tied-weight API. Pin `transformers<5`.
177
 
178
  **Contributions and suggestions are very welcome** β€” issues, PRs, and ideas for
179
  better data mixes, training recipes, or evaluation setups are all appreciated.
 
27
  [InternViT-300M-448px-V2.5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5)
28
  vision encoder and a lightweight MLP projector, for a total of ~628M parameters.
29
 
30
+ It inherits six European languages (EN, FR, DE, ES, IT, PL) from the Baguettotron
31
+ backbone, and β€” unusually β€” its entire LM pretraining corpus is auditable: Baguettotron
32
+ was trained on [SYNTH](https://huggingface.co/datasets/PleIAs/SYNTH), ~58K Wikipedia
33
+ articles expanded synthetically, with no scraped web.
 
34
 
35
  Two checkpoints are published:
36
 
 
73
  "andreagemelli/baguettotron-internvit-alignment",
74
  trust_remote_code=True,
75
  dtype=torch.bfloat16,
76
+ device_map="auto", # also tested on Apple Silicon (mps) and CPU
77
  )
78
  processor = AutoProcessor.from_pretrained(
79
  "andreagemelli/baguettotron-internvit-alignment",
 
90
  print(model.chat(**inputs))
91
  ```
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  ### Example output
94
 
95
+ Greedy, prompt `Describe the image concisely.` β€” verbatim output:
96
 
97
+ | | output |
98
  |---|---|
99
+ | <img src="http://images.cocodataset.org/val2017/000000039769.jpg" width="180"> | `a cat is sleeping on the couch` |
100
+ | <img src="http://images.cocodataset.org/val2017/000000000285.jpg" width="180"> | `the bear is a good friend.` |
101
+ | <img src="http://images.cocodataset.org/val2017/000000000724.jpg" width="180"> | `a sign for a stop sign` |
102
+ | <img src="http://images.cocodataset.org/val2017/000000001584.jpg" width="180"> | `the bus is a red double - decoration` |
103
 
104
  That is the honest range of this checkpoint: it locates the subject and then drifts, which is what 2.7M trained parameters buys. It does not read the text on the sign or the bus.
105
 
 
107
 
108
  Trained on short image captions with no `<think>` traces. The processor emits a bare assistant prefix (`<|im_start|>assistant\n`) and the model completes the caption directly. Keep prompts simple ("Describe the image").
109
 
110
+ ## Recommended settings
 
 
 
 
 
111
 
112
+ Greedy decoding, which is what `chat()` does by default β€” just call it. Four decoding
113
+ presets were compared on held-out images and the differences sat inside noise, so greedy
114
+ is preferred for being deterministic rather than for scoring better.
 
 
 
 
115
 
116
+ Two things that *do* move the needle:
117
 
118
+ - **Ask specific questions.** `"How many cats are there?"` answers `2.`; the vaguer
119
+ `"What is in the picture?"` answers `Yes.` Phrasing matters far more at this scale
120
+ than it does with a large model.
121
+ - **Describe first, then ask.** A follow-up question in a second turn is answered better
122
+ than the same question asked cold, because the model conditions on its own previous
123
+ answer. Multi-turn is in-distribution β€” The Cauldron contains multi-turn conversations.
 
 
 
 
 
 
 
 
 
 
 
124
 
125
  ## Limitations
126
 
 
 
 
 
127
  - **Resolution ceiling.** One 448Γ—448 crop β†’ 256 visual tokens puts document text at
128
  roughly 2–4 px/char. OCR, charts and documents are out of reach by architecture, not
129
  by budget. Neither published checkpoint reads text in an image.
130
  - **Hallucinations**, especially on fine-grained or text-heavy questions.
131
+ - **Undertrained for VQA alignment** relative to the size of the data mixture.
 
132
  - **Multilingual capability is inherited, not verified.** The backbone covers six
133
  languages; the VLM was never evaluated on non-English benchmarks.
134
+
135
+ > Tested against `transformers` 4.57. Newer major versions may need adjustments.
 
 
136
 
137
  **Contributions and suggestions are very welcome** β€” issues, PRs, and ideas for
138
  better data mixes, training recipes, or evaluation setups are all appreciated.