# uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation architecture

> Architecture diagram of the GitHub repository uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation
- Repository: https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation

## Overview

This repository is a research benchmarking framework for structured OCR on three collections of historical German documents. Its workflow runs model experiments on labeled image/JSONL data, generates structured predictions, and compares them with ground truth. The README documents zero/few-shot inference, fine-tuning, HPO, preprocessing and training variants; the tree shows implementations across eight model families, OCR baselines, labeling tools, metrics, and interactive UIs. Relationships among these mostly standalone scripts are shown only where documented or visible in excerpts; many implementations were not sampled.

Main entry points: [`gemma3/finetune`](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/finetune) (Fine-tuning), [`gemma3/zero_few_shots`](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/zero_few_shots) (Zero/few-shot runs), [`map_f1_and_anls`](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/map_f1_and_anls) (OCR metrics), [`data_labels_creation`](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/data_labels_creation) (Label creation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_labeling["Label creation"]
  node_collections[("Document collections")]
end

subgraph group_experiments["VLM experiments"]
  node_donut["Donut experiments"]
  node_florence["Florence-2 experiments"]
  node_paddlevl["PaddleOCR-VL experiments"]
  node_gemma["Gemma experiments"]
  node_nanonets["Nanonets experiments"]
  node_phi["Phi experiments"]
  node_qwen["Qwen experiments"]
  node_shots["Zero/few-shot runs"]
  node_baselines["OCR baselines"]
end

subgraph group_studies["Training studies"]
  node_finetuning["Fine-tuning"]
  node_hpo["Hyperparameter search"]
  node_preprocessing["Image preprocessing"]
  node_multistage["Multi-stage training"]
  node_multidataset["Multi-dataset training"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["OCR metrics"]
end

subgraph group_interfaces["User interfaces"]
  node_phiui["Phi OCR interface<br/>[phi_ui.py]"]
  node_gemmaui["Gemma OCR interface<br/>[gemma_ui_docker.py]"]
  node_model_service["Model inference<br/>[phi_ui.py]"]
end

node_researcher(("Researcher"))
node_ocr_user(("Document user"))

node_researcher -->|"creates labels"| node_labeling
node_labeling -.->|"produces labels"| node_collections
node_collections -.->|"supplies examples"| node_shots
node_collections -->|"supplies splits"| node_finetuning
node_researcher -->|"runs experiments"| node_shots
node_shots -.->|"evaluates predictions"| node_metrics
node_researcher -->|"trains baseline"| node_finetuning
node_finetuning -->|"tunes baseline"| node_hpo
node_hpo -->|"exports best parameters"| node_finetuning
node_finetuning -->|"branches to study"| node_preprocessing
node_finetuning -->|"branches to study"| node_multistage
node_finetuning -->|"branches to study"| node_multidataset
node_collections -->|"combines datasets"| node_multidataset
node_researcher -.->|"runs comparisons"| node_baselines
node_researcher -.->|"runs model scripts"| node_donut
node_researcher -.->|"runs model scripts"| node_florence
node_researcher -.->|"runs model scripts"| node_paddlevl
node_researcher -.->|"runs model scripts"| node_gemma
node_researcher -.->|"runs model scripts"| node_nanonets
node_researcher -.->|"runs model scripts"| node_phi
node_researcher -.->|"runs model scripts"| node_qwen
node_paddlevl -->|"computes CER"| node_metrics
node_metrics -.->|"reports scores"| node_researcher
node_ocr_user -.->|"submits document"| node_phiui
node_phiui -->|"routes prediction"| node_model_service
node_ocr_user -.->|"submits document"| node_gemmaui
node_gemmaui -.->|"runs inference"| node_gemma

click node_labeling "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/data_labels_creation"
click node_donut "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/DONUT"
click node_florence "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/florence2"
click node_paddlevl "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/paddleocr"
click node_gemma "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3"
click node_nanonets "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/nanonets"
click node_phi "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/phivision"
click node_qwen "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/qwen"
click node_shots "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/zero_few_shots"
click node_finetuning "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/finetune"
click node_hpo "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/hpo"
click node_preprocessing "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/image_preprocess"
click node_multistage "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/multistage_and_multidataset"
click node_multidataset "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/gemma3/multistage_and_multidataset/multidataset_finetune.py"
click node_baselines "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/non_vlm"
click node_metrics "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/map_f1_and_anls"
click node_phiui "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/UI_codes/phi_ui.py"
click node_gemmaui "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/UI_main/gemma_ui_docker.py"
click node_model_service "https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/UI_codes/phi_ui.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_labeling,node_collections,node_ocr_user toneBlue
class node_donut,node_florence,node_paddlevl,node_gemma,node_nanonets,node_phi,node_qwen,node_shots,node_baselines toneAmber
class node_finetuning,node_hpo,node_preprocessing,node_multistage,node_multidataset toneMint
class node_metrics toneRose
class node_phiui,node_gemmaui,node_model_service,node_researcher toneIndigo
```

## Components

### Data preparation

- [Label creation](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/data_labels_creation): `data_labels_creation`
- **Document collections**

### VLM experiments

- [Donut experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/DONUT): `DONUT`
- [Florence-2 experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/florence2): `florence2`
- [PaddleOCR-VL experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/paddleocr): `paddleocr`
- [Gemma experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3): `gemma3`
- [Nanonets experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/nanonets): `nanonets`
- [Phi experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/phivision): `phivision`
- [Qwen experiments](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/qwen): `qwen`
- [Zero/few-shot runs](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/zero_few_shots): `gemma3/zero_few_shots`
- [OCR baselines](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/non_vlm): `non_vlm`

### Training studies

- [Fine-tuning](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/finetune): `gemma3/finetune`
- [Hyperparameter search](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/hpo): `gemma3/hpo`
- [Image preprocessing](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/image_preprocess): `gemma3/image_preprocess`
- [Multi-stage training](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/gemma3/multistage_and_multidataset): `gemma3/multistage_and_multidataset`
- [Multi-dataset training](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/gemma3/multistage_and_multidataset/multidataset_finetune.py): `gemma3/multistage_and_multidataset/multidataset_finetune.py`

### Evaluation

- [OCR metrics](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/tree/main/map_f1_and_anls): `map_f1_and_anls`

### User interfaces

- [Phi OCR interface](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/UI_codes/phi_ui.py): `UI_codes/phi_ui.py`
- [Gemma OCR interface](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/UI_main/gemma_ui_docker.py): `UI_main/gemma_ui_docker.py`
- [Model inference](https://github.com/uddipan77/analysis-of-lightweight-vision-language-models-for-document-ocr-and-structured-output-generation/blob/main/UI_codes/phi_ui.py): `UI_codes/phi_ui.py`

### Other components

- **Researcher**
- **Document user**

## Connections

- Researcher → Label creation: creates labels
- Label creation → Document collections: produces labels
- Document collections → Zero/few-shot runs: supplies examples
- Document collections → Fine-tuning: supplies splits
- Researcher → Zero/few-shot runs: runs experiments
- Zero/few-shot runs → OCR metrics: evaluates predictions
- Researcher → Fine-tuning: trains baseline
- Fine-tuning → Hyperparameter search: tunes baseline
- Hyperparameter search → Fine-tuning: exports best parameters
- Fine-tuning → Image preprocessing: branches to study
- Fine-tuning → Multi-stage training: branches to study
- Fine-tuning → Multi-dataset training: branches to study
- Document collections → Multi-dataset training: combines datasets
- Researcher → OCR baselines: runs comparisons
- Researcher → Donut experiments: runs model scripts
- Researcher → Florence-2 experiments: runs model scripts
- Researcher → PaddleOCR-VL experiments: runs model scripts
- Researcher → Gemma experiments: runs model scripts
- Researcher → Nanonets experiments: runs model scripts
- Researcher → Phi experiments: runs model scripts
- Researcher → Qwen experiments: runs model scripts
- PaddleOCR-VL experiments → OCR metrics: computes CER (evidence: `paddleocr/zero_shot_code/stair_inference.py`)
- OCR metrics → Researcher: reports scores
- Document user → Phi OCR interface: submits document (evidence: `UI_codes/phi_ui.py`)
- Phi OCR interface → Model inference: routes prediction (evidence: `UI_codes/phi_ui.py`)
- Document user → Gemma OCR interface: submits document (evidence: `UI_main/gemma_ui_docker.py`)
- Gemma OCR interface → Gemma experiments: runs inference
