Last active
August 31, 2019 21:24
-
-
Save prrao87/59955a79e0239fce15626f6893caaf79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flair.embeddings import FlairEmbeddings, BertEmbeddings, WordEmbeddings, DocumentRNNEmbeddings | |
# init Flair embeddings | |
flair_forward_embedding = FlairEmbeddings('multi-forward') | |
flair_backward_embedding = FlairEmbeddings('multi-backward') | |
# init BERT base (cases) | |
optional_embedding = BertEmbeddings('bert-base-cased') | |
# OR init ELMo (original) | |
# optional_embedding = ELMoEmbeddings('original') | |
word_embeddings = list(filter(None, [ | |
optional_embedding, | |
FlairEmbeddings('news-forward'), | |
FlairEmbeddings('news-backward'), | |
])) | |
# Initialize document embedding by passing list of word embeddings | |
document_embeddings = DocumentRNNEmbeddings( | |
word_embeddings, | |
hidden_size=512, | |
reproject_words=True, | |
reproject_words_dimension=256, | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment