FaissStore#
dbally.similarity.FaissStore
#
FaissStore(index_dir: str, index_name: str, embedding_client: EmbeddingClient, max_distance: Optional[float] = None, index_type: IndexFlat = faiss.IndexFlatL2)
Bases: SimilarityStore
The FaissStore class stores text embeddings using Meta Faiss.
Initializes the FaissStore.
PARAMETER | DESCRIPTION |
---|---|
index_dir |
The directory to store the index file.
TYPE:
|
index_name |
The name of the index.
TYPE:
|
max_distance |
The maximum distance between two text embeddings to be considered similar.
TYPE:
|
embedding_client |
The client to use for creating text embeddings.
TYPE:
|
index_type |
The type of Faiss index to use. Defaults to faiss.IndexFlatL2. See Faiss wiki for more information.
TYPE:
|
Source code in src/dbally/similarity/faiss_store.py
get_index_path
#
Returns the path to the index file.
PARAMETER | DESCRIPTION |
---|---|
create |
If True, the directory will be created if it does not exist.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Path
|
The path to the index file.
TYPE:
|
Source code in src/dbally/similarity/faiss_store.py
store
async
#
Stores the data in a faiss index on disk.
PARAMETER | DESCRIPTION |
---|---|
data |
The data to store.
TYPE:
|
Source code in src/dbally/similarity/faiss_store.py
find_similar
async
#
Finds the most similar text in the store or returns None if no similar text is found.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to find similar to.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[str]
|
The most similar text or None if no similar text is found. |