An open API service indexing awesome lists of open source software.

https://github.com/mybigday/react-native-hnswlib

Hnswlib binding for React Native (WIP)
https://github.com/mybigday/react-native-hnswlib

Last synced: 29 days ago
JSON representation

Hnswlib binding for React Native (WIP)

Awesome Lists containing this project

README

        

# react-native-hnswlib

Hnswlib for React Native

## Installation

```sh
npm install react-native-hnswlib
```

## Usage

```js
import { HierarchicalNSW } from 'react-native-hnswlib';

const numDimensions = 8; // the length of data point vector that will be indexed.
const maxElements = 10; // the maximum number of data points.

const index = new HierarchicalNSW('l2', numDimensions);
index.initIndex(maxElements);

// inserting data points to index.
for (let i = 0; i < maxElements; i++) {
const point = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) point[j] = Math.random();
index.addPoint(point, i);
}

// preparing query data points.
const query = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) query[j] = Math.random();

// searching k-nearest neighbor data points.
const numNeighbors = 3;
const result = index.searchKnn(query, numNeighbors);
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

---






Built and maintained by BRICKS.