GPT中文GPT中文论坛社区AI工具软件大全
AI工具软件大全
首页 / 文章 / LlamaIndex 快速上手教程(GitHub README 中文整理)
📖 教程 · 5 分钟读完 · 2026-06-19

LlamaIndex 快速上手教程(GitHub README 中文整理)

从 LlamaIndex 官方 GitHub README 翻译整理的快速上手指南。

🗂️ LlamaIndex 快速上手

是什么

LlamaIndex 是一个开源的 AI 框架,专门用来构建智能体应用(Agentic Applications)。它由 LlamaIndex 团队维护,GitHub 地址:run-llama/llama_index

简单说,LlamaIndex 是一个数据与 LLM 之间的桥梁——它能帮你把各种格式的数据(PDF、网页、数据库等)变成大模型能理解的结构,然后基于这些数据做问答、分析、自动化任务。

能干什么

怎么装

确保 Python 版本 >= 3.8,然后通过 pip 安装:

pip install llama-index

如果需要使用 LlamaParse(企业级文档解析),额外安装:

pip install llama-parse

注意:LlamaParse 是云端服务,国内访问可能受限,推荐先体验本地核心功能。

怎么用第一个例子

下面是一个最简单的 RAG 示例——从本地文档中读取内容,然后让 LLM 回答相关问题。

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

# 1. 加载本地文档(支持 .txt, .pdf, .docx 等)
documents = SimpleDirectoryReader("data").load_data()

# 2. 构建索引
index = VectorStoreIndex.from_documents(documents)

# 3. 创建问答引擎
query_engine = index.as_query_engine()

# 4. 提问
response = query_engine.query("这份文档的主要内容是什么?")
print(response)

运行前准备

社区资源


翻译整理自 GitHub README,原文:https://github.com/run-llama/llama_index

01

本文涉及的工具

02

相关阅读