examples: add keep_linebreaks option to CLM examples (#13150)

* examples: add keep_linebreaks option to text dataset loader for all CLM examples

* examples: introduce new keep_linebreaks option as data argument in CLM examples
This commit is contained in:
Stefan Schweter
2021-08-27 11:35:45 +02:00
committed by GitHub
parent 45a8eb66bb
commit 319d840b46
4 changed files with 19 additions and 1 deletions

View File

@@ -186,6 +186,9 @@ class DataTrainingArguments:
"value if set."
},
)
keep_linebreaks: bool = field(
default=True, metadata={"help": "Whether to keep line breaks when using CSV/JSON/TXT files or not."}
)
def __post_init__(self):
if self.dataset_name is None and self.train_file is None and self.validation_file is None:
@@ -325,7 +328,7 @@ def main():
extension = data_args.train_file.split(".")[-1]
if extension == "txt":
extension = "text"
raw_datasets = load_dataset(extension, data_files=data_files)
raw_datasets = load_dataset(extension, keep_linebreaks=data_args.keep_linebreaks, data_files=data_files)
# See more about loading any type of standard or custom dataset (from files, python dict, pandas DataFrame, etc) at
# https://huggingface.co/docs/datasets/loading_datasets.html.
# endregion