FaissStore
features and configurations head to the API reference.
Overview
Integration details
Class | Package | PY support | Version |
---|---|---|---|
FaissStore | @langchain/community | ✅ |
Setup
To use Faiss vector stores, you’ll need to install the@langchain/community
integration package and the faiss-node
package as a peer dependency.
This guide will also use OpenAI embeddings, which require you to install the @langchain/openai
integration package. You can also use other supported embeddings models if you wish.
Credentials
Because Faiss runs locally, you do not need any credentials to use it. If you are using OpenAI embeddings for this guide, you’ll need to set your OpenAI key as well:Instantiation
Manage vector store
Add items to vector store
Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:Merging indexes
Faiss also supports merging existing indexes:Save an index to file and load it again
To persist an index on disk, use the.save
and static .load
methods:
Reading saved files from Python
To enable the ability to read the saved file from LangChain Python’s implementation, you’ll need to install thepickleparser
package.
.loadFromPython
static method:
API reference
For detailed documentation of allFaissStore
features and configurations head to the API reference