LangChain is an open-source framework that provides chains to simplify the creation of large language model applications. Chains consist of interconnected LangChain components that perform a sequence of operations. You can use chains for a variety of AI use cases, including RAG and agentic retrieval.
O LangChain oferece pacotes dedicados que expõem os modelos de incorporação do Voyage AI como classes de integração do LangChain padrão. Ao emparelhar esses pacotes com o MongoDB , você pode armazenar suas incorporações junto com seus outros dados e consultá-las com a Vector Search do MongoDB .
This tutorial demonstrates how to use Voyage AI embeddings with LangChain to complete the following tasks:
Load and split source data into documents.
Store the documents and their embeddings in MongoDB.
Create a MongoDB Vector Search index on your embeddings.
Run semantic search queries on your data.
Implemente o RAG para responder a perguntas sobre seus dados.
Plano de fundo
The LangChain integration includes the following Voyage AI packages:
In Python, the
langchain-voyageaipackage provides theVoyageAIEmbeddingsclass.In TypeScript, the
@langchain/mongodbpackage provides theVoyageEmbeddingsclass alongside theMongoDBAtlasVectorSearchvector store.
Because both packages implement LangChain's standard embedding interface, you can pass a Voyage model to any LangChain component that accepts embeddings, including vector stores and retrievers.
Tutorial
The following tutorial demonstrates how to use Voyage AI embeddings with LangChain. Select your preferred language and LLM provider to view the corresponding instructions.
Próximos passos
After you have a working pipeline, you can make the following adjustments to improve retrieval quality without changing your LangChain chain:
Para reduzir o espaço ocupado pelo armazenamento de suas incorporações, passe o parâmetro
output_dimensionao instanciarVoyageAIEmbeddings. O modelovoyage-4-largesuporta as dimensões256,512,1024(padrão) e2048. Para saber mais, consulte Dimensões flexíveis e quantização.To choose a different embedding model for your domain or latency budget, see Text Embeddings.
To reorder your search results by relevance before you pass them to the LLM, add a reranker. To learn more, see Rerankers.
To view additional tutorials, see the following resources:
Para implementar o RAG sem uma framework, consulte Retrieval-Augmented Geração (RAG) com Voyage AI.
To learn about other LangChain tutorials that use MongoDB, see Get Started with the MongoDB LangChain Integration.
To learn how to use Voyage AI models with other LLM frameworks and AI services, see MongoDB AI Integrations and Partners.