From bd6175742370c8e21d07ecbef60c76ce358bf6c9 Mon Sep 17 00:00:00 2001 From: Bal Narendra Sapa <61614290+balnarendrasapa@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:39:40 -0400 Subject: [PATCH] add documentation for serializer function (#8769) Description: Added necessary documentation for serializer functions @baskaryan --- .../integrations/vectorstores/faiss.ipynb | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/extras/integrations/vectorstores/faiss.ipynb b/docs/extras/integrations/vectorstores/faiss.ipynb index b2f75811ae6..e03dd0e7d45 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,