Model reference · open weights
pix2struct is an open-weight language model from Google. pix2struct-base (FP32) weighs 565 MB; the smallest configuration that runs it is RTX 3060 12 GB.
Summary of the google/pix2struct-base model card, 2026-10-01
What it is
| Released by | |
|---|---|
| Released | 2023-03-13 |
| Parameters | 282M |
| VRAM | 565 MB for the weights |
What it runs on
| Card | Requests at once | Context max | Memory | |
|---|---|---|---|---|
| 8K each | 32K each | |||
| RTX 3060 12 GB | 30 | 7 | 128K | 11.6 GB |
| RTX 4060 Ti 16 GB | 43 | 10 | 128K | 15.4 GB |
| RTX 3090 24 GB | 69 | 17 | 128K | 23.4 GB |
| RTX 4090 24 GB | 69 | 17 | 128K | 23.4 GB |
| RTX 5090 32 GB | 94 | 23 | 128K | 31.0 GB |
| L40S 48 GB | 137 | 34 | 128K | 44.0 GB |
| A100 80 GB | 251 | 62 | 128K | 78.2 GB |
| H100 80 GB | 241 | 60 | 128K | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | 293 | 73 | 128K | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | 338 | 84 | 128K | 107 GB |
| H200 141 GB | 439 | 109 | 128K | 138 GB |
| B200 180 GB | 565 | 141 | 128K | 176 GB |
| Requests at once | 8K tokens each | 32K tokens each |
|---|---|---|
| 1 | 2.7 GB | 3.6 GB |
| 5 | 3.9 GB | 8.4 GB |
| 8 | 4.8 GB | 12.0 GB |
| 16 | 7.2 GB | 21.7 GB |
| 32 | 12.0 GB | 41.0 GB |
| 64 | 21.7 GB | 79.7 GB |
One card, with vLLM's small-card settings.
From the model card
This model is the pretrained version of Pix2Struct, use this model for fine-tuning purposes only.
Pix2Struct is an image encoder - text decoder model that is trained on image-text pairs for various tasks, including image captionning and visual question answering. The full list of available models can be found on the Table 1 of the paper:
The abstract of the model states that:
Visually-situated language is ubiquitous—sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and forms. Perhaps due to this diversity, previous work has typically relied on domainspecific recipes with limited sharing of the underlying data, model architectures, and objectives. We present Pix2Struct, a pretrained image-to-text model for purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse masked screenshots of web pages into simplified HTML. The web, with its richness of visual elements cleanly reflected in the HTML structure, provides a large source of pretraining data well suited to the diversity of downstream tasks. Intuitively, this objective subsumes common pretraining signals such as OCR, language modeling, image captioning. In addition to the novel pretraining strategy, we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions are rendered directly on top of the input image. For the first time, we show that a single pretrained model can achieve state-of-the-art results in six out of nine tasks across four domains: documents, illustrations, user interfaces, and natural images.
You can use the convert_pix2struct_checkpoint_to_pytorch.py script as follows:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE
if you are converting a large model, run:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --use-large
Once saved, you can push your converted model with the following snippet:
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
model = Pix2StructForConditionalGeneration.from_pretrained(PATH_TO_SAVE)
processor = Pix2StructProcessor.from_pretrained(PATH_TO_SAVE)
model.push_to_hub("USERNAME/MODEL_NAME")
processor.push_to_hub("USERNAME/MODEL_NAME")
This model was originally contributed by Kenton Lee, Mandar Joshi et al. and added to the Hugging Face ecosystem by Younes Belkada.
If you want to cite this work, please consider citing the original paper:
@misc{https://doi.org/10.48550/arxiv.2210.03347,
doi = {10.48550/ARXIV.2210.03347},
url = {https://arxiv.org/abs/2210.03347},
author = {Lee, Kenton and Joshi, Mandar and Turc, Iulia and Hu, Hexiang and Liu, Fangyu and Eisenschlos, Julian and Khandelwal, Urvashi and Shaw, Peter and Chang, Ming-Wei and Toutanova, Kristina},
keywords = {Computation and Language (cs.CL), Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.