RAG(Retrieval-Augmented Generation:情報検索補強生成)とは、ざっくり言うとLLMにWEBソースや業務知識を喰わせて特定目的での利便性を向上させるツールです。
今回ためすMem0*1は、このRAGを手元環境で簡単に使用可能にするフレームワークです。
類似フレームワークは色々ありますが、Mem0は特にデータの取り込みと質問応答が容易であるという特徴があります。
実際のところ
構築
$ pip install embedchain -U
環境構築が終わると、"ec"というコマンドが追加されます
$ ec --help Usage: ec [OPTIONS] COMMAND [ARGS]... Options: --help Show this message and exit. Commands: create create-app deploy dev install-reqs start
import os from embedchain import App os.environ["OLLAMA_HOST"] = "http://localhost:11434" config_dict = { 'llm': { 'provider': 'ollama', 'config': { 'model': 'llama3', 'temperature': 0.5, 'stream': False, 'base_url': 'http://localhost:11434' } }, 'embedder': { 'provider': 'ollama', 'config': { 'model': 'znbang/bge:small-en-v1.5-q8_0', 'base_url': 'http://localhost:11434' } } } # load llm configuration from config dict app = App.from_config(config=config_dict)
フツーの軽量LLMなら知りようのない質問をしてみます
answer, source = app.query("にじさんじ公式ライバーのルンルンについて教えてください", citations=True)
回答は……まぁ、データがないので知ったかぶりをします
print(answer) #>>にじさんじ is a popular virtual YouTuber group, and their official virtual live stream "バーチャルライブ" features interactive events with fans. The "ルンルン" part likely refers to the energetic and lively atmosphere of these online gatherings. As an official event, it's a unique opportunity for fans to connect with the virtual YouTubers in real-time, making it a special experience for those involved.
参考もと
docs.embedchain.ai
🤖 Large language models (LLMs) - Embedchain
GitHub - mem0ai/mem0: Long-term memory for LLMs
Failed to install frontend requirements. · Issue #1120 · mem0ai/mem0 · GitHub
*1:少し前までembedchainと呼ばれていましたが、リブランドした様子