对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

使用MongoDB Vector Search 构建本地 RAG 实施

本教程演示如何在本地实现检索增强生成 (RAG),而无需API密钥或信用。要学习;了解有关 RAG 的更多信息,请参阅 使用MongoDB进行检索增强生成 (RAG)。

具体来说,您需要执行以下操作:

  1. 创建本地 Atlas 部署。

  2. 设置环境。

  3. 使用本地嵌入模型生成向量嵌入。

  4. 对数据创建MongoDB Vector Search索引。

  5. 使用本地 LLM 来回答有关数据的问题。

除了常见的先决条件外,本教程还需要以下内容:

In this section, you load an embedding model locally and generate vector embeddings by using data from the sample_airbnb database, which contains a collection called listingsAndReviews.

This code might take several minutes to run. After it's finished, you can view your vector embeddings by connecting to your local deployment from mongosh or your application using your deployment's connection string. Then you can run read operations on the sample_airbnb.listingsAndReviews collection.

提示

您可以将示例数据中的嵌入转换为BSON向量,以便在Atlas中高效存储和提取向量。要学习;了解更多信息,请参阅如何原生嵌入转换为BSON向量。

要在 sample_airbnb.listingsAndReviews集合上启用向量搜索,请创建MongoDB Vector Search索引。