'Rcpp' Bindings for 'hnswlib', a Library for Approximate Nearest Neighbors
Overview
'Hnswlib' is a C++ library for Approximate Nearest Neighbors. This package provides a minimal R interface by relying on the 'Rcpp' package. See https://github.com/nmslib/hnswlib for more on 'hnswlib'. 'hnswlib' is released under Version 2.0 of the Apache License.
New features
- New class:
HnswEuclidean. This uses Euclidean distances internally and will
be returned from hnsw_build when distance = "euclidean" is specified. This
fixes an issue where if you created an index with hnsw_build and
distance = "euclidean" (the default), then after saving, you would be unable
to reload the index and have it find Euclidean distances. You would have to
create it as an HsnwL2 object and take the square root of the distances
yourself (<https://github.com/jlmelville/rcpphnsw/issues/21>).
- The
Hnswconstructors and thehnsw_buildandhnsw_knnfunctions now
expose a random_seed parameter that you can use to set the random seed used
in constructing the HNSW index. If not provided, the the hnswlib default of
100 is used (and should preserve previous behavior). Based on a request by
Show all changes in 0.7.0Hide the rest of the changes in 0.7.0
From NEWS.md in the release
Install
Health
ERRORtestsr-patched-linux-x86_64
Running ‘testthat.R’ [3s/4s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
> library(RcppHNSW)
>
> test_check("RcppHNSW")
Saving _problems/test_parallel-45.R
Saving _problems/test_parallel-46.R
[ FAIL 2 | WARN 0 | SKIP 0 | PASS 81 ]
══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test_parallel.R:45:1'): (code run outside of `test_that()`) ───────
Expected `mean(knn_0$dist - knn_2$dist)` < 1e-04.
Actual comparison: 0.0001025 >= 0.0001000
Difference: 0.0000025 >= 0
── Failure ('test_parallel.R:46:1'): (code run outside of `test_that()`) ───────
Expected `mean(knn_1$dist - knn_2$dist)` < 1e-04.
Actual comparison: 0.0001025 >= 0.0001000
Difference: 0.0000025 >= 0
[ FAIL 2 | WARN 0 | SKIP 0 | PASS 81 ]
Error:
! Test failures.
Execution halted- ERROR12 OK, 1 ERROR2026-10-22
- OK13 OK2026-09-21
- ERROR12 OK, 1 ERROR2026-09-20
- OK13 OK2026-09-08
- ERROR12 OK, 1 ERROR2026-09-07
Show 6 earlier changesHide 6 earlier changes
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK12 OK2026-04-25
- NOTE12 OK, 2 NOTE2026-04-22
- ERROR11 OK, 2 NOTE, 1 ERROR2026-04-18
- NOTE12 OK, 2 NOTE2026-03-10
Documentation
The repository also keeps web-only articles.
- Help pages
- 4includes a package overview page
- Examples that run
- 100%3 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- not tracked
- Return-value docs
- not tracked
- Help pages citing references
- 50%
Downloads
Repository
- PRs merged (all time)
- 96%
- Median days to close, 50 most recently updated closed issues
- 40
- Median days to close, 50 most recently updated closed PRs
- 1
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
Commit identities over time
12 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/jlmelville/rcpphnsw on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-18 · The repository has a site deploy workflow
Show all practicesHide 2 practices
Dependencies
Installing RcppHNSW adds 1 package (1 with compiled code, 1.8 MB of source tarballs). Heaviest: Rcpp 1.8 MB.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- 0.7.0Latest
- 0.6.02024-02-04 · diff ↗
- 0.5.02023-09-19 · diff ↗ ·
removed 6 exports
hnsw_knn, hnsw_build, hnsw_search, HnswL2, HnswCosine, HnswIpadded 1 export
pattern:^[Hh]nsw - RR 4.3.0 released · 2023-04-21
- 0.4.12022-07-18 · diff ↗
- 0.4.02022-07-17 · diff ↗
- RR 4.2.0 released · 2022-04-22
- RR 4.1.0 released · 2021-05-18
- 0.3.02020-09-06 · diff ↗
- RR 4.0.0 released · 2020-04-24
- 0.2.02019-09-20 · diff ↗
- RR 3.6.0 released · 2019-04-26
- 0.1.02019-01-22
Show 1 earlier eventHide 1 earlier event
- RR 3.5.0 released · 2018-04-23
Package metadata
- First published
- 2019-01-22
- Total releases
- 8 / 7 yrs
- License
- GPL (>= 3) OSI
- Download size
- 38 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("RcppHNSW")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.