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

[ New features]Trainer support dict parameter #8446

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
4 changes: 3 additions & 1 deletion paddlenlp/trainer/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
elif field.default is dataclasses.MISSING:
kwargs["required"] = True
else:
kwargs["type"] = field.type
kwargs["type"] = json.loads if field.type is dict else field.type
if field.default is not dataclasses.MISSING:
kwargs["default"] = field.default
elif field.default_factory is not dataclasses.MISSING:
Expand Down Expand Up @@ -246,6 +246,8 @@
for key, value in data.items():
if isinstance(value, list):
json_args.extend([f"--{key}", *[str(v) for v in value]])
elif isinstance(value, dict):
json_args.extend([f"--{key}", json.dumps(value)])

Check warning on line 250 in paddlenlp/trainer/argparser.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/argparser.py#L250

Added line #L250 was not covered by tests
else:
json_args.extend([f"--{key}", str(value)])
return json_args
Expand Down
Loading