Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gsm plus preparation #290

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nemo_skills/dataset/gsm-plus/cleaned_indexes.json

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions nemo_skills/dataset/gsm-plus/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import argparse
import json
import os
import pathlib
import urllib.request
from pathlib import Path

Expand All @@ -32,14 +33,15 @@
"adding_operation",
"critical_thinking",
"digit_expansion",
"distractor_insertion",
"distraction_insertion",
"integer-decimal-fraction_conversion",
"numerical_substitution",
"problem_understanding",
"reversing_operation",
],
)
parser.add_argument("--no_rounding_instructions", action='store_true')
parser.add_argument("--cleaning", choices=["none", "light", "hard"], default="none")
args = parser.parse_args()

split = "test"
Expand All @@ -56,15 +58,25 @@
output_file_rounded = str(data_dir / f"{split}_rounded.jsonl")
file_rounded = open(output_file_rounded, 'w')

with open(os.path.join(pathlib.Path(__file__).parent, "cleaned_indexes.json")) as f:
cleaning_options = json.load(f)
for key in cleaning_options.keys():
cleaning_options[key] = set(cleaning_options[key])

with open(original_file, "rt") as original, open(output_file, "w") as test_full:
original_data = [json.loads(line) for line in original.readlines()]
for original_entry in original_data:
if original_entry["perturbation_type"].replace(' ', '_') in args.categories:
cleaning_options['none'] = set(range(len(original_data)))
for i, original_entry in enumerate(original_data):
if (
original_entry["perturbation_type"].replace(' ', '_') in args.categories
and i in cleaning_options[args.cleaning]
):
# original entries
reference_solution = original_entry.get("solution", None) or original_entry.get(
"reference_solution", None
)
expected_answer = original_entry.get("answer", None) or original_entry.get("expected_answer", None)
expected_answer = expected_answer if expected_answer != 'None' else 'insufficient'
Kipok marked this conversation as resolved.
Show resolved Hide resolved
entry = dict(
problem=original_entry["question"],
reference_solution=reference_solution,
Expand Down
Loading