Torus.Embeddings.HuggingFace (Torus v0.4.0)
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.HuggingFaceAdd
reqto yourmix.exsdependencies:def deps do [ {:req, "~> 0.5"} ] endAdd 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.