1 from PIL import Image
2 from tinydoc import TinyDocExtractor
3
4 extractor = TinyDocExtractor ( device = "cpu" )
5
6 # Ask questions
7 img = Image . open ( "invoice.png" )
8 result = extractor . ask ( img , "What is the total?" )
9 print ( result . answer ) # "$1,234.56"
10
11 # Extract structured JSON
12 result = extractor . extract ( img , output_format = "json" )
13 print ( result . fields ) # {"total": "$1,234.56", "date": "2024-01-15", ...}
14
15 # Extract tables
16 result = extractor . extract_table ( img )
17 print ( result . markdown )
1 from tinydoc_vlm import TinyDocVLMForConditionalGeneration , TinyDocVLMProcessor
2
3 model = TinyDocVLMForConditionalGeneration . from_pretrained ( "eulogik/TinyDoc-VLM-256M" )
4 processor = TinyDocVLMProcessor ( )
Image (384×384)
↓
SigLIP Vision Encoder (93M) ← 576 patches × 768 dim
↓
Pixel-Shuffle Compressor (scale=3) ← 9× compression → 64 tokens
↓
Visual Position Embeddings
↓
SmolLM2 Decoder (135M) ← 30 layers, GQA (9:3 heads), 8192 ctx
↓
Multi-Task Output Heads
↓
JSON / KV Extraction / Table / OCR / QA
1 # Generate synthetic docs
2 python data/synthetic/generator.py --num-docs 1000 --output-dir data/synthetic/output
3
4 # Train on M4 Mac (~4.6 hours for 5K steps)
5 python training/fast_train.py --steps 5000 --device mps
6
7 # Train on GPU (~1 hour for 5K steps)
8 python training/fast_train.py --steps 5000 --device cuda
1 @software{eulogik_tinydoc_vlm_2026,
2 author = {eulogik},
3 title = {TinyDoc-VLM: 256M-Param Document-Specialist Vision-Language Model},
4 year = {2026},
5 url = {https://github.com/eulogik/TinyDoc-VLM}
6 }
Apache 2.0. Free for commercial use.
Built by eulogik — AI infrastructure for document intelligence.