Torus.Embeddings.NebulexCache (Torus v0.5.1)
View SourceCaching layer for the embedding module.
A wrapper around Nebulex cache. It allows you to cache the embedding calls in memory, so you save the resources/cost of calling the embedding module multiple times for the same input.
To use it:
Add the following to your
config.exs
:config :torus, cache: Torus.Embeddings.NebulexCache config :torus, Torus.Embeddings.NebulexCache, embedding_module: Torus.Embeddings.PostgresML cache: Nebulex.Cache, otp_name: :your_app, adapter: Nebulex.Adapters.Local, # Other adapter-specific options allocated_memory: 1_000_000_000, # 1GB # Embedding module specific options config :torus, Torus.Embeddings.PostgresML, repo: TorusExample.Repo
Add
nebulex
anddecorator
to yourmix.exs
dependencies:def deps do [ {:nebulex, ">= 0.0.0"}, {:decorator, ">= 0.0.0"} ] end
Add
Torus.Embeddings.NebulexCache
to your supervision tree:def start(_type, _args) do children = [ Torus.Embeddings.NebulexCache ] opts = [strategy: :one_for_one, name: YourApp.Supervisor] Supervisor.start_link(children, opts) end
See the Nebulex documentation for more information on how to configure the cache.
And you're good to go now. As you can see, we can create a chain of embedding modules to compose the embedding process of our choice.
Each of them should implement the Torus.Embedding
behaviour, and we're good to go!
Summary
Functions
A convenience function for retrieving the current generations.
A convenience function for creating new generations.
A convenience function for retrieving the newer generation.
A convenience function for reset the GC timer.
Functions
A convenience function for retrieving the current generations.
A convenience function for creating new generations.
A convenience function for retrieving the newer generation.
A convenience function for reset the GC timer.