Datasets:
Size:
1M<n<10M
ArXiv:
Tags:
Document_Understanding
Document_Packet_Splitting
Document_Comprehension
Document_Classification
Document_Recognition
Document_Segmentation
DOI:
License:
fix: Revise README for accuracy, usability, and dependency compatibility
#2
by vawsgit - opened
17 unmodified lines1819202122236 unmodified lines30313233343592 unmodified lines128129130131132133134135100 unmodified lines2362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822838 unmodified lines29229329429529629729854 unmodified lines3533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973986 unmodified lines4054064074084094104114122 unmodified lines41541641741841942042142242317 unmodified lines**In addition to the dataset, we release this repository containing the complete toolkit for generating the benchmark datasets, along with Jupyter notebooks for data analysis.**# DocSplit: Document Packet Splitting Benchmark GeneratorA toolkit for creating benchmark datasets to test document packet splitting systems. Document packet splitting is the task of separating concatenated multi-page documents into individual documents with correct page ordering.6 unmodified lines2. **Classify document types** accurately3. **Reconstruct correct page ordering** within each document## Document SourceWe uses the documents from **RVL-CDIP-N-MP**:92 unmodified linesConvert raw PDFs into structured assets with page images (300 DPI PNG) and OCR text (Markdown).#### Option A: AWS Textract OCR (Default)Best for English documents. Processes all document categories with Textract.```bash100 unmodified lines2. **`notebooks/02_create_benchmarks.ipynb`** - Generate benchmarks with different strategies3. **`notebooks/03_analyze_benchmarks.ipynb`** - Analyze and visualize benchmark statistics## Benchmark Output FormatEach benchmark JSON contains:```json{"benchmark_name": "poly_seq","strategy": "PolySeq","split": "train","created_at": "2026-01-30T12:00:00","documents": [{"spliced_doc_id": "splice_0001","source_documents": [{"doc_type": "invoice", "doc_name": "doc1", "pages": [1,2,3]},{"doc_type": "letter", "doc_name": "doc2", "pages": [1,2]}],"ground_truth": [{"page_num": 1, "doc_type": "invoice", "source_doc": "doc1", "source_page": 1},{"page_num": 2, "doc_type": "invoice", "source_doc": "doc1", "source_page": 2},...],"total_pages": 5}],"statistics": {"total_spliced_documents": 1000,"total_pages": 7500,"unique_doc_types": 16}}```## Requirements- Python 3.8+- AWS credentials (for Textract OCR)- Dependencies: `boto3`, `loguru`, `pymupdf`, `pillow`---### Generate Benchmark Datasets```bash# 1. Download and extract RVL-CDIP-N-MP source data from HuggingFace (1.25 GB)8 unmodified lines# 2. Create assets from raw PDFs# Extracts each page as PNG image and runs OCR to get text# These assets are then used in step 4 to create benchmark datasets# Output: Structured assets in data/assets/ with images and text per pagepython src/assets/run.py --raw-data-path data/raw_data --output-path data/assets54 unmodified lines- **Challenge**: Worst-case scenario with no structural assumptions- **Use Case**: Document management system failures or emergency recovery## Project Structure```doc-split-benchmark/├── README.md├── requirements.txt # All dependencies├── src/│ ├── assets/ # Asset creation from PDFs│ │ ├── run.py # Main script│ │ ├── models.py # Document models│ │ └── services/│ │ ├── pdf_loader.py│ │ ├── textract_ocr.py│ │ └── asset_writer.py│ ││ └── benchmarks/ # Benchmark generation│ ├── run.py # Main script│ ├── models.py # Benchmark models│ └── services/│ ├── asset_loader.py│ ├── split_manager.py│ ├── benchmark_generator.py│ ├── benchmark_writer.py│ └── strategies/│ ├── mono_seq.py # DocSplit-Mono-Seq│ ├── mono_rand.py # DocSplit-Mono-Rand│ ├── poly_seq.py # DocSplit-Poly-Seq│ ├── poly_int.py # DocSplit-Poly-Int│ └── poly_rand.py # DocSplit-Poly-Rand│├── notebooks/ # Interactive examples│ ├── 01_create_assets.ipynb│ ├── 02_create_benchmarks.ipynb│ └── 03_analyze_benchmarks.ipynb│└── data/ # Generated data (not in repo)├── raw_data/ # Downloaded PDFs├── assets/ # Extracted images + OCR└── benchmarks/ # Generated benchmarks```### Generate Benchmarks [Detailed]6 unmodified lines--assets-path data/assets \--output-path data/benchmarks \--num-docs-train 800 \--num-docs-test 200 \--num-docs-val 500 \--size small \--random-seed 42```2 unmodified lines- `--strategy`: Benchmark strategy - `mono_seq`, `mono_rand`, `poly_seq`, `poly_int`, `poly_rand`, or `all` (default: all)- `--assets-path`: Directory containing assets from Step 1 (default: data/assets)- `--output-path`: Where to save benchmarks (default: data/benchmarks)- `--num-docs-train`: Number of spliced documents for training (default: 8)- `--num-docs-test`: Number of spliced documents for testing (default: 5)- `--num-docs-val`: Number of spliced documents for validation (default: 2)- `--size`: Benchmark size - `small` (5-20 pages) or `large` (20-500 pages) (default: small)- `--split-mapping`: Path to split mapping JSON (default: data/metadata/split_mapping.json)- `--random-seed`: Seed for reproducibility (default: 42)17 unmodified lines18192021222324252627282930313233343536373839404142434445464748496 unmodified lines565758596061626364656667686970717273747576777879808192 unmodified lines174175176177178179180181182183184185100 unmodified lines2862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603618 unmodified lines37037137237337437537654 unmodified lines4314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025036 unmodified lines5105115125135145155165172 unmodified lines52052152252352452552652752817 unmodified lines**In addition to the dataset, we release this repository containing the complete toolkit for generating the benchmark datasets, along with Jupyter notebooks for data analysis.**## Quick Start: Load the Dataset```pythonfrom datasets import load_dataset# Load all splitsds = load_dataset("amazon/doc_split")# Or load a single splittest = load_dataset("amazon/doc_split", split="test")```Each row represents a spliced document packet:```pythondoc = ds["train"][0]print(doc["doc_id"]) # UUID for this packetprint(doc["total_pages"]) # Total pages in the packetprint(len(doc["subdocuments"])) # Number of constituent documentsfor sub in doc["subdocuments"]:print(f" {sub['doc_type_id']}: {len(sub['page_ordinals'])} pages")```> **Note:** The `image_path` and `text_path` fields in each page reference assets that are not included in the dataset download. See [Data Formats](#data-formats) for details.# DocSplit: Document Packet Splitting Benchmark GeneratorA toolkit for creating benchmark datasets to test document packet splitting systems. Document packet splitting is the task of separating concatenated multi-page documents into individual documents with correct page ordering.6 unmodified lines2. **Classify document types** accurately3. **Reconstruct correct page ordering** within each document## Dataset SchemaWhen loaded via `load_dataset()`, each row contains:| Field | Type | Description ||-------|------|-------------|| `doc_id` | string | UUID identifying the spliced packet || `total_pages` | int | Total number of pages in the packet || `subdocuments` | list | Array of constituent documents |Each subdocument contains:| Field | Type | Description ||-------|------|-------------|| `doc_type_id` | string | Document type category || `local_doc_id` | string | Identifier within the packet || `group_id` | string | Group identifier || `page_ordinals` | list[int] | Page positions within the packet || `pages` | list | Per-page metadata (image_path, text_path, original_doc_name) |## Document SourceWe uses the documents from **RVL-CDIP-N-MP**:92 unmodified linesConvert raw PDFs into structured assets with page images (300 DPI PNG) and OCR text (Markdown).> **Note:** The code defaults for `--raw-data-path` (`../raw_data`) and `--output-path` (`../processed_assets`) assume running from within `src/assets/`. When running from the repo root, pass explicit paths as shown below.#### Option A: AWS Textract OCR (Default)> **⚠️ Requires Python 3.12:** This command uses `amazon-textract-textractor`, which has C extension dependencies that may not build on Python 3.13+. See [Requirements](#requirements).Best for English documents. Processes all document categories with Textract.```bash100 unmodified lines2. **`notebooks/02_create_benchmarks.ipynb`** - Generate benchmarks with different strategies3. **`notebooks/03_analyze_benchmarks.ipynb`** - Analyze and visualize benchmark statistics## Data FormatsThe dataset provides two complementary formats for each benchmark:### Ground Truth JSON (used by `load_dataset`)One JSON file per document packet in `datasets/{strategy}/{size}/ground_truth_json/{split}/`:```json{"doc_id": "...","total_pages": ...,"subdocuments": [{"doc_type_id": "...","local_doc_id": "...","group_id": "...","page_ordinals": [...],"pages": [{"page": 1,"original_doc_name": "...","image_path": "rvl-cdip-nmp-assets/...","text_path": "rvl-cdip-nmp-assets/...","local_doc_id_page_ordinal": ...}]}]}```### CSV (flat row-per-page format)One CSV per split in `datasets/{strategy}/{size}/`:| Column | Description ||--------|-------------|| `doc_type` | Document type category || `original_doc_name` | Source document filename || `parent_doc_name` | UUID of the spliced packet (matches `doc_id` in JSON) || `local_doc_id` | Local identifier within the packet || `page` | Page number within the packet || `image_path` | Path to page image (prefix: `data/assets/`) || `text_path` | Path to OCR text (prefix: `data/assets/`) || `group_id` | Group identifier || `local_doc_id_page_ordinal` | Page ordinal within the original source document |### Asset PathsThe image and text paths in both formats reference assets that are **not included** in this repository:- JSON paths use prefix `rvl-cdip-nmp-assets/`- CSV paths use prefix `data/assets/`To resolve these paths, run the asset creation pipeline (see [Create Assets](#step-1-create-assets)). The data can be used for metadata and label analysis without the actual images.## Requirements- Python 3.12+ recommended (see note below)- AWS credentials (for Textract OCR)- Dependencies: `pip install -r requirements.txt`> **⚠️ Python Version:** The `amazon-textract-textractor` package (required by `src/assets/run.py`) depends on C extensions (`editdistance`) that may fail to build on Python 3.13+. **Python 3.12 is recommended.** Using [uv](https://docs.astral.sh/uv/) as your package installer can also help resolve build issues.> **Note:** `requirements.txt` currently includes GPU dependencies (PyTorch, Transformers) that are only needed for DeepSeek OCR on multilingual documents. If you only need Textract OCR or want to explore the pre-generated data, the core dependencies are: `boto3`, `loguru`, `pymupdf`, `pillow`, `pydantic`, `amazon-textract-textractor`, `tenacity`.---### Download Source Data and Generate Benchmarks```bash# 1. Download and extract RVL-CDIP-N-MP source data from HuggingFace (1.25 GB)8 unmodified lines# 2. Create assets from raw PDFs# Extracts each page as PNG image and runs OCR to get text# These assets are then used in step 3 to create benchmark datasets# Output: Structured assets in data/assets/ with images and text per pagepython src/assets/run.py --raw-data-path data/raw_data --output-path data/assets54 unmodified lines- **Challenge**: Worst-case scenario with no structural assumptions- **Use Case**: Document management system failures or emergency recovery### Dataset StatisticsThe pre-generated benchmarks include train, test, and validation splits in both `small` (5–20 pages per packet) and `large` (20–500 pages per packet) sizes. For `mono_rand/large`:| Split | Document Count ||-------|---------------|| Train | 417 || Test | 96 || Validation | 51 |## Project Structure```doc-split-benchmark/├── README.md├── requirements.txt├── src/│ ├── assets/ # Asset creation from PDFs│ │ ├── __init__.py│ │ ├── models.py│ │ ├── run.py # Main entry point│ │ └── services/│ │ ├── __init__.py│ │ ├── asset_creator.py│ │ ├── asset_writer.py│ │ ├── deepseek_ocr.py│ │ ├── pdf_loader.py│ │ └── textract_ocr.py│ ││ └── benchmarks/ # Benchmark generation│ ├── __init__.py│ ├── models.py│ ├── run.py # Main entry point│ └── services/│ ├── __init__.py│ ├── asset_loader.py│ ├── split_manager.py│ ├── benchmark_generator.py│ ├── benchmark_writer.py│ └── shuffle_strategies/│ ├── __init__.py│ ├── base_strategy.py│ ├── mono_seq.py│ ├── mono_rand.py│ ├── poly_seq.py│ ├── poly_int.py│ └── poly_rand.py│├── notebooks/│ ├── 01_create_assets.ipynb│ ├── 02_create_benchmarks.ipynb│ └── 03_analyze_benchmarks.ipynb│├── datasets/ # Pre-generated benchmark data│ └── {strategy}/{size}/│ ├── train.csv│ ├── test.csv│ ├── validation.csv│ └── ground_truth_json/│ ├── train/*.json│ ├── test/*.json│ └── validation/*.json│└── data/ # Generated by toolkit (not in repo)├── raw_data/├── assets/└── benchmarks/```### Generate Benchmarks [Detailed]6 unmodified lines--assets-path data/assets \--output-path data/benchmarks \--num-docs-train 800 \--num-docs-test 500 \--num-docs-val 200 \--size small \--random-seed 42```2 unmodified lines- `--strategy`: Benchmark strategy - `mono_seq`, `mono_rand`, `poly_seq`, `poly_int`, `poly_rand`, or `all` (default: all)- `--assets-path`: Directory containing assets from Step 1 (default: data/assets)- `--output-path`: Where to save benchmarks (default: data/benchmarks)- `--num-docs-train`: Number of spliced documents for training (default: 800)- `--num-docs-test`: Number of spliced documents for testing (default: 500)- `--num-docs-val`: Number of spliced documents for validation (default: 200)- `--size`: Benchmark size - `small` (5-20 pages) or `large` (20-500 pages) (default: small)- `--split-mapping`: Path to split mapping JSON (default: data/metadata/split_mapping.json)- `--random-seed`: Seed for reproducibility (default: 42)
README.md+158-53