Document embeddings
Document embeddings are similar to word embeddings, with the only difference being that instead of getting one embedding for each word, we get one embedding for the entire document.
In Flair, a document can be defined inside the Sentence
object. Instead of accessing the embedding through sentence[n].embedding
, which would return the nth word's embedding, we simply run sentence.embedding
or sentence.get_embedding()
.
Flair currently supports the following embedding types:
TransformerDocumentEmbeddings
, a document embedding class using a pre-trained Hugging Face transformers.DocumentPoolEmbeddings
, a meta document embedding class that takes a word embedding object, computes the embedding for each word, and returns the mean of all word embeddings.DocumentRNNEmbeddings
, a meta document embedding class that takes a word embedding object, trains a recurrent neural network on the entire document, and returns the final state as the embedding...