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

How do you get the embedding/id for the pad token ? #25

Closed
derlin opened this issue Mar 13, 2019 · 3 comments
Closed

How do you get the embedding/id for the pad token ? #25

derlin opened this issue Mar 13, 2019 · 3 comments

Comments

@derlin
Copy link

derlin commented Mar 13, 2019

Hi,
This may be a dummy question, but when creating a BPEmb with add_pad_emb=True, how do I actually get the padding embedding and what is its ID ? This should maybe figure somewhere in the doc:

from bpemb import BPEmb
bp = BPEmb(lang="en", vs=1000, dim=50, add_pad_emb=True)
print(bp.vs) # prints 1000, was expecting 1000+1 ?

Thanks for the great work,
derlin

@derlin
Copy link
Author

derlin commented Mar 13, 2019

Found it in the gensim doc:

bp.emb['<pad>']

It seems to (always ?) be an array of zeros.

@derlin derlin closed this as completed Mar 13, 2019
@bheinzerling
Copy link
Owner

bheinzerling commented Mar 13, 2019

Hi,
not a dummy question at all. I've added this to the docstring:

This embedding is initizalized with zeros and appended to the end
of the embedding matrix. Assuming "bpemb" is a BPEmb instance, the
padding embedding can be looked up with "bpemb['<pad>']", or
directly accessed with "bpemb.vectors[-1]".

@derlin
Copy link
Author

derlin commented Mar 13, 2019

This is perfect, thanks !

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

2 participants