A Python library for benchmarking Weaviate's Query Agent!
Project description
Query Agent Benchmarking
A tool for benchmarking retrieval and question answering systems. Built for Weaviate's Query Agent, but designed to evaluate any system you can plug in.
It supports two evaluation modes:
- Search — Ranked retrieval evaluation using IR metrics (Recall@K, nDCG@K, Coverage, alpha-nDCG)
- Ask — Question answering evaluation using LLM-as-judge (DSPy-based ensemble voting for semantic alignment) or exact match accuracy
News 📯
[9/25] 📊 Search Mode Benchmarking is live on the Weaviate Blog.
Quick Start
Clone the repo and install dependencies:
git clone https://github.com/weaviate/query-agent-benchmarking.git
cd query-agent-benchmarking
uv sync
Populate Weaviate with benchmark data:
uv run python3 scripts/populate-db.py
Run search eval:
uv run python3 scripts/run-search-benchmark.py
Run ask eval:
uv run python3 scripts/run-ask-benchmark.py
See query_agent_benchmarking/benchmark-config.yml to change the dataset, agent type (hybrid-search, query-agent-search-mode, etc.), number of samples, and concurrency parameters.
Using as a Python Library
You can also install the package as a dependency and use it programmatically:
pip install query-agent-benchmarking
Evaluate Weaviate's built-in agents
import query_agent_benchmarking
# Search eval
query_agent_benchmarking.run_search_eval(
search_dataset="beir/scifact/test",
agent_name="query-agent-search-mode",
)
# Compare multiple search agents
query_agent_benchmarking.compare_search_agents(
search_dataset="beir/scifact/test",
agent_names=["hybrid-search", "query-agent-search-mode"],
)
# Ask eval
query_agent_benchmarking.run_ask_eval(
ask_dataset="multihoprag",
agent_name="query-agent-ask-mode",
)
Bring your own retriever
Pass any object that implements the SearchAgent protocol directly to run_search_eval:
from query_agent_benchmarking import run_search_eval, ObjectID
class MyRetriever:
"""Any class with a run() method returning list[ObjectID]."""
def run(self, query: str, tenant=None) -> list[ObjectID]:
results = my_search_function(query)
return [ObjectID(object_id=doc_id) for doc_id in results]
async def run_async(self, query: str, tenant=None) -> list[ObjectID]:
return self.run(query, tenant)
async def initialize_async(self) -> None: pass
async def close_async(self) -> None: pass
metrics = run_search_eval(
search_dataset="beir/scifact/test",
search_agent=MyRetriever(),
)
The library handles dataset loading, query execution, metric computation (Recall@K, nDCG@K, etc.), and results aggregation. See Bring Your Own Retriever for the full protocol definition and more examples.
Evaluate with custom questions and answers
from query_agent_benchmarking import run_ask_eval, DocsCollection, InMemoryAskQuery
queries = [
InMemoryAskQuery(
question="What is HyDE?",
ground_truth_answer="HyDE stands for Hypothetical Document Embeddings...",
),
]
run_ask_eval(
docs_collection=DocsCollection(
collection_name="MyDocs",
content_key="content",
id_key="doc_id",
),
queries=queries,
)
Documentation
- 1. Populate Database — Load benchmark datasets into Weaviate
- 2. Run Built-in Evals — Evaluate Weaviate agents on standard search and ask benchmarks
- 3. Run Custom Evals — Bring your own retriever, QA system, queries, or collections
- Experimental — Synthetic benchmark creation and hard negatives
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file query_agent_benchmarking-0.7.tar.gz.
File metadata
- Download URL: query_agent_benchmarking-0.7.tar.gz
- Upload date:
- Size: 91.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8f3cf896e686b96a87932630da43c0b3dafb85cb6e075e96631a48b8b454d3b
|
|
| MD5 |
290bb0c87f336a227169b4487b023fc7
|
|
| BLAKE2b-256 |
15ef3a76c22a6467dd9edb4154001981f264f863ba4bbe2c75538a8caf872be4
|
File details
Details for the file query_agent_benchmarking-0.7-py3-none-any.whl.
File metadata
- Download URL: query_agent_benchmarking-0.7-py3-none-any.whl
- Upload date:
- Size: 122.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
286b615813010185a8fa215ca0080d28a2abeefd9627a3d526cfbb013b78234e
|
|
| MD5 |
6745b28679d07210e1a64fe7b01ad0e4
|
|
| BLAKE2b-256 |
46a013c56420b54423a2f827be54e32daebb9bf82f3b1ecf5d4af662e6ba882f
|