TransformerTextEncoder

class TransformerTextEncoder(pretrained_model_name_or_path: str = 'bert-base-cased', max_length: int = 512)[source]

Bases: TextEncoder

A combination of a tokenizer and a model.

Initialize the encoder using transformers.AutoModel.

Parameters:
Raises:

ImportError – if the transformers library could not be imported

Methods Summary

forward_normalized(texts)

Encode a batch of text.

Methods Documentation

forward_normalized(texts: Sequence[str]) Tensor[source]

Encode a batch of text.

Parameters:

texts (Sequence[str]) – length: b the texts

Returns:

shape: (b, dim) an encoding of the texts

Return type:

Tensor