354 Downloads Updated 4 months ago
ollama run mikgr/doctype-classifier-vl
Updated 4 months ago
4 months ago
9a1ba722bef0 · 3.2GB ·
{"type": "...", "confidence": 0-100}# Pull the model
ollama pull mikgr/doctype-classifier-vl
# Classify a PDF document
ollama run mikgr/doctype-classifier-vl "Classify this document" /path/to/document.pdf
# Classify text (e.g., OCR output)
ollama run mikgr/doctype-classifier-vl "INVOICE NO. 2024-001..."
invoice, proforma_invoice, credit_note, debit_note, receipt, purchase_order, quote, delivery_note, bank_statement, payslip
contract, agreement, certificate, letter, tax_form, legal_notice
id_card, passport, drivers_license, medical_record, prescription
waybill, shipping_label, customs_declaration, bill_of_lading
utility_bill, insurance_policy, report, form, timesheet, expense_report
unknown - for documents that don’t match any category
# Classify a PDF document
ollama run mikgr/doctype-classifier-vl "Classify this document" invoice.pdf
# Classify an image
ollama run mikgr/doctype-classifier-vl "Classify this document" scan.jpg
# Classify text (OCR output)
ollama run mikgr/doctype-classifier-vl "INVOICE NO. 2024-001
Supplier: Example Company LLC
Tax ID: 12345678
Date: January 15, 2024
Items:
1. Service A - $100.00
VAT 20%: $20.00
TOTAL: $120.00"
import subprocess
import json
def classify_document(file_path: str) -> dict:
"""Classify document using ollama CLI."""
result = subprocess.run(
[
"ollama", "run", "mikgr/doctype-classifier-vl",
"Classify this document", file_path
],
capture_output=True,
text=True
)
# Parse first line (JSON output)
return json.loads(result.stdout.strip().split('\n')[0])
# Usage
result = classify_document("invoice.pdf")
print(f"Type: {result['type']}, Confidence: {result['confidence']}%")
# Output: Type: invoice, Confidence: 95%
#!/bin/bash
# classify.sh - Simple wrapper for clean JSON output
FILE="$1"
ollama run mikgr/doctype-classifier-vl "Classify this document" "$FILE" 2>/dev/null | head -1
Always returns JSON:
{"type": "invoice", "confidence": 95}
ollama run mikgr/doctype-classifier-vl "RAČUN ŠT. 2024-001
Dobavitelj: Example d.o.o.
ID za DDV: SI12345678
Datum: 15.01.2024
Postavke:
1. Storitev A - 100,00 EUR
DDV 22%: 22,00 EUR
SKUPAJ: 122,00 EUR
TRR: SI56 0110 0000 0000 123"
Output: {"type": "invoice", "confidence": 95}
ollama run mikgr/doctype-classifier-vl "POGODBA O SODELOVANJU
Pogodbeni stranki:
Stranka A: Example d.o.o.
Stranka B: Sample Ltd.
Predmet pogodbe:
Dobava materiala
Podpis: ________________"
Output: {"type": "contract", "confidence": 90}
ollama run mikgr/doctype-classifier-vl "Classify this document" quote.pdf
Output: {"type": "quote", "confidence": 95}
ollama run mikgr/doctype-classifier-vl "Classify this document" receipt.jpg
Output: {"type": "receipt", "confidence": 95}
ollama run mikgr/doctype-classifier-vl "Some text about business.
Maybe a document.
Not very clear what type."
Output: {"type": "unknown", "confidence": 35}
The model uses evidence-based scoring: - 90-100%: Document has clear type indicators (header, structure, keywords all match perfectly) - Example: “RAČUN ŠT.” header + VAT table + line items = 95-98% invoice - 70-89%: Strong indicators but minor ambiguity - Example: Contract with parties and terms but no clear “POGODBA” header = 76% - 50-69%: Mixed signals or partial matches - Example: Form-like structure but unclear purpose = 58% - 30-49%: Weak indicators, multiple types possible - Example: Generic text mentioning “invoice” but no structure = 35% - 0-29%: No clear document pattern - Example: Random text without document structure = 12%
This model is suitable for: - ✅ Document routing and classification pipelines - ✅ Pre-processing for OCR systems - ✅ Document management systems (DMS) - ✅ Email attachment auto-sorting - ⚠️ Always verify classification for critical business workflows - ⚠️ Use confidence scores to flag uncertain documents for manual review
Recommended Thresholds: - ≥ 90%: Auto-process with high confidence - 70-89%: Auto-process with logging/audit trail - 50-69%: Flag for review - < 50%: Manual classification required
Based on Qwen2.5-VL-3B. Please refer to the Qwen2.5-VL license for terms.
classification document vision business multilingual slovenian invoice ocr vl qwen pdf contract receipt
mikgr - Created for invoice OCR and document processing systems with focus on Slovenian business documents.