FinQA / README.md
hheiden-roots's picture
Add dataset card with full schema documentation
3d6a736 verified
---
license: mit
language:
- en
task_categories:
- question-answering
- table-question-answering
tags:
- financial
- numerical-reasoning
- table-qa
- earnings-reports
size_categories:
- 1K<n<10K
dataset_info:
features:
- name: id
dtype: string
- name: filename
dtype: string
- name: pre_text
list: string
- name: post_text
list: string
- name: table
list:
list: string
- name: table_ori
list:
list: string
- name: question
dtype: string
- name: answer
dtype: string
- name: exe_ans
dtype: string
- name: explanation
dtype: string
- name: ann_table_rows
list: int32
- name: ann_text_rows
list: int32
- name: steps
struct:
- name: op
list: string
- name: arg1
list: string
- name: arg2
list: string
- name: res
list: string
- name: program
dtype: string
- name: program_re
dtype: string
- name: gold_inds
dtype: string
splits:
- name: train
num_bytes: 32780740
num_examples: 6251
- name: validation
num_bytes: 4573763
num_examples: 883
- name: test
num_bytes: 5911480
num_examples: 1147
download_size: 39700298
dataset_size: 43265983
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
- split: validation
path: data/validation-*
- split: test
path: data/test-*
---
# FinQA
A full-fidelity repackaging of the [FinQA dataset](https://github.com/czyssrs/FinQA) (Chen et al., EMNLP 2021) for numerical reasoning over financial tables.
FinQA contains questions over earnings reports from S&P 500 companies (1999–2019), sourced from the [FinTabNet dataset](https://developer.ibm.com/exchanges/data/all/fintabnet/). Each example pairs a financial table and surrounding text with a question, a human-readable answer, and a structured reasoning program that specifies the arithmetic operations needed to derive the answer.
## Why this version
The existing HuggingFace copy ([dreamerdeo/finqa](https://huggingface.co/datasets/dreamerdeo/finqa)) omits `program`, `program_re`, and `steps` — the reasoning annotations that are FinQA's primary contribution. This version preserves the complete schema from the canonical GitHub release, excluding only model-artifact fields (`table_retrieved*`, `text_retrieved*`, `qa.tfidftopn`, `qa.model_input`) that were bundled with the original retriever checkpoint.
## Splits
| Split | Examples |
|---|---|
| train | 6,251 |
| validation | 883 |
| test | 1,147 |
The private leaderboard test set (no ground-truth references) is intentionally excluded.
## Schema
| Field | Type | Description |
|---|---|---|
| `id` | string | Unique example ID: `{TICKER}/{YEAR}/page_{N}.pdf-{idx}` |
| `filename` | string | Source PDF path: `{TICKER}/{YEAR}/page_{N}.pdf` |
| `pre_text` | list[string] | Text passages before the table |
| `post_text` | list[string] | Text passages after the table |
| `table` | list[list[string]] | Normalized table (numbers unformatted, HTML stripped) |
| `table_ori` | list[list[string]] | Original table with HTML formatting (superscripts, comma-separated numbers) |
| `question` | string | The financial question |
| `answer` | string | Human-readable answer (e.g. `"93.5%"`) |
| `exe_ans` | string | Raw execution result as string; numeric (e.g. `"0.935"`) or `"yes"`/`"no"` |
| `explanation` | string | Free-text explanation; sparse (~16% non-empty) |
| `ann_table_rows` | list[int] | Zero-indexed table rows annotated as gold evidence |
| `ann_text_rows` | list[int] | Zero-indexed text passages annotated as gold evidence |
| `steps` | struct | Structured execution steps (see below) |
| `program` | string | Flat DSL program with `#N` back-references (e.g. `subtract(920, 95), divide(#0, 5)`) |
| `program_re` | string | Fully nested program form (e.g. `divide(subtract(920, 95), 5)`) |
| `gold_inds` | string | JSON-serialized dict mapping evidence keys to text (e.g. `{"table_3": "..."}`) |
### `steps` struct
Each element of `steps` represents one arithmetic operation:
| Subfield | Type | Description |
|---|---|---|
| `op` | string | Operation name with positional suffix (e.g. `minus2-1`, `divide1-2`) |
| `arg1` | string | First argument: a literal value or `#N` reference |
| `arg2` | string | Second argument: a literal value, `const_*`, or `#N` reference |
| `res` | string | Result of this step (intermediate or final) |
Programs range from 1 to 5 steps. `const_100`, `const_1000`, etc. are predefined constants.
## Usage
```python
from datasets import load_dataset
ds = load_dataset("rootsautomation/FinQA")
ex = ds["train"][0]
print(ex["question"])
print(ex["answer"]) # human-readable
print(ex["exe_ans"]) # raw numeric or yes/no
print(ex["program"]) # flat DSL
print(ex["program_re"]) # nested DSL
print(ex["steps"]) # structured ops
import json
gold = json.loads(ex["gold_inds"]) # {key: evidence_text}
```
## Image collation
This dataset is text-only. The source PDF page images are available in FinTabNet (CDLA-Permissive-1.0). The `id` field (`{TICKER}/{YEAR}/page_{N}.pdf-{idx}`) and `filename` field (`{TICKER}/{YEAR}/page_{N}.pdf`) provide a direct join key into FinTabNet's file structure, making it possible to construct an image-grounded version of FinQA.
## License
QA annotations: [MIT](https://github.com/czyssrs/FinQA/blob/main/LICENSE).
Underlying table data is sourced from FinTabNet, which is released under [CDLA-Permissive-1.0](https://cdla.dev/permissive-1-0/). The original earnings reports are publicly available SEC filings. The FinQA paper (§2) explicitly verified that CDLA-Permissive-1.0 permits creating and publishing additional annotations over FinTabNet data.
## Citation
```bibtex
@inproceedings{chen-etal-2021-finqa,
title = "{F}in{QA}: A Dataset of Numerical Reasoning over Financial Data",
author = "Chen, Zhiyu and Chen, Wenhu and Smiley, Charese and Shah, Sameena and Borova, Iana and Langdon, Dylan and Moussa, Reema and Beane, Matt and Huang, Ting-Hao and Routledge, Bryan and Wang, William Yang",
booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing",
year = "2021",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2021.emnlp-main.300",
}
```