Datasets:
Languages:
English
Size:
1K<n<10K
ArXiv:
Tags:
temporal-reasoning
knowledge-graph
question-answering
benchmark
retrieval-augmented-generation
DOI:
License:
| # TempBench construction pipeline | |
| The deterministic pipeline that builds TempBench from a temporal knowledge graph. | |
| This is the code behind the paper's claim that construction is *algorithmic and | |
| reproducible*, not LLM-generated: given the same source KG and the same seed, it | |
| reproduces the released benchmark. | |
| ## Contents | |
| | file | what it does | | |
| | --- | --- | | |
| | `indexer.py` | The foundation. `Triple`, `ValidityWindow`, and `TemporalKGIndexer` (entity index + interval tree). Every other file imports it. Loads the TGB 2.0 `tkgl-smallpedia` CSV format. | | |
| | `build_benchmark.py` | The 6-stage construction pipeline: chain sampling → operator expansion → composability filter → answer-uniqueness filter → MinHash dedup → stratified split, then gold/distractor/stale subgraph construction. | | |
| | `resolve_labels.py` | Rewrites Wikidata QIDs/PIDs into human-readable labels. Two modes: API (rate-limited) and offline dump. | | |
| | `benchmark-design-decisions.md` | The formal operator semantics and the design choices the paper does not have room to state. Read this before extending the generator. | | |
| ## What is *not* here | |
| This directory is the **construction pipeline only**. The reference-baseline | |
| systems evaluated in the paper are not included; their evaluation outputs ship | |
| in `../baselines/` and every number in the paper is re-derivable from those. | |
| The source KG is **not redistributed**. `tkgl-smallpedia` comes from | |
| [TGB 2.0](https://arxiv.org/abs/2406.09639) — download | |
| `tkgl-smallpedia_edgelist.csv` from TGB and point `--kg_path` at it. (550,376 | |
| quadruples, 47,433 entities, 283 relations, 1900–2024.) | |
| ## Running it | |
| No dependencies beyond the Python standard library. Tested on Python 3.11+. | |
| Verify the install with the built-in smoke test, which runs on a synthetic | |
| 5-triple graph and needs no data: | |
| ```bash | |
| python build_benchmark.py --smoke_test | |
| ``` | |
| Then build the benchmark: | |
| ```bash | |
| # 1. Construct. target_n is the pre-filter target; the composability, | |
| # uniqueness and dedup stages reduce 10,000 -> the released 8,710. | |
| python build_benchmark.py \ | |
| --kg_path /path/to/tkgl-smallpedia_edgelist.csv \ | |
| --output_dir ./out/ \ | |
| --target_n 10000 --seed 42 | |
| # 2. Resolve QIDs/PIDs to labels. Dump mode is offline and preferred; | |
| # the fetch step is the only part that needs network access. | |
| python resolve_labels.py --collect_ids ./out/benchmark.jsonl \ | |
| --id_output ./out/ids.txt | |
| python resolve_labels.py --fetch_dump ./out/ids.txt \ | |
| --dump_output ./out/labels.tsv | |
| python resolve_labels.py --input ./out/benchmark.jsonl \ | |
| --label_dump ./out/labels.tsv \ | |
| --output ./out/benchmark_labelled.jsonl | |
| ``` | |
| Step 2 is optional — the benchmark is usable on raw QIDs, which is what you want | |
| if you are running air-gapped. | |
| `--seed 42` is the released configuration. The pipeline is deterministic: the | |
| only nondeterminism is the seed, and label resolution depends on the Wikidata | |
| dump you fetch (we ship ours as `../benchmark/labels.tsv`, so use that for an | |
| exact match). | |
| ## Licence | |
| CC BY 4.0, same as the rest of TempBench. See the top-level `README.md`. | |