LaserEmbeddings#

class langchain_community.embeddings.laser.LaserEmbeddings[source]#

Bases: BaseModel, Embeddings

LASER Language-Agnostic SEntence Representations. LASER is a Python library developed by the Meta AI Research team and used for creating multilingual sentence embeddings for over 147 languages as of 2/25/2024 See more documentation at: * facebookresearch/LASER * facebookresearch/LASER * https://arxiv.org/abs/2205.12654

To use this class, you must install the laser_encoders Python package.

pip install laser_encoders .. rubric:: Example

from laser_encoders import LaserEncoderPipeline encoder = LaserEncoderPipeline(lang=”eng_Latn”) embeddings = encoder.encode_sentences([β€œHello”, β€œWorld”])

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param lang: str | None = None#

The language or language code you’d like to use If empty, this implementation will default to using a multilingual earlier LASER encoder model (called laser2) Find the list of supported languages at facebookresearch/flores

async aembed_documents(texts: List[str]) β†’ List[List[float]]#

Asynchronous Embed search docs.

Parameters:

texts (List[str]) – List of text to embed.

Returns:

List of embeddings.

Return type:

List[List[float]]

async aembed_query(text: str) β†’ List[float]#

Asynchronous Embed query text.

Parameters:

text (str) – Text to embed.

Returns:

Embedding.

Return type:

List[float]

embed_documents(texts: List[str]) β†’ List[List[float]][source]#

Generate embeddings for documents using LASER.

Parameters:

texts (List[str]) – The list of texts to embed.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

embed_query(text: str) β†’ List[float][source]#

Generate single query text embeddings using LASER.

Parameters:

text (str) – The text to embed.

Returns:

Embeddings for the text.

Return type:

List[float]

Examples using LaserEmbeddings