Skip to content

Commit

Permalink
Merge pull request deepset-ai#162 from deepset-ai/faiss_save_load
Browse files Browse the repository at this point in the history
Add Save&Load section under FAISSDocumentStore
  • Loading branch information
ZanSara committed Sep 20, 2021
2 parents 4b2d259 + 2ad8bb0 commit f245ba9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/latest/components/document_store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@ from haystack.document_store import FAISSDocumentStore
document_store = FAISSDocumentStore(faiss_index_factory_str="Flat")
```

#### Save & Load

FAISS document stores can be saved to disk and reloaded:

```python
from haystack.document_store import FAISSDocumentStore

document_store = FAISSDocumentStore(faiss_index_factory_str="Flat")

# Generates two files: my_faiss_index.faiss and my_faiss_index.json
document_store.save("my_faiss_index.faiss")

# Looks for the two files generated above
new_document_store = FAISSDocumentStore.load("my_faiss_index.faiss")

assert new_document_store.faiss_index_factory_str == "Flat"
```

While `my_faiss_index.faiss` contains the index, `my_faiss_index.json`
contains the parameters used to inizialize it (like `faiss_index_factory_store`).
This configuration file is necessary for `load()` to work. It simply contains
the initial parameters in a JSON format.
For example, a hand-written configuration file for the above FAISS index could look like:

```json
{
faiss_index_factory_store: 'Flat'
}
```

<div style={{ marginBottom: "3rem" }} />

### In Memory
Expand Down

0 comments on commit f245ba9

Please sign in to comment.