{"id":17025764,"url":"https://github.com/ewfian/faiss-node","last_synced_at":"2025-10-30T23:29:22.657Z","repository":{"id":149896267,"uuid":"620360914","full_name":"ewfian/faiss-node","owner":"ewfian","description":"Node.js bindings for faiss","archived":false,"fork":false,"pushed_at":"2023-10-15T12:15:01.000Z","size":415,"stargazers_count":136,"open_issues_count":20,"forks_count":17,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-10-03T12:23:42.866Z","etag":null,"topics":["approximate-nearest-neighbor-search","faiss","javascript","machine-learning","nodejs","npm","similarity-search","typescript","underdevelopment"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/faiss-node","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ewfian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-28T14:28:20.000Z","updated_at":"2025-08-29T19:20:22.000Z","dependencies_parsed_at":"2024-06-18T15:22:28.566Z","dependency_job_id":"f177262b-b3ae-4d70-96c0-86161b0bc172","html_url":"https://github.com/ewfian/faiss-node","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/ewfian/faiss-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewfian%2Ffaiss-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewfian%2Ffaiss-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewfian%2Ffaiss-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewfian%2Ffaiss-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ewfian","download_url":"https://codeload.github.com/ewfian/faiss-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewfian%2Ffaiss-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281898418,"owners_count":26580527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["approximate-nearest-neighbor-search","faiss","javascript","machine-learning","nodejs","npm","similarity-search","typescript","underdevelopment"],"created_at":"2024-10-14T07:29:58.178Z","updated_at":"2025-10-30T23:29:22.613Z","avatar_url":"https://github.com/ewfian.png","language":"C++","readme":"# faiss-node\n[![NPM Version](https://img.shields.io/npm/v/faiss-node?logo=npm)](https://www.npmjs.com/package/faiss-node)\n[![Node Version](https://img.shields.io/node/v/faiss-node)](https://github.com/ewfian/faiss-node)\n[![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)\n[![License](https://img.shields.io/github/license/ewfian/faiss-node)](https://github.com/ewfian/faiss-node)\n[![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://ewfian.github.io/faiss-node/)\n\n\nfaiss-node provides Node.js bindings for [faiss](https://github.com/facebookresearch/faiss)\n\n_**This package is in a very early stage of development.**_\n\n\n## Installation\n\n```sh\n$ npm install faiss-node\n```\n\n## Documentation\n\n* [faiss-node API Documentation](https://ewfian.github.io/faiss-node/)\n\n## Usage\n\n```javascript\nconst { IndexFlatL2, Index, IndexFlatIP, MetricType } = require('faiss-node');\n\nconst dimension = 2;\nconst index = new IndexFlatL2(dimension);\n\nconsole.log(index.getDimension()); // 2\nconsole.log(index.isTrained()); // true\nconsole.log(index.ntotal()); // 0\n\n// inserting data into index.\nindex.add([1, 0]);\nindex.add([1, 2]);\nindex.add([1, 3]);\nindex.add([1, 1]);\n\nconsole.log(index.ntotal()); // 4\n\nconst k = 4;\nconst results = index.search([1, 0], k);\nconsole.log(results.labels); // [ 0, 3, 1, 2 ]\nconsole.log(results.distances); // [ 0, 1, 4, 9 ]\n\n// Save index\nconst fname = 'faiss.index';\nindex.write(fname);\n\n// Load saved index\nconst index_loaded = IndexFlatL2.read(fname);\nconsole.log(index_loaded.getDimension()); //2\nconsole.log(index_loaded.ntotal()); //4\nconst results1 = index_loaded.search([1, 1], 4);\nconsole.log(results1.labels); // [ 3, 0, 1, 2 ]\nconsole.log(results1.distances); // [ 0, 1, 1, 4 ]\n\n// Merge index\nconst newIndex = new IndexFlatL2(dimension);\nnewIndex.mergeFrom(index);\nconsole.log(newIndex.ntotal()); // 4\n\n// Remove items\nconsole.log(newIndex.search([1, 2], 1)); // { distances: [ 0 ], labels: [ 1 ] }\nconst removedCount = newIndex.removeIds([0]);\nconsole.log(removedCount); // 1\nconsole.log(newIndex.ntotal()); // 3\nconsole.log(newIndex.search([1, 2], 1)); // { distances: [ 0 ], labels: [ 0 ] }\n\n// IndexFlatIP\nconst ipIndex = new IndexFlatIP(2);\nipIndex.add([1, 0]);\n\n// Serialize an index\nconst index_buf = newIndex.toBuffer();\nconst deserializedIndex = Index.fromBuffer(index_buf);\nconsole.log(deserializedIndex.ntotal()); // 3\n\n// Factory index\nconst hnswIndex = Index.fromFactory(2, 'HNSW,Flat', MetricType.METRIC_INNER_PRODUCT);\nconst x = [1, 0, 0, 1];\nhnswIndex.train(x);\nhnswIndex.add(x);\n```\n\n## License\n\nMIT","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fewfian%2Ffaiss-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fewfian%2Ffaiss-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fewfian%2Ffaiss-node/lists"}