Image Feature Extraction
Transformers
Safetensors
pixtral_large4_vision
feature-extraction
vision
custom_code
Instructions to use immanuelpeter/PixtralViT-Large-4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use immanuelpeter/PixtralViT-Large-4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="immanuelpeter/PixtralViT-Large-4", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("immanuelpeter/PixtralViT-Large-4", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Rewrite the card in the house template
Browse files
README.md
CHANGED
|
@@ -12,7 +12,8 @@ base_model:
|
|
| 12 |
|
| 13 |
# PixtralViT-Large-4
|
| 14 |
|
| 15 |
-
This repository packages the
|
|
|
|
| 16 |
|
| 17 |
## Contents
|
| 18 |
|
|
@@ -20,45 +21,44 @@ This repository packages the vision Tower and Projector from [Mistral Large 4](h
|
|
| 20 |
|---|---|---|
|
| 21 |
| `model.safetensors` | 272 | Pixtral vision encoder, from the parent's `vision_encoder.*` |
|
| 22 |
| `projector.safetensors` | 4 | `pre_mm_projector_norm`, `patch_merger` and `vision_language_adapter` |
|
| 23 |
-
| `modeling_pixtral_large4.py` | | `PixtralVisionModel` subclass
|
| 24 |
-
| `projector.py`, `projector_config.json`
|
| 25 |
-
| `
|
| 26 |
-
| `export_manifest.json`
|
| 27 |
-
| `LICENSE`, `
|
| 28 |
|
| 29 |
## Architecture
|
| 30 |
|
| 31 |
| Component | Details |
|
| 32 |
|---|---|
|
| 33 |
-
| Tower | 30 blocks, 2048 hidden, 16 heads of 128, SwiGLU 6144, RMSNorm, 14 px patches, axial 2D RoPE, no class token
|
| 34 |
-
|
|
|
|
|
| 35 |
|
| 36 |
-
At 448
|
| 37 |
-
of width 2048
|
| 38 |
-
RMS above 2.5e4; standardize channels before fitting a readout on it.
|
| 39 |
|
| 40 |
## Usage
|
| 41 |
|
| 42 |
-
``
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
```
|
| 47 |
-
|
| 48 |
-
[`examples/inference.py`](examples/inference.py) crops an image to 448 x 448 and prints the Tower,
|
| 49 |
-
`merged` and `projected` shapes. Use `trust_remote_code` for BF16 fidelity: stock `PixtralVisionModel`
|
| 50 |
-
loads the same weights but rounds RoPE and attention differently in BF16.
|
| 51 |
|
| 52 |
## Validation
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
## Reproduction
|
| 59 |
|
| 60 |
-
The [export script](https://github.com/immanuel-peter/vision-tower-bench/blob/main/scripts/export_mistral_large4_vision.py)
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
|
| 63 |
## Credits
|
| 64 |
|
|
@@ -66,5 +66,5 @@ Mistral AI released the Mistral Large 4 weights and the mistral-inference refere
|
|
| 66 |
|
| 67 |
## License
|
| 68 |
|
| 69 |
-
The weights keep the
|
| 70 |
-
|
|
|
|
| 12 |
|
| 13 |
# PixtralViT-Large-4
|
| 14 |
|
| 15 |
+
This repository packages the Tower and Projector from
|
| 16 |
+
[Mistral Large 4](https://huggingface.co/mistralai/Mistral-Large-4-1T-A52B).
|
| 17 |
|
| 18 |
## Contents
|
| 19 |
|
|
|
|
| 21 |
|---|---|---|
|
| 22 |
| `model.safetensors` | 272 | Pixtral vision encoder, from the parent's `vision_encoder.*` |
|
| 23 |
| `projector.safetensors` | 4 | `pre_mm_projector_norm`, `patch_merger` and `vision_language_adapter` |
|
| 24 |
+
| `modeling_pixtral_large4.py` | | `PixtralVisionModel` subclass following the parent's numeric order |
|
| 25 |
+
| `projector.py`, `projector_config.json` | | Projector shapes and loader |
|
| 26 |
+
| `config.json`, `preprocessor_config.json` | | Vision configuration and `PixtralImageProcessor` settings |
|
| 27 |
+
| `export_manifest.json` | | Source pin, shard SHA256 and tensor name map |
|
| 28 |
+
| `LICENSE`, `LICENSE-CODE`, `NOTICE` | | Weight license, code license and attribution |
|
| 29 |
|
| 30 |
## Architecture
|
| 31 |
|
| 32 |
| Component | Details |
|
| 33 |
|---|---|
|
| 34 |
+
| Tower | 30 blocks, 2048 hidden, 16 heads of 128, SwiGLU 6144, RMSNorm (eps 1e-5), 14 px patches, axial 2D RoPE, no class token |
|
| 35 |
+
| Final norm | None. The last block's output is the raw residual stream |
|
| 36 |
+
| Projector | `RMSNorm(2048)`, 2x2 patch merge to 8192, `Linear(8192, 2048)`, then `Linear(2048, 6144)`, GELU, `Linear(6144, 6144)`, no biases |
|
| 37 |
|
| 38 |
+
At 448 pixels the bench reports 1,024 Tower tokens of width 2048, 256 merged tokens
|
| 39 |
+
of width 2048 and 256 projected tokens of width 6144.
|
|
|
|
| 40 |
|
| 41 |
## Usage
|
| 42 |
|
| 43 |
+
See [`examples/inference.py`](examples/inference.py) for image feature extraction.
|
| 44 |
+
`AutoModel.from_pretrained(..., trust_remote_code=True)` loads
|
| 45 |
+
`modeling_pixtral_large4.py`, which follows the parent's BF16 numeric order; stock
|
| 46 |
+
`PixtralVisionModel` loads the same weights but rounds differently there.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
## Validation
|
| 49 |
|
| 50 |
+
The release tests compare all 276 tensors with the pinned parent checkpoint using
|
| 51 |
+
`torch.equal`. Fixed-image Tower, merged and projected outputs also match the
|
| 52 |
+
mistral-inference 1.6.0 reference bit-for-bit in FP32 and BF16 at 448 and 1540
|
| 53 |
+
pixels, in 80 of 80 comparisons. The parent itself drifts between BF16 and FP32
|
| 54 |
+
at the deepest Stages; this release matches it in each precision.
|
| 55 |
|
| 56 |
## Reproduction
|
| 57 |
|
| 58 |
+
The [export script](https://github.com/immanuel-peter/vision-tower-bench/blob/main/scripts/export_mistral_large4_vision.py)
|
| 59 |
+
range-reads the 276 vision tensors from the shard the pinned index names, renames
|
| 60 |
+
them to HF Pixtral names and reorders each `wq` and `wk` head from interleaved
|
| 61 |
+
rotary pairs to rotate-half order. It writes the original BF16 tensors.
|
| 62 |
|
| 63 |
## Credits
|
| 64 |
|
|
|
|
| 66 |
|
| 67 |
## License
|
| 68 |
|
| 69 |
+
The weights keep the [Mistral Ecosystem Open-Weight License](LICENSE) from the
|
| 70 |
+
source model. The Python files are MIT; see [LICENSE-CODE](LICENSE-CODE).
|