SentenceTransformerEncoder

class SentenceTransformerEncoder:

This class provides functionalities to generate text embeddings using Sentence Transformers.

References: https://www.sbert.net/

init

def __init__(self, model_name: str = 'intfloat/e5-large-v2', **kwargs):

Initializes the: obj: SentenceTransformerEmbedding class with the specified transformer model.

Parameters:

  • model_name (str, optional): The name of the model to use. (default: :obj:intfloat/e5-large-v2) **kwargs (optional): Additional arguments of :class:SentenceTransformer, such as :obj:prompts etc.

embed_list

def embed_list(self, objs: list[str], **kwargs: Any):

Generates embeddings for the given texts using the model.

Parameters:

  • objs (list[str]): The texts for which to generate the embeddings.

Returns:

list[list[float]]: A list that represents the generated embedding as a list of floating-point numbers.

get_output_dim

def get_output_dim(self):

Returns:

int: The dimensionality of the embeddings.