| # FinixDocBench Markdown Evaluation |
|
|
| This folder contains a lightweight evaluator for FinixDocBench Markdown parsing outputs. It compares a directory of ground-truth `.md` files with a directory of predicted `.md` files whose file names match exactly. |
|
|
| The evaluator is intended for the public Markdown task. It does not evaluate structured JSON layout annotations. |
|
|
| ## Metrics |
|
|
| The evaluator reports: |
|
|
| | Metric | Direction | Meaning | |
| |---|---|---| |
| | `text_block_Edit_dist` | Lower is better | Normalized edit distance over matched text blocks. | |
| | `reading_order_Edit_dist` | Lower is better | Normalized edit distance over serialized reading-order sequences. | |
| | `table_TEDS` | Higher is better | TEDS table-structure similarity, scaled to 0-100. | |
| | `overall` | Higher is better | Composite score on a 0-100 scale. | |
|
|
| The overall score is: |
|
|
| ```python |
| overall = ( |
| (1 - text_block_Edit_dist) * 100 |
| + (1 - reading_order_Edit_dist) * 100 |
| + table_TEDS |
| ) / 3 |
| ``` |
|
|
| Formula parsing is not evaluated separately. |
|
|
| ## Installation |
|
|
| Python 3.9+ is recommended. |
|
|
| ```bash |
| cd FinixDocBench_Eval_for_Markdown |
| python3 -m venv .venv |
| source .venv/bin/activate |
| pip install -r requirements.txt |
| ``` |
|
|
| ## Quick Check |
|
|
| Run the bundled minimal example first: |
|
|
| ```bash |
| python run_eval.py \ |
| --gt_dir examples/gt \ |
| --pred_dir examples/pred \ |
| --output_json outputs/example_result.json |
| ``` |
|
|
| ## Evaluate a FinixDocBench Track |
|
|
| Prepare a prediction directory with one `.md` file per evaluated page. Prediction file names must match the ground-truth Markdown file names. |
|
|
| Example for FinixPhoto: |
|
|
| ```bash |
| python run_eval.py \ |
| --gt_dir ../track2_finixphoto_300/mds \ |
| --pred_dir /path/to/predicted_mds \ |
| --output_json outputs/finixphoto_result.json |
| ``` |
|
|
| Example for FinixHuge-Table: |
|
|
| ```bash |
| python run_eval.py \ |
| --gt_dir ../track3_finixhuge_100_table/mds \ |
| --pred_dir /path/to/predicted_mds \ |
| --output_json outputs/finixhuge_table_result.json |
| ``` |
|
|
| ## Output Format |
|
|
| The output JSON has the following structure: |
|
|
| ```json |
| { |
| "success": true, |
| "metrics": { |
| "text_block_Edit_dist": 0.0123, |
| "reading_order_Edit_dist": 0.0, |
| "table_TEDS": 98.7, |
| "overall": 99.15, |
| "num_samples": 2, |
| "score": 99.15 |
| }, |
| "inputs": { |
| "gt_files": 2, |
| "pred_files": 2, |
| "missing_predictions": 0, |
| "unexpected_predictions": 0 |
| } |
| } |
| ``` |
|
|
| `score` is identical to `overall` and is included for leaderboard or automation systems that expect a generic score field. |
|
|
| ## File Name Validation |
|
|
| By default, the evaluator fails if the `.md` file names in `gt_dir` and `pred_dir` do not match exactly. This avoids accidentally skipping pages. |
|
|
| If you want to allow missing predictions and score missing files as empty outputs, pass: |
|
|
| ```bash |
| python run_eval.py \ |
| --gt_dir /path/to/gt_mds \ |
| --pred_dir /path/to/pred_mds \ |
| --allow_name_mismatch |
| ``` |
|
|
| ## FinixHuge Reporting |
|
|
| For FinixHuge-Long and FinixHuge-Table, also report a success rate outside this script: |
|
|
| ```text |
| success_rate = valid_non_empty_predictions / total_pages |
| ``` |
|
|
| A prediction should be counted as successful only if it is a syntactically valid, non-empty page-level Markdown result without runtime failure, severe truncation, or format errors that prevent downstream evaluation. |
|
|
| ## Large Table Safeguards |
|
|
| TEDS can be slow on extremely large tables. To keep evaluation practical, this implementation assigns a table TEDS score of `0` when a ground-truth or predicted table exceeds `50000` `<td>` cells. |
|
|
| The matching stage also keeps broad safety thresholds: |
|
|
| ```text |
| MAX_PRED_ITEMS = 50000 |
| RATIO_THRESHOLD = 100 |
| MAX_TOTAL_LENGTH = 10000000 |
| MAX_SINGLE_ITEM_LENGTH = 10000000 |
| ``` |
|
|
| ## Notes |
|
|
| - Only `.md` files are evaluated. |
| - Images, JSON annotations, and other files are ignored by this evaluator. |
| - Markdown tables are converted to HTML before table evaluation. |
| - One page image should correspond to one Markdown file. |
| - File names are the matching keys; the evaluator does not read images. |
|
|