dsa-datasets / DATA_GUIDE.md
lschiemanowski's picture
Separate technical data guide from concise dataset card
d632287 verified
|
Raw History Blame Contribute Delete
12.5 kB
# dsa data guide
[Back to the dataset overview](README.md).
## Folder layout
Each top-level dataset folder is a self-contained evaluation pack. There are no version directories in the current layout.
| File | Purpose |
| --- | --- |
| `pack.json` | Entry point: identifies the database, case export, scoring policy, and their checksums. |
| `cases.jsonl` | Machine-readable questions, answer schemas, reference answers, and case metadata; one JSON object per line. |
| `PROBLEMS.md` | Human-readable problem catalog, including calculation conventions and answer fields. |
| `ATTRIBUTION.md` | Original sources, citations, licensing, and attribution. |
| `database/<name>.duckdb` | Ready-to-query database; its exact filename is in `pack.json`. |
| `database/build_report.json` | Dataset-specific build statistics and source provenance. |
| `reference-queries.jsonl` | Retained reference SQL for the cases recomputed during the revision. Not a complete reference implementation for every case. |
| `changes.json` | Per-case revision history and provisional difficulty labels. |
| `source.json` | Identity of the predecessor pack and unchanged source database. |
| `validation.json` | Export digests, case counts, and revision summary. |
| `verification.json` | Recorded schema checks, reference replays, and independent-check coverage. |
Some files are dataset-specific:
- Online Retail II additionally has `database-card.json`, used by the chat application to describe the database.
- Online Retail II and EEA include `database/schema.sql` and `database/views.sql`, documenting the packaged relations. The DuckDB file is already built; these scripts need not be run to use it.
- EEA also includes `database/source_manifest.json`, listing the source-request archives and their identities. These archives are provenance references, not additional files bundled here.
The root `.gitattributes` file is repository storage configuration, not part of the evaluation contract.
## JSON formats
All JSON and JSONL files are UTF-8. A `.json` file contains one JSON value; a `.jsonl` file contains one complete object per line and is not wrapped in an array. SHA-256 digests are lowercase hexadecimal strings. File paths in `pack.json` are relative to its dataset folder.
### `pack.json`: evaluation manifest
The manifest uses the `dsa-evaluation-pack/v1` contract. Its fields are:
| Field | Type and meaning |
| --- | --- |
| `format` | String, exactly `dsa-evaluation-pack/v1`. |
| `pack_id` | String identifying the problem set. |
| `version` | Pack revision as a `major.minor.patch` string; currently `2.0.0`. This is metadata, not a directory name. |
| `license` | License identifier, currently `CC-BY-4.0`. |
| `database` | Object with `id`, `path`, `size_bytes`, and `sha256`. Identifies the exact DuckDB file. |
| `cases` | Object with `path`, `size_bytes`, `sha256`, and `case_count`. Identifies the exact JSONL export. |
| `scorer` | Object selecting the answer-comparison policy. |
| `provenance` | Object containing `source_datasets`, an array of export identities with `name`, `version`, `case_count`, and `export_sha256`. These identify case exports, not the original real-world data providers. |
All three current packs use `{"name":"exact-json","version":"1"}`. Answers are compared structurally, not by their display formatting: object-key order is irrelevant, but array order and numeric types matter. Follow each question's rounding and ordering requirements.
The loader also supports `json-numeric-tolerance` version `1`, with numeric `relative_tolerance` and `absolute_tolerance` fields. That policy allows tolerance for expected floating-point values while preserving exact integer comparisons. It is not selected by the current three manifests; do not silently substitute it when reporting their results.
### `cases.jsonl`: one evaluation case per line
| Field | Type and meaning |
| --- | --- |
| `case_id` | String identifying the case within the pack. |
| `case_version` | String identifying the case revision. |
| `question` | Complete natural-language task, including calculation details and data conventions. |
| `answer_schema` | JSON Schema Draft 2020-12 object defining the required answer shape and constraints. |
| `expected_answer` | JSON value satisfying `answer_schema`; used only by the evaluator. |
| `metadata` | Object with string fields `family` (task category) and `source_level` (provisional difficulty). |
| `derivation` | Optional object `{"format":"dsa-derivation/v1"}` requesting a replay-verified derivation; absent from the current exports. |
For example, a one-number answer may use this `answer_schema`:
```json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {"total_mwh": {"type": "number"}},
"required": ["total_mwh"],
"additionalProperties": false
}
```
Schema validation checks answer structure, not factual correctness. Evaluation additionally compares the answer with `expected_answer` using the manifest's scorer. The full task is in `question`; the short opening sentence alone can omit important constraints.
The authoritative validated manifest and case contracts are defined in [`dsa.pack`](https://github.com/lschiemanowski/dsa/blob/main/src/dsa/pack.py). Each case carries its own answer schema rather than sharing a single universal answer format.
### `database-card.json`: chat presentation
Currently provided only for Online Retail II, this object uses `format: "dsa-database-card/v1"` and contains:
- `title` and `summary`: strings describing the database;
- `coverage`: an object containing `period_start` and `period_end` strings, plus integer counts for `transaction_lines`, `invoices`, `identified_customers`, `product_codes`, and `country_values`;
- `primary_relation`: the schema-qualified name of the recommended table or view;
- `relations`: an array of objects with `name`, `kind` (`table` or `view`), `row_count`, `description`, and `columns`. Each column has string fields `name`, `data_type`, and `description`;
- `example_questions`: an array of strings for user orientation;
- `analysis_notes`: an array of model-facing analytical conventions, separated from the user-facing description.
This is a presentation document, not an evaluation-case export. Its current coverage fields are retail-specific. The validated contract is defined in the [chat application's database-card module](https://github.com/lschiemanowski/dsa/blob/main/apps/private_data_chat/database_card.py).
### Revision and verification records
These are supporting authoring records, not additional model inputs or universally versioned runtime contracts. Their current shapes are:
| File | Contents |
| --- | --- |
| `reference-queries.jsonl` | Objects with `case_id`, `sql`, `origin`, and `array_key`. The nullable `array_key` controls how query rows are wrapped into an answer object by the authoring code. |
| `changes.json` | Array of objects with `case_id`, `previous_case_id`, integer `slot`, `action`, `task_type`, `analytical_operation`, `difficulty`, `difficulty_status`, `reference_status`, and booleans `answer_schema_changed` and `answer_changed`. Slots are one-based positions in the revision. |
| `source.json` | Object with `predecessor`, `database_relative_to_source_root`, `database_sha256`, and `status`. `predecessor` contains `format`, `repo_id`, `revision`, `path`, and `manifest_sha256`, identifying the earlier pack at a pinned repository commit. |
| `validation.json` | Object with `pack`, `version`, `cases`, four digest fields (`cases_sha256`, `database_sha256`, `manifest_sha256`, `reference_queries_sha256`), counts (`replaced`, `rewritten`, `recomputed_answers`, `pinned_predecessor_answers`), and count mappings `difficulty` and `types`. |
| `verification.json` | Object with `pack`, `cases_sha256`, `manifest_sha256`, `database_unchanged`, `production_loader`, `schemas_checked`, `reference_queries_replayed`, and an array of `independent_python_case_slots`. |
`source.json` is retained from authoring: its `status` may say `unpublished-local-candidate`, and its source path may contain an old version directory. These describe the historical build input, not the current publication status or download path. Use `pack.json` for current file locations.
The current revision records 244 replayed reference queries and 11 independent Python checks across the three packs. Another 56 answers were retained from pinned predecessors without new independent recomputation. The `production_loader` receipt records a local-transport check at authoring time; it is not a live service-health report. Difficulty labels are provisional, not calibrated model-performance measurements.
### Database provenance records
`database/build_report.json` varies by dataset; it does not have a single shared schema:
- **Online Retail II:** source archive and SHA-256, build time and tool versions, worksheet/raw/analysis row counts, overlap checks, quality metrics, and build checks.
- **SMARD:** database identity and SHA-256, region and time coverage, interval count, licensing and attribution, and a `source_files` array. Each source-file record includes its identifier, request JSON string, response filename, retrieval time, byte count, row count, and SHA-256.
- **EEA:** `format: "dsa-eea-air-quality-build-report/v1"`, database identity/size/SHA-256, source details, licensing, reporting-time coverage, cities, pollutants, sampling-point and relation counts, and a `source_requests` array containing archive/request identities, request JSON strings, checksums, and measurement-coverage statistics.
EEA's separate `database/source_manifest.json` uses `format: "dsa-eea-source-manifest/v1"`, with `retrieved_at_utc`, `endpoint`, and `entries`. Each entry identifies a source request and archive using `id`, `archive`, `request`, `city_id`, `city`, `source_city`, `country_code`, `start_utc_plus_1`, `end_utc_plus_1_exclusive`, `size_bytes`, and `sha256`. Historical request strings are preserved as sent; reporting-time conventions are described below.
## Working with the databases
The `.duckdb` files can be opened directly with DuckDB; using `dsa` is optional. Tables and views are organized into `raw`, `analysis`, and `metadata` schemas. Start with these relations:
| Database | Recommended relations | Important conventions |
| --- | --- | --- |
| Online Retail II | `analysis.transaction_lines_nonoverlapping` | One transaction line per row; 1,044,848 rows after removing cross-sheet overlap from 1,067,371 raw rows. Quantities are signed, prices are in GBP, and timestamps are timezone-naive. Missing identifiers and within-sheet duplicates remain. Follow the case's eligibility rules. |
| SMARD | `analysis.quarter_hourly`, `analysis.daily` | 35,136 quarter-hour intervals in the 2024 local year. Use `Europe/Berlin` for calendar dates and UTC for unambiguous interval identities. Missing measurements are not imputed. |
| EEA | `analysis.valid_measurements`, `analysis.city_hourly`, `analysis.city_daily`, `analysis.city_monthly`, `analysis.city_annual` | Reporting timestamps use fixed UTC+1, not daylight-saving civil time. CO uses mg/m³; the other pollutants use µg/m³. Coverage varies, and missing observations are not imputed; Rome has no PM₁₀ or PM₂.₅ observations in this snapshot. |
EEA's valid-measurement relation accepts validity codes 1–4. City-hour means average available valid sampling-point values; longer-period means weight each available city-hour mean equally. The original measurements and metadata remain available for coverage and validity audits.
For evaluation, keep `expected_answer`, reference SQL, and verification records out of the model's inputs. Supply the database, complete question, and answer schema; use the remaining material on the evaluator side. Public reference answers make this a transparent demo benchmark, not a contamination-resistant hidden test set.
Download one dataset with the standalone Hugging Face CLI:
```bash
uvx --from huggingface-hub hf download lschiemanowski/dsa-datasets \
--repo-type dataset --include 'online-retail-ii/*' --local-dir data
```
For reproducible experiments, add `--revision <commit-sha>` and retain the selected commit together with the manifest digest. The `main` branch can change; a directory name alone is not a frozen benchmark identity. Existing commit-pinned historical packs remain available through repository history.