Downloads · 30 days
0
Abhiram1404/qwen2vl-doc-ocr-lora
qwen2vl-doc-ocr-lora is a machine learning model from Abhiram1404. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
A LoRA adapter for Qwen2-VL-7B-Instruct fine-tuned for document OCR — given a scanned document image, it outputs the extracted text in reading order.
Downloads · 30 days
0
Access
Public
Updated Aug 26, 2026
Repo size
215 MB
Likes
0
Public
Click a slice to open those files.
.safetensors204 MB · 95%
From the Hugging Face model README
A LoRA adapter for Qwen2-VL-7B-Instruct fine-tuned for document OCR — given a scanned document image, it outputs the extracted text in reading order.
unsloth/Qwen2-VL-7B-Instruct-unsloth-bnb-4bitThis qwen2_vl model was trained 2x faster with Unsloth and TRL's SFTTrainer.
Trained on real scanned documents from RVL-CDIP
(38.7 GB tarball, 16 document classes — letter, form, invoice, resume, memo, etc.) paired with real
per-image OCR annotations from jordyvl/rvl_cdip_easyocr
(EasyOCR word/box outputs, reconstructed into reading-order text lines).
Caveat: RVL-CDIP is built from 1990s tobacco-litigation document scans — real scan artifacts, but era-appropriate layouts (e.g. its "resume" class looks typewriter/dot-matrix-era, not like a modern resume). Ground truth is EasyOCR's own output, not human transcription, so it inherits EasyOCR's error rate on these low-quality scans.
FastVisionModel.get_peft_model, r=16, lora_alpha=16, lora_dropout=0,
target_modules="all-linear", adapters on both vision and language layers (attention + MLP).load_in_4bit=True) with "unsloth" gradient checkpointing.SFTTrainer with UnslothVisionDataCollator, batch size 1, gradient accumulation 8
(effective batch size 8), 120 steps, learning_rate=2e-4, linear schedule with 5 warmup steps,
adamw_8bit, bf16/fp16 mixed precision, max_seq_length=2048.from unsloth import FastVisionModel
model, tokenizer = FastVisionModel.from_pretrained(
"Abhiram1404/qwen2vl-doc-ocr-lora",
load_in_4bit=True,
)
FastVisionModel.for_inference(model)
instruction = "Extract all the text from this document image, preserving line order."
messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": instruction}]}]
input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
inputs = tokenizer(image, input_text, add_special_tokens=False, return_tensors="pt").to("cuda")
output_ids = model.generate(**inputs, max_new_tokens=512, temperature=0.2, do_sample=True)
print(tokenizer.decode(output_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))