langchain_community.embeddings.laser
.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: * https://github.com/facebookresearch/LASER/ * https://github.com/facebookresearch/LASER/tree/main/laser_encoders * 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: Optional[str] = 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 https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200
- 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]