INDEX_ACCURACY_QUERY
Use the DBMS_VECTOR.INDEX_ACCURACY_QUERY function to verify the accuracy of a vector index for a given query vector, top-K, and target accuracy.
Syntax
DBMS_VECTOR.INDEX_ACCURACY_QUERY (
OWNER_NAME IN VARCHAR2,
INDEX_NAME IN VARCHAR2,
QV IN VECTOR,
TOP_K IN NUMBER,
TARGET_ACCURACY IN NUMBER
) return VARCHAR2;
DBMS_VECTOR.INDEX_ACCURACY_QUERY (
OWNER_NAME IN VARCHAR2,
INDEX_NAME IN VARCHAR2,
QV IN VECTOR,
TOP_K IN NUMBER,
QUERY_PARAM IN JSON
) return VARCHAR2;Parameters
Table 12-4 INDEX_ACCURACY_QUERY (IN) Parameters of DBMS_VECTOR
| Parameter | Description |
|---|---|
owner_name |
The name of the vector index owner. |
index_name |
The name of the vector index. |
qv |
Specifies the query vector. |
top_k |
The |
target_accuracy |
The target accuracy value for the vector index. |
query_param |
A JSON input that can be used to specify query parameters to be used during computation of vector index accuracy. The supported values are as follows:
|
For information about determining the accuracy of your vector indexes, see Index Accuracy Report in Oracle AI Database AI Vector Search User's Guide.
Usage Notes
When you specify the rescore factor field in the
query_param parameter, the achieved accuracy is calculated for
the given index using the this value. This allows you to manually choose the
appropriate rescore factor for your scalar-quantized HNSW index based on your
accuracy requirements.
For more information about quantization, see Scalar Quantized HNSW Indexes in Oracle AI Database AI Vector Search User's Guide.
Examples
Examples with IVF indexes:
DECLARE
q_v VECTOR;
report VARCHAR2(128);
BEGIN
q_v := TO_VECTOR('[1, 1, 1]', 3, FLOAT64);
report := DBMS_VECTOR.INDEX_ACCURACY_QUERY(owner_name => 'VEC',
index_name => 'IVF_IDX',
qv => q_v,
top_K => 10,
query_param => json('{"accuracy": 80 }'));
DBMS_OUTPUT.PUT_LINE(report);
END;
/
Result:
Accuracy achieved (100%) is 20% higher than the Target Accuracy requested (80%)
DECLARE
q_v VECTOR;
report VARCHAR2(128);
BEGIN
q_v := TO_VECTOR('[1, 1, 1]', 3, FLOAT64);
report := DBMS_VECTOR.INDEX_ACCURACY_QUERY(owner_name => 'VEC',
index_name => 'IVF_IDX',
qv => q_v,
top_K => 10,
query_param => json('{"neighbor partition probes": 2}'));
DBMS_OUTPUT.PUT_LINE(report);
END;
/
Result:
Accuracy achieved (100%) for NEIGHBOR PARTITION PROBES (2)
Examples with HNSW indexes:
DECLARE
q_v VECTOR;
report VARCHAR2(128);
BEGIN
q_v := TO_VECTOR('[1, 1, 1]', 3, FLOAT64);
report := DBMS_VECTOR.INDEX_ACCURACY_QUERY(owner_name => 'VEC',
index_name => 'HNSW_IDX',
qv => q_v,
top_K => 10,
query_param => json('{"efsearch": 32}'));
DBMS_OUTPUT.PUT_LINE(report);
END;
/
Result:
Accuracy achieved (100%) for EFSEARCH (32)
Examples with quantized HNSW indexes:
DECLARE
q_v VECTOR;
report VARCHAR2(128);
BEGIN
q_v := TO_VECTOR('[1, 1, 1]', 3, FLOAT64);
report := DBMS_VECTOR.INDEX_ACCURACY_QUERY(owner_name => 'VEC',
index_name => 'QUANTIZED_HNSW_IDX',
qv => q_v,
top_K => 10,
query_param => json('{"efsearch": 32, "rescore factor " : 2}'));
DBMS_OUTPUT.PUT_LINE(report);
END;
/
Result:
Accuracy achieved (100%) for EFSEARCH (32), RESCORE FACTOR (2)
Parent topic: DBMS_VECTOR