Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generating attention_mask of ernie-m #4494

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion paddlenlp/transformers/ernie_m/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __init__(
max_position_embeddings: int = 514,
type_vocab_size: int = 16,
initializer_range: float = 0.02,
pad_token_id: int = 0,
pad_token_id: int = 1,
**kwargs
):
super().__init__(pad_token_id=pad_token_id, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion paddlenlp/transformers/ernie_m/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def forward(

if attention_mask is None:
attention_mask = paddle.unsqueeze(
(input_ids == 0).astype(self.pooler.dense.weight.dtype) * -1e4, axis=[1, 2]
(input_ids == self.pad_token_id).astype(self.pooler.dense.weight.dtype) * -1e4, axis=[1, 2]
)
if past_key_values is not None:
batch_size = past_key_values[0][0].shape[0]
Expand Down