このチュートリアルでは、APIキーやクレジットを必要とせずに、検索拡張生成 (RAG)(RAG)をローカルに実装する方法を説明します。RG の詳細については、RAG、「 MongoDBでの検索拡張生成(RAG) 」を参照してください。
具体的には、次のアクションを実行します。
Atlas のローカル配置の作成。
環境を設定します。
ローカル埋め込みモデルを使用してベクトル埋め込みを生成します。
データにMongoDB ベクトル検索インデックスを作成します。
ローカル 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.
MongoDB ベクトル検索インデックスの作成
sample_airbnb.listingsAndReviewsコレクションでベクトル検索を有効にするには、 MongoDB ベクトル検索インデックスを作成します。