pdx_simple.py shows a plug-and-play example that creates a random collection with scikit-learn. The rest of the examples read vectors from the .hdf5 format that you can download here.
Check INSTALL.md for installation instructions. Then, run the examples:
python ./examples/pdx_simple.pyOur examples look for .hdf5 files in /benchmarks/datasets/downloaded. These datasets follow the convention used in the ANN-Benchmarks project. One .hdf5 file with two datasets: train and test. We have a few ways in which you can download the data we used:
- Download and unzip ALL the
.hdf5datasets from here (~60GB zipped and ~80GB unzipped). - Download datasets individually from here.
- Run the script
/benchmarks/python_scripts/setup_data.pyfrom the root folder with the script flagDOWNLOAD = True. This will download and unzip ALL the.hdf5datasets. Make sure you set all the other flags toFalseand comment the elements inside theALGORITHMSarray.
-
pdx_simple.py: Plug-and-play example using random vectors generated with scikit-learn. Builds a single-level IVF index (IndexPDXIVF) and runs approximate nearest-neighbor queries. No external datasets required. -
pdx_ivf.py: Single-level IVF index (IndexPDXIVF, F32 precision) on vector embeddings. Demonstrates building an index, querying with a configurablenprobe, and inspecting index properties like cluster count and in-memory size. -
pdx_ivf_exhaustive.py: Exhaustive search usingnprobe=0(visits all clusters). Compares PDX pruned search against brute-force FAISS (IndexFlatL2) to show the speedup from ADSampling pruning even without approximate search. -
pdx_tree_sq8.py: Two-level hierarchical IVF index with 8-bit scalar quantization (IndexPDXIVFTreeSQ8). The two-level structure allows pruning to happen when finding the most promising clusters. Recall is controlled withnprobe. -
pdx_filtered.py: Filtered (predicated) search usingIndexPDXIVFTreeSQ8. Demonstrates how to pass a set of allowed row IDs tofiltered_search(), restricting results to only those vectors. Includes a correctness check verifying that returned IDs are a subset of the allowed set. -
pdx_persist.py: Save and load a PDX index to/from disk. Builds an index, saves it withindex.save(), then reloads it withload_index()and queries the restored index. -
pdx_maintenance.py: Builds an index with 50% of the data, then inserts the rest of the data and query the index. Recall is maintained and maintenance is very lightweight.append/deletework on every index class, not onlyIndexPDXIVFTreeSQ8.