zhangdw commited on
Commit
14e3e6b
·
verified ·
1 Parent(s): 6e1bc01

feat(dataset): publish reproducible seed-42 unified QA splits

Browse files
README.md ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: cc-by-sa-4.0
5
+ task_categories:
6
+ - question-answering
7
+ size_categories:
8
+ - 1K<n<10K
9
+ pretty_name: "HotpotQA — Unified Multi-hop QA"
10
+ source_datasets:
11
+ - hotpotqa/hotpot_qa
12
+ tags:
13
+ - multi-hop-reasoning
14
+ - supplied-context
15
+ - rag
16
+ - reproducibility
17
+ - jsonl
18
+ configs:
19
+ - config_name: default
20
+ data_files:
21
+ - split: train
22
+ path: train.jsonl
23
+ - split: val
24
+ path: val.jsonl
25
+ - split: test
26
+ path: test.jsonl
27
+ - split: testL
28
+ path: testL.jsonl
29
+ ---
30
+
31
+ <h1 align="center">HotpotQA</h1>
32
+ <p align="center"><strong>Unified multi-hop question answering · Distractor · Seed 42</strong></p>
33
+
34
+ **HotpotQA** packages a compact, reproducible selection of **Distractor** questions for supplied-context reasoning, RAG workflows, and prompt or program optimization. Every question includes its original candidate passages, answer labels, and supporting-passage IDs. The schema matches [MuSiQue](https://huggingface.co/datasets/zhangdw/musique).
35
+
36
+ <table width="100%">
37
+ <tr>
38
+ <td width="33%" align="center"><strong>200 + 200</strong><br>Train · validation</td>
39
+ <td width="33%" align="center"><strong>200 ⊂ 1,000</strong><br>Test · large test</td>
40
+ <td width="33%" align="center"><strong>1,400</strong><br>Unique questions</td>
41
+ </tr>
42
+ </table>
43
+
44
+ <p align="center">
45
+ <a href="#quick-start">Quick start</a> · <a href="#frozen-splits">Frozen splits</a> · <a href="#data-format">Data format</a> · <a href="#reproducibility">Reproducibility</a> · <a href="#provenance-and-license">Provenance</a>
46
+ </p>
47
+
48
+ ## Quick start
49
+
50
+ Download the complete package:
51
+
52
+ ```bash
53
+ uvx hf download zhangdw/hotpotqa --type dataset --local-dir hotpotqa
54
+ ```
55
+
56
+ The four JSONL files are ready to use. No model, vector database, or corpus preparation is needed to read them.
57
+
58
+ ```python
59
+ import json
60
+ from pathlib import Path
61
+
62
+ rows = [json.loads(line) for line in Path("hotpotqa/test.jsonl").read_text().splitlines()]
63
+ example = rows[0]
64
+ solver_input = {"question": example["question"], "contexts": example["contexts"]}
65
+ ```
66
+
67
+ With Hugging Face Datasets installed, `load_dataset("zhangdw/hotpotqa")` loads exactly `train`, `val`, `test`, and `testL`. The raw source files and demos are excluded from automatic split loading by the card configuration.
68
+
69
+ ## Frozen splits
70
+
71
+ | File | Questions | Source | Intended role |
72
+ | --- | ---: | --- | --- |
73
+ | `train.jsonl` | 200 | Official training pool | Prompt/program optimization and feedback |
74
+ | `val.jsonl` | 200 | Remaining official training pool | Candidate selection |
75
+ | `test.jsonl` | 200 | Labeled official validation/dev pool | Fixed small evaluation |
76
+ | `testL.jsonl` | 1,000 | Labeled official validation/dev pool | Final evaluation after the method is fixed |
77
+
78
+ **The first 200 lines of `testL.jsonl` are byte-for-byte identical to `test.jsonl`.** The remaining 800 questions extend the final evaluation. Train, validation, and large test have disjoint IDs and normalized questions; there are **1,400 unique questions** and **1,600 stored rows** across the four files.
79
+
80
+ These are custom subsets, not the official hidden test set or full benchmark evaluation protocol. Use the same frozen files for method comparisons. `train` describes the optimization role of the examples; it does not require model-weight training.
81
+
82
+ ## Data format
83
+
84
+ Every JSONL row contains exactly five fields:
85
+
86
+ | Field | Type | Meaning |
87
+ | --- | --- | --- |
88
+ | `id` | string | `hotpotqa:<original_id>` |
89
+ | `question` | string | Original question |
90
+ | `contexts` | array of objects | All original candidates, in their original order |
91
+ | `answers` | array of strings | Primary answer followed by any original answer aliases, deduplicated |
92
+ | `supporting_context_ids` | array of integers | Supporting passages referenced by their local context IDs |
93
+
94
+ Each context contains exactly `id`, `title`, and `text`. Context IDs are consecutive integers beginning at zero. Supporting IDs refer to passages, not sentence offsets; their array order is not a reasoning trajectory.
95
+
96
+ HotpotQA sentence arrays are joined with one space to form each passage text. Candidate passages are never pruned or padded. Some native questions contain fewer than 10 candidates.
97
+
98
+ **Only `question` and `contexts` are solver inputs.** Answers and supporting IDs are evaluator labels or train-stage optimization feedback. Original sentence-level evidence and/or question decompositions remain available in `raw/`; the compact format stores passage-level evidence.
99
+
100
+ ### English and Chinese examples
101
+
102
+ - [`demo.json`](demo.json): one complete source example converted to the five-field schema.
103
+ - [`demo_zh.json`](demo_zh.json): the corresponding Chinese illustration, with the same question ID, context IDs, context order, and supporting IDs.
104
+
105
+ The Chinese demo is an explanatory translation, not an official translated evaluation set. Both demos are documentation examples and are not additional split rows. The four evaluation/optimization files remain English.
106
+
107
+ ## Reproducibility
108
+
109
+ `prepare.py` is a standalone script that reads only this repository's `raw/` directory. It embeds raw-file SHA-256 checksums and uses **`SEED = 42`**, declared near the top of the file. It needs no companion repository or access to a model.
110
+
111
+ ```bash
112
+ cd hotpotqa
113
+ uv run prepare.py
114
+ ```
115
+
116
+ This rebuilds all four JSONL files next to the script. `uv` selects Python 3.10–3.12 and manages the declared dependencies (pyarrow 19.0.1) in an isolated script environment. Existing experimental Python environments are not modified.
117
+
118
+ To verify the published files against regeneration without rewriting them:
119
+
120
+ ```bash
121
+ uv run prepare.py --check
122
+ ```
123
+
124
+ Change **`SEED = 42`** to another integer and rerun to obtain another deterministic selection. For an alternative output directory, use `uv run prepare.py --output-dir another-seed`. The public files in this release use seed 42. Demo files are fixed illustrations and are not resampled by the script.
125
+
126
+ <details>
127
+ <summary><strong>Selection rules and seed-42 allocation</strong></summary>
128
+
129
+ 1. Verify the bundled raw-file checksums and validate record structure and evidence references. HotpotQA records with an out-of-range supporting-sentence index are excluded.
130
+ 2. Normalize questions with Unicode NFKC, case folding, and punctuation/whitespace normalization. Keep the lexicographically smallest ID for duplicate questions within each source split; exclude training questions also found in official validation.
131
+ 3. Stratify by **question type × difficulty**. Allocate integer quotas proportionally with the largest-remainder method and lexical tie-breaking.
132
+ 4. Rank candidates using SHA-256 of `qa-splits-v1|seed|dataset|split|prefixed_id`. Select 200 train questions, then 200 val questions from the remaining training pool, then 200 test questions from official validation/dev.
133
+ 5. Preserve the entire test set as the large-test prefix. Compute proportional quotas for 1,000 questions and fill each stratum's remaining quota with unused validation/dev questions ranked with the `testL` split key.
134
+ 6. Validate the five-field schema, support references, split counts, test inclusion, and ID/normalized-question separation before writing UTF-8 JSONL.
135
+
136
+ | Source split | Original rows | Invalid evidence | Duplicate exclusions | Eligible rows |
137
+ | --- | ---: | ---: | ---: | ---: |
138
+ | `train` | 90,447 | 22 | 13 | 90,412 |
139
+ | `validation` | 7,405 | 1 | 0 | 7,404 |
140
+
141
+ | Stratum | Train | Val | Test | TestL |
142
+ | --- | ---: | ---: | ---: | ---: |
143
+ | bridge × easy | 32 | 32 | 0 | 0 |
144
+ | bridge × hard | 27 | 27 | 160 | 799 |
145
+ | bridge × medium | 102 | 102 | 0 | 0 |
146
+ | comparison × easy | 8 | 8 | 0 | 0 |
147
+ | comparison × hard | 7 | 7 | 40 | 201 |
148
+ | comparison × medium | 24 | 24 | 0 | 0 |
149
+
150
+ No model scores are used for selection. Deduplication does not remove semantic paraphrases or enforce passage-disjoint splits. Reproduction produces the published files byte for byte; the source hash checks make the input snapshot explicit.
151
+
152
+ </details>
153
+
154
+ <details>
155
+ <summary><strong>Published JSONL checksums (SHA-256)</strong></summary>
156
+
157
+ | File | SHA-256 |
158
+ | --- | --- |
159
+ | `train.jsonl` | `6091ed80011bc4e04704a19f4dd29b17ce6fc87f522521b58f02caec2ed1179e` |
160
+ | `val.jsonl` | `21b5d6bd6090949225569f5b6d1fc501fca4d61ffb5acdd574b617e760767a76` |
161
+ | `test.jsonl` | `922e5fc9b3149ca630484843005c9ecd40f604b1dd3b36807761fbba80c22859` |
162
+ | `testL.jsonl` | `63dbd6895787b435616937b0e231f9556a9162d9b7f8eebb17a52ced2c90dd78` |
163
+
164
+ </details>
165
+
166
+ ## What's inside
167
+
168
+ ```text
169
+ hotpotqa/
170
+ ├── raw/
171
+ │ └── distractor/
172
+ │ ├── train-00000-of-00002.parquet
173
+ │ ├── train-00001-of-00002.parquet
174
+ │ └── validation-00000-of-00001.parquet
175
+ ├── train.jsonl
176
+ ├── val.jsonl
177
+ ├── test.jsonl
178
+ ├── testL.jsonl
179
+ ├── demo.json
180
+ ├── demo_zh.json
181
+ ├── prepare.py
182
+ └── README.md
183
+ ```
184
+
185
+ `raw/` contains the unmodified Hugging Face Distractor Parquet snapshot (90,447 training and 7,405 validation questions). It retains upstream fields and annotations and is not replaced by the compact schema.
186
+
187
+ ## Provenance and license
188
+
189
+ Source snapshot: [`hotpotqa/hotpot_qa@1908d6afbbea`](https://huggingface.co/datasets/hotpotqa/hotpot_qa/tree/1908d6afbbead072334abe2965f91bd2709910ab). These are the original downloaded HF Parquet files, not a claim that the authors originally distributed Parquet.
190
+
191
+ [Original project](https://hotpotqa.github.io/) · [Paper](https://aclanthology.org/D18-1259/) · [Companion MuSiQue dataset](https://huggingface.co/datasets/zhangdw/musique)
192
+
193
+ This release changes packaging, sampling, and field representation. Attribution remains with the original dataset authors. HotpotQA is distributed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/); this adapted dataset retains that license.
194
+
195
+ <details>
196
+ <summary><strong>Unmodified source-file checksums</strong></summary>
197
+
198
+ | File | SHA-256 |
199
+ | --- | --- |
200
+ | `raw/distractor/train-00000-of-00002.parquet` | `76d3bb3048a7cc73c1958107c0c5872a00d7e7d00c105b81e92f6769e7822e68` |
201
+ | `raw/distractor/train-00001-of-00002.parquet` | `713661628434fbb19fff7392e2e321e4ed107e3c7c7784d0690946e5f722763f` |
202
+ | `raw/distractor/validation-00000-of-00001.parquet` | `c20b638ca82b21d04fe12e14ff417ad05153d4d215a65de54497fca4e972f7c6` |
203
+
204
+ </details>
205
+
206
+ ### Citation
207
+
208
+ Please cite the original dataset when using these questions:
209
+
210
+ ```bibtex
211
+ @inproceedings{yang2018hotpotqa,
212
+ title = {HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answering},
213
+ author = {Yang, Zhilin and Qi, Peng and Zhang, Saizheng and Bengio, Yoshua and Cohen, William W. and Salakhutdinov, Ruslan and Manning, Christopher D.},
214
+ booktitle = {Proceedings of EMNLP},
215
+ year = {2018}
216
+ }
217
+ ```
demo.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "hotpotqa:5a8b57f25542995d1e6f1371",
3
+ "question": "Were Scott Derrickson and Ed Wood of the same nationality?",
4
+ "contexts": [
5
+ {
6
+ "id": 0,
7
+ "title": "Ed Wood (film)",
8
+ "text": "Ed Wood is a 1994 American biographical period comedy-drama film directed and produced by Tim Burton, and starring Johnny Depp as cult filmmaker Ed Wood. The film concerns the period in Wood's life when he made his best-known films as well as his relationship with actor Bela Lugosi, played by Martin Landau. Sarah Jessica Parker, Patricia Arquette, Jeffrey Jones, Lisa Marie, and Bill Murray are among the supporting cast."
9
+ },
10
+ {
11
+ "id": 1,
12
+ "title": "Scott Derrickson",
13
+ "text": "Scott Derrickson (born July 16, 1966) is an American director, screenwriter and producer. He lives in Los Angeles, California. He is best known for directing horror films such as \"Sinister\", \"The Exorcism of Emily Rose\", and \"Deliver Us From Evil\", as well as the 2016 Marvel Cinematic Universe installment, \"Doctor Strange.\""
14
+ },
15
+ {
16
+ "id": 2,
17
+ "title": "Woodson, Arkansas",
18
+ "text": "Woodson is a census-designated place (CDP) in Pulaski County, Arkansas, in the United States. Its population was 403 at the 2010 census. It is part of the Little Rock–North Little Rock–Conway Metropolitan Statistical Area. Woodson and its accompanying Woodson Lake and Wood Hollow are the namesake for Ed Wood Sr., a prominent plantation owner, trader, and businessman at the turn of the 20th century. Woodson is adjacent to the Wood Plantation, the largest of the plantations own by Ed Wood Sr."
19
+ },
20
+ {
21
+ "id": 3,
22
+ "title": "Tyler Bates",
23
+ "text": "Tyler Bates (born June 5, 1965) is an American musician, music producer, and composer for films, television, and video games. Much of his work is in the action and horror film genres, with films like \"Dawn of the Dead, 300, Sucker Punch,\" and \"John Wick.\" He has collaborated with directors like Zack Snyder, Rob Zombie, Neil Marshall, William Friedkin, Scott Derrickson, and James Gunn. With Gunn, he has scored every one of the director's films; including \"Guardians of the Galaxy\", which became one of the highest grossing domestic movies of 2014, and its 2017 sequel. In addition, he is also the lead guitarist of the American rock band Marilyn Manson, and produced its albums \"The Pale Emperor\" and \"Heaven Upside Down\"."
24
+ },
25
+ {
26
+ "id": 4,
27
+ "title": "Ed Wood",
28
+ "text": "Edward Davis Wood Jr. (October 10, 1924 – December 10, 1978) was an American filmmaker, actor, writer, producer, and director."
29
+ },
30
+ {
31
+ "id": 5,
32
+ "title": "Deliver Us from Evil (2014 film)",
33
+ "text": "Deliver Us from Evil is a 2014 American supernatural horror film directed by Scott Derrickson and produced by Jerry Bruckheimer. The film is officially based on a 2001 non-fiction book entitled \"Beware the Night\" by Ralph Sarchie and Lisa Collier Cool, and its marketing campaign highlighted that it was \"inspired by actual accounts\". The film stars Eric Bana, Édgar Ramírez, Sean Harris, Olivia Munn, and Joel McHale in the main roles and was released on July 2, 2014."
34
+ },
35
+ {
36
+ "id": 6,
37
+ "title": "Adam Collis",
38
+ "text": "Adam Collis is an American filmmaker and actor. He attended the Duke University from 1986 to 1990 and the University of California, Los Angeles from 2007 to 2010. He also studied cinema at the University of Southern California from 1991 to 1997. Collis first work was the assistant director for the Scott Derrickson's short \"Love in the Ruins\" (1995). In 1998, he played \"Crankshaft\" in Eric Koyanagi's \"Hundred Percent\"."
39
+ },
40
+ {
41
+ "id": 7,
42
+ "title": "Sinister (film)",
43
+ "text": "Sinister is a 2012 supernatural horror film directed by Scott Derrickson and written by Derrickson and C. Robert Cargill. It stars Ethan Hawke as fictional true-crime writer Ellison Oswalt who discovers a box of home movies in his attic that puts his family in danger."
44
+ },
45
+ {
46
+ "id": 8,
47
+ "title": "Conrad Brooks",
48
+ "text": "Conrad Brooks (born Conrad Biedrzycki on January 3, 1931 in Baltimore, Maryland) is an American actor. He moved to Hollywood, California in 1948 to pursue a career in acting. He got his start in movies appearing in Ed Wood films such as \"Plan 9 from Outer Space\", \"Glen or Glenda\", and \"Jail Bait.\" He took a break from acting during the 1960s and 1970s but due to the ongoing interest in the films of Ed Wood, he reemerged in the 1980s and has become a prolific actor. He also has since gone on to write, produce and direct several films."
49
+ },
50
+ {
51
+ "id": 9,
52
+ "title": "Doctor Strange (2016 film)",
53
+ "text": "Doctor Strange is a 2016 American superhero film based on the Marvel Comics character of the same name, produced by Marvel Studios and distributed by Walt Disney Studios Motion Pictures. It is the fourteenth film of the Marvel Cinematic Universe (MCU). The film was directed by Scott Derrickson, who wrote it with Jon Spaihts and C. Robert Cargill, and stars Benedict Cumberbatch as Stephen Strange, along with Chiwetel Ejiofor, Rachel McAdams, Benedict Wong, Michael Stuhlbarg, Benjamin Bratt, Scott Adkins, Mads Mikkelsen, and Tilda Swinton. In \"Doctor Strange\", surgeon Strange learns the mystic arts after a career-ending car accident."
54
+ }
55
+ ],
56
+ "answers": [
57
+ "yes"
58
+ ],
59
+ "supporting_context_ids": [
60
+ 1,
61
+ 4
62
+ ]
63
+ }
demo_zh.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "hotpotqa:5a8b57f25542995d1e6f1371",
3
+ "question": "斯科特·德里克森和艾德·伍德的国籍相同吗?",
4
+ "contexts": [
5
+ {
6
+ "id": 0,
7
+ "title": "艾德·伍德(电影)",
8
+ "text": "《艾德·伍德》是一部1994年的美国传记年代喜剧剧情片,由蒂姆·伯顿执导并制作,约翰尼·德普饰演具有邪典电影风格的电影人艾德·伍德。 影片讲述了伍德拍摄其最知名电影的那段人生,以及他与演员贝拉·卢戈西的关系;卢戈西由马丁·兰道饰演。 配角演员包括莎拉·杰西卡·帕克、帕特里夏·阿奎特、杰弗里·琼斯、丽莎·玛丽和比尔·默瑞。"
9
+ },
10
+ {
11
+ "id": 1,
12
+ "title": "斯科特·德里克森",
13
+ "text": "斯科特·德里克森(1966年7月16日出生)是一位美国导演、编剧和制片人。 他居住在加利福尼亚州洛杉矶。 他以执导《险恶》《驱魔》和《驱魔警探》等恐怖片,以及2016年漫威电影宇宙作品《奇异博士》而闻名。"
14
+ },
15
+ {
16
+ "id": 2,
17
+ "title": "伍德森(阿肯色州)",
18
+ "text": "伍德森是美国阿肯色州普拉斯基县的一个人口普查指定地区(CDP)。 2010年人口普查时,该地人口为403人。 它属于小石城—北小石城—康威大都市统计区。 伍德森及其附近的伍德森湖和伍德谷,均以老艾德·伍德命名;他是19世纪末20世纪初一位知名的种植园主、贸易商和商人。 伍德森毗邻伍德种植园,后者是老艾德·伍德所拥有的种植园中最大的一座。"
19
+ },
20
+ {
21
+ "id": 3,
22
+ "title": "泰勒·贝茨",
23
+ "text": "泰勒·贝茨(1965年6月5日出生)是一位美国音乐人、音乐制作人,以及电影、电视和电子游戏配乐作曲家。 他的许多作品属于动作片和恐怖片类型,例如《活死人黎明》《斯巴达300勇士》《美少女特攻队》和《疾速追杀》。 他曾与扎克·施奈德、罗布·赞比、尼尔·马歇尔、威廉·弗里德金、斯科特·德里克森和詹姆斯·古恩等导演合作。 在与古恩的合作中,他为这位导演的每部电影都创作了配乐,其中包括2014年美国国内票房最高的电影之一《银河护卫队》及其2017年的续集。 此外,他还是美国摇滚乐队玛丽莲·曼森的主音吉他手,并制作了该乐队的专辑《苍白皇帝》(The Pale Emperor)和《颠倒天堂》(Heaven Upside Down)。"
24
+ },
25
+ {
26
+ "id": 4,
27
+ "title": "艾德·伍德",
28
+ "text": "小爱德华·戴维斯·伍德(1924年10月10日—1978年12月10日)是一位美国电影人、演员、作家、制片人和导演。"
29
+ },
30
+ {
31
+ "id": 5,
32
+ "title": "驱魔警探(2014年电影)",
33
+ "text": "《驱魔警探》是一部2014年的美国超自然恐怖片,由斯科特·德里克森执导,杰瑞·布鲁克海默制作。 影片官方称改编自拉尔夫·萨奇和丽莎·科利尔·库尔于2001年出版的非虚构书籍《当心夜晚》(Beware the Night),其宣传强调影片“受到真实叙述的启发”。 影片由艾瑞克·巴纳、埃德加·拉米雷兹、肖恩·哈里斯、奥利维亚·穆恩和乔尔·麦克哈尔担任主要演员,于2014年7月2日上映。"
34
+ },
35
+ {
36
+ "id": 6,
37
+ "title": "亚当·科利斯",
38
+ "text": "亚当·科利斯是一位美国电影人和演员。 他于1986年至1990年就读于杜克大学,并于2007年至2010年就读于加利福尼亚大学洛杉矶分校。 他还于1991年至1997年在南加利福尼亚大学学习电影。 科利斯的第一份工作是担任斯科特·德里克森短片《废墟中的爱》(Love in the Ruins,1995年)的副导演。 1998年,他在埃里克·小柳的《百分之百》(Hundred Percent)中饰演“曲轴”(Crankshaft)。"
39
+ },
40
+ {
41
+ "id": 7,
42
+ "title": "险恶(电影)",
43
+ "text": "《险恶》是一部2012年的超自然恐怖片,由斯科特·德里克森执导,德里克森与C.罗伯特·卡吉尔共同编剧。 伊桑·霍克在片中饰演虚构的真实犯罪题材作家埃里森·奥斯瓦尔特,他在阁楼上发现了一箱家庭电影胶片,使家人陷入危险。"
44
+ },
45
+ {
46
+ "id": 8,
47
+ "title": "康拉德·布鲁克斯",
48
+ "text": "康拉德·布鲁克斯是一位美国演员,原名康拉德·比德日茨基,1931年1月3日出生于马里兰州巴尔的摩。 1948年,他搬到加利福尼亚州好莱坞,追求演艺事业。 他通过参演艾德·伍德的《外太空计划9》《格伦或格伦达》和《诱饵》等电影开始了电影生涯。 他在20世纪60年代和70年代暂停了演艺工作,但由于人们对艾德·伍德电影的持续关注,他在80年代复出,并成为一位作品众多的演员。 此后,他还为多部电影担任编剧、制片人和导演。"
49
+ },
50
+ {
51
+ "id": 9,
52
+ "title": "奇异博士(2016年电影)",
53
+ "text": "《奇��博士》是一部2016年的美国超级英雄电影,改编自漫威漫画中的同名角色,由漫威影业制作、华特迪士尼影业发行。 它是漫威电影宇宙(MCU)的第十四部电影。 影片由斯科特·德里克森执导,他与乔恩·斯派茨、C.罗伯特·卡吉尔共同编剧;本尼迪克特·康伯巴奇饰演史蒂芬·斯特兰奇,其他主演包括切瓦特·埃加福特、瑞秋·麦克亚当斯、黄凯旋、迈克尔·斯图巴、 本杰明·布拉特、斯科特·阿金斯、麦斯·米科尔森和蒂尔达·斯文顿。 在《奇异博士》中,外科医生斯特兰奇在一场终结其职业生涯的车祸后开始学习神秘法术。"
54
+ }
55
+ ],
56
+ "answers": [
57
+ "是"
58
+ ],
59
+ "supporting_context_ids": [
60
+ 1,
61
+ 4
62
+ ]
63
+ }
prepare.py ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.10,<3.13"
4
+ # dependencies = ["pyarrow==19.0.1"]
5
+ # ///
6
+ """Rebuild the four hotpotqa JSONL splits from this repository's raw/ snapshot.
7
+
8
+ Run: uv run prepare.py
9
+ Verify published bytes: uv run prepare.py --check
10
+ Change SEED below to produce another deterministic split. No model is used.
11
+ """
12
+ import argparse
13
+ from collections import Counter, defaultdict
14
+ import hashlib
15
+ import json
16
+ from pathlib import Path
17
+ import re
18
+ import unicodedata
19
+
20
+ SEED = 42 # Change this integer to generate a different reproducible split.
21
+ DATASET = 'hotpotqa'
22
+ VERSION = "qa-splits-v1" # Sampling algorithm version; independent of the output schema.
23
+ ROOT = Path(__file__).resolve().parent
24
+ RAW_SHA256 = {'distractor/train-00000-of-00002.parquet': '76d3bb3048a7cc73c1958107c0c5872a00d7e7d00c105b81e92f6769e7822e68', 'distractor/train-00001-of-00002.parquet': '713661628434fbb19fff7392e2e321e4ed107e3c7c7784d0690946e5f722763f', 'distractor/validation-00000-of-00001.parquet': 'c20b638ca82b21d04fe12e14ff417ad05153d4d215a65de54497fca4e972f7c6'}
25
+
26
+
27
+ def canonical_question(text):
28
+ text = unicodedata.normalize("NFKC", text).casefold()
29
+ return re.sub(r"[\W_]+", " ", text).strip()
30
+
31
+
32
+
33
+ def digest(path):
34
+ h = hashlib.sha256()
35
+ with path.open("rb") as stream:
36
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
37
+ h.update(chunk)
38
+ return h.hexdigest()
39
+
40
+
41
+
42
+ def convert(row, dataset, split, source_file):
43
+ candidates = []
44
+ if dataset == "hotpotqa":
45
+ ctx = row["context"]
46
+ assert len(ctx["title"]) == len(ctx["sentences"])
47
+ for i, (title, sentences) in enumerate(zip(ctx["title"], ctx["sentences"])):
48
+ candidates.append({"id": f"p{i}", "title": title,
49
+ "text": " ".join(sentences), "sentences": sentences})
50
+ assert len({p["title"] for p in candidates}) == len(candidates)
51
+ title_map = {p["title"]: p for p in candidates}
52
+ sf = row["supporting_facts"]
53
+ assert len(sf["title"]) == len(sf["sent_id"])
54
+ facts = []
55
+ for title, sent_id in zip(sf["title"], sf["sent_id"]):
56
+ p = title_map[title]
57
+ if not 0 <= sent_id < len(p["sentences"]):
58
+ raise ValueError("support_sentence_out_of_range")
59
+ facts.append({"candidate_id": p["id"], "sentence_index": sent_id})
60
+ support_ids = list(dict.fromkeys(f["candidate_id"] for f in facts))
61
+ gold = {"answers": [row["answer"]], "supporting_candidate_ids": support_ids,
62
+ "supporting_facts": facts}
63
+ metadata = {"type": row["type"], "level": row["level"]}
64
+ stratum = f"{row['type']}|{row['level']}"
65
+ else:
66
+ assert row["answerable"] is True
67
+ for p in row["paragraphs"]:
68
+ candidates.append({"id": f"p{p['idx']}", "title": p["title"],
69
+ "text": p["paragraph_text"]})
70
+ support_ids = [f"p{p['idx']}" for p in row["paragraphs"] if p["is_supporting"]]
71
+ decomposition = row["question_decomposition"]
72
+ assert {f"p{d['paragraph_support_idx']}" for d in decomposition} == set(support_ids)
73
+ gold = {"answers": list(dict.fromkeys([row["answer"], *row["answer_aliases"]])),
74
+ "supporting_candidate_ids": support_ids,
75
+ "question_decomposition": decomposition, "answerable": True}
76
+ metadata = {"num_hops": len(decomposition)}
77
+ stratum = f"{len(decomposition)}hop"
78
+ assert candidates and len({p["id"] for p in candidates}) == len(candidates)
79
+ assert all(isinstance(p["text"], str) and p["text"].strip() for p in candidates)
80
+ assert support_ids and set(support_ids) <= {p["id"] for p in candidates}
81
+ assert gold["answers"] and all(isinstance(a, str) and a for a in gold["answers"])
82
+ assert canonical_question(row["question"])
83
+ metadata["stratum"] = stratum
84
+ return {"id": f"{dataset}:{row['id']}", "dataset": dataset,
85
+ "source": {"id": row["id"], "split": split, "file": source_file},
86
+ "question": row["question"], "candidates": candidates,
87
+ "gold": gold, "metadata": metadata}
88
+
89
+
90
+
91
+ def apportion(counts, total):
92
+ population = sum(counts.values())
93
+ assert population >= total
94
+ quotas = {k: total * v // population for k, v in counts.items()}
95
+ order = sorted(counts, key=lambda k: (-(total * counts[k] % population), k))
96
+ for key in order[:total - sum(quotas.values())]:
97
+ quotas[key] += 1
98
+ assert sum(quotas.values()) == total
99
+ return quotas
100
+
101
+
102
+
103
+ def sample(pool, dataset, split, count, seed):
104
+ groups = defaultdict(list)
105
+ for row in pool:
106
+ groups[row["stratum"]].append(row)
107
+ quotas = apportion({k: len(v) for k, v in groups.items()}, count)
108
+ def rank(row):
109
+ return hashlib.sha256(f"{VERSION}|{seed}|{dataset}|{split}|{row['id']}".encode()).hexdigest()
110
+ chosen = []
111
+ for key in sorted(groups):
112
+ chosen.extend(sorted(groups[key], key=rank)[:quotas[key]])
113
+ return sorted(chosen, key=rank), dict(sorted(quotas.items()))
114
+
115
+
116
+
117
+ def simplify(record):
118
+ mapping = {p["id"]: i for i, p in enumerate(record["candidates"])}
119
+ return {
120
+ "id": record["id"],
121
+ "question": record["question"],
122
+ "contexts": [{"id": i, "title": p["title"], "text": p["text"]}
123
+ for i, p in enumerate(record["candidates"])],
124
+ "answers": record["gold"]["answers"],
125
+ "supporting_context_ids": [mapping[x] for x in record["gold"]["supporting_candidate_ids"]],
126
+ }
127
+
128
+
129
+
130
+ def validate_record(r, dataset):
131
+ assert set(r) == {"id", "question", "contexts", "answers", "supporting_context_ids"}
132
+ assert isinstance(r["id"], str) and r["id"].startswith(dataset + ":")
133
+ assert isinstance(r["question"], str) and canonical_question(r["question"])
134
+ assert isinstance(r["contexts"], list) and r["contexts"]
135
+ for i, context in enumerate(r["contexts"]):
136
+ assert set(context) == {"id", "title", "text"}
137
+ assert type(context["id"]) is int and context["id"] == i
138
+ assert isinstance(context["title"], str)
139
+ assert isinstance(context["text"], str) and context["text"].strip()
140
+ assert isinstance(r["answers"], list) and r["answers"]
141
+ assert all(isinstance(a, str) and a for a in r["answers"])
142
+ support = r["supporting_context_ids"]
143
+ assert isinstance(support, list) and support
144
+ assert all(type(x) is int and 0 <= x < len(r["contexts"]) for x in support)
145
+ assert len(support) == len(set(support))
146
+
147
+
148
+
149
+ def extend_test(pool, test, dataset, total, seed):
150
+ quotas = apportion(dict(Counter(r["stratum"] for r in pool)), total)
151
+ used_counts = Counter(r["stratum"] for r in test)
152
+ used_ids = {r["id"] for r in test}
153
+ groups = defaultdict(list)
154
+ for row in pool:
155
+ if row["id"] not in used_ids:
156
+ groups[row["stratum"]].append(row)
157
+ def rank(row):
158
+ return hashlib.sha256(f"{VERSION}|{seed}|{dataset}|testL|{row['id']}".encode()).hexdigest()
159
+ extra = []
160
+ for key in sorted(quotas):
161
+ need = quotas[key] - used_counts[key]
162
+ assert 0 <= need <= len(groups[key])
163
+ extra.extend(sorted(groups[key], key=rank)[:need])
164
+ result = test + sorted(extra, key=rank)
165
+ assert len(result) == total
166
+ return result, dict(sorted(quotas.items()))
167
+
168
+
169
+
170
+ def raw_rows(raw_root, split):
171
+ if DATASET == "hotpotqa":
172
+ import pyarrow.parquet as pq
173
+ prefix = "train" if split == "train" else "validation"
174
+ paths = sorted((raw_root / "distractor").glob(prefix + "-*.parquet"))
175
+ assert paths, f"No {split} Parquet files in {raw_root}"
176
+ for path in paths:
177
+ for batch in pq.ParquetFile(path).iter_batches(batch_size=1024):
178
+ yield from batch.to_pylist()
179
+ else:
180
+ suffix = "train" if split == "train" else "dev"
181
+ with (raw_root / f"musique_ans_v1.0_{suffix}.jsonl").open(encoding="utf-8") as stream:
182
+ for line in stream:
183
+ yield json.loads(line)
184
+
185
+
186
+ def scan(raw_root):
187
+ indices, report = {}, {}
188
+ for split in ("train", "validation"):
189
+ rows, ids, invalid = [], set(), []
190
+ count = 0
191
+ for raw in raw_rows(raw_root, split):
192
+ count += 1
193
+ try:
194
+ r = convert(raw, DATASET, split, "raw")
195
+ except ValueError as error:
196
+ if str(error) != "support_sentence_out_of_range":
197
+ raise
198
+ invalid.append(raw["id"])
199
+ continue
200
+ assert r["id"] not in ids, r["id"]
201
+ ids.add(r["id"])
202
+ rows.append({"id": r["id"], "question_key": canonical_question(r["question"]),
203
+ "stratum": r["metadata"]["stratum"]})
204
+ indices[split] = rows
205
+ report[split] = {"source_rows": count, "invalid_support_sentence_ids": invalid}
206
+ dev_questions = {r["question_key"] for r in indices["validation"]}
207
+ pools = {}
208
+ for split in ("train", "validation"):
209
+ seen, kept = set(), []
210
+ for r in sorted(indices[split], key=lambda r: r["id"]):
211
+ q = r["question_key"]
212
+ if (split == "train" and q in dev_questions) or q in seen:
213
+ continue
214
+ seen.add(q)
215
+ kept.append(r)
216
+ pools[split] = kept
217
+ report[split]["eligible_rows"] = len(kept)
218
+ report[split]["excluded_duplicate_rows"] = len(indices[split]) - len(kept)
219
+ return pools, report
220
+
221
+
222
+ def validate_splits(outputs):
223
+ assert {k: len(v) for k, v in outputs.items()} == {"train": 200, "val": 200, "test": 200, "testL": 1000}
224
+ assert outputs["testL"][:200] == outputs["test"]
225
+ ids, questions = set(), set()
226
+ for split in ("train", "val", "testL"):
227
+ for r in outputs[split]:
228
+ validate_record(r, DATASET)
229
+ q = canonical_question(r["question"])
230
+ assert r["id"] not in ids and q not in questions
231
+ ids.add(r["id"])
232
+ questions.add(q)
233
+ assert len(ids) == len(questions) == 1400
234
+
235
+
236
+ def main():
237
+ parser = argparse.ArgumentParser(description=__doc__)
238
+ parser.add_argument("--output-dir", type=Path, default=ROOT,
239
+ help="Output directory (default: next to this script)")
240
+ parser.add_argument("--check", action="store_true",
241
+ help="Recompute from raw/ and compare existing outputs byte for byte without writing")
242
+ args = parser.parse_args()
243
+ raw_root = ROOT / "raw"
244
+ for name, expected in RAW_SHA256.items():
245
+ assert digest(raw_root / name) == expected, f"Raw source checksum mismatch: {name}"
246
+ pools, report = scan(raw_root)
247
+ chosen, quotas = {}, {}
248
+ chosen["train"], quotas["train"] = sample(pools["train"], DATASET, "train", 200, SEED)
249
+ used = {r["id"] for r in chosen["train"]}
250
+ remaining = [r for r in pools["train"] if r["id"] not in used]
251
+ chosen["val"], quotas["val"] = sample(remaining, DATASET, "val", 200, SEED)
252
+ chosen["test"], quotas["test"] = sample(pools["validation"], DATASET, "test", 200, SEED)
253
+ chosen["testL"], quotas["testL"] = extend_test(pools["validation"], chosen["test"], DATASET, 1000, SEED)
254
+ needed = {r["id"] for rows in chosen.values() for r in rows}
255
+ records = {}
256
+ for split in ("train", "validation"):
257
+ for raw in raw_rows(raw_root, split):
258
+ rid = f"{DATASET}:{raw['id']}"
259
+ if rid in needed:
260
+ records[rid] = simplify(convert(raw, DATASET, split, "raw"))
261
+ assert set(records) == needed
262
+ outputs = {split: [records[r["id"]] for r in rows] for split, rows in chosen.items()}
263
+ validate_splits(outputs)
264
+ encoded = {split: "".join(json.dumps(r, ensure_ascii=False, separators=(",", ":")) + "\n" for r in rows).encode("utf-8")
265
+ for split, rows in outputs.items()}
266
+ assert encoded["testL"].startswith(encoded["test"])
267
+ if not args.check:
268
+ args.output_dir.mkdir(parents=True, exist_ok=True)
269
+ for split, content in encoded.items():
270
+ path = args.output_dir / f"{split}.jsonl"
271
+ if args.check:
272
+ assert path.read_bytes() == content, f"Reproduction mismatch: {path}"
273
+ else:
274
+ temporary = path.with_suffix(".jsonl.tmp")
275
+ temporary.write_bytes(content)
276
+ temporary.replace(path)
277
+ print(json.dumps({"dataset": DATASET, "seed": SEED, "mode": "check" if args.check else "build",
278
+ "sources": report, "quotas": quotas, "unique_questions": 1400,
279
+ "test_is_testL_prefix": True,
280
+ "files": {s + ".jsonl": {"rows": len(outputs[s]), "sha256": hashlib.sha256(b).hexdigest()}
281
+ for s, b in encoded.items()}}, indent=2))
282
+
283
+
284
+ if __name__ == "__main__":
285
+ main()
raw/distractor/train-00000-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76d3bb3048a7cc73c1958107c0c5872a00d7e7d00c105b81e92f6769e7822e68
3
+ size 165624177
raw/distractor/train-00001-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:713661628434fbb19fff7392e2e321e4ed107e3c7c7784d0690946e5f722763f
3
+ size 166162479
raw/distractor/validation-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c20b638ca82b21d04fe12e14ff417ad05153d4d215a65de54497fca4e972f7c6
3
+ size 27452575
test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
testL.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
val.jsonl ADDED
The diff for this file is too large to render. See raw diff