Datasets:
|
Download README.md from williamTLmiller/pdf-document-qa-citations: direct link, hf CLI and curl.
- Browser
- Download file 9.27 kB
-
https://huggingface.co/datasets/williamTLmiller/pdf-document-qa-citations/resolve/main/README.md
- Command line
-
hf download hf://datasets/williamTLmiller/pdf-document-qa-citations/README.md
-
curl -L -o README.md https://huggingface.co/datasets/williamTLmiller/pdf-document-qa-citations/resolve/main/README.md
9.27 kB
| pretty_name: 'PDF Document QA with Citations: Grounded Question Answering, Tables & Abstention' | |
| license: cc-by-nc-4.0 | |
| language: | |
| - en | |
| multilinguality: | |
| - monolingual | |
| size_categories: | |
| - n<1K | |
| task_categories: | |
| - document-question-answering | |
| - question-answering | |
| task_ids: | |
| - extractive-qa | |
| annotations_creators: | |
| - machine-generated | |
| language_creators: | |
| - found | |
| source_datasets: | |
| - original | |
| tags: | |
| - document-ai | |
| - document-understanding | |
| - pdf-qa | |
| - citations | |
| - grounded-qa | |
| - rag | |
| - retrieval-augmented-generation | |
| - tables | |
| - layout | |
| - contracts | |
| - unanswerable-questions | |
| - abstention | |
| - hallucination | |
| - synthetic | |
| - matrixnorm | |
| configs: | |
| - config_name: document_qa | |
| data_files: | |
| - split: train | |
| path: data/document_qa/train.csv | |
| - config_name: document_structure | |
| data_files: | |
| - split: train | |
| path: data/document_structure/train.csv | |
| - config_name: source_attributions | |
| data_files: | |
| - split: train | |
| path: data/source_attributions.csv | |
| # PDF Document QA with Citations: Grounded Question Answering, Tables & Abstention | |
| *Release name: MatrixNorm DocEvidence v1 (free toy sample)* | |
| **Grounded document QA with exact citations** over multi-page PDFs: invoices with long line tables, policies with effective-dated revisions, equipment manuals, quarterly reports and service agreements. Every answer cites the exact character span on the exact page that supports it, every page region has a bounding box, and tables are reconstructed as logical tables even when they continue across pages (the header row repeats on each page). Some questions (28 of the 191 in this toy sample) are deliberately unanswerable from the documents and are paired with an explicit abstention, and the same question wording appears answerable in other families, so abstention has to come from reading, not from the question template. | |
| ## Free toy sample | |
| This public repo is a deliberately tiny, CSV-only toy sample: 191 grounded QA rows over 38 documents plus the rows linked to them. It is meant for looking at the schema and running a pipeline once (a toy training run), not for training a real model. The full and training-ready versions (`williamTLmiller/pdf-document-qa-citations-full`) are private and licensed separately; contact energea@energeatech.com. | |
| Every record in this toy comes from the training split of the paid release, so none of the paid validation or test records is public. | |
| This toy sample draws from **32 document families** (train groups): their 38 documents in | |
| `document_structure` and 191 of their 193 questions in `document_qa` (a question is left out when its question and | |
| answer text also occur in a paid validation or test row, and a family is left out whole when its documents are the | |
| same document as a paid validation or test family). The PDF files themselves and the full set are in the | |
| private full release. Every row here is train. | |
| ## Rows | |
| | View | File | Rows (train) | | |
| |---|---|---:| | |
| | `document_qa` | `data/document_qa/train.csv` | 191 | | |
| | `document_structure` | `data/document_structure/train.csv` | 38 | | |
| | `source_attributions` | `data/source_attributions.csv` | 38 | | |
| ```python | |
| from datasets import load_dataset | |
| ds = load_dataset("williamTLmiller/pdf-document-qa-citations", "document_qa") | |
| ``` | |
| Every view is one plain CSV file. Nested fields (`documents`, `citations`, `pages`, `regions`, `tables`, | |
| `continuations`, `source_refs`) are JSON text in their cell: read them with `json.loads`. The extracted text of | |
| every page region is in `document_structure.regions[].text`. `source_attributions.csv` has one row per document. | |
| **Views.** `document_qa`: question, the documents it is about (`document_id`, PDF `uri`, `revision`), answer, `citations` (`document_id`, `page_index`, `selector` = `codepoints:start:end` into that page's text, and the exact `quoted_text`) and `answerability`. `document_structure`: per document, the pages, regions (type, bbox in PDF points with a top-left origin, text), logical tables with cells, and table continuations across pages. Join QA to structure with `document_qa.documents[].document_id` == the structure row's `sample_id` minus the `de-doc-` prefix. The PDFs are **not** in this toy repo: they ship with the private full release. The PDF links in `document_ref`, `documents[].uri` and `source_refs[].uri` are the paths the files had in this repo's earlier, larger sample (`pdfs/<document_id>.pdf`), kept as identifiers. You do not need the PDFs to check a citation: every page's text can be rebuilt from `document_structure`, as described next. | |
| A citation's `selector` indexes the page text, which you can rebuild exactly from the structure view: a page has 49 lines (48 body lines, then the footer), line `i` starts at `y = 54 + 14 * i` points, so each region's text (which may span several lines) starts at line `(bbox[1] - 54) / 14`; fill every other line with an empty string and join the 49 lines with `\n`. | |
| ## What is in this toy sample | |
| * **Documents:** 38 in 32 families, by kind: contract 6 (36 questions), invoice 7 (44 questions), manual 6 (36 questions), policy 12 (42 questions), report 7 (33 questions). 43 pages (5 documents have more | |
| than one page), 325 regions, 20 logical tables, 2 table continuations across pages. | |
| * **Questions:** 191: `answerable` 163, `unanswerable` 28 (each paired | |
| with an explicit abstention); 42 questions are about two documents (a policy and its later revision); | |
| 175 citations in all. | |
| ## How it was built | |
| Documents are generated from seeded templates, laid out deterministically (US Letter, Courier 10 pt, 6 pt per character and 14 pt per line, so every box is exact) and written as PDFs. Each PDF is checked independently with poppler `pdftotext -bbox`: the page count must match, and every word must fall inside a declared region. Each citation is re-located in the page text, its slice must equal the quoted value, and numeric answers must parse. Policy families add a second, later-effective revision, version-sensitive questions and a conflict that is resolved by effective date. Groups = one document family. | |
| ## Validation | |
| Every record is checked before it is written: schema, cross-references, split membership, and the dataset-specific checks described above. A family that fails any check is quarantined as a whole, never silently dropped or partially kept. | |
| Full-release build stats (not this toy sample): `{"documents": 7200, "families": 6000, "kinds": {"conflict_resolution": 1200, "cross_page": 438, "extractive": 14383, "numeric": 7207, "table_lookup": 4800, "unanswerable": 6010, "version_sensitive": 2400}, "pages": 7929, "questions": 36438}` | |
| ## How the toy sample was drawn | |
| Document families (train groups) only, each picked whole. The candidates were the 299 document families of this repo's | |
| earlier, larger sample, all of them in the paid training split. Families are grouped by document kind and taken round-robin over the | |
| kinds; inside a kind they go in a fixed salted-SHA-256 order of the family id | |
| (`sha256("matrixnorm-toy-v1|" + family_id)`). A family is added only while the sample stays within 50 documents | |
| and 200 questions, so the pick is deterministic and every kind is represented. Then every question whose question and | |
| answer text (compared after whitespace normalisation) also occur in a paid validation or test row is left out: 6 of | |
| the 200. A toy family is also left out, whole (its documents, their source attributions and all its questions), when | |
| its documents are the same document as a paid validation or test family: the same title and company, the same | |
| effective dates and several of the same stated facts (approver, daily allowance cap, request mailbox), so the toy text | |
| would answer paid validation or test questions. One policy | |
| family (2 documents, 7 questions, 4 of them among the 6 above) is left out this way, so 38 documents in 32 families | |
| and 191 questions stay. | |
| ## Trainability baseline | |
| Measured on the full release's held-out splits (this toy sample is train only). Task: predict answerability (answerable vs unanswerable) from the question and the documents' text. Model: a simple CPU classifier on TF-IDF text features plus structural counts, trained on the full release's 35,712 train rows, no GPU: | |
| | Split | Rows | Accuracy | Macro-F1 | Majority class | | |
| |---|---:|---:|---:|---:| | |
| | validation | 363 | 0.995 | 0.991 | 0.813 | | |
| | test | 363 | 0.997 | 0.995 | 0.826 | | |
| Ablation: the same model given only the question text (no document features) scores 0.846 accuracy and 0.700 macro-F1 on test, against a 0.826 majority class. Answerability comes from reading the documents, not from the wording of the question. | |
| ## Limitations | |
| - Documents are synthetic and typeset in a monospaced font, with no scans, handwriting, images or multi-column layouts. Use it to teach citation discipline, table continuation and abstention, and pair it with real scanned data for visual robustness. | |
| - Questions come from templates, so wording varies less than real user queries. | |
| ## Licensing | |
| CC BY-NC 4.0 (see `LICENSE` and `NOTICE`). The whole dataset is MatrixNorm-generated content. Commercial licensing: energea@energeatech.com. | |
| ## Citation | |
| ``` | |
| MatrixNorm DocEvidence v1 (free toy sample). williamTLmiller, MatrixNorm, 2026. https://huggingface.co/datasets/williamTLmiller/pdf-document-qa-citations | |
| ``` | |