LlamaIndex 项目介绍
LlamaIndex 🦙 项目介绍
项目定位
LlamaIndex 是一个开源数据框架,用于将私有数据与 LLM 连接起来,构建 RAG(检索增强生成)和 Agent 应用。核心版本 v0.14.22(commit f027669)。
核心能力
- 数据连接与摄入:支持 PDF、文档、SQL、API 等 300+ 数据源,通过 IngestionPipeline 实现加载 → 分块 → 嵌入 → 向量存储的自动化流水线
- 多种索引类型:VectorStoreIndex(向量索引)、TreeIndex(树形索引)、KnowledgeGraph(知识图谱)、PropertyGraph(属性图)等
- 高级检索系统:向量检索、融合检索、路由检索、自动合并检索、递归检索等多种策略,配合 LLM Rerank、Cross-Encoder Rerank 等后处理器
- 事件驱动 Agent:基于 Workflow 引擎的 ReActAgent、FunctionAgent、CodeActAgent,支持多 Agent 编排与 handoff
- 插件式架构:核心 + 集成包分离设计,300+ 集成包覆盖 LLM、向量存储、嵌入模型等
- 可观测性:CallbackManager + Instrumentation 双层追踪系统,支持调试、日志与 OpenTelemetry
技术栈
| 维度 | 选择 |
|---|---|
| 语言 | Python 3.10+ |
| 数据验证 | Pydantic v2 |
| 异步 | asyncio 原生,httpx + aiohttp |
| 构建 | Hatchling |
| 包管理 | uv |
| LLM 抽象 | 统一 BaseLLM 接口 + 插件注册 |
| 工作流引擎 | llama-index-workflows(独立 PyPI 包,事件驱动状态机) |
架构概览
快速体验
# 安装核心 + 所需集成pip install llama-index-corepip install llama-index-llms-openaipip install llama-index-embeddings-huggingface
# 5 行代码构建 RAGfrom llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader("your_data/").load_data()index = VectorStoreIndex.from_documents(documents)query_engine = index.as_query_engine()response = query_engine.query("你的问题")教程导读
本教程分为 AI 应用 和 编程核心 两部分:
AI 应用教程(ai/)
| 章节 | 主题 | 引用的 Common 教程 |
|---|---|---|
| 01 | RAG 核心链路:从数据到答案 | RAG 全链路管线 |
| 02 | 高级检索器组合 | RAG 管线、Chunking 策略 |
| 03 | 事件驱动 Agent 循环 | 事件驱动运行时、工具调用协议 |
| 04 | 多 Agent 编排与 Handoff | 多 Agent 路由 |
| 05 | 工具调用与 Function Calling | 工具调用协议 |
| 06 | LLM 多模型适配 | 多模型架构 |
| 07 | Agent 记忆与长期知识 | 记忆系统、长期记忆 |
编程核心教程(dev/)
| 章节 | 主题 |
|---|---|
| 01 | 插件式架构:核心 + 集成包设计 |
| 02 | 事件驱动工作流引擎架构 |
| 03 | TransformComponent 数据流水线模式 |
| 04 | 存储抽象层:StorageContext 与多后端 |
| 05 | 可观测性系统:Callback + Instrumentation |
| 06 | Settings 单例与惰性加载模式 |
| 07 | 构建与分发:Hatchling + uv + 300+ 包管理 |
共 14 篇技术章节(7 篇 AI + 7 篇 Dev),基于 v0.14.22 (commit f027669) 分析。