Interactive demo
OVec
OVec is a vector database written from scratch in pure Python and NumPy, with no
FAISS and no scikit-learn. A fresh database searches exactly : it
compares the query with every stored vector. Calling build_index()
clusters the vectors with k-means++, and from then on a search scans only the
nprobe clusters closest to the query. That is faster, but it can miss
true neighbours.
Source on GitHub
·
How this page works
Starting Python in your browser
Python runtime Pyodide 314.0.7
NumPy
OVec source vector_db/*.py
Generating vectors
Taking longer than usual. Either the connection is slow, or something
(an extension, a strict Content-Security-Policy) is blocking WebAssembly.
Recall@k
Vectors scanned, % of all
Build the index to measure the trade-off.
Show as a table
How this page works
The page downloads Pyodide (CPython
compiled to WebAssembly) and NumPy from jsDelivr, then fetches the library's own
files from this site, writes them into Pyodide's filesystem and imports them:
distance.py ,
index.py , core.py .
They are the same files as in the repository, copied unchanged by the build script.
Nothing about search is reimplemented in JavaScript.
A small bridge, ovec_bridge.py , creates a
VectorDB, calls build_index() and search(), and
reports what the library did. It counts vectors by watching the library's own calls
to compute_distances, so "vectors scored" and the probed clusters are
observed, not estimated. Timings are wall-clock in your browser, averaged over repeated
runs with nothing patched; at a few thousand 2-D vectors both searches take
microseconds, so the number of vectors scored is the better guide to how each one scales.