Voyage AI provides cutting-edge embedding/vectorizations models.Let’s load the Voyage AI Embedding class. (Install the LangChain partner package with
pip install langchain-voyageai)
voyage-3-largevoyage-3voyage-3-litevoyage-large-2voyage-code-2voyage-2voyage-law-2voyage-large-2-instructvoyage-finance-2voyage-multilingual-2
embed_documents to get their embeddings.
embed_query to embed the query.
A minimalist retrieval system
The main feature of the embeddings is that the cosine similarity between two embeddings captures the semantic relatedness of the corresponding original passages. This allows us to use the embeddings to do semantic retrieval / search. We can find a few closest embeddings in the documents embeddings based on the cosine similarity, and retrieve the corresponding document using theKNNRetriever class from LangChain.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.