llama-index(LlamaIndex) LlamaIndex 0.12
LlamaIndex系列 · LlamaIndex 社区 · 2022-11发布
模型介绍
LlamaIndex 是构建 RAG 应用的核心 Python 框架,连接数据与 LLM,文档索引、查询与 Agent 工具一应俱全。
模型基础信息
免费额度与收费政策
免费规则详情
MIT 免费(云服务可选)。
收费标准简介
框架免费,云 API 按量。
模型能力介绍
✅ 核心优势
- 生态完善
- RAG 强大
- gent 支持
- MIT
⚠️ 短板与局限
- 学习曲线陡
- 抽象多
- 性能需调优
🎯 适用场景
- 知识库 RAG
- 文档问答
- gent 应用
- 企业搜索
模型使用教程
本章节整理 llama-index(LlamaIndex) 的在线体验、API调用、本地部署全套入门教程,快速上手使用该模型。
- 本地工具,安装后即可使用。
- 支持对接主流模型与本地推理引擎。
启动服务后按提示操作即可。
export HF_ENDPOINT=https://hf-mirror.com
模型权重通过 HuggingFace 镜像或 ModelScope 下载。
提供 HTTP API:
curl http://localhost:PORT/v1/chat/completions -H "Content-Type: application/json" -d '{"model":"default","messages":[{"role":"user","content":"你好"}]}'
LlamaIndex 是数据检索框架,主打 RAG;配合本地 Ollama 可离线构建个人知识库问答。
- 安装:
pip install llama-index llama-index-llms-ollama
- 对文档建索引并查询:
python -c "from llama_index.core import SimpleDirectoryReader, VectorStoreIndex; from llama_index.llms.ollama import Ollama; llm=Ollama(model='qwen2.5:7b', request_timeout=120.0); docs=SimpleDirectoryReader('./docs').load_data(); idx=VectorStoreIndex.from_documents(docs); print(idx.as_query_engine(llm=llm).query('这段文档讲了什么?'))"
- 进阶可换向量库(Chroma/Qdrant)与 Agent。
Tips:Ollama 需要本地服务运行;文档目录含 .pdf/.md/.txt 均可。
💡 使用小技巧
pip install llama-index。
❓ 常见问题 FAQ
Q1:LlamaIndex 用途?\nA1:构建 RAG 应用。
访问备注与注意事项
- Python 生态
Aitishiku.com