Visual Question Answering
PEFT
Safetensors
PyTorch
English
lora
vision-language-model
document-understanding
ocr
tinyml
fine-tuning
huggingface
low-resource
edge-deployment
cpu-inference
small-language-model
document-ai
structured-extraction
Instructions to use eulogik/TinyDoc-VLM-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use eulogik/TinyDoc-VLM-LoRA with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("eulogik/TinyDoc-VLM-256M") model = PeftModel.from_pretrained(base_model, "eulogik/TinyDoc-VLM-LoRA") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -21,106 +21,39 @@ base_model: eulogik/TinyDoc-VLM-256M
|
|
| 21 |
library_name: peft
|
| 22 |
pipeline_tag: visual-question-answering
|
| 23 |
---
|
| 24 |
-
|
| 25 |
# TinyDoc-VLM LoRA Checkpoint
|
| 26 |
|
| 27 |
-
>
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
A **LoRA adapter** for TinyDoc-VLM-256M that fine-tunes the model on document understanding tasks. Only **2.7M params** (0.93% of total) are trained, making it efficient to train and deploy.
|
| 36 |
-
|
| 37 |
-
## Quick Start
|
| 38 |
|
| 39 |
-
|
| 40 |
-
from tinydoc_vlm import TinyDocVLMForConditionalGeneration, TinyDocVLMProcessor
|
| 41 |
-
from peft import PeftModel
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
model = PeftModel.from_pretrained(model, "eulogik/TinyDoc-VLM-LoRA")
|
| 48 |
-
|
| 49 |
-
# Merge for inference (optional, but faster)
|
| 50 |
-
model = model.merge_and_unload()
|
| 51 |
-
|
| 52 |
-
processor = TinyDocVLMProcessor()
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
## Training Details
|
| 56 |
|
| 57 |
| Parameter | Value |
|
| 58 |
-
|---
|
| 59 |
-
| Base model | [eulogik/TinyDoc-VLM-256M](https://huggingface.co/eulogik/TinyDoc-VLM-256M) |
|
| 60 |
-
| LoRA rank | 16 |
|
| 61 |
-
|
|
| 62 |
-
| Trainable params | 2,727,936 (0.93% of total) |
|
| 63 |
| Target modules | q_proj, v_proj, k_proj, o_proj |
|
| 64 |
-
|
|
| 65 |
-
|
|
| 66 |
-
|
|
| 67 |
-
| Final loss | 17.2 (from 43.3) |
|
| 68 |
-
| Hardware | Apple M4 Mac |
|
| 69 |
-
| Training time | 15.1 hours |
|
| 70 |
-
|
| 71 |
-
## Training Curve
|
| 72 |
-
|
| 73 |
-
```
|
| 74 |
-
Step 25: 43.3 ββββββββββββββββββββββββββββββββββββββββββββ
|
| 75 |
-
Step 500: 25.7 βββββββββββββββββββββββββββ
|
| 76 |
-
Step 1000: 20.9 βββββββββββββββββββββ
|
| 77 |
-
Step 5000: 18.6 ββββββββββββββββββ
|
| 78 |
-
Step 10000: 16.5 ββββββββββββββββ
|
| 79 |
-
Step 14000: 15.0 βββββββββββββββ β
Best
|
| 80 |
-
Step 17000: 17.2 βββββββββββββββββ
|
| 81 |
-
```
|
| 82 |
-
|
| 83 |
-
## What This Trains
|
| 84 |
-
|
| 85 |
-
- **Document OCR** β Printed text recognition
|
| 86 |
-
- **Form field extraction** β Key-value pair extraction
|
| 87 |
-
- **Receipt/invoice parsing** β Amount, date, vendor extraction
|
| 88 |
-
- **Table structure understanding** β Cell extraction
|
| 89 |
-
- **Visual question answering** β Answer questions about documents
|
| 90 |
-
|
| 91 |
-
## How to Reproduce
|
| 92 |
-
|
| 93 |
-
```bash
|
| 94 |
-
# Clone repo
|
| 95 |
-
git clone https://github.com/eulogik/TinyDoc-VLM.git
|
| 96 |
-
cd TinyDoc-VLM
|
| 97 |
-
pip install -e .
|
| 98 |
-
|
| 99 |
-
# Generate synthetic docs
|
| 100 |
-
python data/synthetic/generator.py --num-docs 3000 --output-dir data/synthetic/output
|
| 101 |
-
|
| 102 |
-
# Train LoRA (17K steps, ~15 hours on M4)
|
| 103 |
-
python training/fast_train.py --manifest data/synthetic/output/manifest.jsonl --data-root data/synthetic --steps 17000 --batch-size 1 --grad-accum 4 --device mps
|
| 104 |
-
|
| 105 |
-
# Or use overnight script
|
| 106 |
-
bash training/overnight_train.sh
|
| 107 |
-
```
|
| 108 |
-
|
| 109 |
-
## Next Steps
|
| 110 |
-
|
| 111 |
-
- Scale to 10K+ documents
|
| 112 |
-
- Add public benchmarks (DocVQA, FUNSD, CORD)
|
| 113 |
-
- Train for 50K+ steps
|
| 114 |
-
- Export to ONNX
|
| 115 |
-
|
| 116 |
-
## Links
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
| Base Model | [eulogik/TinyDoc-VLM-256M](https://huggingface.co/eulogik/TinyDoc-VLM-256M) |
|
| 121 |
-
| GitHub | [github.com/eulogik/TinyDoc-VLM](https://github.com/eulogik/TinyDoc-VLM) |
|
| 122 |
-
| Live Demo | [huggingface.co/spaces/eulogik/TinyDoc-VLM](https://huggingface.co/spaces/eulogik/TinyDoc-VLM) |
|
| 123 |
-
| Training Script | [training/fast_train.py](https://github.com/eulogik/TinyDoc-VLM/blob/main/training/fast_train.py) |
|
| 124 |
|
| 125 |
## License
|
| 126 |
|
|
|
|
| 21 |
library_name: peft
|
| 22 |
pipeline_tag: visual-question-answering
|
| 23 |
---
|
| 24 |
+
---
|
| 25 |
# TinyDoc-VLM LoRA Checkpoint
|
| 26 |
|
| 27 |
+
> ## β οΈ RETIRED β adapter makes outputs worse
|
| 28 |
+
>
|
| 29 |
+
> This LoRA adapter is part of the failed training line of the 256M checkpoint.
|
| 30 |
+
> In paired evaluation it **degrades generation into literal degeneration**
|
| 31 |
+
> (`"$ "$ "$"`, `22222`) compared even already-broken base weights, which
|
| 32 |
+
> themselves measure **0.0% OCRBench (n=1,000)**. Loss values below are training
|
| 33 |
+
> loss only β they never correlated with output quality. Kept for
|
| 34 |
+
> reproducibility; do not use for extraction.
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
## What actually ships
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
The working product is the **local grounded-extraction SDK** running on free
|
| 39 |
+
`ollama:qwen2.5vl:3b` β measured **SROIE field F1 0.870 vs 0.376** for the free
|
| 40 |
+
PP-OCR+heuristics competitor (same 100 docs, same scorer):
|
| 41 |
+
[github.com/eulogik/TinyDoc-VLM](https://github.com/eulogik/TinyDoc-VLM).
|
| 42 |
|
| 43 |
+
## Historical training record (2026-06)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
| Parameter | Value |
|
| 46 |
+
|---|---|
|
| 47 |
+
| Base model | [eulogik/TinyDoc-VLM-256M](https://huggingface.co/eulogik/TinyDoc-VLM-256M) (retired) |
|
| 48 |
+
| LoRA rank / alpha | 16 / 32 |
|
| 49 |
+
| Trainable params | 2,727,936 (0.93%) |
|
|
|
|
| 50 |
| Target modules | q_proj, v_proj, k_proj, o_proj |
|
| 51 |
+
| Data | 3,000 synthetic documents (6,815 QA pairs) |
|
| 52 |
+
| Steps / best step | 17,000 / 14,000 (train loss 15.0) |
|
| 53 |
+
| Hardware / time | Apple M4, 15.1 h |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
Training loss trajectory (loss only β not a quality metric):
|
| 56 |
+
`43.3 β 25.7 β 20.9 β 18.6 β 16.5 β 15.0 (best, step 14k) β 17.2 (final)`
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
## License
|
| 59 |
|