Skip to content
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
11 changes: 11 additions & 0 deletions optimum/habana/transformers/generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,17 @@ def _sample(
if streamer is not None:
streamer.end()

if batch_size > 1 and has_eos_stopping_criteria:
eos_token_id = generation_config.eos_token_id
idx_bs = generation_config.max_length
for i in range(batch_size):
for idx in range(len(input_ids[i])):
if input_ids[i][idx] == eos_token_id:
idx_bs = idx
if idx > idx_bs:
input_ids[i][idx] = pad_token_id
idx_bs = generation_config.max_length
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still want to return padding token in this case or just stop here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to customer requirement, we need to padding token after <|endoftext|>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://huggingface.co/facebook/bart-large-cnn/blob/main/config.json
For bart decoder_start_token_id and eos_token_id are same.
This breaks bart generation


if return_dict_in_generate:
if self.config.is_encoder_decoder:
return GenerateEncoderDecoderOutput(
Expand Down