Instructions to use hxcsa/qwen35-4b-docvqa-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use hxcsa/qwen35-4b-docvqa-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-4B") model = PeftModel.from_pretrained(base_model, "hxcsa/qwen35-4b-docvqa-lora") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use hxcsa/qwen35-4b-docvqa-lora with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for hxcsa/qwen35-4b-docvqa-lora to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for hxcsa/qwen35-4b-docvqa-lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for hxcsa/qwen35-4b-docvqa-lora to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="hxcsa/qwen35-4b-docvqa-lora", max_seq_length=2048, )
Qwen3.5-4B DocVQA LoRA (v2_r32_mlp)
LoRA adapters fine-tuning Qwen/Qwen3.5-4B for document visual question answering. Trained with Unsloth on 2,000 curated DocVQA samples from the train split.
Usage (critical: disable thinking)
from unsloth import FastVisionModel
from peft import PeftModel
base, processor = FastVisionModel.from_pretrained("Qwen/Qwen3.5-4B", load_in_4bit=True)
FastVisionModel.for_inference(base)
model = PeftModel.from_pretrained(base, "hxcsa/qwen35-4b-docvqa-lora")
FastVisionModel.for_inference(model)
# Qwen3.5 is a thinking-style model โ disable thinking for concise answers
text = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=False,
enable_thinking=False, # โ essential
)
inputs = processor(images=image, text=text, add_special_tokens=False, return_tensors="pt").to("cuda")
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
answer = processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()
Results (ANLS on 300 DocVQA validation, seed 1234, 1344px)
| Model | ANLS | Exact Match |
|---|---|---|
| Qwen3.5-4B base (zero-shot) | 0.6265 | 0.5933 |
| v1 LoRA (1k from val, contaminated) | 0.8626 | 0.8333 |
| v2 r16 attn-only (2k train, 2 epochs) | 0.8687 | 0.8567 |
| v2 r32 + MLP (2k train, 2 epochs) | 0.8833 | 0.8667 |
+0.26 ANLS over zero-shot. Clean eval (trained on train, tested on val).
Training
- Base: Qwen/Qwen3.5-4B (4-bit NF4)
- LoRA: r=32, ฮฑ=32, dropout 0 โ attention (q/k/v/o) + MLP (gate/up/down)
- ViT frozen; loss on assistant tokens only
- 2 epochs, 2,000 samples, eff. batch 8, LR 2e-4 cosine, bf16
- 5% holdout eval โ best checkpoint auto-restored
- ~34 min on A6000 48 GB, peak VRAM 4.8 GB
Data
Trained on hxcsa/docvqa-2k-train (2,000 samples from DocVQA train split,
quality-filtered, 1344px max edge). The validation ANLS uses the clean
DocVQA validation split.
Files
adapter_model.safetensorsโ LoRA weights (34 MB)tokenizer.json/tokenizer_config.json/chat_template.jinjaโ Qwen3.5 templateprocessor_config.jsonโ vision processor config
- Downloads last month
- 87
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ Ask for provider support