Skip to content

Add a dedicated padding token to beam search to avoid padding with the start sentence token - #10386

Open
LoicDagnas wants to merge 1 commit into
tensorflow:masterfrom
LoicDagnas:loic-daganas/beam-seach-padding-with-dedicated-token
Open

LoicDagnas wants to merge 1 commit into
tensorflow:masterfrom
LoicDagnas:loic-daganas/beam-seach-padding-with-dedicated-token

Conversation

@LoicDagnas

Copy link
Copy Markdown

Description

So far, the beam search module pads its predictions using the initial token ids, it is more modular and easy to use to have the capacity to specify the padding token. By default this padding token should be zero and not the initial token id.

Type of change

For a new feature or function, please create an issue first to discuss it
with us before submitting a pull request.

Note: Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Tests

I have added a naive unittest which failed before my modification and passes now.

Checklist

@google-cla google-cla Bot added the cla: yes label Nov 23, 2021
@saberkun
saberkun requested review from frederick0329 and removed request for jaeyounkim, lehougoogle and rachellj218 December 15, 2021 05:19
@laxmareddyp laxmareddyp added the models:official models that come under official repository label Nov 16, 2022
@saberkun

Copy link
Copy Markdown
Member

Conflicts need to resolve.
Reassign to @ByzanTine

@saberkun
saberkun requested review from ByzanTine and removed request for frederick0329 and saberkun January 20, 2023 20:21
alive_seq = tf.expand_dims(alive_seq, axis=2)
if self.padded_decode:
alive_seq = tf.tile(alive_seq, [1, 1, self.max_decode_length + 1])
alive_seq = tf.pad(alive_seq, [[0, 0], [0, 0], [0, self.max_decode_length]], constant_values=self.pad_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We need to remove the extra spaces in front of this line to conform to our Python styling

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.

I think need to resolve the conflict as well, will create a new PR with all above changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes models:official models that come under official repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants