Run this model with HF Jobs
Run hf-tuner/donut-base-finetuned-docvqa on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/hf-tuner/donut-base-finetuned-docvqa. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/hf-tuner/donut-base-finetuned-docvqa on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/hf-tuner/donut-base-finetuned-docvqa. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/hf-tuner/donut-base-finetuned-docvqa. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use hf-tuner/donut-base-finetuned-docvqa with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hf-tuner/donut-base-finetuned-docvqa with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="hf-tuner/donut-base-finetuned-docvqa")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("hf-tuner/donut-base-finetuned-docvqa") model = AutoModel.from_pretrained("hf-tuner/donut-base-finetuned-docvqa", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hf-tuner/donut-base-finetuned-docvqa with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hf-tuner/donut-base-finetuned-docvqa" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hf-tuner/donut-base-finetuned-docvqa", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hf-tuner/donut-base-finetuned-docvqa
- SGLang
How to use hf-tuner/donut-base-finetuned-docvqa with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hf-tuner/donut-base-finetuned-docvqa" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hf-tuner/donut-base-finetuned-docvqa", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "hf-tuner/donut-base-finetuned-docvqa" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hf-tuner/donut-base-finetuned-docvqa", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hf-tuner/donut-base-finetuned-docvqa with Docker Model Runner:
docker model run hf.co/hf-tuner/donut-base-finetuned-docvqa
donut-base-finetuned-docvqa
This model is a fine-tuned version of naver-clova-ix/donut-base on hf-tuner/docvqa-10k-donut dataset.
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.

How to use
import torch
from PIL import Image
from transformers import DonutProcessor, VisionEncoderDecoderConfig, VisionEncoderDecoderModel
model_id = "hf-tuner/donut-base-finetuned-docvqa"
config = VisionEncoderDecoderConfig.from_pretrained(model_id)
processor = DonutProcessor.from_pretrained(model_id)
device = "cuda" if torch.cuda.is_available() else "cpu"
config.dtype = torch.float16 if torch.cuda.is_available() else torch.float32
model = VisionEncoderDecoderModel.from_pretrained(ckpt, config=config)
model.to(device)
PROMPT_TEMPLATE = "<doc_vqa><s><s_question>{}</s_question><s_answer>"
def predict(image, question):
prompt = PROMPT_TEMPLATE.format(question)
pixel_values = processor(image,
return_tensors="pt"
).pixel_values.to(device)
decoder_input_ids = processor.tokenizer(prompt,
add_special_tokens=False,
return_tensors="pt"
).input_ids.to(device)
generated_ids = model.generate(pixel_values,
decoder_input_ids=decoder_input_ids,
max_length=64,
bad_words_ids=[[processor.tokenizer.unk_token_id]]
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
output_json = processor.token2json(generated_text)
return output_json
output = predict(image=Image.open('doc-image.png'), question="Which is the date of the approval form?")
# {"question": "Which is the date of the approval form?", "answer": "april 5, 1995"}
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 1
- eval_batch_size: 8
- seed: 42
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
- lr_scheduler_type: linear
- num_epochs: 1
- mixed_precision_training: Native AMP
Framework versions
- Transformers 4.56.1
- Pytorch 2.6.0+cu124
- Datasets 3.6.0
- Tokenizers 0.22.1
- Downloads last month
- 13
Model tree for hf-tuner/donut-base-finetuned-docvqa
Base model
naver-clova-ix/donut-base