diff --git a/docs/extras/integrations/vectorstores/faiss.ipynb b/docs/extras/integrations/vectorstores/faiss.ipynb index b2f75811ae..e03dd0e7d4 100644 --- a/docs/extras/integrations/vectorstores/faiss.ipynb +++ b/docs/extras/integrations/vectorstores/faiss.ipynb @@ -249,6 +249,36 @@ "docs[0]" ] }, + { + "cell_type": "markdown", + "id": "30c8f57b", + "metadata": {}, + "source": [ + "# Serializing and De-Serializing to bytes\n", + "\n", + "you can pickle the FAISS Index by these functions. If you use embeddings model which is of 90 mb (sentence-transformers/all-MiniLM-L6-v2 or any other model), the resultant pickle size would be more than 90 mb. the size of the model is also included in the overall size. To overcome this, use the below functions. These functions only serializes FAISS index and size would be much lesser. this can be helpful if you wish to store the index in database like sql." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d8faead5", + "metadata": {}, + "outputs": [], + "source": [ + "pkl = db.serialize_to_bytes() # serializes the faiss index" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e36e220b", + "metadata": {}, + "outputs": [], + "source": [ + "db = FAISS.deserialize_from_bytes(pkl) # Load the index" + ] + }, { "cell_type": "markdown", "id": "57da60d4", @@ -491,7 +521,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.9.17" } }, "nbformat": 4,