Skip to content
Other

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 moreDetails
Metrics (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.
Discuss Telegram 0

Will it run?

Working out the memory needs

The bot is still collecting this model's weight sizes; the estimate will appear here in a few minutes. Meanwhile you can rent a GPU with headroom.

Massed ComputeOpen Massed Compute

Run it on Massed Compute

The script downloads the model to the rented machine. How to run it is in the model card.

  1. 1. Rent a machine with a fitting GPU

    Open Massed Compute
  2. 2. Paste the script into the machine's terminal

    Connect over SSH (the Massed Compute panel shows the command) or open a terminal on the machine's desktop.

    HF_TOKEN / CIVITAI_TOKENThe script starts with token lines: paste yours between the quotes. The Hugging Face token is for gated models, the Civitai one for Civitai models.

    # wjwjwjwjwjww/Qwen3.5-0.8B-TextPreprocessor-struct-lora
    # ===== Tokens: paste yours between the quotes =====
    export HF_TOKEN=""        # huggingface.co/settings/tokens, for gated models
    # ==========================================
    mkdir -p ~/models
    curl -LsSf https://astral.sh/uv/install.sh | sh
    source "$HOME/.local/bin/env"
    uv tool install "huggingface_hub[cli]"
    hf download wjwjwjwjwjww/Qwen3.5-0.8B-TextPreprocessor-struct-lora --local-dir ~/models/Qwen3.5-0.8B-TextPreprocessor-struct-lora
    # The model is in ~/models. How to run it is in the model card (link above).
  3. 3. Use it

    The model is in ~/models. How to run it is in the model card (link above).

Stop the machine in the panel when you are done: it bills by the minute while it runs.

How to speed it up

Picked for this model type. Choose your hardware above to see what fits you exactly.

  • FlashAttention 44.0.0b40from November 18, 2026new release

    fastest exact attention on B200

    Kernels for Blackwell (beta). Exact attention without quantisation — fine for everything, LLMs included.

    How to enable: pip install flash-attn-4; vLLM and SGLang pick it up themselves.

    Earlier generations (2)
    • FlashAttention 3 — The Hopper (H100/H200) version with FP8.
    • FlashAttention 2 — The standard for RTX 30/40/50 and A100: exact attention without the memory cost of long contexts.
  • torch.compile2.15.0from October 28, 2026new release

    10–30% for free

    Compiles the model for your GPU. Slower first run, faster afterwards.

    How to enable: model = torch.compile(model); in ComfyUI the TorchCompileModel node.

Model family

New posts about versions of Qwen3.5-0.8B-TextPreprocessor-struct-lora (quants, finetunes, LoRAs) will show up under the bell.

No known relatives of this model yet. All derivatives on Hugging Face

About the model

wjwjwjwjwjww/Qwen3.5-0.8B-TextPreprocessor-struct-lora
Author
wjwjwjwjwjww
Category
Other
Released
Posted

On NeyroLearn

Hugging Face

00

Ask AI about this model

Answered by Gemini 4 · the chat is kept only in this tab

Comments