Stacked embeddings
Stacked embeddings are a type of meta embeddings that allow us to form new embeddings by combining two or more embeddings together. These meta embeddings, as the name suggests, simply stack multiple embeddings on top of each other. They are ideal for combining the forward and backward versions of Flair embeddings. They can also be used for adding other embedding types to the mix, for example, to mix contextual string embeddings with the classic word embeddings. In fact, this is the type of a combination suggested by Flair and often the combination yielding state-of-the-art results.
To use stacked embeddings, simply instantiate a StackedEmbeddings
class, passing in a list of embedding objects. You may then use this meta embedding in the same exact way you would use any other embedding in Flair.
Let's try this out on the set of embeddings recommended by Flair for best performance. We will stack glove
word embeddings combined with news-forward
and news-backward...