Sha256: 9fd1843995e216012be6f9bd6880c56cadf508325f8d319598d4f687288aff16

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

# Hnswlib.rb

[![Build Status](https://github.com/yoshoku/hnswlib.rb/actions/workflows/build.yml/badge.svg)](https://github.com/yoshoku/hnswlib.rb/actions/workflows/build.yml)
[![Gem Version](https://badge.fury.io/rb/hnswlib.svg)](https://badge.fury.io/rb/hnswlib)
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://github.com/yoshoku/hnswlib.rb/blob/main/LICENSE.txt)
[![Documentation](http://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/hnswlib.rb/doc/)

Hnswlib.rb provides Ruby bindings for the [Hnswlib](https://github.com/nmslib/hnswlib)
that implements approximate nearest-neghbor search based on
hierarchical navigable small world graphs.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'hnswlib'
```

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install hnswlib

## Documentation

* [Hnswlib.rb API Documentation](https://yoshoku.github.io/hnswlib.rb/doc/)

## Usage

```ruby
require 'hnswlib'

f = 40 # length of item vector that will be indexed.
t = Hnswlib::Index.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::Index.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.
```

## 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](https://github.com/yoshoku/hnswlib.rb/blob/main/CODE_OF_CONDUCT.md).

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hnswlib-0.1.1 README.md
hnswlib-0.1.0 README.md