LlamaIndex:产品、工程与评测·· 2024-01-26精选AI 评分65
LlamaIndex 发布 RAG 命令行工具 llamaindex-cli,无需写代码即可本地检索问答
Introducing the LlamaIndex retrieval-augmented generation command-line tool
AI 导读
LlamaIndex 推出 llamaindex-cli 命令行工具,随 pip install llama-index 安装,底层使用 Chroma 向量数据库,可不经写代码完成 RAG。
推荐理由
官方发布零代码 RAG 命令行工具,给出完整上手步骤和可换本地模型的自定义路径,读者可以直接照着试。
正文 · AI 翻译
想尝试检索增强生成(RAG)却不想写一行代码?我们帮你搞定!隆重推出全新的 llamaindex-cli 工具,当你 pip install llama-index 时就会自动安装!它在底层使用 Chroma,因此你还需要 pip install chromadb。
立即探索我们的免费和付费方案。
- 设置
OPENAI_API_KEY环境变量:默认情况下,此工具使用 OpenAI 的 API。因此,无论何时使用该工具,你都需要确保在OPENAI_API_KEY环境变量下设置了 OpenAI API Key。
$ export OPENAI_API_KEY=<api_key>2. 摄取一些文件:现在,你需要将该工具指向一些本地文件,以便它将其摄取到本地向量数据库中。在本示例中,我们将摄取 LlamaIndex README.md 文件:
$ llamaindex-cli rag --files "./README.md"你只能指定诸如以下形式的文件通配符模式
$ llamaindex-cli rag --files "./docs/**/*.rst"3. 提问:现在你可以开始就上一步中摄取的任何文档提问了:
$ llamaindex-cli rag --question "What is LlamaIndex?"
LlamaIndex is a data framework that helps in ingesting, structuring, and accessing private or domain-specific data for LLM-based applications. It provides tools such as data connectors to ingest data from various sources, data indexes to structure the data, and engines for natural language access to the data. LlamaIndex follows a Retrieval-Augmented Generation (RAG) approach, where it retrieves information from data sources, adds it to the question as context, and then asks the LLM to generate an answer based on the enriched prompt. This approach overcomes the limitations of fine-tuning LLMs and provides a more cost-effective, up-to-date, and trustworthy solution for data augmentation. LlamaIndex is designed for both beginner and advanced users, with a high-level API for easy usage and lower-level APIs for customization and extension.4. 打开聊天 REPL:你甚至可以在终端内打开聊天界面!只需运行 llamaindex-cli rag --chat,然后开始就你已摄取的文件提问即可。
随心所欲地自定义它!
你可以自定义 llamaindex-cli 以使用任何 LLM 模型,甚至是通过 Ollama 使用的 Mixtral 8x7b 等本地模型,并且你可以构建更高级的查询和检索技术。查看文档了解如何入门的详细信息。
来源:LlamaIndex:产品、工程与评测 · llamaindex.ai