WorksComputer Science
Errpedia: Is Your Exact -NN Vector Search Really Exact?
Abstract
Exact -nearest-neighbor (-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- 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 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 -nearest-neighbor (-NN) vector search returns the 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 be a collection of -dimensional vectors and 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 . Unless otherwise stated, distance refers to this measure. For , contains the nearest members of , with identifiers breaking exact ties. Errpedia uses and a strictly positive top- boundary gap, making membership in 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 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 in floating point produces a computed distance score 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- boundary can change the returned set. Wider arithmetic can reduce errors but does not certify the order.
Cancellation. An equivalent expression is
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- by these scores can lose distinctions preserved by the distance computation and select a farther candidate from a computed tie.
Candidate handling. Top- 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 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.
| Category | Queries | Category | Queries |
| Arithmetic precision (AP) | Norm-dot-product evaluation (ND) | ||
sub | 58 | normdot_cancel | 49 |
sq_round | 59 | normdot_overflow | 20 |
absorb | 150 | Similarity mappings (SM) | |
order_disc | 480 | sim_saturation | 30 |
neartie | 405 | exp_similarity | 8 |
collision_ladder | 83 | Input representation (IR) | |
sqrt | 28 | decimal_ingest | 12 |
| Range limits (RL) | 16-bit float computation (FP) | ||
sq_underflow | 50 | fp16_term | 14 |
sq_subnormal | 28 | fp16_underflow | 96 |
overflow_inf | 19 | fp16_absorb | 6 |
diff_overflow | 6 | fp16_overflow | 9 |
max_sentinel | 6 |
Table 2. Query counts by category.
The Errpedia Dataset
Specification
Errpedia contains a vector collection with members and a query collection with , , and . All coordinates are finite 32-bit float values. Each query defines a test case over with a unique ground-truth top-10 result set as defined in § 2. The 21 categories form 6 evaluation groups (Table 1).
| Group (code) | Categories | Queries |
| Arithmetic precision (AP) | 7 | 1,263 |
| Range limits (RL) | 5 | 109 |
| Norm-dot-product evaluation (ND) | 2 | 69 |
| 16-bit float computation (FP) | 4 | 125 |
| Similarity mappings (SM) | 2 | 38 |
| Input representation (IR) | 1 | 12 |
| Total | 21 | 1,616 |
Table 1. Evaluation groups in Errpedia.
Contents. The release stores 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 , let contain its categories with applicable, executed queries, and let be the number of these queries that pass in category . The group score is
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 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 whose 32-bit float similarity scores both become 1. For exp_similarity, distinct distances produce 32-bit float similarity scores 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 . Squared distances can therefore be compared using exact integer arithmetic in units of . 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- 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 . 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- 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.
| System | Type | AP | RL | ND | FP | SM | IR | Overall* |
| Faiss v1.15.124 | Vector library | 572/1263 | 41/109 | 24/69 | 94/125 | 38/38 | 6/12 | 49.0% |
| scikit-learn v1.9.15 | Machine learning library | 1181/1263 | 102/109 | 43/69 | 125/125 | 38/38 | 6/12 | 86.5% |
| SciPy v1.18.16 | Scientific library | 1189/1263 | 109/109 | 69/69 | 125/125 | 38/38 | 12/12 | 95.6% |
| Milvus v3.0.57 | Vector database | 829/1263 | 40/109 | 68/69 | 125/125 | 38/38 | 12/12 | 64.4% |
| Qdrant v1.20.18 | Vector database | 780/1263 | 27/109 | 66/69 | 125/125 | 38/38 | 12/12 | 62.7% |
| Weaviate v1.40.59 | Vector database | 928/1263 | 54/109 | 68/69 | 125/125 | 38/38 | 12/12 | 73.8% |
| LanceDB v0.41.010 | Vector database | 767/1263 | 44/109 | 68/69 | 125/125 | 38/38 | 12/12 | 66.4% |
| ClickHouse v26.8.34.1311 | SQL database | 798/1263 | 34/109 | 65/69 | 125/125 | 38/38 | 12/12 | 66.3% |
| DuckDB v2.0.012 | SQL database | 943/1263 | 56/109 | 68/69 | 125/125 | 38/38 | 12/12 | 75.4% |
| TiDB v8.5.813 | SQL database | 870/1263 | 57/109 | 68/69 | 125/125 | 38/38 | 12/12 | 73.7% |
| MariaDB v12.3.3143 | SQL database | 1172/1263 | 78/78 | 49/49 | 125/125 | 38/38 | 12/12 | 92.5% |
| pgvector v0.8.715 | SQL extension | 958/1263 | 56/109 | 68/69 | 125/125 | 38/38 | 12/12 | 74.8% |
| Elasticsearch v9.5.6163 | Search engine | 648/1263 | 0/78 | 38/49 | 125/125 | 13/38 | 8/12 | 55.8% |
| OpenSearch v3.9.017 | Search engine | 616/1263 | 4/109 | 56/69 | 86/125 | 8/38 | 8/12 | 48.8% |
| Apache Solr v10.1.018 | Search engine | 592/1263 | 4/109 | 56/69 | 86/125 | 8/38 | 8/12 | 48.5% |
| Redis v7.4.719 | Key-value database | 829/1263 | 44/109 | 68/69 | 125/125 | 38/38 | 12/12 | 67.6% |
| Dragonfly v2.120 | Key-value database | 774/1263 | 44/109 | 68/69 | 125/125 | 38/38 | 12/12 | 66.3% |
| MongoDB v9.0.821 | Document database | 584/1263 | 2/109 | 47/69 | 64/125 | 8/38 | 7/12 | 43.6% |
| Neo4j v5.26.122 | Graph database | 770/1263 | 6/109 | 56/69 | 86/125 | 8/38 | 8/12 | 54.2% |
| SurrealDB v4.0.123 | Multi-model database | 1163/1263 | 109/109 | 69/69 | 125/125 | 38/38 | 12/12 | 93.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 and , where and . The positive gap is smaller than 1/2 of the 64-bit float spacing 0.25 at . SciPy v1.18.1’s 4-accumulator distance kernel24 therefore produces the same distance score for both candidates. Distance probes also return the same unsquared Euclidean distance, . 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 . 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 in 1 coordinate. Its squared distance is , below 1/2 of the smallest positive 16-bit float subnormal, . 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 , . This distance survives 32-bit float, but rounds to 1. The Lucene v9.11.1 mapping 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 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- 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 and . Extending its coverage to other distance measures and parameter settings remains future work.
References
- [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]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]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]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]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]David Goldberg. What every computer scientist should know about floating-point arithmetic. *ACM Computing Surveys*, 23(1):5–48, March 1991.DOI
- [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
- [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
- [10]Jonathan Richard Shewchuk. Adaptive precision floating-point arithmetic and fast robust geometric predicates. *Discrete & Computational Geometry*, 18(3):305–363, 1997.DOI
- [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