flair.embeddings.document#

class flair.embeddings.document.TransformerDocumentEmbeddings(model='bert-base-uncased', layers='-1', layer_mean=False, is_token_embedding=False, **kwargs)View on GitHub#

Bases: DocumentEmbeddings, TransformerEmbeddings

onnx_clsView on GitHub#

alias of TransformerOnnxDocumentEmbeddings

classmethod create_from_state(**state)View on GitHub#
embeddings_name: str = 'TransformerDocumentEmbeddings'#
class flair.embeddings.document.DocumentPoolEmbeddings(embeddings, fine_tune_mode='none', pooling='mean')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.

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.

classmethod from_params(params)View on GitHub#
Return type:

DocumentPoolEmbeddings

to_params()View on GitHub#
Return type:

Dict[str, Any]

embeddings_name: str = 'DocumentPoolEmbeddings'#
class flair.embeddings.document.DocumentTFIDFEmbeddings(train_dataset, vectorizer=None, **vectorizer_params)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.

classmethod from_params(params)View on GitHub#
Return type:

DocumentTFIDFEmbeddings

to_params()View on GitHub#
Return type:

Dict[str, Any]

embeddings_name: str = 'DocumentTFIDFEmbeddings'#
class flair.embeddings.document.DocumentRNNEmbeddings(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, rnn_type='GRU', fine_tune=True)View on GitHub#

Bases: DocumentEmbeddings

property embedding_length: int#

Returns the length of the embedding vector.

to_params()View on GitHub#
classmethod from_params(params)View on GitHub#
Return type:

DocumentRNNEmbeddings

embeddings_name: str = 'DocumentRNNEmbeddings'#
class flair.embeddings.document.DocumentLMEmbeddings(flair_embeddings)View on GitHub#

Bases: DocumentEmbeddings

property embedding_length: int#

Returns the length of the embedding vector.

get_names()View on GitHub#

Returns a list of embedding names.

In most cases, it is just a list with one item, namely the name of this embedding. But in some cases, the embedding is made up by different embeddings (StackedEmbedding). Then, the list contains the names of all embeddings in the stack.

Return type:

List[str]

to_params()View on GitHub#
Return type:

Dict[str, Any]

classmethod from_params(params)View on GitHub#
Return type:

DocumentLMEmbeddings

embeddings_name: str = 'DocumentLMEmbeddings'#
class flair.embeddings.document.SentenceTransformerDocumentEmbeddings(model='bert-base-nli-mean-tokens', batch_size=1)View on GitHub#

Bases: DocumentEmbeddings

property embedding_length: int#

Returns the length of the embedding vector.

classmethod from_params(params)View on GitHub#
Return type:

SentenceTransformerDocumentEmbeddings

to_params()View on GitHub#
Return type:

Dict[str, Any]

embeddings_name: str = 'SentenceTransformerDocumentEmbeddings'#
class flair.embeddings.document.DocumentCNNEmbeddings(embeddings, kernels=((100, 3), (100, 4), (100, 5)), reproject_words=True, reproject_words_dimension=None, dropout=0.5, word_dropout=0.0, locked_dropout=0.0, fine_tune=True)View on GitHub#

Bases: DocumentEmbeddings

embeddings_name: str = 'DocumentCNNEmbeddings'#
property embedding_length: int#

Returns the length of the embedding vector.

classmethod from_params(params)View on GitHub#
Return type:

DocumentCNNEmbeddings

to_params()View on GitHub#
Return type:

Dict[str, Any]