faiss-node
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -0,15 +1,58 @@ | ||
/** Searh result object. */ | ||
export interface SearchResult { | ||
/** The disances of the nearest negihbors found, size n*k. */ | ||
distances: number[], | ||
/** The labels of the nearest neighbors found, size n*k. */ | ||
labels: number[] | ||
} | ||
/** | ||
* IndexFlatL2 Index. | ||
* Index that stores the full vectors and performs exhaustive search. | ||
* @param {number} d The dimensionality of index. | ||
*/ | ||
export class IndexFlatL2 { | ||
constructor(dimension: number); | ||
constructor(d: number); | ||
/** | ||
* returns the number of verctors currently indexed. | ||
* @return {numbers} The number of verctors currently indexed. | ||
*/ | ||
ntotal(): number; | ||
/** | ||
* returns the dimensionality of verctors. | ||
* @return {number} The dimensionality of verctors. | ||
*/ | ||
getDimension(): number; | ||
/** | ||
* returns a boolean that indicates whether training is required. | ||
* @return {number} Whether training is required. | ||
*/ | ||
isTrained(): boolean; | ||
/** | ||
* Add n vectors of dimension d to the index. | ||
* Vectors are implicitly assigned labels ntotal .. ntotal + n - 1 | ||
* @param {number[]} x Input matrix, size n * d | ||
*/ | ||
add(x: number[]): void; | ||
/** | ||
* Query n vectors of dimension d to the index. | ||
* return at most k vectors. If there are not enough results for a | ||
* query, the result array is padded with -1s. | ||
* | ||
* @param {number[]} x Input vectors to search, size n * d. | ||
* @param {number} k The number of nearest neighbors to search for. | ||
* @return {SearchResult} Output of the search result. | ||
*/ | ||
search(x: number[], k: number): SearchResult; | ||
/** | ||
* Write index to a file. | ||
* @param {string} fname File path to write. | ||
*/ | ||
write(fname: string): void | ||
/** | ||
* Read index from a file. | ||
* @param {string} fname File path to read. | ||
* @return {IndexFlatL2} The index read. | ||
*/ | ||
static read(fname: string): IndexFlatL2; | ||
} |
{ | ||
"name": "faiss-node", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Node.js bindings for faiss", | ||
@@ -22,3 +22,4 @@ "main": "lib/index.js", | ||
"install": "prebuild-install --runtime napi --verbose || npm run build", | ||
"test": "jest" | ||
"test": "jest", | ||
"doc": "typedoc" | ||
}, | ||
@@ -52,4 +53,5 @@ "repository": { | ||
"cmake-js": "^7.2.1", | ||
"jest": "^29.5.0", | ||
"prebuild": "^11.0.4", | ||
"jest": "^29.5.0" | ||
"typedoc": "^0.23.28" | ||
}, | ||
@@ -56,0 +58,0 @@ "dependencies": { |
# faiss-node | ||
[![NPM Version](https://img.shields.io/npm/v/faiss-node?logo=npm)](https://www.npmjs.com/package/faiss-node) | ||
![Node Version](https://img.shields.io/node/v/faiss-node) | ||
[![Node Version](https://img.shields.io/node/v/faiss-node)](https://github.com/ewfian/faiss-node) | ||
[![Unit Test](https://github.com/ewfian/faiss-node/actions/workflows/unit_test.yml/badge.svg)](https://github.com/ewfian/faiss-node/actions/workflows/unit_test.yml) | ||
[![license](https://img.shields.io/github/license/ewfian/faiss-node)](https://github.com/ewfian/faiss-node) | ||
[![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://ewfian.github.io/faiss-node/) | ||
@@ -19,2 +20,6 @@ | ||
## Documentation | ||
* [faiss-node API Documentation](https://ewfian.github.io/faiss-node/) | ||
## Usage | ||
@@ -40,3 +45,4 @@ | ||
const results = index.search([1, 0], 4); | ||
const k = 4; | ||
const results = index.search([1, 0], k); | ||
console.log(results.labels); // [ 0, 3, 1, 2 ] | ||
@@ -43,0 +49,0 @@ console.log(results.distances); // [ 0, 1, 4, 9 ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23743
170
64
4
9
1