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

Getting Started

  • Installation and Setup
  • Starter Tutorial

Guides

  • A Primer to using LlamaIndex
    • LlamaIndex Usage Pattern
    • How Each Index Works
  • Tutorials
    • 💬🤖 How to Build a Chatbot
    • A Guide to Building a Full-Stack Web App with LLamaIndex
    • A Guide to Building a Full-Stack LlamaIndex Web App with Delphic
    • A Guide to LlamaIndex + Structured Data
    • A Guide to Extracting Terms and Definitions
    • A Guide to Creating a Unified Query Framework over your Indexes
    • SEC 10k Analysis

Use Cases

  • Queries over your Data
  • Integrations into LLM Applications

Key Components

  • 🔌 Data Connectors (LlamaHub)
    • 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
  • 🗃️ Index Structures
    • How Each Index Works
    • Updating an Index
    • Composability
      • Composable Graph Basic
      • Composable Graph with Weaviate
      • Composable Graph
    • Knowledge Graph Index
    • Pandas Index
    • SQL Index
    • Document Summary Index Demo
  • 🔍 Query Interface
    • LlamaIndex Usage Pattern
    • Composability
      • Composable Graph Basic
      • Composable Graph with Weaviate
      • Composable Graph
    • Query Transformations
      • HyDE Query Transform
      • Multi-Step Decompose Query Transform
    • Second-Stage Processing
      • Forward/Backward Augmentation
      • Recency Filtering
      • Time-Weighted Rerank
      • PII Masking
      • Cohere Rerank
    • Optimizers
      • Sentence Embedding Optimizer
    • Response Synthesis
    • Query Engines
      • Retriever Query Engine with Custom Retrievers - Simple Hybrid Search
      • Router Query Engine
      • Retriever Router Query Engine
      • Joint QA Summary Query Engine
  • 🛠️ Customization
    • Defining LLMs
      • Azure OpenAI
    • Defining Prompts
    • Embedding support
    • Customizing Storage
  • 🧠 Analysis
    • Cost Analysis
      • Token Predictors
    • Playground
      • Playground
  • 🔢 Output Parsing
    • Guardrails Output Parsing
    • Langchain Output Parsing
  • 🔬 Evaluation
    • Response Evaluator
    • Query Response Evaluator
    • Question Generation
  • ⛓️ Integrations
    • Using Vector Stores
      • Simple Vector Store
      • Qdrant Vector Store
      • Faiss Vector Store
      • DeepLake Vector Store
      • MyScale Vector Store
      • Metal Vector Store
      • Weaviate Vector Store
      • Using as a vector index.
      • Pinecone Vector Store
      • Chroma Vector Store
      • LanceDB Vector Store
      • Milvus Vector Store
      • Weaviate Vector Store - Hybrid Search
      • Pinecone Vector Store - Hybrid Search
      • Simple Vector Store - Async Index Creation
    • ChatGPT Plugin Integrations
    • Using with Langchain 🦜🔗
  • 💾 Storage
    • Persisting & Loading Data
    • Customizing Storage
    • Document Stores
    • Index Stores
    • Vector Stores
      • Simple Vector Store
      • Qdrant Vector Store
      • Faiss Vector Store
      • DeepLake Vector Store
      • MyScale Vector Store
      • Metal Vector Store
      • Weaviate Vector Store
      • Using as a vector index.
      • Pinecone Vector Store
      • Chroma Vector Store
      • LanceDB Vector Store
      • Milvus Vector Store
      • Weaviate Vector Store - Hybrid Search
      • Pinecone Vector Store - Hybrid Search
      • Simple Vector Store - Async Index Creation
    • Key-Value Stores

Reference

  • Indices
    • List Index
    • Table Index
    • Tree Index
    • Vector Store Index
    • Structured Store Index
    • Knowledge Graph Index
    • Empty Index
  • Querying an Index
    • Retrievers
      • Empty Index Retriever
      • Knowledge Graph Retriever
      • List Retriever
      • Keyword Table Retrievers
      • Tree Retrievers
      • Vector Store Retrievers
      • Transform Retriever
    • Response Synthesizer
    • Query Engines
      • Graph Query Engine
      • Multistep Query Engine
      • Retriever Query Engine
      • Transform Query Engine
      • Router Query Engine
      • SQL Query Engine
      • Pandas Query Engine
    • Query Bundle
    • Query Transform
  • Node
  • LLM Predictors
  • Node Postprocessor
  • Storage Context
    • Document Store
    • Index Store
    • Vector Store
    • KV Storage
    • Loading Indices
  • Composability
  • Data Connectors
  • Prompt Templates
  • Service Context
    • Embeddings
    • LLMPredictor
    • PromptHelper
    • Llama Logger 🪵
  • Optimizers
  • Callbacks
  • Structured Index Configuration
  • Response
  • Playground
  • Node Parser
  • Example Notebooks
  • Langchain Integrations

Gallery

  • 😎 App Showcase
  v: v0.6.3
Versions
latest
stable
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.27
Downloads
On Read the Docs
Project Home
Builds
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)
Next
Pinecone Vector Store - Hybrid Search
Previous
Milvus Vector Store
Copyright © 2022, 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