Fix generation from the published artifact; rewrite model card
Browse files
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 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 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 |
-
|
| 110 |
|
| 111 |
-
|
|
| 112 |
|---|---|
|
| 113 |
-
|
|
| 114 |
-
|
|
| 115 |
-
|
|
| 116 |
-
|
|
| 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 |
-
##
|
| 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 |
-
|
| 132 |
-
|
| 133 |
-
|
| 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 |
-
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 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**
|
| 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 |
-
|
| 174 |
-
|
| 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.
|