# alibaba/logics-parsing architecture

> Architecture diagram of the GitHub repository alibaba/logics-parsing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alibaba/logics-parsing
- Repository: https://github.com/alibaba/logics-parsing

## Overview

Logics-Parsing-V3 is a vision-language document parser for single pages and long documents. The primary workflow accepts an image, PDF, or image directory; performs sequential, state-recurrent parsing for multi-page inputs; and saves structured parsing outputs. Model weights can be obtained separately from Hugging Face or ModelScope. The README documents capabilities such as hierarchy recovery and cross-page merging, but the single-file implementation excerpt is incomplete, so internal processing links are limited to documented relationships.

Main entry points: [`inference_v3.py`](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py) (Inference runner), [`download_model.py`](https://github.com/alibaba/logics-parsing/blob/main/download_model.py) (Model downloader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Document inference"]
  node_input["Page inputs<br/>[inference_v3.py]"]
  node_runner["Inference runner<br/>[inference_v3.py]"]
  node_recurrence["Window state<br/>[inference_v3.py]"]
  node_model["Vision-language model<br/>[inference_v3.py]"]
end

subgraph group_results["Parsing results"]
  node_hierarchy["Document structure<br/>[inference_v3.py]"]
  node_outputs["DSL and Markdown<br/>[inference_v3.py]"]
end

subgraph group_weights["Model weights"]
  node_downloader["Model downloader<br/>[download_model.py]"]
  node_weights_store[("Local weights<br/>[download_model.py]")]
end

node_user(("User"))
node_hf["Hugging Face"]
node_modelscope["ModelScope"]

node_user -->|"provides pages"| node_input
node_user -->|"starts inference"| node_runner
node_input -->|"parses input"| node_runner
node_runner -->|"carries state"| node_recurrence
node_runner -->|"infers pages"| node_model
node_model -->|"recovers structure"| node_hierarchy
node_recurrence -->|"preserves context"| node_hierarchy
node_hierarchy -->|"emits results"| node_outputs
node_user -->|"requests weights"| node_downloader
node_downloader -.->|"downloads from"| node_hf
node_downloader -.->|"downloads from"| node_modelscope
node_hf -.->|"provides weights"| node_weights_store
node_modelscope -.->|"provides weights"| node_weights_store

click node_input "https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py"
click node_runner "https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py"
click node_recurrence "https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py"
click node_model "https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py"
click node_hierarchy "https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py"
click node_outputs "https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py"
click node_downloader "https://github.com/alibaba/logics-parsing/blob/main/download_model.py"
click node_weights_store "https://github.com/alibaba/logics-parsing/blob/main/download_model.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_input,node_runner,node_recurrence,node_model,node_user toneBlue
class node_hierarchy,node_outputs toneAmber
class node_downloader,node_weights_store toneMint
class node_hf,node_modelscope toneIndigo
```

## Components

### Document inference

- [Page inputs](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py): `inference_v3.py`
- [Inference runner](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py): `inference_v3.py`
- [Window state](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py): `inference_v3.py`
- [Vision-language model](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py): `inference_v3.py`

### Parsing results

- [Document structure](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py): `inference_v3.py`
- [DSL and Markdown](https://github.com/alibaba/logics-parsing/blob/main/inference_v3.py): `inference_v3.py`

### Model weights

- [Model downloader](https://github.com/alibaba/logics-parsing/blob/main/download_model.py): `download_model.py`
- [Local weights](https://github.com/alibaba/logics-parsing/blob/main/download_model.py): `download_model.py`

### Other components

- **User**
- **Hugging Face**
- **ModelScope**

## Connections

- User → Page inputs: provides pages (evidence: `README.md`)
- User → Inference runner: starts inference (evidence: `README.md`)
- Page inputs → Inference runner: parses input (evidence: `README.md`)
- Inference runner → Window state: carries state (evidence: `README.md`)
- Inference runner → Vision-language model: infers pages (evidence: `README.md`)
- Vision-language model → Document structure: recovers structure (evidence: `README.md`)
- Window state → Document structure: preserves context (evidence: `README.md`)
- Document structure → DSL and Markdown: emits results (evidence: `README.md`)
- User → Model downloader: requests weights (evidence: `README.md`)
- Model downloader → Hugging Face: downloads from (evidence: `download_model.py`)
- Model downloader → ModelScope: downloads from (evidence: `download_model.py`)
- Hugging Face → Local weights: provides weights (evidence: `download_model.py`)
- ModelScope → Local weights: provides weights (evidence: `download_model.py`)
