mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
Add rescore index for ANN queries
Add rescore index type: stores full-precision float vectors in a rowid-keyed shadow table, quantizes to int8 for fast initial scan, then rescores top candidates with original vectors. Includes config parser, shadow table management, insert/delete support, KNN integration, compile flag (SQLITE_VEC_ENABLE_RESCORE), fuzz targets, and tests.
This commit is contained in:
parent
bf2455f2ba
commit
ba0db0b6d6
19 changed files with 3378 additions and 8 deletions
|
|
@ -140,6 +140,39 @@ INDEX_REGISTRY["baseline"] = {
|
|||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Rescore implementation
|
||||
# ============================================================================
|
||||
|
||||
|
||||
def _rescore_create_table_sql(params):
|
||||
quantizer = params.get("quantizer", "bit")
|
||||
oversample = params.get("oversample", 8)
|
||||
return (
|
||||
f"CREATE VIRTUAL TABLE vec_items USING vec0("
|
||||
f" chunk_size=256,"
|
||||
f" id integer primary key,"
|
||||
f" embedding float[768] distance_metric=cosine"
|
||||
f" indexed by rescore(quantizer={quantizer}, oversample={oversample}))"
|
||||
)
|
||||
|
||||
|
||||
def _rescore_describe(params):
|
||||
q = params.get("quantizer", "bit")
|
||||
os = params.get("oversample", 8)
|
||||
return f"rescore {q} (os={os})"
|
||||
|
||||
|
||||
INDEX_REGISTRY["rescore"] = {
|
||||
"defaults": {"quantizer": "bit", "oversample": 8},
|
||||
"create_table_sql": _rescore_create_table_sql,
|
||||
"insert_sql": None,
|
||||
"post_insert_hook": None,
|
||||
"run_query": None, # default MATCH query works — rescore is automatic
|
||||
"describe": _rescore_describe,
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Config parsing
|
||||
# ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue