Downloads · 30 days
0
SwinginBaloo/sdpo-fewshot-ocr-qwen2vl-2b
sdpo-fewshot-ocr-qwen2vl-2b is a machine learning model from SwinginBaloo. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This project implements Self-Distillation Policy Optimization (SDPO) to train a small VLM (Qwen2-VL-2B-Instruct) to perform document information extraction without few-shot examples, by distilling knowledge from its o…
Downloads · 30 days
0
Access
Public
Updated May 5, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py17.1 KB · 78%
From the Hugging Face model README
This project implements Self-Distillation Policy Optimization (SDPO) to train a small VLM (Qwen2-VL-2B-Instruct) to perform document information extraction without few-shot examples, by distilling knowledge from its own few-shot-augmented teacher.
A_t = log P_teacher(y_t) - log P_student(y_t)
nielsr/docvqa_1200_examples) — document images with questions and answersprepare_sdpo_dataset.py — prepares DocVQA with student/teacher promptstrain_sdpo_vlm.py — SDPO training loop# Prepare dataset (creates docvqa_sdpo_train/ and docvqa_sdpo_test/)
python prepare_sdpo_dataset.py
# Train (requires CUDA GPU, ~16GB VRAM)
python train_sdpo_vlm.py
| Param | Value |
|---|---|
| Learning rate | 5e-6 |
| Epochs | 2 |
| Micro batch size | 1 |
| Gradient accumulation | 8 (effective batch = 8) |
| Max completion length | 64 tokens |
| Temperature | 0.7 |
| Top-p | 0.9 |
| Max examples | 600 |
| Few-shot bank size | 25 |
| Few-shot per sample | 2 |
The few-shot bank acts as an episodic memory. During training, we randomly sample different subsets of examples for each training step. The model learns to extract patterns from these examples and internalize them into its weights. Over time, the zero-shot student matches the few-shot teacher, effectively "learning" from the bank without needing the bank at inference time. New examples can be continually added to the bank and the model re-trained.
<!-- ml-intern-provenance -->This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.