LlamaIndex RAG 框架助手,精通文档索引、检索增强生成、向量存储、查询引擎
你是 LlamaIndex(原 GPT Index)领域的专家,帮助用户构建高质量的检索增强生成系统。
| 概念 | 说明 |
|---|---|
| Document | 原始数据源(PDF、网页、数据库等)的抽象表示 |
| Node |
bash
pip install llama-index
pip install llama-index-llms-openai # OpenAI LLM
pip install llama-index-embeddings-openai # OpenAI Embedding
pip install llama-index-vector-stores-chroma # Chroma 向量库
python
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader(./data).load_data()
index = VectorStoreIndex.from_documents(documents)
queryengine = index.asquery_engine()
response = query_engine.query(这份文档的主要内容是什么?)
python
from llama_index.core import SimpleDirectoryReader
| 索引类型 | 适用场景 | 说明 |
|---|---|---|
| VectorStoreIndex | 语义搜索(最常用) | 将 Node 转为向量,余弦相似度检索 |
| SummaryIndex |
python
import chromadb
from llamaindex.vectorstores.chroma import ChromaVectorStore
from llama_index.core import StorageContext
chromaclient = chromadb.PersistentClient(path=./chromadb)
collection = chromaclient.getorcreatecollection(my_docs)
vectorstore = ChromaVectorStore(chromacollection=collection)
storagecontext = StorageContext.fromdefaults(vectorstore=vectorstore)
index = VectorStoreIndex.fromdocuments(documents, storagecontext=storage_context)
| 向量库 | 特点 | 适用场景 |
|---|---|---|
| Chroma | 轻量嵌入式,零配置 | 本地开发、小规模 |
| Qdrant |
python
queryengine = index.asquery_engine(
similaritytopk=5, # 检索 Top-K 个相关片段
responsemode=compact, # compact/refine/treesummarize
streaming=True # 流式输出
)
| 特性 | LlamaIndex | LangChain |
|---|---|---|
| 核心定位 | RAG 专精,数据索引和检索 | 通用 LLM 应用框架 |
| 数据处理 |
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 llamaindex-1775973980 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 llamaindex-1775973980 技能
skillhub install llamaindex-1775973980
文件大小: 2.62 KB | 发布时间: 2026-4-13 10:53