Spectre.Classifier.Encoder (Spectre v0.3.0)

Copy Markdown View Source

Configurable embedding boundary for Spectre classifier artifacts.

Encoder calls are adapter-driven so tests and host applications can inject a fake or hosted embedding provider without changing classifier training or runtime code.

Summary

Functions

Returns the default embedding model used by the lightweight classifier.

Downloads/loads the embedding model and returns its vector dimensions.

Embeds one text value with the loaded model.

Loads the embedding model and returns its vector dimensions.

Types

embedding()

@type embedding() :: [float()]

Functions

default_model()

@spec default_model() :: String.t()

Returns the default embedding model used by the lightweight classifier.

download(model \\ "intfloat/multilingual-e5-small", opts \\ [])

@spec download(
  String.t(),
  keyword()
) :: {:ok, pos_integer()} | {:error, term()}

Downloads/loads the embedding model and returns its vector dimensions.

{:ok, dimensions} = Spectre.Classifier.Encoder.download()

embed(text, opts \\ [])

@spec embed(
  String.t(),
  keyword()
) :: {:ok, embedding()} | {:error, term()}

Embeds one text value with the loaded model.

{:ok, vector} = Spectre.Classifier.Encoder.embed("hello")

load(model \\ "intfloat/multilingual-e5-small", opts \\ [])

@spec load(
  String.t(),
  keyword()
) :: {:ok, pos_integer()} | {:error, term()}

Loads the embedding model and returns its vector dimensions.

{:ok, dimensions} = Spectre.Classifier.Encoder.load("intfloat/multilingual-e5-small")