Embeddings
Embedding models create a vector representation of a piece of text.
This page documents integrations with various model providers that allow you to use embeddings in LangChain.
Pick your embedding model:
- OpenAI
- Azure
- AWS
- VertexAI
- MistralAI
- Cohere
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/openai
yarn add @langchain/openai
pnpm add @langchain/openai
OPENAI_API_KEY=your-api-key
import { OpenAIEmbeddings } from "@langchain/openai";
const embeddings = new OpenAIEmbeddings({
model: "text-embedding-3-large"
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/openai
yarn add @langchain/openai
pnpm add @langchain/openai
AZURE_OPENAI_API_INSTANCE_NAME=<YOUR_INSTANCE_NAME>
AZURE_OPENAI_API_KEY=<YOUR_KEY>
AZURE_OPENAI_API_VERSION="2024-02-01"
import { AzureOpenAIEmbeddings } from "@langchain/openai";
const embeddings = new AzureOpenAIEmbeddings({
azureOpenAIApiEmbeddingsDeploymentName: "text-embedding-ada-002"
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/aws
yarn add @langchain/aws
pnpm add @langchain/aws
BEDROCK_AWS_REGION=your-region
import { BedrockEmbeddings } from "@langchain/aws";
const embeddings = new BedrockEmbeddings({
model: "amazon.titan-embed-text-v1"
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/google-vertexai
yarn add @langchain/google-vertexai
pnpm add @langchain/google-vertexai
GOOGLE_APPLICATION_CREDENTIALS=credentials.json
import { VertexAIEmbeddings } from "@langchain/google-vertexai";
const embeddings = new VertexAIEmbeddings({
model: "text-embedding-004"
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/mistralai
yarn add @langchain/mistralai
pnpm add @langchain/mistralai
MISTRAL_API_KEY=your-api-key
import { MistralAIEmbeddings } from "@langchain/mistralai";
const embeddings = new MistralAIEmbeddings({
model: "mistral-embed"
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/cohere
yarn add @langchain/cohere
pnpm add @langchain/cohere
COHERE_API_KEY=your-api-key
import { CohereEmbeddings } from "@langchain/cohere";
const embeddings = new CohereEmbeddings({
model: "embed-english-v3.0"
});
await embeddings.embedQuery("Hello, world!");
Name | Description |
---|---|
Alibaba Tongyi | The AlibabaTongyiEmbeddings class uses the Alibaba Tongyi API to gene... |
Azure OpenAI | [Azure |
Baidu Qianfan | The BaiduQianfanEmbeddings class uses the Baidu Qianfan API to genera... |
Amazon Bedrock | Amazon Bedrock is a fully managed |
Cloudflare Workers AI | This will help you get started with Cloudflare Workers AI [embedding |
Cohere | This will help you get started with CohereEmbeddings [embedding |
DeepInfra | The DeepInfraEmbeddings class utilizes the DeepInfra API to generate ... |
Fireworks | This will help you get started with FireworksEmbeddings [embedding |
Google Generative AI | This will help you get started with Google Generative AI [embedding |
Google Vertex AI | Google Vertex is a service that |
Gradient AI | The GradientEmbeddings class uses the Gradient AI API to generate emb... |
HuggingFace Inference | This Embeddings integration uses the HuggingFace Inference API to gen... |
IBM watsonx.ai | This will help you get started with IBM watsonx.ai [embedding |
Jina | The JinaEmbeddings class utilizes the Jina API to generate embeddings... |
Llama CPP | Only available on Node.js. |
Minimax | The MinimaxEmbeddings class uses the Minimax API to generate embeddin... |
MistralAI | This will help you get started with MistralAIEmbeddings [embedding |
Mixedbread AI | The MixedbreadAIEmbeddings class uses the Mixedbread AI API to genera... |
Nomic | The NomicEmbeddings class uses the Nomic AI API to generate embedding... |
Ollama | This will help you get started with Ollama [embedding |
OpenAI | This will help you get started with OpenAIEmbeddings [embedding |
Pinecone | This will help you get started with PineconeEmbeddings [embedding |
Prem AI | The PremEmbeddings class uses the Prem AI API to generate embeddings ... |
Tencent Hunyuan | The TencentHunyuanEmbeddings class uses the Tencent Hunyuan API to ge... |
TensorFlow | This Embeddings integration runs the embeddings entirely in your brow... |
TogetherAI | This will help you get started with TogetherAIEmbeddings [embedding |
HuggingFace Transformers | The TransformerEmbeddings class uses the Transformers.js package to g... |
Voyage AI | The VoyageEmbeddings class uses the Voyage AI REST API to generate em... |
ZhipuAI | The ZhipuAIEmbeddings class uses the ZhipuAI API to generate embeddin... |