You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi ,i want to use flair embedding and use myself model instead of the API function ,how should i do , thanks.anyone can give me a advice , thanks a lot.
#829
Closed
cpmss521 opened this issue
Jun 22, 2019
· 3 comments
does it help when you use the embeddings for each token of an input sequence?
E.g. you have the sentence "Berlin and Munich are nice cities.". Then you can use the Sentence class + its internal tokenizer:
fromflair.dataimportSentencefromflair.embeddingsimportFlairEmbeddingsinput_sequence="Berlin and Munich are nice cities."sentence=Sentence(text=input_sequence, use_tokenizer=True)
# Forward language modelforward_embeddings=FlairEmbeddings('news-forward')
# Backward language modelbackward_embeddings=FlairEmbeddings('news-backward')
# Get embeddings for each token in sentence (both forward and backward language model)forward_embeddings.embed(sentence)
backward_embeddings.embed(sentence)
fortokeninsentence:
# Dimension of forward language model is 2048# Same as for the backward language model# So final embedding vector for each token is 4096print(token.get_embedding())
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
A clear and concise description of what you want to know.
The text was updated successfully, but these errors were encountered: