syun1013kate commited on
Commit
59a6924
·
verified ·
1 Parent(s): 9c24826

Update dataset card

Browse files
Files changed (1) hide show
  1. README.md +447 -0
README.md ADDED
@@ -0,0 +1,447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: OFF-AllergenQA-JP8
3
+ language:
4
+ - en
5
+ license: odbl
6
+ task_categories:
7
+ - text-classification
8
+ tags:
9
+ - text
10
+ - tabular
11
+ - food
12
+ - allergens
13
+ - english
14
+ - safety
15
+ - evaluation
16
+ ---
17
+
18
+ # OFF-AllergenQA-JP8
19
+
20
+ ## Dataset Summary
21
+
22
+ OFF-AllergenQA-JP8 is a curated benchmark derived from Open Food Facts (OFF) product data for evaluating allergen detection under an abstention-aware, safety-oriented setting.
23
+
24
+ The released examples are restricted to U.S.-market packaged multi-ingredient foods whose raw `ingredients_text` is in English.
25
+
26
+ Each record represents a `(product_id, allergen)` pair for one of the Japanese 8 priority allergens (JP8). The "JP8" part refers to the target allergen set, not to the language of the product label:
27
+
28
+ - egg
29
+ - milk
30
+ - wheat
31
+ - buckwheat
32
+ - peanuts
33
+ - walnuts
34
+ - shrimp
35
+ - crab
36
+
37
+ The dataset is designed for evaluating systems that read ingredient text, normalize ingredient mentions to taxonomy IDs, trace evidence through a taxonomy graph, and output one of the following labels:
38
+
39
+ - `PRESENT`
40
+ - `TRACE`
41
+ - `ABSENT`
42
+ - `UNKNOWN`
43
+ - `CONFLICT`
44
+
45
+ This is an evaluation dataset, not a consumer-facing food safety database.
46
+
47
+ ## What Is Included
48
+
49
+ The final dataset package contains:
50
+
51
+ - `products.jsonl`: one row per product, with `product_id`, `lang`, English `ingredients_text`, and selected OFF metadata tags
52
+ - `gold.jsonl`: one row per `(product_id, allergen)` gold label
53
+ - `examples.jsonl`: one joined row per example with context, label, and provenance fields
54
+ - `splits/train`, `splits/calib`, `splits/test`: fixed reproducible splits
55
+ - `DATASET_MANIFEST.json`: build-time metadata and file hashes
56
+
57
+ ## Source Data
58
+
59
+ This dataset is derived from the public Open Food Facts database.
60
+
61
+ From each OFF product, we extract only the fields needed for allergen evaluation:
62
+
63
+ - `product_id`
64
+ - `lang`
65
+ - `ingredients_text`
66
+ - `allergens_tags`
67
+ - `traces_tags`
68
+ - `labels_tags`
69
+
70
+ We do not rely on OFF tags alone as final ground truth. OFF metadata is used as one source of evidence and as part of candidate selection for human review.
71
+
72
+ For the released benchmark, we additionally restrict the pool to:
73
+
74
+ - U.S.-market products
75
+ - packaged multi-ingredient foods
76
+ - raw English `ingredients_text` only
77
+ - rows without HTML-tagged ingredient text
78
+
79
+ ## How We Built the Dataset
80
+
81
+ The dataset was built in five stages.
82
+
83
+ ### 1. Fixed-snapshot download
84
+
85
+ We first downloaded a date-pinned OFF snapshot so that the source data is reproducible.
86
+
87
+ Example command:
88
+
89
+ ```bash
90
+ export OFF_USER_AGENT="YourProjectName/0.1 (your-email@example.com)"
91
+ python scripts/download_off_snapshot.py --date YYYY-MM-DD --write_latest
92
+ ```
93
+
94
+ This creates a snapshot directory containing:
95
+
96
+ - the products dump
97
+ - OFF taxonomies such as `ingredients.json`
98
+ - a `MANIFEST.json` file used for traceability
99
+
100
+ ### 2. Compact product extraction
101
+
102
+ We then extracted a compact product table from the OFF products dump, keeping only ingredient text and the metadata fields needed for allergen experiments.
103
+
104
+ Example command:
105
+
106
+ ```bash
107
+ python scripts/extract_off_products.py --date YYYY-MM-DD --mode primary
108
+ ```
109
+
110
+ ### 3. Candidate mining
111
+
112
+ From the extracted product table, we automatically mined difficult or informative candidate examples. Candidate selection is based on:
113
+
114
+ - ingredient text
115
+ - OFF metadata tags
116
+ - deterministic normalization to taxonomy IDs
117
+ - taxonomy traversal
118
+ - abstention-aware decision logic
119
+
120
+ Before mining, the pool is filtered to U.S.-market packaged multi-ingredient foods with English raw `ingredients_text`.
121
+
122
+ The candidate miner prioritizes cases such as:
123
+
124
+ - apparent allergen evidence in text but missing OFF tags
125
+ - positive OFF tags without matching taxonomy evidence
126
+ - conflicting evidence between text and metadata
127
+ - empty or incomplete inputs
128
+ - low-confidence normalization cases
129
+
130
+ Example command:
131
+
132
+ ```bash
133
+ python benchmarks/off_allergenqa_jp8/build_candidates.py \
134
+ --snapshot data/snapshots/YYYY-MM-DD \
135
+ --out runs/off_allergenqa/candidates.jsonl \
136
+ --summary_out runs/off_allergenqa/candidates_summary.csv
137
+ ```
138
+
139
+ Important: `candidates.jsonl` is not gold data. It is a queue for human annotation.
140
+
141
+ ## Rule-Based Provisional Labels Used During Candidate Mining
142
+
143
+ Before human annotation, each `(product_id, allergen)` pair may receive a provisional 3-way class used only for candidate mining and balanced selection:
144
+
145
+ - `0`: Absent / Trap
146
+ - `1`: Warning / Trace
147
+ - `2`: Intentional ingredient
148
+
149
+ These provisional classes are not the released gold labels. The final public labels are the 5-way human-reviewed labels (`PRESENT`, `TRACE`, `ABSENT`, `UNKNOWN`, `CONFLICT`), so there is no direct one-to-one mapping from `0/1/2` to the released labels.
150
+
151
+ The rule-based candidate miner applies the following decision order:
152
+
153
+ 1. If a `Contains ...` summary explicitly names the target allergen, assign provisional class `2`.
154
+ 2. Else if warning wording such as `may contain`, `traces of`, `processed in a facility`, or `shared equipment` names the target allergen, assign provisional class `1`.
155
+ 3. Else if only a lexical trap is found, such as `eggplant` for egg, `coconut milk` for milk, or `buckwheat` for wheat, assign provisional class `0`.
156
+ 4. Else if an ingredient term, synonym, or derivative indicates intentional inclusion, assign provisional class `2`.
157
+ 5. Else if OFF `traces_tags` contains a target-specific trace hit, assign provisional class `1`.
158
+ 6. Else if the target allergen is absent but the example is useful as a negative control because other allergen signals or category hints are present, assign provisional class `0`.
159
+
160
+ Additional mining rules and flags:
161
+
162
+ - The scope of `Contains` is cut off at the next `May contain`, `Traces of`, `.`, or `;` boundary so that warning text is not incorrectly absorbed into intentional-ingredient evidence.
163
+ - Generic warnings such as `may contain tree nuts`, `may contain shellfish`, or `contains gluten` are separated into a generic warning / abstention slice instead of the main benchmark.
164
+ - Contradictions between raw text and OFF metadata are flagged during mining, for example tag-present but text-not-intentional, text-intentional but tag-missing, or text-warning but trace-tag-missing.
165
+ - Candidate mining artifacts may include audit fields such as `proposed_class`, `reason`, `evidence`, `contradiction`, and `difficulty_tag`.
166
+
167
+ ## How a Small Annotation Set Was Selected from a Large OFF Pool
168
+
169
+ The implemented curation pipeline does not sample rows uniformly from all OFF products. It first reduces the search space deterministically, then mines `(product, allergen)` pairs, then performs balanced hard-case selection.
170
+
171
+ At a high level, the implemented pipeline is:
172
+
173
+ 1. Start from a large OFF parquet export.
174
+ 2. Apply coarse deterministic filters:
175
+ - U.S.-market products only
176
+ - packaged multi-ingredient foods only
177
+ - raw English `ingredients_text` only
178
+ - no HTML-tagged ingredient text
179
+ - minimum normalized ingredient length
180
+ 3. Perform exact deduplication on normalized ingredient text.
181
+ 4. Expand each retained product into up to 8 `(product, allergen)` candidate pairs, one for each JP8 allergen.
182
+ 5. Assign a provisional mining class (`0/1/2`), hard-case tags, contradiction flags, and evidence snippets.
183
+ 6. Split the pool into:
184
+ - a core snack-centric pool used for all allergens
185
+ - a supplement pool used only for rare allergens such as buckwheat, shrimp, and crab when the core pool is insufficient
186
+ 7. Select a balanced subset over `8 allergens x 3 provisional classes = 24 cells`.
187
+
188
+ In the documented `annotation_hf_v2` run, the pipeline recorded:
189
+
190
+ - `4,401,229` raw OFF rows scanned
191
+ - `49,691` eligible products kept after filtering and exact deduplication
192
+ - `269,877` mined `(product, allergen)` candidates
193
+ - `86,187` hard candidates
194
+ - `77,661` text-grounded hard candidates
195
+ - `1,714` generic warning candidates separated into a distinct slice
196
+
197
+ The balanced selector then targeted `25` examples per cell (the `600` preset), while allowing shortfalls for cells that are genuinely sparse.
198
+
199
+ The code prioritizes candidates in this order:
200
+
201
+ 1. text-grounded hard cases
202
+ 2. lower-signal hard cases
203
+ 3. easy backfill only when needed
204
+
205
+ Within each cell, the selection logic further tries to preserve diversity by:
206
+
207
+ - limiting how many selected pairs can come from the same barcode
208
+ - limiting how many selected pairs can share the same normalized product name
209
+ - limiting how many examples from the same brand can appear in a single cell
210
+ - suppressing near-duplicate ingredient texts within a cell
211
+ - interleaving different `selection_family` buckets so that one wording pattern does not dominate
212
+ - using deterministic seed-based tie-breaking
213
+
214
+ This means the final annotation set is intentionally difficult and diverse, not population-representative.
215
+
216
+ The curation was also iterative. One intermediate run summary reports `561` selected rows, while a later curated annotation package in `annotation_hf_v2_584` contains `584` selected rows derived from a retained base subset plus `41` curated additions. For publication, the count reported in the dataset card should match the final packaged release artifact rather than an intermediate run summary.
217
+
218
+ ### 4. Double annotation and adjudication
219
+
220
+ Candidate examples were manually reviewed, ideally by two annotators independently, followed by adjudication for disagreements.
221
+
222
+ The current annotation tooling is implemented around Label Studio. Each task shown to annotators includes:
223
+
224
+ - `example_id`
225
+ - `product_id`
226
+ - `lang`
227
+ - `allergen`
228
+ - `category`
229
+ - raw `ingredients_text`
230
+ - OFF reference metadata fields such as `allergens_tags`, `traces_tags`, and `labels_tags`
231
+
232
+ The current UI requires a final 5-way label and optionally collects:
233
+
234
+ - `source_type` for the evidence (`ingredients_text`, `off_tags`, `allergen_statement`, or `packaging_image`)
235
+ - evidence confidence (`high`, `medium`, `low`)
236
+ - a free-text evidence excerpt
237
+ - annotator notes
238
+
239
+ To reduce bias, model outputs are excluded from exported annotation tasks by default.
240
+
241
+ The implemented review workflow is:
242
+
243
+ 1. Export mined candidates to Label Studio tasks.
244
+ 2. Have two annotators label the same `(product, allergen)` items independently.
245
+ 3. Accept exact label agreements automatically.
246
+ 4. Send mismatches or one-sided missing labels to an adjudication sheet.
247
+ 5. Have a human adjudicator fill the final label and optional adjudication evidence/notes.
248
+ 6. Build `annotations_final.jsonl`, an adjudication audit log, and a QA report.
249
+
250
+ The adjudication template includes enough context to resolve disagreements without reloading the full mining pipeline, including:
251
+
252
+ - candidate metadata and category
253
+ - raw `ingredients_text`
254
+ - OFF metadata tags
255
+ - both annotators' labels
256
+ - both annotators' notes
257
+ - both annotators' evidence summaries
258
+
259
+ The adjudication outputs include:
260
+
261
+ - `annotations_final.jsonl`
262
+ - `adjudication_audit.jsonl`
263
+ - `qa_report.json`
264
+ - QA tables such as disagreement counts and confusion matrices
265
+
266
+ The QA code computes agreement statistics including raw agreement and Cohen's kappa, and can break disagreements down by allergen and candidate category.
267
+
268
+ Current implementation note: the Label Studio path stores evidence primarily as free-text excerpts plus source/confidence metadata. Exact character offsets are not collected by default and are stored as `[-1, -1]` unless added externally.
269
+
270
+ Label set:
271
+
272
+ - `PRESENT`: the allergen is present
273
+ - `TRACE`: trace contamination or may-contain style evidence
274
+ - `ABSENT`: the allergen is absent based on available evidence
275
+ - `UNKNOWN`: evidence is insufficient to decide
276
+ - `CONFLICT`: available signals contradict each other
277
+
278
+ Example commands:
279
+
280
+ ```bash
281
+ python benchmarks/off_allergenqa_jp8/merge_double_annotations.py \
282
+ --ann_a annotation/exports/annotations_a.jsonl \
283
+ --ann_b annotation/exports/annotations_b.jsonl \
284
+ --merged_out annotation/exports/annotations_merged_agreement.jsonl \
285
+ --disagreements_out annotation/exports/disagreements.csv
286
+ ```
287
+
288
+ ```bash
289
+ python benchmarks/off_allergenqa_jp8/apply_adjudication.py \
290
+ --agreements annotation/exports/annotations_merged_agreement.jsonl \
291
+ --adjudication annotation/exports/adjudication_filled.csv \
292
+ --ann_a annotation/exports/annotations_a.jsonl \
293
+ --ann_b annotation/exports/annotations_b.jsonl \
294
+ --candidates runs/off_allergenqa/candidates.jsonl \
295
+ --out_final annotation/exports/annotations_final.jsonl
296
+ ```
297
+
298
+ ### 5. Final dataset packaging
299
+
300
+ Finally, we packaged the reviewed examples into a reproducible dataset artifact with fixed splits.
301
+
302
+ Example command:
303
+
304
+ ```bash
305
+ python benchmarks/off_allergenqa_jp8/build_dataset.py \
306
+ --candidates runs/off_allergenqa/candidates.jsonl \
307
+ --annotations_final annotation/exports/annotations_final.jsonl \
308
+ --out_dir runs/off_allergenqa/dataset \
309
+ --seed 0 \
310
+ --train_ratio 0.7 \
311
+ --calib_ratio 0.1 \
312
+ --test_ratio 0.2
313
+ ```
314
+
315
+ ## Label Semantics
316
+
317
+ ### PRESENT
318
+
319
+ The target allergen is explicitly present in the product based on ingredient text or equivalent evidence.
320
+
321
+ ### TRACE
322
+
323
+ The product indicates possible trace contamination or may-contain style evidence, but not confirmed direct inclusion.
324
+
325
+ ### ABSENT
326
+
327
+ The available evidence supports absence of the target allergen.
328
+
329
+ ### UNKNOWN
330
+
331
+ The available evidence is insufficient to decide.
332
+
333
+ ### CONFLICT
334
+
335
+ The available evidence is internally inconsistent, for example if different fields suggest incompatible conclusions.
336
+
337
+ ## Sample Records
338
+
339
+ Concrete sample rows are intentionally omitted from this draft because the current workspace only contains bundled sample artifacts for development and smoke testing, not the intended release artifact.
340
+
341
+ Before publishing on Hugging Face, replace this section with five rows sampled from the actual release files, ideally from `examples.jsonl`.
342
+
343
+ Recommended fields to show:
344
+
345
+ - `example_id`
346
+ - `lang` (if retained as metadata)
347
+ - `allergen`
348
+ - `label`
349
+ - `category`
350
+ - `ingredients_text`
351
+
352
+ If you prefer not to show raw examples publicly, you can instead describe the row schema and provide aggregate statistics only.
353
+
354
+ ## Recommended Uses
355
+
356
+ - Evaluation of allergen-detection pipelines on noisy ingredient text
357
+ - Evaluation of abstention-aware systems that may output `UNKNOWN` or `CONFLICT`
358
+ - Auditable experiments on taxonomy-based food ingredient reasoning
359
+ - Error analysis on difficult cases involving missing tags, conflicting evidence, or incomplete text
360
+
361
+ ## Out-of-Scope Uses
362
+
363
+ - Direct consumer safety advice
364
+ - Clinical, medical, or regulatory decision making
365
+ - Product recall decisions
366
+ - Claims that a product is "safe" for consumption
367
+ - Estimating real-world allergen prevalence from the label distribution in this dataset
368
+
369
+ ## Important Limitations
370
+
371
+ - This dataset is not a random sample of all OFF products. It is intentionally curated toward informative or difficult cases.
372
+ - The label distribution is therefore not representative of population prevalence.
373
+ - OFF entries may be incomplete, inconsistent, or user-contributed.
374
+ - Although the released dataset filters to English `ingredients_text`, OFF metadata can still be noisy or inconsistent.
375
+ - Human annotation reduces noise, but does not eliminate all ambiguity.
376
+ - `TRACE`, `UNKNOWN`, and `CONFLICT` reflect epistemic uncertainty and data quality issues, not only product properties.
377
+
378
+ ## Disclaimer
379
+
380
+ - This dataset is provided for research and evaluation purposes only.
381
+ - It does not guarantee food safety.
382
+ - A label of `ABSENT` or a model output such as `SAFE` should not be interpreted as a guarantee that a product is safe for people with allergies.
383
+ - When evidence is missing, ambiguous, or contradictory, the correct operational response may be to abstain rather than to predict safety.
384
+ - Users are responsible for checking current product labels, manufacturer disclosures, and jurisdiction-specific regulations before any real-world use.
385
+
386
+ ## License and Attribution
387
+
388
+ This dataset is derived from Open Food Facts data.
389
+
390
+ According to the official Open Food Facts knowledge base, the OFF database is available under the Open Database License (ODbL), and the two key conditions are attribution and share-alike.
391
+
392
+ For that reason:
393
+
394
+ - please attribute Open Food Facts clearly in the dataset card and any derivative releases
395
+ - do not assume that raw OFF dumps can be republished in arbitrary form
396
+ - if you combine OFF data with other databases, review the share-alike implications carefully
397
+
398
+ Suggested attribution text:
399
+
400
+ > This dataset is derived in part from Open Food Facts data. Open Food Facts data is made available under the Open Database License (ODbL). Please see the Open Food Facts terms and reuse guidance for details.
401
+
402
+ Suggested links:
403
+
404
+ - Open Food Facts API/data reuse guidance: `https://support.openfoodfacts.org/help/en-gb/12-api-data-reuse/94-are-there-conditions-to-use-the-api`
405
+ - Open Food Facts terms of use: `https://world.openfoodfacts.org/terms-of-use`
406
+
407
+ If your release includes only curated derived rows and human annotations, you may still want to add a repository-level `LICENSE` file explaining how the released artifact relates to OFF's ODbL terms.
408
+
409
+ ## Reproducibility Notes
410
+
411
+ For reproducibility, we recommend publishing:
412
+
413
+ - the snapshot date
414
+ - the snapshot `MANIFEST.json`
415
+ - the extraction command and configuration
416
+ - the candidate mining command and configuration
417
+ - the annotation policy
418
+ - the dataset build command
419
+ - hashes for the released files
420
+
421
+ ## Citation
422
+
423
+ If you publish this dataset on Hugging Face, add:
424
+
425
+ - the citation for your own paper or project
426
+ - an attribution note for Open Food Facts
427
+
428
+ ---
429
+
430
+ ### Maintainer Note
431
+
432
+ This file is a draft for a Hugging Face dataset card (`README.md`).
433
+
434
+ For a private draft repository on Hugging Face, the minimum practical layout is:
435
+
436
+ - `README.md`: this dataset card
437
+ - `NOTICE` or `LICENSE`: attribution and redistribution note for Open Food Facts-derived content
438
+ - optionally `data/examples_preview.jsonl`: a very small preview file, or the final dataset files when they are ready
439
+
440
+ If the release artifact is not finalized yet, a README-only private repo is also acceptable as a temporary placeholder.
441
+
442
+ Before publishing:
443
+
444
+ 1. Replace the five sample rows with real rows from the release artifact.
445
+ 2. Fill in any missing dataset statistics using the final packaged release files, not an intermediate mining summary.
446
+ 3. Confirm the final redistribution policy and license text.
447
+ 4. Add your project citation and contact information.