Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions benchmarks/dbpedia-openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ contains 1M openai embeddings.
## Prepare Dataset

```sh
# Python 3.10+
python3 -m venv venv
. ./venv/bin/activate

# install dependencies
pip install -r requirements.txt

# Generate dataset in lance format.
./datagen.py
uv run ./datagen.py
```

## Run benchmark
Expand All @@ -23,5 +16,5 @@ pip install -r requirements.txt
as well as `refine_factor`.

```sh
./benchmarks.py -k 20
uv run ./benchmarks.py
```
8 changes: 6 additions & 2 deletions benchmarks/dbpedia-openai/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#

import argparse
import time

import lance
import numpy as np
Expand All @@ -20,7 +21,7 @@ def run_query(
results = []
for query in queries:
tbl = ds.scanner(
columns=["_id"],
columns=["_id", "_distance"],
nearest={
"column": "openai",
"q": query,
Expand Down Expand Up @@ -56,7 +57,7 @@ def compute_recall(gt: np.ndarray, result: np.ndarray) -> float:

def main():
parser = argparse.ArgumentParser()
parser.add_argument("uri", help="dataset uri")
parser.add_argument("--uri", help="dataset uri", default="./dbpedia.lance")
parser.add_argument(
"-k",
"--top-k",
Expand Down Expand Up @@ -90,6 +91,7 @@ def main():

for ivf in [256, 512, 1024]:
for pq in [32, 96, 192]:
start = time.perf_counter()
ds.create_index(
"openai",
"IVF_PQ",
Expand All @@ -98,6 +100,8 @@ def main():
replace=True,
metric=args.metric,
)
end = time.perf_counter()
print(f"Create IVF{ivf}_PQ{pq} index in {end - start:0.2f}s")
for refine in [None, 2, 5, 10, 50, 100]:
results = run_query(
ds,
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/dbpedia-openai/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "dbpedia-openai"
version = "0.1.0"
description = "Benchmarks for huggingface dpbedia dataset with OpenAI embeddings"
readme = "README.md"
requires-python = ">=3.12,<3.14"
dependencies = ["pylance", "datasets"]

[dependency-groups]
dev = ["ruff"]