Embeddings convert text into numerical vectors.
Understand and use embeddings for semantic search.
Embedding Models
✅ OpenAI Embeddings
✅ HuggingFace Embeddings
✅ Cohere Embeddings
✅ Local models
Example
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
vector = embeddings.embed_query(“Hello world”)
vectors = embeddings.embed_documents([“doc1”, “doc2”])
Similarity Calculation
Use cosine similarity to compare embeddings.
Conclusion
Embeddings enable semantic understanding!