Torus.Embeddings.HuggingFace (Torus v0.5.2)
View SourceA wrapper around Hugging Face API. It allows you to generate embeddings using a variety of models available on Hugging Face.
To use it:
Add the following to your
config.exs
:config :torus, embedding_module: Torus.Embeddings.HuggingFace
Add
req
to yourmix.exs
dependencies:def deps do [ {:req, "~> 0.5"} ] end
Add an API token for hugging face to your
runtime.exs
. You can get your token here.config :torus, Torus.Embeddings.HuggingFace, token: System.get_env("HUGGING_FACE_API_KEY")
By default, it uses sentence-transformers/all-MiniLM-L6-v2
model, but you can specify a different model by explicitly passing model
to the config:
config :torus, Torus.Embeddings.HuggingFace, model: "your/model"
See Torus.semantic/5
on how to use this module to introduce semantic search in your application.