-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
The dimension choose of Elmo using flair #886
Comments
Hi @nininininini ELMo exposes three layers a 1024 states and by default we take all three to make embeddings. It is currently not possible to select only a subset of these layers, but this is a feature that could be added in a future PR. |
I get it, Thanks for your complete answer @alanakbik |
I think that you can to use average layers. |
@gabrielcustodio there is a PR #1547 by @falcaopetri that adresses this issue. You can now choose whether to use a concatenation of all three layers (default) or alternatively only the topmost layer or an average. The latter two options only have 1024 dimensions! # example sentence
sentence = Sentence("The grass is green")
# default option: concatenate all three layers (size: 3072)
embeddings = ELMoEmbeddings(embedding_mode='all')
embeddings.embed(sentence)
print(sentence[0].embedding.size())
# use only the topmost layer (size: 1024)
embeddings = ELMoEmbeddings(embedding_mode='top')
sentence.clear_embeddings()
embeddings.embed(sentence)
print(sentence[0].embedding.size())
# use an average of all layers (size: 1024)
embeddings = ELMoEmbeddings(embedding_mode='average')
sentence.clear_embeddings()
embeddings.embed(sentence)
print(sentence[0].embedding.size()) After the PR is merged, this feature is available in master branch and will be part of the next Flair release. |
Hi, when I choose Elmo as word embedding, it seems that I can only choose a fixed dimension of 3072. Can I choose other dimensions for Elmo in flair? What part of this 3072 is composed of?
The text was updated successfully, but these errors were encountered: