Qwen3.5-0.8B-TextPreprocessor (v2)
structural LoRA for document OCR to Markdown
2 min readupdated
This is a LoRA (a lightweight add-on built on top of a base model) that trains the compact Qwen/3.5-0.8B model to convert document page images into structured Markdown with headings and HTML tables. The base model has 0.8B parameters and is a native multimodal solution. Version v2 was trained on a mix of real and synthetic data, significantly improving its table recognition performance. It is useful for developers and researchers who need to quickly convert scans or PDF pages into clean, structured text locally.
Key features
- Added support for outputting headings and HTML tables from page images.
- Version v2 shows a 116% increase in the Table TEDS metric compared to the baseline.
- Compact footprint: just 3.19M parameters for the LoRA (rank r=8).
- Low hardware requirements thanks to the modest size of the base model.
What you can do
- Apply the v2 LoRA weights on top of the base checkpoint to extract tables and layout structure from documents.
- Run a Python script with the transformers and peft libraries for batch page processing.
- Convert document pages into clean, structured Markdown content.
Example
import torch
from PIL import Image
from transformers import AutoTokenizer, AutoImageProcessor, AutoModelForImageTextToText
from transformers.processing_utils import ProcessorMixin
from peft import PeftModel
ProcessorMixin.check_argument_for_proper_class = lambda self, attr, arg: None
from transformers.models.qwen3_vl.processing_qwen3_vl import Qwen3VLProcessor
BASE = "w666j66666/Qwen3.5-0.8B-TextPreprocessor"
tok = AutoTokenizer.from_pretrained(BASE)
imgp = AutoImageProcessor.from_pretrained(BASE)
proc = Qwen3VLProcessor(image_processor=imgp, tokenizer=tok)
model = AutoModelForImageTextToText.from_pretrained(BASE, dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, "./adapter_v2")
model.eval()
img = Image.open("page.png").convert("RGB")
msg = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Convert this document page into Markdown."}]}]
text = tok.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
enc = proc(text=[text], images=[img], return_tensors="pt")
Read more
DetailsMetrics (OmniDocBench, 30 pages): v2 TEDS 0.2307 (+116% over baseline), rule 96.0%.
Hardware requirements: peak VRAM around 1.8 GB.
Training: r=8, alpha=16, dropout=0.05, target=q/k/v/o/gate/up/down_proj, vision tower frozen.
Limitations: drop in plain text accuracy (Text Edit 0.284 to 0.361), sensitivity to resolutions below 900px.










Comments