tempbench / code /benchmark-design-decisions.md
Guen's picture
Add the deterministic construction pipeline
210b340 verified
|
Raw
History Blame Contribute Delete
13 kB
# TempBench — Benchmark Generator Design Decisions
This document records the design choices made while implementing `build_benchmark.py` where the TempBench paper leaves the spec open.
Treat this as the source of truth for §5 formal semantics. Anything the paper states verbatim wins; everything below fills gaps.
## 1. Operator semantics
The paper commits to four operator types from the TimelineKGQA taxonomy and gives one natural-language example per operator. It does not give formal semantics, a template grammar, or answer-type definitions. Concrete choices:
### 1.1 Point-in-time (PIT)
- Paper example: *"Who held role X at time T?"*
- **Formal semantics**: Given an anchor entity `e_0`, a relation path `(r_1, r_2, ..., r_n)`, and a query time `t_q`, the answer is the terminal object `o_n` reached by walking the chain where each hop is valid at `t_q`.
- **Template surface**: `"In {year}, what was the {r_n} of {e_0}'s {r_1}'s ... 's {r_{n-1}}?"` (and two surface variants rotating the `{year}` position).
- **Answer type**: entity.
- **Complexity**: supports 1-hop, 2-hop, 3+-hop.
### 1.2 Before/after (BA)
- Paper example: *"Which entity held role X before entity Y did?"*
- **Formal semantics**: Same compositional chain as PIT, but the temporal anchor is *not* `t_q` — it is a **sibling fact** elsewhere in the KG. Given chain `C` ending at `o_n` at time `t_a`, a valid BA candidate requires a sibling triple `(penultimate_entity, r_n, sibling_entity, t_ref)` with `t_ref ≠ t_a`. The question asks for `o_n` positioned relative to `sibling_entity`.
- **Template surface**: `"Who was the {r_n} of {e_0}'s {r_1}'s ... before/after {sibling_entity}?"`. `"before"` when `t_a < t_ref`, `"after"` when `t_a > t_ref`.
- **Answer type**: entity.
- **Complexity**: supports 1-hop, 2-hop, 3+-hop. Yield will be lower than PIT — requires a sibling to exist.
- **Divergence from paper example**: paper's example is 1-hop; we extend to multi-hop by keeping the composition intact and attaching the temporal qualifier to the terminal hop.
### 1.3 Interval (INT)
- Paper example: *"During which period did X hold role Y?"*
- **Known limitation**: `tkgl-smallpedia` is a point-in-time TKG — 100% of triples have `t_start == t_end`. True *period* questions are not expressible.
- **Operational redefinition**: Ask for the **year** at which a composed chain resolves to a specified terminal. Equivalent to a "when did this hold?" question on a point-in-time KG.
- **Template surface**: `"In what year was the {r_n} of {e_0}'s {r_1}'s ... equal to {terminal}?"`.
- **Answer type**: integer year.
- **Complexity**: supports 1-hop, 2-hop, 3+-hop.
- **Divergence**: the paper's §5.1 wording ("During which period") has been softened to "In what year did X hold role Y?" to match the benchmark's point-in-time answer type. Resolved 2026-04-23; a footnote at §5.1 now explains the reason for deviating from TimelineKGQA's original phrasing.
### 1.4 Sequence (SEQ)
- Paper example: *"What happened to X after event Y?"*
- §6.5 case study: *"Who led the organisation that acquired [Company X] after [Company X]'s CEO resigned?"*
- **Formal semantics**: Composed chain ending at `o_n` at time `t_a`, paired with a **reference triple** `(s_ref, r_ref, o_ref, t_ref)` elsewhere in the KG where `t_ref < t_a` (for "after") or `t_ref > t_a` (for "before" phrasing — included under SEQ when the qualifier is an event, versus BA when the qualifier is a sibling entity).
- **Template surface**: `"After {s_ref} {r_ref} {o_ref}, what was the {r_n} of {e_0}'s {r_1}'s ...?"`.
- **Answer type**: entity.
- **Complexity**: supports 1-hop, 2-hop, 3+-hop. Requires a reference triple to exist at an earlier time.
- **Difference from BA**: BA's temporal anchor is an **entity** (another holder of the same terminal relation); SEQ's is a **triple** (an arbitrary earlier event). Mechanically they are siblings in the code.
## 2. 12-cell distribution
Paper §5.2 commits to "all 12 combinations of complexity level × operator type" but gives counts only at the complexity level (`4,000 / 4,000 / 2,000`). Per-cell counts are unspecified.
**Chosen distribution** (target):
| Operator | 1-hop | 2-hop | 3+-hop |
|---|---|---|---|
| Point-in-time | 1,000 | 1,000 | 500 |
| Before/after | 1,000 | 1,000 | 500 |
| Interval | 1,000 | 1,000 | 500 |
| Sequence | 1,000 | 1,000 | 500 |
| **Total** | **4,000** | **4,000** | **2,000** |
Even allocation by operator within each complexity bucket. If any cell under-yields (BA and SEQ depend on sibling/reference availability), we top up with PIT in that complexity bucket — 10K total takes priority over perfect operator balance.
## 3. Answer uniqueness
Paper §5.2 Step 4: *"filtered by answer uniqueness (removing ambiguous questions with multiple valid answers at `t_q`)"*. Scope is unspecified.
- **Chosen semantics**: Uniqueness applies to the **terminal answer only**. A candidate is retained iff, given the specific `e_0` and the first `n-1` hops of the gold chain, the final `(penultimate_entity, r_n)` pair has exactly one valid object at `t_q`.
- Intermediate-hop fan-out is **permitted**: if `e_0` has multiple valid `r_1` edges, those still enter the pool as separate chains, and each is independently checked for terminal uniqueness.
- **For INT questions**: uniqueness means the composed chain holds at exactly one discrete year in the KG. If the same terminal appears at two or more years via the same chain, the candidate is dropped.
## 4. Subgraph construction
Paper §5.2 Step 5 provides only loose descriptions; the critical terms ("semantically similar", `Δt`) are not formalised.
- **`S_star`**: the gold chain itself, serialised as a list of triples in hop order. Unambiguous.
- **`S_dist`** ("semantically similar but incorrect"): one hop replaced by a triple sharing the same `(subject, relation)` but a different object, at **any** validity window. Rationale: this produces a factually-wrong-for-`t_q` alternative that would be indistinguishable from the gold triple without temporal reasoning — i.e., the exact failure mode the paper is trying to diagnose.
- **`S_stale`** ("temporally adjacent version"): one hop replaced by a triple with the **same** `(subject, relation, object)` but a different `t_start` that is not valid at `t_q`. The nearest such neighbour by `|t - t_q|` is preferred when multiple exist; no explicit `Δt` threshold is enforced.
- **Failure mode**: for ~25–45% of multi-hop candidates, no `S_dist` alternative exists in the KG (the `(s, r)` pair has exactly one object across all time). Those questions ship with `S_dist == S_star`; annotation guidelines should flag them as "distractor not available".
## 5. Chain generation guards
Not spec'd in the paper; chosen to keep questions non-degenerate.
- **Forward-only chain walk**: each hop must have `triple.subject == current_entity`. The `entity_index` in [code/indexer.py](code/indexer.py) is double-keyed by subject and object, so without this guard the walk becomes an undirected traversal and produces non-chains.
- **Cycle guard**: no intermediate entity may be revisited within a single chain. This is stricter than the minimum needed (only cycles that return to the anchor produce tautological questions) but keeps all chain entities distinct, which simplifies the subgraph semantics.
- **Adjacent-relation guard**: two *adjacent* hops may not share a relation. This is the relaxed form of the earlier "no repeated relation anywhere" rule — non-adjacent repeats (e.g. `r_1, r_2, r_1`) are legitimate compositional patterns and are kept.
## 6. Known deviations from paper wording
Recorded here so the `.tex` can be aligned in a single pass before submission.
1. ~~§5.1 says *"During which period did X hold role Y?"* for interval. The benchmark produces year-level answers, not periods. Suggested rewording: *"In what year did X hold role Y?"*.~~ **Resolved 2026-04-23.** Step-9 section draft updated; a footnote at §5.1 explains the deviation from TimelineKGQA's original phrasing. The `.tex` operator list does not include example phrasings, so no `.tex` edit was needed.
2. §5.1 examples are 1-hop for all four operators. The benchmark extends each operator to 1/2/3+hop; the paper should add a sentence: *"Each operator is generated across all three complexity levels via compositional extension (§5.2)."*.
3. The paper's abstract and §1 advertise "10,000 questions"; the current run lands close but not exactly on 10,000 due to yield variability. The exact count should be taken from the shipped `benchmark.jsonl` and written into the `.tex` at camera-ready.
## 7. Revisiting these choices
Any of the decisions in §1–§5 can be overridden by:
- A firmer commitment in a new paper revision (then adjust code to match).
- A discovered inconsistency with the TimelineKGQA original (then take TimelineKGQA's exact wording).
Sections 6.1 and 6.2 are the most likely to change at reviewer request.
## 8. As-built distribution (run of 2026-04-19)
Running `build_benchmark.py` at `target_n=10000, seed=42` against [code/data/tkgl-smallpedia_edgelist.csv](code/data/tkgl-smallpedia_edgelist.csv) yields 8,710 questions:
| Complexity | PIT | BA | INT | SEQ | Row total | Paper target |
|---|---|---|---|---|---|---|
| 1hop | 1,349 | 1,135 | 403 | 1,113 | **4,000** | 4,000 ✓ |
| 2hop | 1,259 | 1,065 | 435 | 1,241 | **4,000** | 4,000 ✓ |
| 3plus | 274 | 131 | 26 | 279 | **710** | 2,000 ✗ |
| **Column** | 2,882 | 2,331 | 864 | 2,633 | **8,710** | 10,000 |
Quality: 100% correct chain structure, 0.1% answer-in-question (noise-level), 71.5% of multi-hop candidates have a constructed `S_dist`, 81.3% have `S_stale`. Wikidata label coverage 99.4% (53 QIDs unresolved, fall back to raw IDs).
### Why 3+hop falls short
tkgl-smallpedia is 100% point-in-time — every triple has `t_start == t_end`. A 3+hop chain requires every hop to be valid at the same exact year, not merely overlap a window. Year-density of related facts around a given anchor entity is typically 0–3 per year, so 3-hop and 4-hop chains that also pass uniqueness and adjacent-relation filters are genuinely rare. Additional attempt-budget does not help beyond ~710; the structural cap is roughly the count of shortest year-constrained 3-paths that share an anchor.
### Options for closing the 3+hop gap
1. **Edit §5.1/Table tab:bench-stats to 710 (or omit the 2,000 target)**. Honest, simple; reduces the paper's multi-hop headline claim.
2. **Switch KG to one with interval or open-ended facts** (ICEWS, YAGO3, the temporal slice of Freebase). Breaks the tkgl-smallpedia commitment in §3 and requires re-running the indexer against a new schema.
3. **Allow multi-year windowing for 3+hop chains** (e.g. each hop must be valid at `t_query ± 2 years`). Would ~10× the yield but weakens the temporal semantics — each hop is then only approximately at `t_query`, which the paper's §4 ⊕ operator doesn't formally permit.
4. **Accept the 710 count, spend the delta on 1hop/2hop** (paper stays at 10K headline, 3+hop is a smaller evaluation slice). The stratified trim already does this implicitly — 1hop and 2hop are at target, 3+hop is at its ceiling.
### Decision (2026-04-23): Option 1, reframed as a finding
**Chosen:** Option 1 with the 3+hop shortfall framed as a structural property of point-in-time multi-hop QA on Wikidata rather than a pipeline failure. New §5.4 "Structural Yield of Point-in-Time Multi-Hop QA" in the `.tex` reports ~710 as the structural ceiling.
**Why Option 1, not 2/3/4:**
- Option 2 (switch KG) was not feasible in the time remaining.
- Option 3 (multi-year windowing) would weaken the paper's core theoretical contribution — the ⊕ operator's strict timestamp-consistency semantics.
- Option 4 (inflate 1hop/2hop to hit 10K) looks like gaming the target; asymmetric inflation to hit a round number is exactly what reviewers catch.
**Bonus fix rolled into the same pass.** The shipped jsonl has **zero** `implicit` question_type entries — the code in `build_benchmark.py` labels `point_in_time → explicit` and BA/INT/SEQ all as `ordinal`, so the paper's old "3.5K / 3.5K / 3K" question-type row was always misrepresenting reality. The three-way question-type split was dropped entirely from Table 2 in favour of the operator × complexity matrix the paper's §4 is actually built on. This simultaneously resolves Deviation #1 and the question_type mislabelling.
**Deviation #2 (§5.1 examples being 1-hop only) resolution:** the rewritten §5.1 spanning sentence now names "the 12-cell operator × complexity matrix reported in Table~\ref{tab:bench-stats}", which makes the multi-hop extension explicit without needing separate worked examples per operator × complexity cell.
**Deviation #3 resolution:** all instances of "10K" / "10,000" in abstract, contributions list, §5.2 Step 4, Table 3 row, and appendix pointer now read "8,710" or "8.7K".