Add faiss-node-native as async alternative vector store for FAISS
anupammaurya
·
2026-04-20
·
via LangChain Forum - Latest posts
Summary I’m the maintainer of faiss-node-native ( @faiss-node /native on npm), a high-performance async Node.js native binding for Facebook FAISS. I’d like to propose adding it as an alternative to the existing faiss-node integration in LangChain.js. Problem with current faiss-node integration The current LangChain.js FAISS vector store uses faiss-node which has a synchronous blocking API it freezes the Node.js event loop during search. In production servers handling concurrent requests, this causes significant performance degradation and unresponsive APIs. See this open issue for reference: github.com/langchain-ai/langchainjs Could not import faiss-node (NextJS) when loading from python opened 04:58PM - 15 Jan 24 UTC closed 09:32PM - 17 Jan 24 UTC Simbaclaws Hi, I know this is a duplicate of: https://github.com/langchain-ai/langchainj … s/issues/2107 However, in that issue it says that this has been resolved. While I'm on the latest release: 0.1.2 Which should have the fix for this available here: https://github.com/langchain-ai/langchainjs/pull/2178 My issue is the following: https://github.com/langchain-ai/langchainjs/issues/2107#issuecomment-1891106038 For reference, I'll post it below: Hi there, I'm getting the same type of error message in my console when I try to: ```javascript const vectorstore = await FaissStore.loadFromPython("./knowledge", new OpenAIEmbeddings({ modelName: "text-embedding-ada-002" })); ``` knowledge is a folder in the root folder that includes 2 files: ``` index.pkl index.faiss ``` I am using the following to see whether my API route in nextjs can reach the files: ```javascript const knowledge = path.resolve('./knowledge'); const filenames = fs.readdirSync(knowledge); console.log(filenames); ``` this logs the actual filenames, so I know they're there... I'm getting the following error message in my console: ``` Error: Could not import faiss-node. Please install faiss-node as a dependency with, e.g. `npm install -S faiss-node`. Error: Cannot read properties of undefined (reading 'indexOf') at FaissStore.importFaiss (webpack-internal:///(rsc)/./node_modules/@langchain/community/dist/vectorstores/faiss.js:363:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async readIndex (webpack-internal:///(rsc)/./node_modules/@langchain/community/dist/vectorstores/faiss.js:292:37) at async Promise.all (index 1) at async FaissStore.loadFromPython (webpack-internal:///(rsc)/./node_modules/@langchain/community/dist/vectorstores/faiss.js:295:32) at async POST (webpack-internal:///(rsc)/./app/api/chat/route.ts:56:29) at async D:\Development\Persoonlijk\gpt-creator\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:63251 ``` I'm running this on windows with ```npm run dev``` I've already tried installing the package, but I have no clue why my nextjs isn't importing the files... My node version is 20.10.0 Is there anything I can do to get this issue sorted? It says read properties of undefined (reading 'indexOf') This to me indicates it can not read the ./knowledge folder with files for some reason. But I haven't been able to figure out why yet. I could be totally wrong here though. What faiss-node-native offers Fully async Promise-based API — never blocks the event loop Thread-safe concurrent operations with mutex protection HNSW index support (not available in faiss-node) Buffer serialization — store indexes in Redis/MongoDB Multiple index types: FLAT_L2, IVF_FLAT, HNSW Full TypeScript support Actively maintained (v0.1.5, 103 commits) Links GitHub: GitHub - anupammaurya6767/faiss-node-native · GitHub npm: https://npmjs.com/package/@faiss-node/native Docs: @faiss-node/native Documentation Blog post explaining the problem in detail: Building High-Performance Vector Search in Node.js with FAISS — Without Blocking the Event Loop - DEV Community Proposal Two possible approaches: Add faiss-node-native as a drop-in alternative alongside existing faiss-node support I can submit a PR implementing the integration if the team is open to it Happy to help with implementation! 1 post - 1 participant Read full topic
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。