betaFeedback

WorksComputer Science

Errpedia: Is Your Exact kk-NN Vector Search Really Exact?

Abstract

Exact kk-nearest-neighbor (kk-NN) vector search is a common feature of vector libraries and database systems. It serves applications that require exact results and provides the ground truth for evaluating approximate search. However, floating-point rounding and overflow can cause an exact search to return mathematically incorrect top-kk result sets. These errors can go unnoticed and affect downstream tasks that rely on exact results. We present Errpedia, a purpose-built dataset for testing the numerical correctness of exact vector search. Errpedia contains 1,616 queries across 21 error categories, with ground truth independently verified using exact rational arithmetic. We evaluate 20 widely used library and database configurations and find that every tested configuration returns mathematically incorrect top-10 result sets on at least 1 applicable query. Failures include misranking nearly equidistant vectors and returning incomplete results: 1 library omits all 10 exact matches to a query, and several systems return fewer than kk neighbors. We release Errpedia as a reproducible benchmark for developers and researchers to test their implementations. The dataset is publicly available at https://github.com/dynos01/errpedia.

Introduction

Exact kk-nearest-neighbor (kk-NN) vector search returns the kk vectors closest to a query under a specified distance measure, and is widely supported by vector libraries and database systems [4, 5]. It serves recommendation workloads [9] and provides ground truth for evaluating approximate nearest neighbor (ANN) search [1], training query cost estimators [11], and learning query termination policies [3]. Errors in these answers can therefore affect retrieval, evaluation, and training. Despite its importance as a reference oracle, the numerical correctness of exact vector search implementations is rarely evaluated independently. In particular, existing vector search benchmarks typically focus on the accuracy and performance of approximate search [2, 7], while the correctness of the underlying exact search is often taken for granted.

Sources of Error

Problem definition. Let X={x1,…,xn}X = \{x_1, \ldots, x_n\} be a collection of dd-dimensional vectors and qq a query vector in the same space. Each member has a unique identifier. Distinct members may have identical coordinates. All coordinates are finite IEEE 754 32-bit float values interpreted as exact reals. We use squared Euclidean distance D(q,x)=∑j=1d(qj−xj)2D(q,x) = \sum_{j=1}^{d}(q_j-x_j)^2. Unless otherwise stated, distance refers to this measure. For 1≤k≤n1 \le k \le n, Rk(q)R_k(q) contains the kk nearest members of XX, with identifiers breaking exact ties. Errpedia uses k<nk < n and a strictly positive top-kk boundary gap, making membership in Rk(q)R_k(q) independent of tie-breaking. We independently verify each ground-truth set using exact rational arithmetic. We consider an unordered result set that contains exactly the identifiers of these kk members as correct.

Under this setting, even exhaustive search can violate this criterion when numerical errors alter comparisons or candidate selection for multiple reasons.

Rounding and accumulation. Evaluating D(q,x)D(q,x) in floating point produces a computed distance score D^(q,x)\widehat{D}(q,x) through subtraction, multiplication, and addition, each of which can round its exact result to the working precision [6]. Small terms may be absorbed into a large partial sum, and changing the accumulation order can change the result. Distinct distances can then become tied or reversed. Errors comparable to the gap at the top-kk boundary can change the returned set. Wider arithmetic can reduce errors but does not certify the order.

Cancellation. An equivalent expression is

D(q,x)=∥q∥2+∥x∥2−2qTx.(1)D(q,x) = \lVert q\rVert^2 + \lVert x\rVert^2 - 2q^{\mathsf{T}}x. \tag*{(1)}

For nearby vectors with large norms, this expression subtracts large, already rounded quantities to obtain a small residual. Errors in those quantities can dominate the true distance and obscure the ordering of candidates. Algebraic equivalence therefore does not guarantee equivalent numerical behavior.

Overflow and underflow. Finite coordinates do not ensure that every intermediate result is representable. A difference, square, or partial sum can overflow to infinity, while a tiny nonzero term can round to 0. Subsequent operations involving infinities can produce NaN. Intermediates can be out of range even when the final distance is representable, so checking inputs alone cannot rule out range failures.

Score conversion. Distance evaluation may be followed by a square root, conversion to a similarity score, or a reduction in precision. Strictly monotone transformations retain distance distinctions in real arithmetic, but their floating-point implementations can map different inputs to the same output. Selecting the top-kk by these scores can lose distinctions preserved by the distance computation and select a farther candidate from a computed tie.

Candidate handling. Top-kk collection must distinguish valid candidates from unused slots. Using an extreme distance score for an empty slot can make it indistinguishable from a candidate with that score. If insertion requires strict improvement, the candidate may be rejected while a slot is still empty. NaN distance scores also require explicit handling because ordered comparisons with them are false. These interactions can leave fewer than kk neighbors despite enough eligible vectors.

Other sources. Additional failures can arise from unintended coordinate changes during parsing or type conversion, non-conservative pruning bounds that discard true neighbors, or output and transport failures that prevent complete results from reaching the caller. These mechanisms can interact: overflow during distance computation may become missing neighbors when combined with candidate handling.

CategoryQueriesCategoryQueries
Arithmetic precision (AP)Norm-dot-product evaluation (ND)
sub58normdot_cancel49
sq_round59normdot_overflow20
absorb150Similarity mappings (SM)
order_disc480sim_saturation30
neartie405exp_similarity8
collision_ladder83Input representation (IR)
sqrt28decimal_ingest12
Range limits (RL)16-bit float computation (FP)
sq_underflow50fp16_term14
sq_subnormal28fp16_underflow96
overflow_inf19fp16_absorb6
diff_overflow6fp16_overflow9
max_sentinel6

Table 2. Query counts by category.

The Errpedia Dataset

Specification

Errpedia contains a vector collection XX with n=22,501n = 22{,}501 members and a query collection Q=(q1,…,qb)Q = (q_1,\ldots,q_b) with b=1,616b = 1{,}616, d=128d = 128, and k=10k = 10. All coordinates are finite 32-bit float values. Each query q∈Qq \in Q defines a test case over XX with a unique ground-truth top-10 result set as defined in § 2. The 21 categories form 6 evaluation groups (Table 1).

Group (code)CategoriesQueries
Arithmetic precision (AP)71,263
Range limits (RL)5109
Norm-dot-product evaluation (ND)269
16-bit float computation (FP)4125
Similarity mappings (SM)238
Input representation (IR)112
Total211,616

Table 1. Evaluation groups in Errpedia.

Contents. The release stores XX in data/base.csv, 1 vector per row without a header. Identifiers are 0-based row indices. Query JSON files occupy 6 group directories under data/: ap, rl, nd, fp, sm, and ir. For example, data/ap/sub_01.json stores case_id, category, query_row (the original 0-based query index), query (the coordinates), and gt_ids (the 10 ground-truth identifiers). Coordinates use complete exact decimal values, preserving the inputs under correctly rounded 32- or 64-bit float parsing.

Applicability. Some systems impose numerical constraints on their inputs. We mark a query as not applicable when its inputs do not satisfy these constraints. Although an implementation may accept such inputs and even return correct results, evaluation should respect the input requirements specified by its developers.

Scoring. A query passes only if it returns exactly the 10 distinct ground-truth identifiers, regardless of order or rounding in reported distances. For an evaluation group GG, let CGC_G contain its categories with applicable, executed queries, and let pcp_c be the number of these ncn_c queries that pass in category cc. The group score is

Score⁡(G)=100∣CG∣∑c∈CGpcnc.(2)\operatorname{Score}(G) = \frac{100}{|C_G|}\sum_{c\in C_G}\frac{p_c}{n_c}. \tag*{(2)}

Categories therefore receive equal weight within a group despite different query counts. Overall is the mean pass rate across all applicable, executed categories. Report raw passed/total query counts alongside these scores. Categories with no applicable, executed queries are marked N/A. Input rejections and execution failures are reported separately.

Construction

General Methodology. Each case starts from a small candidate set. A typical case contains 9 vectors closer to the query than 2 remaining candidates. These 2 candidates should occupy ranks 10 and 11, respectively. We choose their coordinates so that a floating-point model of the computation can lose the difference between their distances.

Arithmetic precision (AP). The sub construction pairs a large query coordinate with small, opposite-sign candidate coordinates, making distinct exact differences round identically. For sq_round, we search for 2-term squared sums whose order is lost through product rounding. The absorb construction adds a nonzero squared term smaller than 1/21/2 of the local spacing of a large partial sum, while order_disc varies term order and placement across accumulator lanes. To expose small gaps, neartie perturbs coordinate-permuted distance patterns. The collision_ladder construction places several strictly ordered candidates within a region of tied distance scores in the floating-point model. The sqrt construction uses distinct squared distances whose rounded square roots coincide in the targeted precision.

Range limits (RL). For sq_underflow, we perturb exact matches so that nonzero squared differences round to 0 or are cleared under flush-to-zero. The sq_subnormal construction searches for ordered squared sums that tie or reverse after product rounding on the 32-bit float subnormal grid. In overflow_inf, individual squares or their sum overflow. The diff_overflow cases use large, finite, opposite-sign coordinates whose differences exceed the 32-bit float range. The max_sentinel construction makes boundary distance scores round to the largest finite 32-bit float value, testing implementations that also use it as an empty-slot threshold.

Norm-dot-product evaluation (ND). The normdot_cancel construction uses identical or nearby vectors with large norms, so cancellation in the expanded distance formula obscures their small exact distances. The normdot_overflow cases contain 10 exact query matches whose individual norm terms or accumulated norms overflow in the same formula.

16-bit float computation (FP). These categories target IEEE 754 16-bit float operations on 32-bit float inputs. The fp16_term construction uses coordinates representable in 16-bit float whose squared sums tie or reverse after product rounding. For fp16_underflow, differences remain nonzero in 16-bit float but their squares round to 0. The fp16_absorb cases place small terms after a large term in 1 accumulator lane. The fp16_overflow cases overflow 16-bit float products or lane sums while keeping inputs representable.

Similarity mappings (SM). The sim_saturation construction pairs 0 and small positive squared distances DD whose 32-bit float similarity scores 1/(1+D)1/(1+D) both become 1. For exp_similarity, distinct distances produce 32-bit float similarity scores exp⁡(−D)\exp(-\sqrt{D}) that underflow to 0.

Input representation (IR). For decimal_ingest, we search for distinct 32-bit float coordinates that serialize to identical 7-significant-digit text. The serialization erases the distinction at an exact-match boundary.

Packing and ground truth. We pack the candidate sets into 1 shared base collection. Where coordinate positions are available, we give a query and its candidates shared values at those positions to separate them from other candidate sets. These values cancel in direct coordinate differences but still participate in norm-dot-product evaluation, so validation uses the complete vectors. Every finite 32-bit float coordinate is an integer multiple of 2−1492^{-149}. Squared distances can therefore be compared using exact integer arithmetic in units of 2−2982^{-298}. We check the ground-truth sets against the shared collection and independently verify them using exact rational arithmetic to ensure that other candidate sets do not change a query’s top-10 result set.

Coverage and selection. Constructions vary target precision, scale, coordinate position, accumulator layout, candidate count, and identifier placement. We generate cases by formula and search, retaining only those with a strictly positive top-kk boundary gap lost in the targeted floating-point model.

The compact release preserves declared coverage of construction variants, parameter ranges, candidate identifier orders, floating-point model behavior, and numerical endpoints. Selection is independent of measured product outcomes. Category sizes reflect the configurations needed to meet these requirements. For example, the 480 order_disc queries conservatively retain strata for the number and placement of small terms under both candidate identifier orders. The 6 max_sentinel queries cover 1 threshold regime, model behavior, and numerical endpoints. Different parameter settings can produce the same model outcome.

Evaluation

We evaluate 20 libraries and database systems in exact-search or exhaustive-search configurations, with k=10k = 10. We check each configuration’s input conditions and compare its returned neighbor identifiers with the ground-truth sets.

18 configurations search all 22,501 base vectors for all 1,616 queries. Elasticsearch and MariaDB each reject 578 base vectors at ingestion. For these 2 configurations, we search the 21,923 admitted vectors and score the 1,565 applicable queries whose original ground-truth sets remain intact. We retain the remaining 51 queries in the dataset and mark them not applicable for these configurations.

Table 3 reports passed/total query counts by system type and evaluation group, together with the Overall score. All 20 configurations return mathematically incorrect top-kk result sets on AP queries within their scored scopes. RL and ND also expose failures in 17 configurations each. FP and SM each expose failures in 5 configurations, and IR exposes failures in 7.

SystemTypeAPRLNDFPSMIROverall*
Faiss v1.15.124Vector library572/126341/10924/6994/12538/386/1249.0%
scikit-learn v1.9.15Machine learning library1181/1263102/10943/69125/12538/386/1286.5%
SciPy v1.18.16Scientific library1189/1263109/10969/69125/12538/3812/1295.6%
Milvus v3.0.57Vector database829/126340/10968/69125/12538/3812/1264.4%
Qdrant v1.20.18Vector database780/126327/10966/69125/12538/3812/1262.7%
Weaviate v1.40.59Vector database928/126354/10968/69125/12538/3812/1273.8%
LanceDB v0.41.010Vector database767/126344/10968/69125/12538/3812/1266.4%
ClickHouse v26.8.34.1311SQL database798/126334/10965/69125/12538/3812/1266.3%
DuckDB v2.0.012SQL database943/126356/10968/69125/12538/3812/1275.4%
TiDB v8.5.813SQL database870/126357/10968/69125/12538/3812/1273.7%
MariaDB v12.3.3143SQL database1172/126378/7849/49125/12538/3812/1292.5%
pgvector v0.8.715SQL extension958/126356/10968/69125/12538/3812/1274.8%
Elasticsearch v9.5.6163Search engine648/12630/7838/49125/12513/388/1255.8%
OpenSearch v3.9.017Search engine616/12634/10956/6986/1258/388/1248.8%
Apache Solr v10.1.018Search engine592/12634/10956/6986/1258/388/1248.5%
Redis v7.4.719Key-value database829/126344/10968/69125/12538/3812/1267.6%
Dragonfly v2.120Key-value database774/126344/10968/69125/12538/3812/1266.3%
MongoDB v9.0.821Document database584/12632/10947/6964/1258/387/1243.6%
Neo4j v5.26.122Graph database770/12636/10956/6986/1258/388/1254.2%
SurrealDB v4.0.123Multi-model database1163/1263109/10969/69125/12538/3812/1293.1%

Table 3. Evaluation results for 20 configurations. Bold indicates the highest pass rate(s) in each group.

The failure profiles differ substantially across systems. Among the 18 configurations tested on the complete collection, SciPy and SurrealDB fail 74 and 100 queries, respectively, all in AP. Both pass every query in the other 5 groups. OpenSearch, Apache Solr, MongoDB, and Neo4j each fail queries in all 6 groups. The differences are especially clear in RL: scikit-learn passes 102/109 queries, OpenSearch and Apache Solr each pass 4/109, and MongoDB passes 2/109. Elasticsearch also fails all 78 applicable RL queries in its admitted-row collection. MariaDB fails 91 of its 1,565 applicable queries, all in AP.

Failure Analysis

We analyze 1 representative case from each of the 6 groups to explain how numerical errors lead to incorrect search results. For each case, we trace how the error arises, show its effect on the returned neighbors, and discuss how to prevent it.

Arithmetic precision (AP)

Case absorb_129 exposes a distinction lost even in 64-bit floats. Its boundary candidates have exact squared distances R2R^2 and R2+t2R^2+t^2, where R=4155292R=4155292 and t=265/8192t=265/8192. The positive gap t2≈0.001046t^2 \approx0.001046 is smaller than 1/2 of the 64-bit float spacing 0.25 at R2R^2. SciPy v1.18.1’s 4-accumulator distance kernel24 therefore produces the same distance score D^(q,x)\widehat{D}(q,x) for both candidates. Distance probes also return the same unsquared Euclidean distance, RR. The full-collection search selects the farther candidate at the boundary.

The computation has lost the information needed to distinguish the candidates. Changing the rule for breaking computed ties cannot guarantee the correct set. An uncertain boundary comparison needs more accurate evaluation, ultimately exact arithmetic if the distinction remains unresolved.

Range limits (RL)

Case max_sentinel_02 makes Milvus v3.0.5 return 9 neighbors for k=10k = 10. 9 local candidates have distance scores below FLT_MAX. The remaining 2 boundary distance scores round to that finite value. The underlying Knowhere collector initializes empty slots to FLT_MAX and accepts candidates only when their distance scores strictly improve the threshold25. Neither boundary candidate can therefore fill the 10th slot.

Collectors should track occupancy independently of distance scores and admit eligible candidates while slots remain empty. This restores completeness for the finite sentinel collision. Resolving the rounded distance tie still requires an accurate boundary comparison.

Norm-dot-product evaluation (ND)

Case normdot_overflow_17 contains 10 exact copies of the query. Each individual coordinate square is finite in 32-bit float, but their norm sum overflows. Faiss v1.15.1’s BLAS path26 evaluates Eq. (1), producing an indeterminate expression involving infinities even for an exact match. The full-collection search returns 10 invalid identifier slots, omitting every neighbor at distance 0. A local test uses the 11-vector candidate set and a fixed batch of 1,616 query copies. Changing only the dispatch threshold to select direct differences restores all 10 matches with distances of 0.

Direct differences avoid this failure for identical vectors. More generally, nonfinite intermediate results require recomputation with sufficient range. Candidate selection must not silently discard a possible neighbor because its provisional distance is NaN.

16-bit float computation (FP)

Case fp16_underflow_13 isolates product underflow in a 16-bit float model. The inputs are exactly representable in 16-bit float. A nonmatching vector differs from 10 exact query copies by 2−132^{-13} in 1 coordinate. Its squared distance is 2−262^{-26}, below 1/2 of the smallest positive 16-bit float subnormal, 2−242^{-24}. The product rounds to 0, creating a computed tie. The model then includes the nonmatch among its 10 results.

Promoting the operands before multiplication preserves this term in 32-bit float and restores the local top-10 result set. Widening only the accumulator cannot recover a product already rounded to 0. The model isolates underflow during multiplication, before accumulation.

Similarity mappings (SM)

Case sim_saturation_04 has 10 exact query copies and a perturbed candidate with D=9D = 9, 2−56>02^{-56} > 0. This distance survives 32-bit float, but 1+D1 + D rounds to 1. The Lucene v9.11.1 mapping 1/(1+D)1/(1+D) used by Neo4j v5.26.1227 therefore assigns it the same similarity score as a match at distance 0. In the full-collection search, all 10 returned identifiers lie outside the exact-match set, and all have reported similarity score 1. The mapping hides distinct exact distances.

To preserve distance order, selection should retain the unmapped distance and refine uncertain comparisons. Similarity scores may be rounded after the neighbor set has been selected. Reranking only the returned identifiers cannot recover matches already excluded by score saturation.

Input representation (IR)

Case decimal_ingest_05 illustrates information loss before distance evaluation. Its decisive coordinates are 12570212 and 12570213, both exact 32-bit float values. In a serialization test, a serializer retaining 7 significant decimal digits writes both as 1.257021e+07. Parsing this text merges an exact match and a nonmatch, and a search over the parsed vectors returns an incorrect top-10 result set.

Base and query vectors should be transported in binary or decimal text that preserves every 32-bit float value. 9 significant digits suffice with correctly rounded 32-bit float parsing. Our 9-digit serialization test preserves every local coordinate and restores the correct top-10 result set. Wider arithmetic after 7-digit ingestion cannot recover the original distinction.

Protecting True Neighbors

The fixes above address specific errors. To guarantee correct results, a system must also avoid discarding true neighbors during search. If floating-point calculations cannot reliably determine which of 2 candidates is closer, keep both until an exact comparison resolves their order [10]. A tree branch should likewise be skipped only when its vectors are certainly too far away. Recomputing distances for the final kk results cannot recover a true neighbor discarded earlier.

Conclusion

We present Errpedia, a dataset for testing the numerical correctness of exact vector search. It contains 1,616 queries across 21 categories, with unique ground-truth sets verified using exact rational arithmetic. Each of the 20 tested configurations returns mathematically incorrect top-kk result sets for some applicable queries. Errpedia provides reproducible cases for validating implementations, checking benchmark ground truth, and detecting numerical regressions.

Errpedia has 2 main known limitations: it covers only squared Euclidean distance and uses fixed parameters of d=128d = 128 and k=10k = 10. Extending its coverage to other distance measures and parameter settings remains future work.

References

  1. [1]Martin Aumüller, Erik Bernhardsson, and Alexander Faithfull. ANN-Benchmarks: A benchmarking tool for approximate nearest neighbor algorithms. *Information Systems*, 87:101374, 2020.
  2. [2]Ilias Azizi, Karima Echihabi, and Themis Palpanas. Graph-based vector search: An experimental evaluation of the state-of-the-art. *Proc. ACM Manag. Data*, 3(1), February 2025.DOI
  3. [3]Manos Chatzakis, Yannis Papakonstantinou, and Themis Palpanas. DARTH: Declarative recall through early termination for approximate nearest neighbor search. *Proc. ACM Manag. Data*, 3(4), September 2025.DOI
  4. [4]Cheng Chen, Chenzhe Jin, Yunan Zhang, Sasha Podolsky, Chun Wu, Szu-Po Wang, Eric Hanson, Zhou Sun, Robert Walzer, and Jianguo Wang. SingleStore-V: An integrated vector database system in singlestore. *Proc. VLDB Endow.*, 17(12):3772–3785, August 2024.
  5. [5]Matthijs Douze, Alexandr Guzhva, Chengqi Deng, Jeff Johnson, Gergely Szilvasy, Pierre-Emmanuel Mazaré, Maria Lomeli, Lucas Hosseini, and Hervé Jégou. The Faiss library. *IEEE Trans. Big Data*, 12(2):346–361, 2026.
  6. [6]David Goldberg. What every computer scientist should know about floating-point arithmetic. *ACM Computing Surveys*, 23(1):5–48, March 1991.DOI
  7. [7]Guoxin Kang, Zhongxin Ge, Jingpei Hu, Xueya Zhang, Lei Wang, and Jianfeng Zhan. Bigvectorbench: Heterogeneous data embedding and compound queries are essential in evaluating vector databases. *Proc. VLDB Endow.*, 18(5):1536–1550, January 2025.DOI
  8. [9]Hui Li, Tsz Nam Chan, Man Lung Yiu, and Nikos Mamoulis. FEXIPRO: Fast and exact inner product retrieval in recommender systems. In *Proceedings of the 2017 ACM International Conference on Management of Data*, SIGMOD ’17, pages 835–850, New York, NY, USA, 2017. Association for Computing Machinery.DOI
  9. [10]Jonathan Richard Shewchuk. Adaptive precision floating-point arithmetic and fast robust geometric predicates. *Discrete & Computational Geometry*, 18(3):305–363, 1997.DOI
  10. [11]Zeyu Wang, Manos Chatzakis, Qitong Wang, Themis Palpanas, Peng Wang, and Wei Wang. Annie: A learned query cost estimator for graph-based approximate nearest neighbor search. *Proc. VLDB Endow.*, 19(11):3820–3833, September 2026.DOI

Paper details

vlnc:W_g9vurjkq
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 12

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents