Some specified arguments are not used by the HfArgumentParser: (remaining_args)
Package:
transformers
50617

Exception Class:
ValueError
Raise code
if len(namespace.__dict__) > 0:
# additional namespace.
outputs.append(namespace)
if return_remaining_strings:
return (*outputs, remaining_args)
else:
if remaining_args:
raise ValueError(f"Some specified arguments are not used by the HfArgumentParser: {remaining_args}")
return (*outputs,)
def parse_json_file(self, json_file: str) -> Tuple[DataClass, ...]:
"""
Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the
dataclass types. """
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too!
We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Links to the raise (1)
https://github.com/huggingface/transformers/blob/bd9871657bb9500a9f4437a873db6df5f1ae6dbb/src/transformers/hf_argparser.py#L196Ways to fix
HfArgumentParser is subclass of argparse.ArgumentParser
uses type hints on data classes to generate arguments.
The class is designed to play well with the native argparse. In particular, you can add more (non-data class backed) arguments to the parser after initialization and you'll get the output back after parsing as an additional namespace.
parse_args_into_dataclasses - Parse command-line args into instances of the specified data class types
Error code:
from transformers import HfArgumentParser,PyTorchBenchmarkArguments
parser = HfArgumentParser(PyTorchBenchmarkArguments)
benchmark_args = parser.parse_args_into_dataclasses()[0]
print(benchmark_args)
Explanation:
According to code
if return_remaining_strings:
return (*outputs, remaining_args)
else:
if remaining_args:
raise ValueError(f"Some specified arguments are not used by the HfArgumentParser: {remaining_args}")
If arguments remain, it doesn't allow us to use them.
To avoid, return_remaining_strings can be used.
return_remaining_strings - allows to return a list of remaining argument strings
Fix code:
from transformers import HfArgumentParser,PyTorchBenchmarkArguments
parser = HfArgumentParser(PyTorchBenchmarkArguments)
benchmark_args = parser.parse_args_into_dataclasses(return_remaining_strings=True)[0]
print(benchmark_args)
Add a possible fix
Please authorize to post fix