Fine-tuned
Qwen3-VL-2B-Instruct for
PDF-to-markdown conversion using Supervised Fine-Tuning (SFT) only.
This is the
intermediate SFT checkpoint before GRPO refinement. The best model with GRPO is available at
blazeofchi/pdf-ocr-rl-qwen3vl2b-sft-grpo.
This checkpoint was produced by Stage 1 of the two-stage training pipeline.
Teaches the model the image-to-markdown mapping using supervised examples from rendered PDF pages paired with their source markdown.
-
Intermediate checkpoint for GRPO: This is the starting point for Stage 2 (GRPO refinement). GRPO alone produces near-zero gradients on vision-language models — SFT warm-up is essential.
-
SFT-only baseline: Compare against the full SFT+GRPO model to measure the contribution of GRPO refinement.
1from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2from peft import PeftModel
3from qwen_vl_utils import process_vision_info
4from PIL import Image
5import torch
6
7base_model = Qwen3VLForConditionalGeneration.from_pretrained(
8 "unsloth/Qwen3-VL-2B-Instruct",
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11)
12
13model = PeftModel.from_pretrained(
14 base_model, "blazeofchi/pdf-ocr-rl-qwen3vl2b-sft-only"
15)
16processor = AutoProcessor.from_pretrained(
17 "blazeofchi/pdf-ocr-rl-qwen3vl2b-sft-only"
18)
19
20image = Image.open("page.png")
21messages = [
22 {"role": "user", "content": [
23 {"type": "image", "image": image},
24 {"type": "text", "text": "Convert this PDF page to well-structured markdown."}
25 ]}
26]
27
28text = processor.apply_chat_template(
29 messages, tokenize=False, add_generation_prompt=True
30)
31image_inputs, video_inputs = process_vision_info(messages)
32inputs = processor(
33 text=[text], images=image_inputs,
34 padding=True, return_tensors="pt"
35).to(model.device)
36
37output = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
38result = processor.decode(
39 output[0][inputs.input_ids.shape[1]:], skip_special_tokens=True
40)
41print(result)
1@misc{pdf-ocr-rl-2026,
2 title={PDF-OCR-RL: Fine-tuning Vision-Language Models for PDF-to-Markdown with GRPO},
3 author={Paras Sharma},
4 year={2026},
5 url={https://github.com/Parassharmaa/pdf-ocr-rl}
6}