MosaicMLInstructorEmbeddings#
- class langchain_community.embeddings.mosaicml.MosaicMLInstructorEmbeddings[source]#
Bases:
BaseModel
,Embeddings
MosaicML embedding service.
To use, you should have the environment variable
MOSAICML_API_TOKEN
set with your API token, or pass it as a named parameter to the constructor.Example
from langchain_community.llms import MosaicMLInstructorEmbeddings endpoint_url = ( "https://models.hosted-on.mosaicml.hosting/instructor-large/v1/predict" ) mosaic_llm = MosaicMLInstructorEmbeddings( endpoint_url=endpoint_url, mosaicml_api_token="my-api-key" )
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 embed_instruction: str = 'Represent the document for retrieval: '#
Instruction used to embed documents.
- param endpoint_url: str = 'https://models.hosted-on.mosaicml.hosting/instructor-xl/v1/predict'#
Endpoint URL to use.
- param mosaicml_api_token: str | None = None#
- param query_instruction: str = 'Represent the question for retrieving supporting documents: '#
Instruction used to embed the query.
- param retry_sleep: float = 1.0#
How long to try sleeping for if a rate limit is encountered
- 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]
Examples using MosaicMLInstructorEmbeddings