Recollect.Embedding.Local (recollect v0.5.1)

Copy Markdown View Source

Local embedding provider using Bumblebee with sentence-transformers/all-MiniLM-L6-v2.

This is the default embedding provider for Recollect. It runs entirely locally — no API keys or external services required. Model weights are downloaded from HuggingFace Hub on first use and cached on disk.

Requirements

Add to your mix.exs dependencies:

{:bumblebee, "~> 0.6.0"}

Configuration

The local provider is used by default when no other provider is configured. You can explicitly select it:

config :recollect,
  embedding: [
    provider: Recollect.Embedding.Local
  ]

Options can be passed via :local_embedding:

config :recollect, :local_embedding,
  model: "sentence-transformers/all-MiniLM-L6-v2",
  compile: [batch_size: 32, sequence_length: 128]

Overriding with another provider

To use a different embedding provider (e.g. an API-based one), set the :provider key:

config :recollect,
  embedding: [
    provider: Recollect.Embedding.OpenRouter,
    credentials_fn: fn ->
      %{api_key: "...", model: "google/text-embedding-004", dimensions: 768}
    end
  ]

Summary

Functions

Build the Nx.Serving for the embedding model.

Returns the embedding dimensions for the configured model.

The registered name of the Nx.Serving process.

Functions

build_serving()

Build the Nx.Serving for the embedding model.

Called by Recollect.Application during startup. Downloads model weights from HuggingFace Hub on first call (cached afterward).

Returns {:ok, serving} or {:error, reason}.

dimensions()

Returns the embedding dimensions for the configured model.

serving_name()

The registered name of the Nx.Serving process.