MistralAI
This notebook explains how to use MistralAIEmbeddings, which is included in the langchain_mistralai package, to embed texts in langchain.
# pip install -U langchain-mistralai
import the libraryโ
from langchain_mistralai import MistralAIEmbeddings
API Reference:
embedding = MistralAIEmbeddings(api_key="your-api-key")
Using the Embedding Model
With MistralAIEmbeddings
, you can directly use the default model 'mistral-embed', or set a different one if available.
embedding.model = "mistral-embed" # or your preferred model if available
res_query = embedding.embed_query("The test information")
res_document = embedding.embed_documents(["test1", "another test"])