Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Clarify embeddings.save documentation, closes #325

davidmezzettibbae444bdfca
diff --git a/docs/embeddings/indexing.md b/docs/embeddings/indexing.md
index f63137b5..7b0aab5f 100644
--- a/docs/embeddings/indexing.md
+++ b/docs/embeddings/indexing.md
@@ -31,15 +31,31 @@ The `index` call will build a brand new index replacing an existing one. `upsert
## Save
-Indexes don't automatically persist. Indexes can be persisted using the [save](../methods/#txtai.embeddings.base.Embeddings.save) method.
+Indexes can be stored in a directory using the [save](../methods/#txtai.embeddings.base.Embeddings.save) method.
```python
embeddings.save("/path/to/save")
```
+Compressed indexes are also supported.
+
+```python
+embeddings.save("/path/to/save/index.tar.gz")
+```
+
+In addition to saving indexes locally, they can also be persisted to [cloud storage](../configuration#cloud).
+
+```python
+embeddings.save("/path/to/save/index.tar.gz", cloud={...})
+```
+
+This is especially useful when running in a serverless context or otherwise running on temporary compute. Cloud storage is only supported with compressed indexes.
+
Embeddings indexes can be restored using the [load](../methods/#txtai.embeddings.base.Embeddings.load) method.
-In addition to saving indexes locally, they can also be persisted to [cloud storage](../configuration#cloud). This is especially useful when running from a serverless context or otherwise running on temporary compute.
+```python
+embeddings.load("/path/to/load")
+```
## Delete
diff --git a/src/python/txtai/embeddings/base.py b/src/python/txtai/embeddings/base.py
index 51287640..f692547f 100644
--- a/src/python/txtai/embeddings/base.py
+++ b/src/python/txtai/embeddings/base.py
@@ -445,7 +445,8 @@ class Embeddings:
def save(self, path, cloud=None):
"""
- Saves an index.
+ Saves an index in a directory at path unless path ends with tar.gz, tar.bz2, tar.xz or zip.
+ In those cases, the index is stored as a compressed file.
Args:
path: output path