OCR DocVQA Donut
Overview
Highlights
- OCR-free architecture reduces pipeline complexity and latency
- Direct visual-to-text mapping eliminates OCR transcription errors
- Optimized for structured documents like receipts and invoices
- MIT licensed for flexible commercial and private integration
Usage
# Install Hugging Face transformers
pip install transformers torch
# Load model with transformers
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("jinhybr/OCR-DocVQA-Donut")
tokenizer = AutoTokenizer.from_pretrained("jinhybr/OCR-DocVQA-Donut")
Hugging Face Download
We recommend downloading the model via the Hugging Face CLI or Hub SDK.
Guidance:Before downloading, install huggingface_hub with:
pip install -U huggingface_hub
CLI Download
Download the full repository
huggingface-cli download jinhybr/OCR-DocVQA-Donut
Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download jinhybr/OCR-DocVQA-Donut config.json --local-dir ./dir
See the official docs for more CLI options
SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('jinhybr/OCR-DocVQA-Donut')
Git Download
Make sure git-lfs is installed first
git lfs install
git clone https://huggingface.co/jinhybr/OCR-DocVQA-Donut
To skip LFS large-file downloads, use:
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/jinhybr/OCR-DocVQA-Donut
Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.
PyTorch / Transformers Usage
Install Transformers
pip install -U transformers torch
Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('jinhybr/OCR-DocVQA-Donut')
tokenizer = AutoTokenizer.from_pretrained('jinhybr/OCR-DocVQA-Donut')
Full Documentation
---
license: mit
pipeline_tag: document-question-answering
tags:
- donut
- image-to-text
- vision
widget:
- text: "What is the invoice number?"
src: "https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"
- text: "What is the purchase amount?"
src: "https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/contract.jpeg"
---
Donut (base-sized model, fine-tuned on DocVQA)
Donut model fine-tuned on DocVQA. It was introduced in the paper OCR-free Document Understanding Transformer by Geewok et al. and first released in this repository.
Disclaimer: The team releasing Donut did not write a model card for this model so this model card has been written by the Hugging Face team.
Model description
Donut consists of a vision encoder (Swin Transformer) and a text decoder (BART). Given an image, the encoder first encodes the image into a tensor of embeddings (of shape batch_size, seq_len, hidden_size), after which the decoder autoregressively generates text, conditioned on the encoding of the encoder.
Intended uses & limitations
This model is fine-tuned on DocVQA, a document visual question answering dataset.
We refer to the documentation which includes code examples.