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][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- 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]]
Examples using LaserEmbeddings