flair.embeddings.legacy#

Warning

All embeddings in flair.embeddings.legacy are considered deprecated. there is no guarantee that they are still working and we recommend using different embeddings instead.

class flair.embeddings.legacy.ELMoEmbeddings(model='original', options_file=None, weight_file=None, embedding_mode='all')View on GitHub#

Bases: TokenEmbeddings

Contextual word embeddings using word-level LM, as proposed in Peters et al., 2018. ELMo word vectors can be constructed by combining layers in different ways. Default is to concatene the top 3 layers in the LM.

property embedding_length: int#

Returns the length of the embedding vector.

use_layers_all(x)View on GitHub#
use_layers_top(x)View on GitHub#
use_layers_average(x)View on GitHub#
extra_repr()View on GitHub#

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

class flair.embeddings.legacy.CharLMEmbeddings(model, detach=True, use_cache=False, cache_directory=None)View on GitHub#

Bases: TokenEmbeddings

Contextual string embeddings of words, as proposed in Akbik et al., 2018.

train(mode=True)View on GitHub#

Set the module in training mode.

This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. Dropout, BatchNorm, etc.

Parameters:

mode (bool) – whether to set training mode (True) or evaluation mode (False). Default: True.

Returns:

self

Return type:

Module

property embedding_length: int#

Returns the length of the embedding vector.

class flair.embeddings.legacy.DocumentMeanEmbeddings(token_embeddings)View on GitHub#

Bases: DocumentEmbeddings

property embedding_length: int#

Returns the length of the embedding vector.

embed(sentences)View on GitHub#

Add embeddings to every sentence in the given list of sentences. If embeddings are already added, updates only if embeddings are non-static.

class flair.embeddings.legacy.DocumentLSTMEmbeddings(embeddings, hidden_size=128, rnn_layers=1, reproject_words=True, reproject_words_dimension=None, bidirectional=False, dropout=0.5, word_dropout=0.0, locked_dropout=0.0)View on GitHub#

Bases: DocumentEmbeddings

property embedding_length: int#

Returns the length of the embedding vector.

embed(sentences)View on GitHub#

Add embeddings to all sentences in the given list of sentences. If embeddings are already added, update only if embeddings are non-static.