CoolFace
Modelpublic

eulogik/TinyDoc-VLM-256M

sourceHugging Faceupdated 2mo agoView on Hugging Face
7likes437downloads
Model Card
[!NOTE] This repository contains legacy weights. We are currently preparing the retrained 768px version. Feel free to run our live Space demo below.

TinyDoc-VLM-256M

Smallest document AI that actually works. 256M params. Runs on a MacBook. Apache 2.0.

![GitHub](https://github.com/eulogik/TinyDoc-VLM) ![PyPI](https://pypi.org/project/tinydoc/) ![HF Space](https://huggingface.co/spaces/eulogik/TinyDoc-VLM) ![LoRA](https://huggingface.co/eulogik/TinyDoc-VLM-LoRA) ![License](https://opensource.org/licenses/Apache-2.0)

What is this?

A 256M-parameter vision-language model that reads documents: invoices, receipts, forms, tables, charts. It extracts structured data, answers questions, and parses tables โ€” all from a single model that runs on CPU.

Why does this exist? Most document AI models are 7B+ params and need expensive GPUs. TinyDoc-VLM fits in <1GB VRAM and runs on a MacBook Air, Raspberry Pi 5, or any CPU with ONNX.

Quick Start

bash
pip install tinydoc
python
from PIL import Image
from tinydoc import TinyDocExtractor

extractor = TinyDocExtractor(device="cpu")

# Ask questions
img = Image.open("invoice.png")
result = extractor.ask(img, "What is the total?")
print(result.answer)  # "$1,234.56"

# Extract structured JSON
result = extractor.extract(img, output_format="json")
print(result.fields)  # {"total": "$1,234.56", "date": "2024-01-15", ...}

# Extract tables
result = extractor.extract_table(img)
print(result.markdown)

Direct Model Access

python
from tinydoc_vlm import TinyDocVLMForConditionalGeneration, TinyDocVLMProcessor

model = TinyDocVLMForConditionalGeneration.from_pretrained("eulogik/TinyDoc-VLM-256M")
processor = TinyDocVLMProcessor()

Architecture

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

Total: 256M params | Vision: 93M | Compressor: 3M | Decoder: 135M | Heads: 25M

LoRA Fine-tuning

Train on your own documents with LoRA โ€” only 2.7M params (0.93%) are trainable.

bash
# Generate synthetic docs
python data/synthetic/generator.py --num-docs 1000 --output-dir data/synthetic/output

# Train on M4 Mac (~4.6 hours for 5K steps)
python training/fast_train.py --steps 5000 --device mps

# Train on GPU (~1 hour for 5K steps)
python training/fast_train.py --steps 5000 --device cuda

Colab notebook: training/colab_train.ipynb

Training Results

MetricValue
Best checkpointStep 14,000 (loss: 15.0)
Training data3,000 synthetic docs (6,815 QA pairs)
Training time15.1 hours on M4 Mac
LoRA adaptereulogik/TinyDoc-VLM-LoRA

Deployment

ONNX (Recommended for Production)

bash
python export/export_onnx.py --model-path eulogik/TinyDoc-VLM-256M --output model.onnx

ONNX files on HF Hub:

  • โ€”tinydoc-vlm-vision.onnx โ€” Vision encoder (33KB)
  • โ€”tinydoc-vlm-compressor.onnx โ€” Token compressor (31KB)
  • โ€”tinydoc-vlm-decoder.onnx โ€” Language decoder (59MB)

HuggingFace Spaces

Live demo: huggingface.co/spaces/eulogik/TinyDoc-VLM

Benchmarks

BenchmarkStatusTarget
OCRBenchIn progress>75%
DocVQAPending>85%
FUNSDPending>95%

What can it do?

  • โ€”Invoice processing โ€” Extract line items, totals, dates, vendor info
  • โ€”Receipt scanning โ€” Parse store receipts, extract amounts
  • โ€”Form understanding โ€” Read forms, extract field-value pairs
  • โ€”Table extraction โ€” Convert tables to structured data
  • โ€”Document Q&A โ€” Ask questions about any document
  • โ€”OCR โ€” Read printed text from images
  • โ€”Chart understanding โ€” Extract data from charts and graphs

Related Models

Links

Citation

bibtex
@software{eulogik_tinydoc_vlm_2026,
  author = {eulogik},
  title = {TinyDoc-VLM: 256M-Param Document-Specialist Vision-Language Model},
  year = {2026},
  url = {https://github.com/eulogik/TinyDoc-VLM}
}

License

Apache 2.0. Free for commercial use.


Built by [eulogik](https://eulogik.com) โ€” AI infrastructure for document intelligence.