# hamdilaziz/tableseq architecture

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

- Interactive diagram: https://gitdiagram.com/hamdilaziz/tableseq
- Repository: https://github.com/hamdilaziz/tableseq

## Overview

TableSeq turns table images into one autoregressive sequence containing HTML structure, cell text, and coordinate tokens. The main user workflow is single-image inference: the CLI loads a checkpoint and tokenizer, preprocesses an image, generates a sequence, then writes cleaned HTML, boxes, metadata, and a visual report. The repository also supports dataset-based training and split evaluation with structure and box metrics. The graph reflects documented workflows and source-index references; unsampled implementation details are not inferred.

Main entry points: [`scripts/eval_tableseq.py`](https://github.com/hamdilaziz/tableseq/blob/main/scripts/eval_tableseq.py) (Evaluation entrypoint), [`tableseq/inference.py`](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/inference.py) (Image inference), [`tableseq/modeling.py`](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/modeling.py) (TableSeq model), [`scripts/train_tableseq.py`](https://github.com/hamdilaziz/tableseq/blob/main/scripts/train_tableseq.py) (Training entrypoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User workflows"]
  node_infer_cli["Inference CLI<br/>[infer_tableseq.py]"]
  node_runner["Inference runner<br/>[run_tableseq.py]"]
  node_infer["Image inference<br/>[inference.py]"]
  node_report["Prediction report<br/>[inference.py]"]
  node_outputs["Inference artifacts"]
end

subgraph group_prep["Data and coordinates"]
  node_dataset["Dataset loader<br/>[data.py]"]
  node_coords["Coordinate scaling<br/>[coordinates.py]"]
  node_training_data[("Training dataset")]
  node_evaluation_data[("Evaluation split")]
end

subgraph group_model["Generation model"]
  node_model["TableSeq model<br/>[modeling.py]"]
  node_encoder["Visual encoder<br/>[encoder.py]"]
  node_decoder["TableSeq decoder<br/>[decoder.py]"]
  node_mbart["mBART implementation<br/>[modeling_mbart.py]"]
end

subgraph group_assessment["Training and evaluation"]
  node_train_cli["Training entrypoint<br/>[train_tableseq.py]"]
  node_trainer["Trainer<br/>[trainer.py]"]
  node_eval_cli["Evaluation entrypoint<br/>[eval_tableseq.py]"]
  node_sequence_metrics["Sequence metrics<br/>[fast_metrics.py]"]
  node_html_metrics["HTML metrics<br/>[html_metrics.py]"]
  node_box_metrics["Box metrics<br/>[box_metrics.py]"]
  node_metric_cleanup["Metric HTML cleanup<br/>[metrics.py]"]
end

node_user(("User"))

node_user -->|"runs inference"| node_infer_cli
node_infer_cli -->|"invokes runner"| node_runner
node_runner -->|"calls inference"| node_infer
node_infer -->|"generates sequence"| node_model
node_infer -->|"decodes boxes"| node_coords
node_infer -->|"builds report"| node_report
node_infer -->|"writes artifacts"| node_outputs
node_model -->|"uses encoder"| node_encoder
node_model -->|"uses decoder"| node_decoder
node_decoder -->|"wraps implementation"| node_mbart
node_user -->|"starts training"| node_train_cli
node_train_cli -->|"loads samples"| node_dataset
node_train_cli -->|"starts trainer"| node_trainer
node_trainer -->|"trains and generates"| node_model
node_dataset -->|"scales labels"| node_coords
node_user -->|"runs evaluation"| node_eval_cli
node_eval_cli -->|"loads split"| node_dataset
node_eval_cli -->|"loads model"| node_model
node_eval_cli -->|"uses evaluation routines"| node_trainer
node_eval_cli -->|"scores structure"| node_sequence_metrics
node_eval_cli -->|"scores boxes"| node_box_metrics
node_eval_cli -->|"cleans generated HTML"| node_metric_cleanup
node_sequence_metrics -.->|"optional TEDS"| node_html_metrics
node_user -->|"provides dataset"| node_training_data
node_user -->|"selects split"| node_evaluation_data

click node_infer_cli "https://github.com/hamdilaziz/tableseq/blob/main/scripts/infer_tableseq.py"
click node_runner "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/run_tableseq.py"
click node_infer "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/inference.py"
click node_report "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/inference.py"
click node_dataset "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/data.py"
click node_coords "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/coordinates.py"
click node_model "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/modeling.py"
click node_encoder "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/models/encoder.py"
click node_decoder "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/models/decoder.py"
click node_mbart "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/models/modeling_mbart.py"
click node_train_cli "https://github.com/hamdilaziz/tableseq/blob/main/scripts/train_tableseq.py"
click node_trainer "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/trainer.py"
click node_eval_cli "https://github.com/hamdilaziz/tableseq/blob/main/scripts/eval_tableseq.py"
click node_sequence_metrics "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/fast_metrics.py"
click node_html_metrics "https://github.com/hamdilaziz/tableseq/blob/main/metrics_utils/html_metrics.py"
click node_box_metrics "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/box_metrics.py"
click node_metric_cleanup "https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/metrics.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_infer_cli,node_runner,node_infer,node_report,node_outputs,node_user toneBlue
class node_dataset,node_coords,node_training_data,node_evaluation_data toneAmber
class node_model,node_encoder,node_decoder,node_mbart toneMint
class node_train_cli,node_trainer,node_eval_cli,node_sequence_metrics,node_html_metrics,node_box_metrics,node_metric_cleanup toneRose
```

## Components

### User workflows

- [Inference CLI](https://github.com/hamdilaziz/tableseq/blob/main/scripts/infer_tableseq.py): `scripts/infer_tableseq.py`
- [Inference runner](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/run_tableseq.py): `tableseq/run_tableseq.py`
- [Image inference](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/inference.py): `tableseq/inference.py`
- [Prediction report](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/inference.py): `tableseq/inference.py`
- **Inference artifacts**

### Data and coordinates

- [Dataset loader](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/data.py): `tableseq/data.py`
- [Coordinate scaling](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/coordinates.py): `tableseq/coordinates.py`
- **Training dataset**
- **Evaluation split**

### Generation model

- [TableSeq model](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/modeling.py): `tableseq/modeling.py`
- [Visual encoder](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/models/encoder.py): `tableseq/models/encoder.py`
- [TableSeq decoder](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/models/decoder.py): `tableseq/models/decoder.py`
- [mBART implementation](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/models/modeling_mbart.py): `tableseq/models/modeling_mbart.py`

### Training and evaluation

- [Training entrypoint](https://github.com/hamdilaziz/tableseq/blob/main/scripts/train_tableseq.py): `scripts/train_tableseq.py`
- [Trainer](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/trainer.py): `tableseq/training/trainer.py`
- [Evaluation entrypoint](https://github.com/hamdilaziz/tableseq/blob/main/scripts/eval_tableseq.py): `scripts/eval_tableseq.py`
- [Sequence metrics](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/fast_metrics.py): `tableseq/training/fast_metrics.py`
- [HTML metrics](https://github.com/hamdilaziz/tableseq/blob/main/metrics_utils/html_metrics.py): `metrics_utils/html_metrics.py`
- [Box metrics](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/box_metrics.py): `tableseq/training/box_metrics.py`
- [Metric HTML cleanup](https://github.com/hamdilaziz/tableseq/blob/main/tableseq/training/metrics.py): `tableseq/training/metrics.py`

### Other components

- **User**

## Connections

- User → Inference CLI: runs inference (evidence: `README.md`)
- Inference CLI → Inference runner: invokes runner (evidence: `scripts/infer_tableseq.py`)
- Inference runner → Image inference: calls inference (evidence: `tableseq/run_tableseq.py`)
- Image inference → TableSeq model: generates sequence (evidence: `tableseq/inference.py`)
- Image inference → Coordinate scaling: decodes boxes (evidence: `tableseq/inference.py`)
- Image inference → Prediction report: builds report (evidence: `README.md`)
- Image inference → Inference artifacts: writes artifacts (evidence: `README.md`)
- TableSeq model → Visual encoder: uses encoder (evidence: `tableseq/modeling.py`)
- TableSeq model → TableSeq decoder: uses decoder (evidence: `tableseq/modeling.py`)
- TableSeq decoder → mBART implementation: wraps implementation (evidence: `tableseq/models/decoder.py`)
- User → Training entrypoint: starts training (evidence: `README.md`)
- Training entrypoint → Dataset loader: loads samples (evidence: `scripts/train_tableseq.py`)
- Training entrypoint → Trainer: starts trainer (evidence: `scripts/train_tableseq.py`)
- Trainer → TableSeq model: trains and generates (evidence: `tableseq/training/trainer.py`)
- Dataset loader → Coordinate scaling: scales labels (evidence: `tableseq/data.py`)
- User → Evaluation entrypoint: runs evaluation (evidence: `README.md`)
- Evaluation entrypoint → Dataset loader: loads split (evidence: `scripts/eval_tableseq.py`)
- Evaluation entrypoint → TableSeq model: loads model (evidence: `scripts/eval_tableseq.py`)
- Evaluation entrypoint → Trainer: uses evaluation routines (evidence: `scripts/eval_tableseq.py`)
- Evaluation entrypoint → Sequence metrics: scores structure (evidence: `scripts/eval_tableseq.py`)
- Evaluation entrypoint → Box metrics: scores boxes (evidence: `scripts/eval_tableseq.py`)
- Evaluation entrypoint → Metric HTML cleanup: cleans generated HTML (evidence: `tableseq/training/metrics.py`)
- Sequence metrics → HTML metrics: optional TEDS
- User → Training dataset: provides dataset (evidence: `README.md`)
- User → Evaluation split: selects split (evidence: `README.md`)
