faiss-node icon indicating copy to clipboard operation
faiss-node copied to clipboard

feat: add reconstruct method

Open mikhael-remboski opened this issue 5 months ago • 2 comments

This pull request adds a new reconstruct method to the FAISS index classes, allowing users to retrieve the original vector for a given index key. It also exposes this method to the JavaScript API and provides tests to verify its correctness and error handling.

New API feature: Vector reconstruction

  • Added a reconstruct method to the base class IndexBase, enabling retrieval of the stored vector at a specified key, with validation and error handling. (src/faiss.cc)

  • Exposed the reconstruct method as an instance method on the Index, IndexFlatL2, and IndexFlatIP classes, making it available in the JavaScript API. (src/faiss.cc) [1] [2] [3]

Testing

  • Added a new test suite reconstruct.test.js to verify correct reconstruction of vectors, handling of invalid keys, and compatibility with both IndexFlatL2 and Index classes. (test/reconstruct.test.js)

mikhael-remboski avatar Aug 19 '25 16:08 mikhael-remboski

If this doesn't get merged feel free to use the maintained fork. https://github.com/asilvas/faiss-node/blob/main/README.md?plain=1#L94-L96

asilvas avatar Aug 19 '25 16:08 asilvas

If this doesn't get merged feel free to use the maintained fork. https://github.com/asilvas/faiss-node/blob/main/README.md?plain=1#L94-L96

Thank you, i will

mikhael-remboski avatar Aug 19 '25 17:08 mikhael-remboski