Using Embeddinghub in Local Mode
Embeddinghub can be used without a backend. If you're interested in running Embeddinghub locally via a Docker container backend check out our section on it, or head over to the quickstart. If you're interested in using Embeddinghub as a better wrapper for embeddings locally, read on.
When connecting or creating an Embeddinghub instance, a LocalConfig can be used instead.
1
import embeddinghub as eh
2
3
hub = eh.connect(LocalConfig("directory"))
Copied!
This version of Embeddinghub works similarly to a traditional Embeddinghub instance in that you can create and get spaces and write and read from them.
1
item_space = hub.create_space("items", 3)
Copied!
One difference is that a local Embeddinghub should be saved to disk when done.
1
hub.save()
Copied!
This is done automatically when used with the with statement
1
with hub as eh.connect(eh.LocalConfig("directory")):
2
pass
Copied!
All spaces and data are loaded into memory and used in-memory. An approximate nearest neighbor index is created using the same algorithm as the backend, so you can expect similar latency and throughput as you would with a local snapshot.
Last modified 16d ago
Copy link