Views
No views yet
unsloth/Qwen2-VL-7B-Instruct-unsloth-bnb-4bitSFTTrainer.jordyvl/rvl_cdip_easyocr
(EasyOCR word/box outputs, reconstructed into reading-order text lines).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.1from unsloth import FastVisionModel
2
3model, tokenizer = FastVisionModel.from_pretrained(
4 "Abhiram1404/qwen2vl-doc-ocr-lora",
5 load_in_4bit=True,
6)
7FastVisionModel.for_inference(model)
8
9instruction = "Extract all the text from this document image, preserving line order."
10messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": instruction}]}]
11input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
12inputs = tokenizer(image, input_text, add_special_tokens=False, return_tensors="pt").to("cuda")
13
14output_ids = model.generate(**inputs, max_new_tokens=512, temperature=0.2, do_sample=True)
15print(tokenizer.decode(output_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
16