Ivan1008 commited on
Commit
e4eaded
·
verified ·
1 Parent(s): 5ed66ea

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +85 -183
README.md CHANGED
@@ -18,173 +18,36 @@ size_categories:
18
  configs:
19
  - config_name: combined
20
  data_files:
21
- - split: train
22
- path: combined/train-*
23
- - split: validation
24
- path: combined/validation-*
25
- - split: test
26
- path: combined/test-*
27
  - config_name: contradiction
28
  data_files:
29
- - split: train
30
- path: contradiction/train-*
31
- - split: validation
32
- path: contradiction/validation-*
33
- - split: test
34
- path: contradiction/test-*
35
  - config_name: missing_tool
36
  data_files:
37
- - split: train
38
- path: missing_tool/train-*
39
- - split: validation
40
- path: missing_tool/validation-*
41
- - split: test
42
- path: missing_tool/test-*
43
  - config_name: overgeneration
44
  data_files:
45
- - split: train
46
- path: overgeneration/train-*
47
- - split: validation
48
- path: overgeneration/validation-*
49
- - split: test
50
- path: overgeneration/test-*
51
- dataset_info:
52
- - config_name: combined
53
- features:
54
- - name: context
55
- dtype: string
56
- - name: hallucination_labels
57
- list:
58
- - name: end
59
- dtype: int64
60
- - name: label
61
- dtype: string
62
- - name: start
63
- dtype: int64
64
- - name: text
65
- dtype: string
66
- - name: id
67
- dtype: string
68
- - name: meta
69
- dtype: json
70
- - name: output
71
- dtype: string
72
- - name: query
73
- dtype: string
74
- splits:
75
- - name: train
76
- num_bytes: 7534691
77
- num_examples: 1955
78
- - name: validation
79
- num_bytes: 929179
80
- num_examples: 241
81
- - name: test
82
- num_bytes: 935928
83
- num_examples: 235
84
- download_size: 2267301
85
- dataset_size: 9399798
86
- - config_name: contradiction
87
- features:
88
- - name: context
89
- dtype: string
90
- - name: hallucination_labels
91
- list:
92
- - name: end
93
- dtype: int64
94
- - name: label
95
- dtype: string
96
- - name: start
97
- dtype: int64
98
- - name: text
99
- dtype: string
100
- - name: id
101
- dtype: string
102
- - name: meta
103
- dtype: json
104
- - name: output
105
- dtype: string
106
- - name: query
107
- dtype: string
108
- splits:
109
- - name: train
110
- num_bytes: 1936639
111
- num_examples: 559
112
- - name: validation
113
- num_bytes: 226630
114
- num_examples: 68
115
- - name: test
116
- num_bytes: 240455
117
- num_examples: 67
118
- download_size: 818644
119
- dataset_size: 2403724
120
- - config_name: missing_tool
121
- features:
122
- - name: context
123
- dtype: string
124
- - name: hallucination_labels
125
- list:
126
- - name: end
127
- dtype: int64
128
- - name: label
129
- dtype: string
130
- - name: start
131
- dtype: int64
132
- - name: text
133
- dtype: string
134
- - name: id
135
- dtype: string
136
- - name: meta
137
- dtype: json
138
- - name: output
139
- dtype: string
140
- - name: query
141
- dtype: string
142
- splits:
143
- - name: train
144
- num_bytes: 3004086
145
- num_examples: 829
146
- - name: validation
147
- num_bytes: 372663
148
- num_examples: 103
149
- - name: test
150
- num_bytes: 378414
151
- num_examples: 101
152
- download_size: 1258888
153
- dataset_size: 3755163
154
- - config_name: overgeneration
155
- features:
156
- - name: context
157
- dtype: string
158
- - name: hallucination_labels
159
- list:
160
- - name: end
161
- dtype: int64
162
- - name: label
163
- dtype: string
164
- - name: start
165
- dtype: int64
166
- - name: text
167
- dtype: string
168
- - name: id
169
- dtype: string
170
- - name: meta
171
- dtype: json
172
- - name: output
173
- dtype: string
174
- - name: query
175
- dtype: string
176
- splits:
177
- - name: train
178
- num_bytes: 4324124
179
- num_examples: 1101
180
- - name: validation
181
- num_bytes: 532894
182
- num_examples: 136
183
- - name: test
184
- num_bytes: 520845
185
- num_examples: 129
186
- download_size: 1860119
187
- dataset_size: 5377863
188
  ---
189
 
190
  # ToolACE Hallucination Spans
@@ -254,18 +117,42 @@ Only ToolACE rows that pass all of the following are kept:
254
  - `80 <= len(output) <= 2500` characters (avoid trivial or overlong answers)
255
  - `len(query_words ∩ output_words) / len(query_words) >= 0.10` — drops off-topic rows that the parsed ToolACE occasionally contains (e.g. caste-system query answered with a linked-list explanation), which would otherwise pollute the corruption signal.
256
 
 
 
 
 
 
 
 
 
 
 
 
257
  ## Build statistics
258
 
259
  | Item | Value |
260
  |---|---|
261
- | Rows scanned | 11,072 |
262
- | Rows accepted | 720 |
263
- | Records by type | clean: 720, contradiction: 486, missing_tool: 720, overgeneration: 720 |
264
- | Records (combined config) | train 2,118 / val 264 / test 264 |
265
- | Splits | 80 / 10 / 10 by deterministic hash over `base_id` (all variants of one base stay in one split) |
 
 
 
 
 
 
 
 
 
 
 
266
 
267
  ## Zero-shot baseline (validation split)
268
 
 
 
269
  | Config | Lexical baseline F1 | LettuceDetect F1 |
270
  |---|---|---|
271
  | `combined` (n=264) | 0.156 | 0.198 |
@@ -273,40 +160,55 @@ Only ToolACE rows that pass all of the following are kept:
273
  | `missing_tool` (n=144) | 0.104 | 0.118 |
274
  | `overgeneration` (n=144) | 0.167 | 0.225 |
275
 
276
- - `lexical baseline`: char marked as hallucinated iff it belongs to a content word that is absent from the tool context. Recall is high (~0.75), precision is very low (~0.09) — i.e. tool answers mention many context-absent words even on clean records.
277
- - `LettuceDetect`: zero-shot inference with [`KRLabsOrg/lettucedect-base-modernbert-en-v1`](https://huggingface.co/KRLabsOrg/lettucedect-base-modernbert-en-v1). The model was trained on RAGTruth (news/QA domain), not tool-calling, so its precision in this domain is also low (~0.11) but it consistently improves recall and F1 over the lexical baseline.
278
 
279
  Reproducible from this repo:
280
 
281
  ```bash
282
- python scripts/zero_shot_eval.py --dataset-dir data/combined --split validation
283
- python scripts/zero_shot_eval.py --dataset-dir data/contradiction --split validation
284
- python scripts/zero_shot_eval.py --dataset-dir data/missing_tool --split validation
285
- python scripts/zero_shot_eval.py --dataset-dir data/overgeneration --split validation
286
  ```
287
 
288
- The per-record / per-type breakdown is written to `validation_report_validation.{md,json}` inside each dataset directory.
289
-
290
  ## Build
291
 
292
  ```bash
293
  python -m pip install -r requirements.txt
294
- python scripts/build_from_toolace.py
295
- python scripts/validate_spans.py --allow-clean data/combined/*.jsonl
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  ```
297
 
298
  ## Push to the Hub
299
 
300
  ```bash
301
- python scripts/push_to_hub.py <user>/toolace-hallucination-spans --private
 
302
  ```
303
 
304
- This pushes all four configs (`combined`, `contradiction`, `missing_tool`, `overgeneration`) as separate dataset configurations.
305
 
306
  ## Known limitations
307
 
308
- - Corruptions are synthetic and deterministic: each base example produces the same corruption seed-by-seed across runs. Useful for supervised span localization, but does not cover naturally occurring hallucination patterns (e.g. cascading errors across multi-turn dialogue).
309
- - `missing_tool` actions come from a curated list they do not cover every tool capability that might be implied by an arbitrary user query.
310
- - `contradiction` quality depends on whether the clean final answer contains values that can be plausibly substituted. Examples without any grounded value of length ≥4 in the output are simply skipped, which is why `contradiction` has fewer records (486) than the other types (720 each).
311
- - The context is serialized JSON from tool/function messages, not re-rendered into natural language, so token positions and length distribution differ from RAGTruth's news-corpus context.
312
- - Baseline numbers above are zero-shot; we have not fine-tuned a detector yet. Fine-tuning is the natural next step (see the `Improve baselines` section of the task spec).
 
 
 
18
  configs:
19
  - config_name: combined
20
  data_files:
21
+ - split: train
22
+ path: combined/train-*.parquet
23
+ - split: validation
24
+ path: combined/validation-*.parquet
25
+ - split: test
26
+ path: combined/test-*.parquet
27
  - config_name: contradiction
28
  data_files:
29
+ - split: train
30
+ path: contradiction/train-*.parquet
31
+ - split: validation
32
+ path: contradiction/validation-*.parquet
33
+ - split: test
34
+ path: contradiction/test-*.parquet
35
  - config_name: missing_tool
36
  data_files:
37
+ - split: train
38
+ path: missing_tool/train-*.parquet
39
+ - split: validation
40
+ path: missing_tool/validation-*.parquet
41
+ - split: test
42
+ path: missing_tool/test-*.parquet
43
  - config_name: overgeneration
44
  data_files:
45
+ - split: train
46
+ path: overgeneration/train-*.parquet
47
+ - split: validation
48
+ path: overgeneration/validation-*.parquet
49
+ - split: test
50
+ path: overgeneration/test-*.parquet
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  ---
52
 
53
  # ToolACE Hallucination Spans
 
117
  - `80 <= len(output) <= 2500` characters (avoid trivial or overlong answers)
118
  - `len(query_words ∩ output_words) / len(query_words) >= 0.10` — drops off-topic rows that the parsed ToolACE occasionally contains (e.g. caste-system query answered with a linked-list explanation), which would otherwise pollute the corruption signal.
119
 
120
+ ## Pipeline
121
+
122
+ The dataset is built in four stages:
123
+
124
+ 1. **Build** (`build_from_toolace.py` + `corruptors.py`) — load ToolACE, filter, inject regex-based corruptions.
125
+ 2. **Audit** (`audit run` with `openai/gpt-oss-120b:free` via OpenRouter) — LLM-as-judge validates every label.
126
+ 3. **Recover + Patch** (`recover cleans`, `recover extra-spans`) — salvage records the audit found problematic:
127
+ - `recover` turns false-negative cleans (clean records where judge spotted a hallucination) into labeled records.
128
+ - `patch` adds extra labels to confirmed-corrupted records where judge found a *second* hallucination.
129
+ 4. **Merge** (`merge_final.py`) — assemble `data/final/<config>/<split>.jsonl` from patched + recovered, dropping labels whose type doesn't match the record's primary `corruption_type` to satisfy the strict RAGTruth one-type-per-record schema.
130
+
131
  ## Build statistics
132
 
133
  | Item | Value |
134
  |---|---|
135
+ | ToolACE rows scanned | 11,072 |
136
+ | Rows accepted by schema + length + overlap filters | 720 |
137
+ | Records after regex corruption | 2,646 (720 clean + 486 contradiction + 720 missing_tool + 720 overgeneration) |
138
+ | Records confirmed by LLM judge (gpt-oss-120b) | 1,675 / 209 / 205 (train/val/test) |
139
+ | Records recovered from false-negative cleans | 280 / 32 / 30 |
140
+ | Final dataset (combined config) | **train 1,955 / val 241 / test 235** = 2,431 records |
141
+ | Splits | 80 / 10 / 10 by deterministic hash over `base_id`; all variants of one base stay in one split |
142
+
143
+ Counts per type across all configs (each clean record appears in all four):
144
+
145
+ | Type | Total |
146
+ |---|---:|
147
+ | clean | 1,324 |
148
+ | contradiction | 726 |
149
+ | missing_tool | 1,404 |
150
+ | overgeneration | 2,070 |
151
 
152
  ## Zero-shot baseline (validation split)
153
 
154
+ > Numbers measured before the LLM-as-judge audit and recovery. They establish the pre-audit floor.
155
+
156
  | Config | Lexical baseline F1 | LettuceDetect F1 |
157
  |---|---|---|
158
  | `combined` (n=264) | 0.156 | 0.198 |
 
160
  | `missing_tool` (n=144) | 0.104 | 0.118 |
161
  | `overgeneration` (n=144) | 0.167 | 0.225 |
162
 
163
+ - `lexical baseline`: char marked as hallucinated iff it belongs to a content word that is absent from the tool context. Recall is high (~0.75), precision is very low (~0.09).
164
+ - `LettuceDetect`: zero-shot inference with [`KRLabsOrg/lettucedect-base-modernbert-en-v1`](https://huggingface.co/KRLabsOrg/lettucedect-base-modernbert-en-v1). Trained on RAGTruth (news/QA domain), not tool-calling, so precision in this domain is also low (~0.11) but consistently improves recall and F1 over lexical.
165
 
166
  Reproducible from this repo:
167
 
168
  ```bash
169
+ python src/data_processing/zero_shot_eval.py --dataset-dir data/final/combined --split validation
170
+ python src/data_processing/zero_shot_eval.py --dataset-dir data/final/contradiction --split validation
171
+ python src/data_processing/zero_shot_eval.py --dataset-dir data/final/missing_tool --split validation
172
+ python src/data_processing/zero_shot_eval.py --dataset-dir data/final/overgeneration --split validation
173
  ```
174
 
 
 
175
  ## Build
176
 
177
  ```bash
178
  python -m pip install -r requirements.txt
179
+ python src/data_processing/build_from_toolace.py # → data/combined/...
180
+ python src/data_processing/audit.py run --backend openrouter \
181
+ --judge-model openai/gpt-oss-120b:free \
182
+ --dataset-dir data/combined --split train # repeat for val/test
183
+ python src/data_processing/audit.py filter \
184
+ --audit-dir data/quality_audit_openrouter/combined \
185
+ --source-dir data/combined --split train \
186
+ --out-dir data/combined_filtered/combined
187
+ python src/data_processing/recover.py cleans \
188
+ --decisions data/quality_audit_openrouter/combined/train/decisions.jsonl \
189
+ --source data/combined/train.jsonl \
190
+ --out-dir data/recovered --split train
191
+ python src/data_processing/recover.py extra-spans
192
+ python src/data_processing/merge_final.py # → data/final/
193
+ python src/data_processing/validate_spans.py --allow-clean \
194
+ data/final/combined/*.jsonl data/final/*/*.jsonl
195
  ```
196
 
197
  ## Push to the Hub
198
 
199
  ```bash
200
+ python src/data_processing/push_to_hub.py <user>/toolace-hallucination-spans \
201
+ --data-dir data/final --readme DATASET_CARD.md
202
  ```
203
 
204
+ `--data-dir data/final` is the default; pass `--public` to make the repo public.
205
 
206
  ## Known limitations
207
 
208
+ - **Synthetic & deterministic.** Regex-based corruptions plus LLM-recovered real hallucinations. They don't cover naturally occurring cascading errors across multi-turn dialogue.
209
+ - **Strict single-type schema.** Each record is annotated with a single corruption_type, and every label in the record must match it. When the audit found a *second* hallucination of a different type inside an already-corrupted record, the secondary label is dropped at merge — **the hallucinated text remains in the output but is no longer annotated**. This affected 288 records (231 train / 30 val / 27 test). The unannotated spans are preserved in `data/combined_patched/` for downstream consumers who want them.
210
+ - **Off-topic answers** (data is grounded but the answer doesn't address the user query) don't fit the 3-type RAGTruth taxonomy. They are collected separately under `data/other/` (47 records) and excluded from the final dataset to keep the validator schema strict.
211
+ - **`contradiction` is the hardest type.** Single-character substitutions are not allowed (`MIN_CONTRADICTION_LEN = 4`), and records without any grounded value of length ≥4 in the output are simply skipped, so `contradiction` has fewer records than the other types.
212
+ - **`missing_tool` actions** come from a curated list they don't cover every tool capability that might be implied by an arbitrary user query.
213
+ - **Context format**: JSON-serialized tool messages, not re-rendered into natural language, so token positions and length distribution differ from RAGTruth's news-corpus context.
214
+ - **Pre-fine-tune baselines only.** Numbers above are zero-shot. Fine-tuning is the natural next step (see the `Improve baselines` section of the task spec).