Para agentes de IA: um índice de documentação está disponível em https://www.mongodb.com/pt-br/docs/llms.txt — as versões de markdown de todas as páginas estão disponíveis anexando .md a qualquer caminho de URL.
Menu Docs

Integrate Voyage AI with LangChain

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:

  1. Load and split source data into documents.

  2. Store the documents and their embeddings in MongoDB.

  3. Create a MongoDB Vector Search index on your embeddings.

  4. Run semantic search queries on your data.

  5. Implemente o RAG para responder a perguntas sobre seus dados.

The LangChain integration includes the following Voyage AI packages:

  • In Python, the langchain-voyageai package provides the VoyageAIEmbeddings class.

  • In TypeScript, the @langchain/mongodb package provides the VoyageEmbeddings class alongside the MongoDBAtlasVectorSearch vector 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.

The following tutorial demonstrates how to use Voyage AI embeddings with LangChain. Select your preferred language and LLM provider to view the corresponding instructions.

Linguagem
Provedor de LLM

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_dimension ao instanciar VoyageAIEmbeddings. O modelo voyage-4-large suporta as dimensões 256, 512, 1024 (padrão) e 2048. 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: