Project

hnswlib

0.0
The project is in a healthy, maintained state
Hnswlib.rb provides Ruby bindings for the Hnswlib.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies
 Project Readme

Hnswlib.rb

Build Status Gem Version License Documentation

Hnswlib.rb provides Ruby bindings for the Hnswlib that implements approximate nearest-neghbor search based on hierarchical navigable small world graphs.

Installation

Add this line to your application's Gemfile:

gem 'hnswlib'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install hnswlib

Documentation

Usage

require 'hnswlib'

f = 40 # length of item vector that will be indexed.
t = Hnswlib::HnswIndex.new(n_features: f, max_item: 1000)

1000.times do |i|
  v = Array.new(f) { rand }
  t.add_item(i, v)
end

t.save('test.ann')

u = Hnswlib::HnswIndex.new(n_features: f, max_item: 1000)
u.load('test.ann')
p u.get_nns_by_item(0, 100) # will find the 100 nearest neighbors.

License

The gem is available as open source under the terms of the Apache-2.0 License.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/hnswlib.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.