Contents Menu Expand Light mode Dark mode Auto light/dark mode
LlamaIndex 🦙 0.6.18
LlamaIndex 🦙 0.6.18

Getting Started

  • 安装和设置
  • 从Pip安装
  • 从源代码安装
  • 环境设置

Guides

  • LlamaIndex使用指南
    • 1.加载文档
    • 2.将文档解析为节点
    • 3.索引构建
    • 列表索引
    • 向量存储索引
    • 树索引
    • 关键字表索引
    • 架构概述
  • 教程
    • 上下文
    • 摄取数据
    • 为每年设置向量索引
    • 测试代理
    • Flask后端
    • 结论
    • 我们要建造什么
    • 架构概述
    • 系统要求
    • Django后端
    • 推断结构数据点
    • Text-to-SQL(基本)
    • 注入上下文
    • 将表上下文存储在索引中
    • 最后总结
    • 上传文本
    • LLM设置
    • 保存提取的术语
    • 干预测试
    • 改进#1 - 创建一个起点索引
    • 改进#2 -(细化)更好的提示
    • 设置
    • 定义索引集
    • 设置
    • 定义索引集
    • 查询我们的统一接口
    • SEC 10k分析
    • 使用LlamaIndex与本地模型

Use Cases

  • 语义搜索
  • 摘要
  • 对结构化数据的查询
  • 跨异构数据源的路由
  • 比较/对比查询
  • 多文档查询
  • 聊天机器人
  • 全栈Web应用程序

Key Components

  • DeepLake Reader
  • Qdrant Reader
  • Discord Reader
  • MongoDB Reader
  • Chroma Reader
  • MyScale Reader
  • Faiss Reader
  • Obsidian Reader
  • Slack Reader
  • Web Page Reader
  • Pinecone Reader
  • Mbox Reader
  • MilvusReader
  • Notion Reader
  • Github Repo Reader
  • Google Docs Reader
  • Database Reader
  • Twitter Reader
  • Weaviate Reader
  • Make Reader
  • 🗃️索引结构
    • 列表索引
    • 向量存储索引
    • 树索引
    • 关键字表索引
    • 插入
    • 删除
    • 更新
    • 您可以根据您的知识库的层次结构堆叠指数,尽可能多地堆叠指数! [可选]持久化图 图也可以持久化到存储,然后在需要时再次加载。请注意,您需要设置根索引的ID,或者跟踪默认值。 我们可以看一下代码示例。我们首先构建两个树索引,一个是维基百科的纽约市页面,另一个是保罗·格雷厄姆的文章。然后,我们定义一个关键字提取索引,覆盖这两个树索引。 这里有一个示例笔记本--- 标题:示例 最大深度:1
    • Knowledge Graph Index
    • Pandas Index
    • SQL Index Guide (Core)
    • Document Summary Index
  • 设计哲学:逐步披露复杂性
  • 资源
  • 🛠️定制
    • 示例:更改底层LLM
    • 示例:更改输出令牌数(用于OpenAI,Cohere,AI21)
    • 定义自定义提示
    • 将自定义提示传递到管道中
    • 完整示例
    • 将嵌入添加到Document对象
    • 使用向量存储作为底层索引
    • 在列表/树索引中使用嵌入查询模式
    • 全局ServiceContext
    • 低级API
    • 设置
    • 流式响应
  • 🔬 Evaluation
    • Response Evaluator
    • Query Response Evaluator
    • Question Generation
  • 使用向量存储作为索引
  • 使用数据连接器从向量存储加载数据
  • ChatGPT插件集成
  • Llama Tool abstractions
  • Llama Demo Notebook:Tool + Memory module
  • 💾存储
    • 持久化数据
    • 加载数据
    • 使用远程后端
    • 低级API
    • 简单文档存储
    • MongoDB文档存储
    • 简单索引存储
    • MongoDB索引存储
    • 简单向量存储
    • 第三方向量存储集成

Reference

  • 索引
  • 查询索引
    • 检索器
      • 空索引检索器
      • 知识图检索器
      • 列表检索器
      • 关键词表检索器
      • 树检索器
      • 向量存储检索器
      • 变换检索器
    • 响应合成器
    • 查询引擎
      • 图查询引擎
      • 多步查询引擎
      • 检索查询引擎
      • 变换查询引擎
      • 路由器查询引擎
      • 子问题查询引擎
      • SQL查询引擎
      • Pandas查询引擎
    • Chat Engines
      • 简单聊天引擎
      • 紧缩问题聊天引擎
      • ReAct聊天引擎
    • 查询包
    • 查询转换
  • 节点
  • 节点后处理器
  • 存储上下文
    • 文档存储
    • 索引存储
    • Vector Store
    • 向量存储
    • KV存储
    • 加载索引
  • 可组合性
  • 数据连接器
  • Prompt Templates
  • 优化器
  • 回调
  • 结构化索引配置
  • 响应
  • 游乐场
  • 节点解析器
  • 示例笔记本
  • Langchain集成

Gallery

  • Meru - 密集数据检索API
  • Algovera
  • ChatGPT LlamaIndex
  • AgentHQ
  • PapersGPT
  • VideoQues + DocsQues
  • PaperBrain
  • CACTUS
  • 个人笔记聊天机器人
  • RHOBH AMA
  • Mynd
  • Al-X by OpenExO
  • AnySummary:
  • Blackmaria:
Back to top
Edit this page

Weaviate Vector Store - Hybrid Search

import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))

Creating a Weaviate Client

import weaviate
resource_owner_config = weaviate.AuthClientPassword(
  username = "<username>", 
  password = "<password>", 
)
# Connect to cloud instance
# client = weaviate.Client("https://<cluster-id>.semi.network/", auth_client_secret=resource_owner_config)

# Connect to local instance
client = weaviate.Client("http://localhost:8080")

Load documents

from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
from llama_index.vector_stores import WeaviateVectorStore
from llama_index.response.notebook_utils import display_response
# load documents
documents = SimpleDirectoryReader('../paul_graham_essay/data').load_data()

Build the GPTVectorStoreIndex with WeaviateVectorStore

from llama_index.storage.storage_context import StorageContext


vector_store = WeaviateVectorStore(weaviate_client=client)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = GPTVectorStoreIndex.from_documents(documents, storage_context=storage_context)

# NOTE: you may also choose to define a class_prefix manually.
# class_prefix = "test_prefix"
# vector_store = WeaviateVectorStore(weaviate_client=client, class_prefix=class_prefix)

Query Index with Default Vector Search

# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine(
    similarity_top_k=2
)
response = query_engine.query("What did the author do growing up?")
display_response(response)

Query Index with Hybrid Search

Use hybrid search with bm25 and vector.
alpha parameter determines weighting (alpha = 0 -> bm25, alpha=1 -> vector search).

By default, alpha=0.75 is used (very similar to vector search)

# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine(
    vector_store_query_mode="hybrid", 
    similarity_top_k=2
)
response = query_engine.query(
    "What did the author do growing up?", 
)
display_response(response)

Set alpha=0. to favor bm25

# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine(
    vector_store_query_mode="hybrid", 
    similarity_top_k=2, 
    alpha=0.
)
response = query_engine.query(
    "What did the author do growing up?", 
)
display_response(response)
Copyright © 2023, Jerry Liu
Made with Sphinx and @pradyunsg's Furo
On this page
  • Weaviate Vector Store - Hybrid Search
    • Creating a Weaviate Client
    • Load documents
    • Build the GPTVectorStoreIndex with WeaviateVectorStore
    • Query Index with Default Vector Search
    • Query Index with Hybrid Search
      • By default, alpha=0.75 is used (very similar to vector search)
      • Set alpha=0. to favor bm25