For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Get Started with the LangChainGo Integration

You can integrate MongoDB Vector Search with LangChainGo to build large language model (LLM) applications and implement retrieval-augmented generation (RAG). This tutorial demonstrates how to start using MongoDB Vector Search with LangChainGo to perform semantic search on your data and build a RAG implementation. Specifically, you perform the following actions:

  1. Set up the environment.

  2. Store custom data in MongoDB.

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

  4. Run the following vector search queries:

    • Semantic search.

    • Semantic search with metadata pre-filtering.

  5. Implement RAG by using MongoDB Vector Search to answer questions on your data.

LangChainGo is the Go programming language implementation of LangChain. It is a community-driven, third-party port of the LangChain framework.

LangChain is an open-source framework that simplifies the creation of LLM applications through the use of "chains." Chains are LangChain-specific components that can be combined for a variety of AI use cases, including RAG.

By integrating MongoDB Vector Search with LangChain, you can use MongoDB as a vector database and use MongoDB Vector Search to implement RAG by retrieving semantically similar documents from your data. To learn more about RAG, see Retrieval-Augmented Generation (RAG) with MongoDB.

LangChainGo facilitates the orchestration of LLMs for AI applications, bringing the capabilities of LangChain into the Go ecosystem. It also allows developers to connect to their preferred vector-store-compatible databases, including MongoDB.

After you complete this tutorial, you have successfully integrated MongoDB Vector Search with LangChainGo to build a RAG application. You have accomplished the following tasks:

  • Initiated and configured the necessary environment to support your application.

  • Stored custom data in MongoDB and instantiated MongoDB as a vector store.

  • Built a MongoDB Vector Search index on your data, enabling semantic search capabilities.

  • Used vector embeddings to retrieve semantically relevant data.

  • Enhanced search results by incorporating metadata filters.

  • Implemented a RAG workflow using MongoDB Vector Search to provide meaningful answers to questions based on your data.

MongoDB also provides the following developer resource:

Tip

To learn more about integrating LangChainGo, OpenAI, and MongoDB, see Using MongoDB Atlas as a Vector Store with OpenAI Embeddings.