Views
No views yet



q_proj and v_proj attention layers, fine-tuned specifically for JSON syntax and Key-Value extraction.| Feature | PaddleOCR (v2) | Grab's Custom DocLLM | Chhagan-DocVL-Qwen3 |
|---|---|---|---|
| Generation | Gen 1 (Detection + Recognition) | Gen 3 (Composite LLM) | Gen 4 (Unified Vision-LLM) |
| Core Tech | CNN + RNN + CTC | Custom 1B (Encoder + Decoder) | Qwen3-VL-2B (Instruct Base) |
| Output | Unstructured Text Swatches | Structured JSON | Structured JSON |
| Reasoning | ❌ None (Text Only) | ⚠️ Moderate (0.5B Decoder) | ✅ High (2B Instruct Base) |
| Complexity | High (Multi-stage Pipeline) | High (Custom Pre-training) | Low (Single LoRA Adapter) |
| Use Case | General Text Recognition | Ride-Hailing Documents | Global Identity & Finance |

pip install -U transformers peft accelerate qwen-vl-utils1import torch
2from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
3from peft import PeftModel
4from qwen_vl_utils import process_vision_info
5
6# 1. Initialize
7base_model = "Qwen/Qwen3-VL-2B-Instruct"
8adapter = "Chhagan005/Chhagan-DocVL-Qwen3"
9
10model = Qwen2VLForConditionalGeneration.from_pretrained(
11 base_model, torch_dtype=torch.float16, device_map="auto"
12)
13model = PeftModel.from_pretrained(model, adapter)
14processor = AutoProcessor.from_pretrained(base_model)
15
16# 2. Run Inference
17messages = [
18 {
19 "role": "user",
20 "content": [
21 {"type": "image", "image": "https://example.com/passport.jpg"},
22 {"type": "text", "text": "Extract fields: Name, Passport No, Nationality, DOB."}
23 ]
24 }
25]
26
27text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28image_inputs, video_inputs = process_vision_info(messages)
29inputs = processor(
30 text=[text],
31 images=image_inputs,
32 videos=video_inputs,
33 padding=True,
34 return_tensors="pt"
35).to("cuda")
36
37generated_ids = model.generate(**inputs, max_new_tokens=1024)
38print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])