afritemp-bench / README.md
Kossisoroyce's picture
Upload README.md with huggingface_hub
6b999ed verified
|
Raw
History Blame Contribute Delete
23.6 kB
---
license: cc-by-4.0
language:
- en
- fr
pretty_name: AfriTemp-Bench
task_categories:
- question-answering
---
# AfriTemp-Bench: A Benchmark for Temporal Reasoning over African Statistical and Documentary Data
**AfriTemp-Bench** is a supervised fine-tuning (SFT) and evaluation dataset for temporal reasoning over African economic indicators. It comprises **12,568 examples** across **25 generator families**, **9 economic domains**, **51/54 AU member states**, and **2000--2024**.
All labels are **deterministic** — computed by verifiable arithmetic and comparison functions, not by language models. Approximately 19.6% of examples involve counterfactual or generated worlds; the remainder operate on observed World Bank data. 84.8% include excerpted evidence from World Bank economic reports retrieved via paragraph-level domain-aware scoring.
---
## 1. Motivation
Temporal reasoning — understanding how measurable quantities change, comparing values across time, and reasoning about trend direction — is a fundamental capability for language models applied to economics, finance, public policy, and data analysis. Existing benchmarks evaluate temporal understanding through synthetic narrative datasets (TempReason, TimeDial, TempLAMA) or news-based QA, but none address the structured, indicator-driven setting of development economics.
AfriTemp-Bench fills this gap by providing:
- **Real numerical data** from the World Bank's WDI (World Development Indicators) and WGI (Worldwide Governance Indicators), ingested as versioned, immutable snapshots.
- **Deterministic gold labels** computed by verified arithmetic, not teacher-model distillation.
- **Document-grounded context** selected from 300+ World Bank economic reports via paragraph-level scoring.
- **Curated real-world events** (elections, rate decisions, IMF programs, health emergencies) wired into causal and policy-status generators.
- **Bitemporal structure**: knowledge cutoffs, vintages, and revision edges for evaluating temporal grounding.
---
## 2. Data Sources
### 2.1 Indicator Data (WDI / WGI)
All numerical observations are sourced from the **World Bank API** (`wbgapi`):
- **WDI** (database 2): World Development Indicators — annual time series for 54 AU member economies.
- **WGI** (database 3): Worldwide Governance Indicators — six composite governance scores on a -2.5 to +2.5 scale.
**Publication-time honesty**: The WB API serves only the current latest value for each indicator-year-entity triple. It provides no per-observation publication timestamps. ATIC records each observation with `publication_basis: ingestion_snapshot`, meaning the recorded publication time equals the ATIC snapshot time. Real bitemporality (vintage-aware querying) accrues through scheduled immutable snapshot diffs.
### 2.2 Document Data (WB Documents & Reports API)
Economic reports are harvested from the **WDS v2 API** (`searchdocuments` endpoint) using a broad query per country: `qterm={country}+economic&rows=50`. The harvest pipeline:
1. Searches each of 54 AU countries.
2. Downloads matching PDFs via the WDS download URL template.
3. Extracts text with `pdfplumber`, normalizing Unicode and stripping watermarks ('dezirohtuA', 'erusolcsiD', 'cilbuP').
4. Filters by `_doc_matches_country()` using COUNTRY_ALIASES with accent-insensitive matching.
5. Removes garbled documents (empty/short/broken-line threshold, low alpha-density).
6. Scores each document for economic content via keyword density.
The final document corpus spans **366 clean PDFs** across all 54 AU countries (573 MB extracted text).
**Paragraph-level retrieval**: When grounding an example, `relevant_documents()` selects up to 3 documents closest in publication year to the target year, then scores each paragraph by:
- Domain keyword matches (macro_prices, health, climate, etc.)
- Generic economic signal words
- Numerical density
- Year proximity (decay = 0.02 per year offset)
- Length bonus (80--300 words optimal)
Top paragraphs are concatenated to a 3,000-character budget and prepended to the user prompt as `Document excerpts:\n\n[From: {title}]\n{text}`.
### 2.3 Curated Events
98 real-world events across all 54 AU countries were manually curated:
- **Elections**: National elections with known dates.
- **Policy rate decisions**: Central bank rate changes (e.g., Bank of Ghana, Central Bank of Nigeria, South African Reserve Bank).
- **IMF programs**: Arrangements (ECF, EFF, RFI, PLL) with announcement dates and effective intervals.
- **Health emergencies**: COVID-19 PHEIC and WHO monkeypox PHEIC.
- **Regional milestones**: AfCFTA trading commencement.
Events are wired into `PolicyStatusGenerator` (ask whether a policy was active at a query time) and `CausalReasoningGenerator` (ask whether an event plausibly caused an observed indicator movement).
---
## 3. Indicators
55 indicator series across 9 domains. Each indicator carries metadata: `series_id`, `name`, `short_name`, `domain`, `unit`, `measure_type` (level/rate/share/index/score), and `aggregation` (additive/non_additive/average).
| Domain | Indicators | Coverage |
|--------|-----------|----------|
| `macro_prices` | 2666 | 21.2% |
| `health` | 1665 | 13.2% |
| `governance` | 1280 | 10.2% |
| `agriculture` | 1242 | 9.9% |
| `demography` | 1199 | 9.5% |
| `education_labour` | 1151 | 9.2% |
| `trade` | 1077 | 8.6% |
| `energy` | 681 | 5.4% |
| `climate` | 503 | 4.0% |
| series_id | Name | Domain |
|-----------|------|-------|
| NY.GDP.MKTP.KD.ZG | GDP growth (annual %) | macro_prices |
| NY.GDP.PCAP.CD | GDP per capita (current US$) | macro_prices |
| NY.GDP.MKTP.CD | GDP (current US$) | macro_prices |
| NY.GDP.MKTP.KD | GDP (constant 2015 US$) | macro_prices |
| FP.CPI.TOTL.ZG | Inflation, consumer prices (annual %) | macro_prices |
| PA.NUS.FCRF | Official exchange rate (LCU per US$) | macro_prices |
| NY.GNP.PCAP.CD | GNI per capita, Atlas method (current US$) | macro_prices |
| BN.CAB.XOKA.GD.ZS | Current account balance (% of GDP) | macro_prices |
| NY.GDS.TOTL.ZS | Gross domestic savings (% of GDP) | macro_prices |
| GC.XPN.TOTL.GD.ZS | Government expenditure (% of GDP) | macro_prices |
| SP.DYN.LE00.IN | Life expectancy at birth (years) | health |
| SP.DYN.IMRT.IN | Infant mortality rate (per 1,000) | health |
| SH.XPD.CHEX.GD.ZS | Health expenditure (% of GDP) | health |
| SH.IMM.MEAS | Measles immunization (% of children) | health |
| SH.DYN.MORT | Under-5 mortality rate (per 1,000) | health |
| SH.STA.MMRT | Maternal mortality ratio (per 100,000) | health |
| SH.STA.BRTC.ZS | Skilled birth attendance (% of total) | health |
| SH.HIV.INCD.TL | HIV incidence (per 1,000 uninfected) | health |
| AG.LND.FRST.ZS | Forest area (% of land area) | climate |
| EG.FEC.RNEW.ZS | Renewable energy (% of total final) | climate |
| EG.USE.COMM.FO.ZS | Fossil fuel energy (% of total) | climate |
| ER.PTD.TOTL.ZS | Protected areas (% of total) | climate |
| NV.AGR.TOTL.ZS | Agriculture (% of GDP) | agriculture |
| AG.YLD.CREL.KG | Cereal yield (kg/ha) | agriculture |
| AG.PRD.CROP.XD | Crop production index (2014-2016=100) | agriculture |
| AG.LND.ARBL.ZS | Arable land (% of land area) | agriculture |
| SP.POP.TOTL | Population (total) | demography |
| SP.POP.GROW | Population growth (annual %) | demography |
| SP.URB.TOTL.IN.ZS | Urban population (% of total) | demography |
| SP.POP.65UP.TO.ZS | Population ages 65+ (% of total) | demography |
| SP.DYN.CBRT.IN | Crude birth rate (per 1,000) | demography |
| SP.DYN.CDRT.IN | Crude death rate (per 1,000) | demography |
| GOV_WGI_GE.EST | Government Effectiveness (score) | governance |
| GOV_WGI_CC.EST | Control of Corruption (score) | governance |
| GOV_WGI_RL.EST | Rule of Law (score) | governance |
| GOV_WGI_PV.EST | Political Stability (score) | governance |
| GOV_WGI_RQ.EST | Regulatory Quality (score) | governance |
| GOV_WGI_VA.EST | Voice and Accountability (score) | governance |
| NE.EXP.GNFS.ZS | Exports (% of GDP) | trade |
| NV.IND.TOTL.ZS | Industry (% of GDP) | trade |
| NE.TRD.GNFS.ZS | Trade (% of GDP) | trade |
| BX.KLT.DINV.WD.GD.ZS | FDI net inflows (% of GDP) | trade |
| NE.IMP.GNFS.ZS | Imports (% of GDP) | trade |
| TX.VAL.TECH.MF.ZS | High-tech exports (% of manufactured) | trade |
| EG.ELC.ACCS.ZS | Electricity access (% of population) | energy |
| IT.NET.USER.ZS | Internet users (% of population) | energy |
| EG.USE.PCAP.KG.OE | Energy use (kg oil eq. per capita) | energy |
| EG.IMP.CONS.ZS | Energy imports, net (% of use) | energy |
| SE.PRM.ENRR | Primary enrollment (% gross) | education_labour |
| SE.SEC.ENRR | Secondary enrollment (% gross) | education_labour |
| SL.UEM.TOTL.ZS | Unemployment (% of labor force) | education_labour |
| SL.TLF.CACT.ZS | Labor force participation (%) | education_labour |
| SE.ADT.LITR.ZS | Adult literacy rate (% ages 15+) | education_labour |
| SE.TER.ENRR | Tertiary enrollment (% gross) | education_labour |
| SL.EMP.TOTL.SP.ZS | Employment-to-population ratio (%) | education_labour |
---
## 4. Geography
All 54 African Union member states, grouped into 5 AU official regions:
| Region | ISO3 Codes |
|--------|-----------|
| **North** (6) | DZA, EGY, LBY, MRT, MAR, TUN |
| **West** (15) | BEN, BFA, CPV, CIV, GMB, GHA, GIN, GNB, LBR, MLI, NER, NGA, SEN, SLE, TGO |
| **Central** (8) | CMR, CAF, TCD, COG, COD, GNQ, GAB, STP |
| **East** (15) | BDI, COM, DJI, ERI, ETH, KEN, MDG, MUS, RWA, SYC, SOM, SSD, SDN, TZA, UGA |
| **Southern** (10) | AGO, BWA, SWZ, LSO, MWI, MOZ, NAM, ZAF, ZMB, ZWE |
The Sahrawi Arab Democratic Republic (ESH) is not a WB economy and is excluded. Regional quotas (`REGION_QUOTAS`) follow AU official proportions: North 0.15, West 0.25, Central 0.15, East 0.25, Southern 0.20.
Fiscal calendar overrides are defined for KEN (July--June), EGY (July--June), ZAF (April--March), and ETH (July 8--July 7).
---
## 5. Temporal Framework
### 5.1 Intervals
All temporal extents are modeled as half-open `[start, end)` intervals with metadata (`precision`, `label`, `calendar`, `certainty`). Supported normalization patterns:
- `"2019"` → calendar year
- `"Q3 2019"` → calendar quarter
- `"H2 2021"` → half-year
- `"2019-05"` → calendar month
- `"FY 2022/23"` → fiscal year (jurisdiction-aware)
- `"FY2022"` → fiscal year starting in 2022
### 5.2 Snapshots and Vintages
The WB API is stateless — it always returns the current latest revision. ATIC builds bitemporality through scheduled immutable snapshot pulls:
1. Each snapshot is an independent Parquet file keyed by `(series_id, entity_id, year, snapshot_id)`.
2. Observation IDs are SHA1 hashes of `{series_id}|{entity_id}|{year}|{snapshot_id}`.
3. The `Warehouse` class compares consecutive snapshots to detect revision edges (value changes between vintages).
**Seeded revisions**: `seed_revisions.py` creates a perturbed prior snapshot at 30% perturbation rate (magnitude ±3%--15%) so that `RealVintageGenerator` can produce T4 cutoff examples with real revision edges. The current corpus has 1,309 seeded revision edges across 9 series.
### 5.3 Knowledge Cutoffs
Every example carries a `knowledge_cutoff` timestamp. Verifiers ensure:
- No evidence published after the cutoff is cited (`verify_cutoff`).
- Any evidence explicitly excluded must actually be post-cutoff (`verify_excluded_evidence`).
- Abstention-consistency: if the cutoff makes answer impossible, the model must abstain (`verify_abstention_consistency`).
---
## 6. Generator Families
25 generator families produce the 12,568 examples. Each family implements `generate(ctx, budget) -> Iterator[TrainingExample]` and targets a specific temporal reasoning capability.
| Family | Count | Share | Description |
|--------|-------|-------|-------------|
| `cutoff.synthetic_vintage` | 1500 | 11.9% | Minimal-pair T4 reasoning across synthetic revision worlds |
| `real.change` | 1346 | 10.7% | Absolute difference computation between two years |
| `real.trend` | 1047 | 8.3% | Trend classification (increasing/decreasing/stable/non-directional) |
| `real.state_at_time` | 893 | 7.1% | Factual retrieval with document grounding |
| `tool.use` | 749 | 6.0% | Multi-step tool composition for compound questions |
| `real.yoy` | 742 | 5.9% | Single-period relative (year-over-year) change |
| `counterfactual` | 669 | 5.3% | Perturb-then-recompute what-if scenarios |
| `events.causal_reasoning` | 524 | 4.2% | Temporal alignment of events with indicator movements |
| `real.cagr` | 450 | 3.6% | Compound annual growth rate computation |
| `real.rank` | 450 | 3.6% | Cross-sectional ordinal ranking among peer countries |
| `spatial.extrema` | 450 | 3.6% | Find the year with the highest/lowest indicator value in a window |
| `spatial.first_last` | 443 | 3.5% | Identify the first year an indicator exceeded a threshold |
| `spatial.before_after` | 435 | 3.5% | Compare average indicator values before vs after a pivot year or event |
| `negative.unit_trap` | 387 | 3.1% | Unit/scale mismatch detection |
| `events.policy_status` | 377 | 3.0% | Binary classification of policy/event active status at a query date |
| `negative.missingness` | 324 | 2.6% | Abstention when observations are absent |
| `cutoff.real_vintage` | 300 | 2.4% | Cutoff-aware retrieval over seeded revision edges |
| `periods.normalize` | 295 | 2.3% | Fiscal-calendar-aware period expression conversion |
| `dpo.causal` | 210 | 1.7% | DPO preference pair for causally-grounded vs. spurious claims |
| `spatial.multi_entity` | 209 | 1.7% | Cross-country comparison of the same indicator in the same year |
| `dpo.comparative` | 196 | 1.6% | DPO preference pair for correct vs. incorrect comparisons |
| `dpo.cutoff` | 190 | 1.5% | DPO preference pair for cutoff-aware vs. cutoff-oblivious answers |
| `dpo.schema` | 160 | 1.3% | DPO preference pair for schema-compliant vs. malformed answers |
| `events.causal_evidence` | 142 | 1.1% | Document-grounded causal evidence from paragraph co-occurrence |
| `dpo.unit` | 80 | 0.6% | DPO preference pair for unit-correct vs. unit-confused answers |
### 6.1 Real-Data Tasks
**`real.state_at_time`**: "What was the value of indicator X for country Y in year Z?" — factual retrieval with document grounding.
**`real.change`**: "By how much did indicator X change for country Y between year A and year B?" — absolute difference computation.
**`real.trend`**: "Was the trend of indicator X for country Y over period P increasing, decreasing, stable, or not directional?" — requires 4+ data points, 70% monotonic share threshold, ±5% relative epsilon.
**`real.cagr`**: "What was the CAGR of indicator X for country Y from year A to year B?" — compound annual growth rate calculation.
**`real.yoy`**: "What was the year-over-year change of indicator X for country Y in year Z?" — single-period relative change.
**`real.rank`**: "Among [countries], where did country Y rank on indicator X in year Z?" — cross-sectional ordinal comparison.
### 6.2 Temporal Cutoff Tasks
**`cutoff.synthetic_vintage`**: Creates two parallel worlds differing only in the knowledge cutoff date. Earlier cutoff sees older observation; later cutoff sees revised value. The gold answers differ between worlds, creating a minimal pair for T4 (cutoff-aware) reasoning.
**`cutoff.real_vintage`**: Uses the 1,309 seeded revision edges. Asks "According to a report published at time T1, what was the value of X in year Y for country Z?" — requires reading the correct vintage layer.
### 6.3 Event-Driven Tasks
**`events.policy_status`**: "As of [query date], was [specific policy/event] active?" — requires knowing effective intervals of real-world events.
**`events.causal_reasoning`**: "Did [event E] plausibly cause the observed change in indicator X for country Y between T1 and T2?" — temporal alignment of event intervals with indicator movements, with hedging-aware verifiers.
### 6.4 Negative / Robustness Tasks
**`negative.missingness`**: Indicator has no observation for the requested year — model must abstain rather than hallucinate.
**`negative.unit_trap`**: Questions with mismatched units (e.g., asking for GDP per capita when given total GDP) — model must detect the mismatch.
### 6.5 Period Normalization
**`periods.normalize`**: Convert between period expressions (e.g., "what was the value in Q3 2019?") using the fiscal calendar and quarter resolution system.
### 6.6 Counterfactual
**`counterfactual`**: "If indicator X had been [value] instead of [actual] in year Y, what would the rank/change/GDP be?" — perturb-then-recompute.
### 6.7 Tool-Use
**`tool.use`**: Multi-step reasoning where the model must select and compose tools (lookup, compute, compare) to answer a compound question.
### 6.8 DPO Preference Pairs
**`dpo.cutoff`**, **`dpo.schema`**, **`dpo.comparative`**, **`dpo.causal`**, **`dpo.unit`**: Preference pairs for DPO alignment. Each pair contrasts a correctly-grounded answer against a plausible-but-wrong answer sharing surface form features.
---
## 7. Verification Pipeline
Every example passes deterministic verification before being written to the output. Verification is **not** a model-based judge; all checks are computable functions.
| Check | Description |
|-------|-------------|
| `verify_calculation` | Recomputed every arithmetic operation (identity, absolute change, percent change, CAGR) from input observations. Tolerance: `rtol=1e-6`, `atol=1e-9`. |
| `verify_cutoff` | No evidence citation has a publication timestamp after the example's `knowledge_cutoff`. |
| `verify_abstention_consistency` | If `abstention` is set, no calculations or evidenced claims may be present; conversely, if the answer claims a value, abstention must be false. |
| `verify_excluded_evidence` | Every item in `excluded_evidence` must have a publication timestamp strictly after `knowledge_cutoff`. |
| `trend_classification` | For T3_TREND tasks: re-computes `classify_trend(observations)` and compares to the gold `trend_label`. |
Examples that fail verification are counted (`verify_failed`) but still included; they are flagged via `verification.verified: false` and can be filtered downstream.
---
## 8. Dataset Splits
Splits are **group-based**, not row-level random. Each example carries a set of `group_keys` derived from its generator family and entity/synthetic-world identity. The split assignment is deterministic via SHA1 hashing:
```python
bucket = int(hashlib.sha1("|".join(sorted(group_keys)).encode()).hexdigest(), 16) % 1000 / 1000.0
if bucket < 0.08: benchmark
elif bucket < 0.16: validation
else: train
```
This guarantees that all examples from the same underlying world (e.g., both views of a synthetic-vintage minimal pair) land in the same split, preventing information leakage.
| Split | Examples | Share |
|-------|----------|-------|
| train | 10,727 | 84.6% |
| validation | 998 | 7.9% |
| benchmark | 956 | 7.5% |
---
## 9. Dataset Schema
Each example is a flat dictionary with the following keys:
| Field | Type | Description |
|-------|------|-------------|
| `example_id` | string | Unique hash-based identifier |
| Field | Type | Description |
|-------|------|-------------|
| `example_id` | string | Unique hash-based identifier |
| `system_prompt` | string | ATIC system prompt defining the model persona |
| `user_prompt` | string | User query, optionally prefixed with document excerpts |
| `gold_answer` | string | Deterministically computed answer |
| `generator_family` | string | Generator family name (25 total) |
| `task_id` | string | Primary task taxonomy (e.g., T2_STATE_AT_TIME, T3_TREND, T5_CAUSAL_EVIDENCE) |
| `synthetic` | bool | True if the example is set in a generated/counterfactual world |
| `split` | string | train / validation / benchmark |
| `difficulty` | int | 0--4 ordinal difficulty rating |
| `answer_value` | float or null | Numeric answer value (extreme_value, cagr, delta, or null) |
| `answer_year` | int or null | Target year of the question |
| `answer_entity` | string | Human-readable entity name (e.g., 'Ghana') |
| `answer_entity_id` | string | Internal entity ID (e.g., 'geo_gha') |
| `answer_indicator` | string | WB series ID (e.g., 'NY.GDP.MKTP.KD.ZG') |
| `answer_unit` | string | Unit of measurement |
| `answer_region` | string | AU region (west/east/central/southern/north) |
| `answer_country_iso3` | string | ISO3 country code |
| `requires_calculation` | bool | Whether arithmetic is needed |
| `requires_retrieval` | bool | Whether evidence retrieval is needed |
| `requires_reasoning` | bool | Whether multi-hop reasoning is needed |
| `num_evidence_items` | int | Number of observations in context |
| `num_documents` | int | Number of document excerpts provided |
| `num_events` | int | Number of curated events in context |
| `sources` | list | Provenance source IDs for traceability |
| `observation_ids` | list | Source observation IDs |
The full internal schema (Pydantic models) includes `Observation`, `Interval`, `TrainingExample` (the universal envelope), `Verification`, `Target`, `TemporalScope`, `EventRecord`, and `DocumentRecord` — all defined in `atic/models.py`.
---
## 10. Quality Assurance
- **Watermark stripping**: Removed WB document watermarks ('dezirohtuA', 'erusolcsiD', 'cilbuP') from 252/313 documents. Post-strip watermark artifacts in excerpts: 0%.
- **Garbage document filter**: Rejects documents with <500 chars, alpha-density <0.35, short-line ratio >0.5, or no economic keyword hits. 22 documents removed.
- **Country-match filter**: Accent-insensitive alias matching with COUNTRY_ALIASES eliminates false positives (e.g., Turkey/ZAF, Iran/LBY).
- **Verification**: All 5 deterministric checks pass on every example. Failed examples are flagged, not silently dropped.
- **Test suite**: 38 pytest tests covering interval arithmetic, trend classification, all generator families, and end-to-end pipeline integrity.
---
## 11. Limitations
1. **Publication-time approximation**: WB API statelessness means real vintage discovery depends on snapshot diffs. Some revision edges may be missed between infrequent snapshots.
2. **Document quality variance**: some countries have only procurement plans or sector reports; quality filter may still reject thin economic content for a few countries.
3. **Temporal coverage**: Data spans 2000--2024; earlier periods are not represented.
4. **Language bias**: Documents are primarily English and French; Portuguese-language documents (ANG, MOZ) are fewer.
5. **Event depth**: 98 events cover all 54 countries, but countries average only 1--2 events each. Event-driven examples may lack variety per country.
---
## 12. License
### 12.1 Attribution
Base indicator data sourced from the **World Bank's World Development Indicators (WDI)** and **Worldwide Governance Indicators (WGI)**. Document corpus sourced from the **World Bank Documents & Reports** repository.
The World Bank bears no responsibility for the derived labels, task definitions, temporal reasoning framework, or any analysis presented in this dataset.
### 12.2 Licenses
- WDI data: CC-BY-4.0
- WGI data: CC-BY-NC-3.0-IGO (requires manual review per source terms)
- WB Documents: CC-BY-NC-3.0-IGO
- Curated events and generated labels: CC-BY-4.0
---
## 13. Citation
```bibtex
@misc{afritemp-bench-2026,
author = {{Electric Sheep Africa}},
title = {AfriTemp-Bench: A Benchmark for Temporal Reasoning over African Statistical and Documentary Data},
year = {2026},
howpublished = {\url{https://huggingface.co/datasets/africatic/afritemp-bench}},
}
```