Skip to content

Commit df7325f

Browse files
Merge branch 'online_training' of github.com:facebookresearch/fairseq2 into jacklanchantin/verifiable_nonverifiable
2 parents 0a1d1d4 + 76be659 commit df7325f

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/fairseq2/datasets/preference.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@ def cat_source_and_target(example: dict[str, Any]) -> dict[str, Any]:
224224
and all(isinstance(i, str) for i in jsonl_keys)
225225
):
226226
raise ValueError(f"{jsonl_keys} must be a list of strings")
227-
jsonl_content = {k: example.get(k, None) for k in jsonl_keys}
227+
jsonl_content = {}
228+
for k in jsonl_keys:
229+
if k not in example:
230+
raise KeyError(
231+
f"Required key '{k}' not found in example dictionary."
232+
)
233+
jsonl_content[k] = example[k]
228234
else:
229235
jsonl_content = None
230236

src/fairseq2/datasets/prompt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,13 @@ def process_examples(example: dict[str, Any]) -> dict[str, Any]:
247247
and all(isinstance(i, str) for i in jsonl_keys)
248248
):
249249
raise ValueError(f"{jsonl_keys} must be a list of strings")
250-
jsonl_content = {k: example.get(k, None) for k in jsonl_keys}
250+
jsonl_content = {}
251+
for k in jsonl_keys:
252+
if k not in example:
253+
raise KeyError(
254+
f"Required key '{k}' not found in example dictionary."
255+
)
256+
jsonl_content[k] = example[k]
251257
else:
252258
jsonl_content = None
253259

0 commit comments

Comments
 (0)