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

Position ids in RoBERTa #10736

Closed
qhd1996 opened this issue Mar 16, 2021 · 3 comments
Closed

Position ids in RoBERTa #10736

qhd1996 opened this issue Mar 16, 2021 · 3 comments

Comments

@qhd1996
Copy link

qhd1996 commented Mar 16, 2021

Environment info

  • transformers version:
  • Platform: Ubuntu 20.04
  • Python version: Python 3.7.10
  • PyTorch version (GPU?): 1.6.0_py3.7_cuda10.1.243_cudnn7.6.3_0
  • Tensorflow version (GPU?): No
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

Who can help

@LysandreJik

Information

Position ids in RoBERTa is not implemented properly.
The problem arises when using:
create_position_ids_from_input_ids in transformers.models.roberta.modeling_roberta.py
Based on this function, position id 0 is never used. This may cause problem when the sequence is long, for example, 512. Token whose id >= 511 will not get its corresponding token ids.

@NielsRogge
Copy link
Contributor

There's a reason why position ids don't start at 0 for RoBERTa, see #5285

@patil-suraj
Copy link
Contributor

RoBERTa never uses 0 and 1 positional ids, in ROBERTa, all pad tokens have position id of 1, and the rest of the tokens have position ids in the range (2, seq_length - num_pad_tokens). It's implemented like this to match the original implementation in fairseq.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants