Skip to content

Commit

Permalink
[examples/summarization] deal with None in data records (#14816)
Browse files Browse the repository at this point in the history
* [examples/summarization] deal with None in data records

* rewrite to use a simpler (slower) variant
  • Loading branch information
stas00 authored Dec 21, 2021
1 parent c075fb7 commit 033c3ed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/pytorch/summarization/run_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,14 @@ def main():
)

def preprocess_function(examples):
inputs = examples[text_column]
targets = examples[summary_column]

# remove pairs where at least one record is None
inputs, targets = [], []
for i in range(len(examples[text_column])):
if examples[text_column][i] is not None and examples[summary_column][i] is not None:
inputs.append(examples[text_column][i])
targets.append(examples[summary_column][i])

inputs = [prefix + inp for inp in inputs]
model_inputs = tokenizer(inputs, max_length=data_args.max_source_length, padding=padding, truncation=True)

Expand Down

0 comments on commit 033c3ed

Please sign in to comment.