Overview
This overview covers text-based embedding models. LangChain does not currently support multimodal embeddings.
How it works
- Vectorization — The model encodes each input string as a high-dimensional vector.
- Similarity scoring — Vectors are compared using mathematical metrics to measure how closely related the underlying texts are.
Similarity metrics
Several metrics are commonly used to compare embeddings:- Cosine similarity — measures the angle between two vectors.
- Euclidean distance — measures the straight-line distance between points.
- Dot product — measures how much one vector projects onto another.
Interface
LangChain provides a standard interface for text embedding models (e.g., OpenAI, Cohere, Hugging Face) via the Embeddings interface. Two main methods are available:embed_documents(texts: List[str]) → List[List[float]]: Embeds a list of documents.embed_query(text: str) → List[float]: Embeds a single query.
The interface allows queries and documents to be embedded with different strategies, though most providers handle them the same way in practice.
Top integrations
Caching
Embeddings can be stored or temporarily cached to avoid needing to recompute them. Caching embeddings can be done using aCacheBackedEmbeddings. This wrapper stores embeddings in a key-value store, where the text is hashed and the hash is used as the key in the cache.
The main supported way to initialize a CacheBackedEmbeddings is from_bytes_store. It takes the following parameters:
underlying_embedder: The embedder to use for embedding.document_embedding_cache: AnyByteStorefor caching document embeddings.batch_size: (optional, defaults toNone) The number of documents to embed between store updates.namespace: (optional, defaults to"") The namespace to use for the document cache. Helps avoid collisions (e.g., set it to the embedding model name).query_embedding_cache: (optional, defaults toNone) AByteStorefor caching query embeddings, orTrueto reuse the same store asdocument_embedding_cache.
All embedding models
Aleph Alpha
Anyscale
Ascend
AI/ML API
AwaDB
AzureOpenAI
Baichuan Text Embeddings
Baidu Qianfan
Baseten
Bedrock
BGE on Hugging Face
Bookend AI
Clarifai
Cloudflare Workers AI
Clova Embeddings
Cohere
DashScope
Databricks
DeepInfra
EDEN AI
Elasticsearch
Embaas
Fake Embeddings
FastEmbed by Qdrant
Fireworks
Google Gemini
Google Vertex AI
GPT4All
Gradient
GreenNode
Hugging Face
IBM watsonx.ai
Infinity
Instruct Embeddings
IPEX-LLM CPU
IPEX-LLM GPU
Intel Extension for Transformers
Jina
John Snow Labs
LASER
Lindorm
Llama.cpp
LLMRails
LocalAI
MiniMax
MistralAI
Model2Vec
ModelScope
MosaicML
Naver
Nebius
Netmind
NLP Cloud
Nomic
NVIDIA NIMs
Oracle Cloud Infrastructure
Ollama
OpenClip
OpenAI
OpenVINO
Optimum Intel
Oracle AI Vector Search
OVHcloud
Pinecone Embeddings
PredictionGuard
PremAI
SageMaker
SambaNovaCloud
SambaStudio
Self Hosted
Sentence Transformers
Solar
SpaCy
SparkLLM
TensorFlow Hub
Text Embeddings Inference
TextEmbed
Titan Takeoff
Together AI
Upstage
Volc Engine
Voyage AI
Xinference
YandexGPT
ZhipuAI
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.