Recipes / Document & invoice OCR
Fine-tune Qwen2-VL-7B to answer questions about charts and documents (HF Cookbook)
Qwen2-VL-7B fine-tuned with TRL on ChartQA (questions about charts), with a QLoRA setup.
- GPL-3.0 data
Source: HF Cookbook ↗ · by Sergio Paniego · last updated Jan 9, 2026
What a local business could build with it
Questions answered from a sales chart or report page. A step up from plain OCR when staff ask 'what was March revenue?'
How to run it
Commands are copied from the source, unchanged except where a notebook cell is cut at 40 lines (marked in the code). Placeholders like <you> are the source's own. Credit goes to the authors named on each block.
Install (as written in the notebook)
!pip install -U -q git+https://github.com/huggingface/trl.git bitsandbytes peft qwen-vl-utils trackio
# Tested with trl==0.22.0.dev0, bitsandbytes==0.47.0, peft==0.17.1, qwen-vl-utils==0.0.11, trackio==0.2.8
Set up training
from trl import SFTTrainer
trainer = SFTTrainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
peft_config=peft_config,
processing_class=processor,
)
Licenses
License flags to read before commercial use:
- Dataset: GPL-3.0 copyleft: check what it means for your product. GPL-3.0 (copyleft)
| Part | License, as the source or Hub states it |
|---|---|
| Code | Apache-2.0 (huggingface/cookbook) |
| Base model | Apache-2.0 |
| Dataset | GPL-3.0 (copyleft) |
Checked against the Hugging Face API and each repo on December 4, 2026. A grouping like “$10M revenue cap” is our shorthand, not legal advice.