Ragex.Embeddings.Registry (Ragex v0.13.0)

View Source

Registry of available embedding models with metadata.

Provides model definitions, metadata, and lookup functions for different embedding models that can be used with Ragex.

Summary

Functions

Returns all available models.

Lists models by type.

Checks if two models are compatible (same dimensions).

Returns the default model ID.

Gets dimension count for a model.

Finds a model by repository name.

Gets a model by ID.

Gets a model by ID, raises if not found.

Returns model recommendations as a formatted string.

Validates if a model ID is valid.

Types

model_id()

@type model_id() :: atom()

model_info()

@type model_info() :: %{
  id: model_id(),
  name: String.t(),
  repo: String.t(),
  dimensions: pos_integer(),
  max_tokens: pos_integer(),
  description: String.t(),
  type: :sentence_transformer | :code_model | :multilingual,
  recommended_for: [String.t()]
}

Functions

all()

@spec all() :: [model_info()]

Returns all available models.

by_type(type)

@spec by_type(:sentence_transformer | :code_model | :multilingual) :: [model_info()]

Lists models by type.

Examples

iex> Registry.by_type(:code_model)
[%{id: :codebert_base, ...}]

compatible?(model_id1, model_id2)

@spec compatible?(model_id(), model_id()) :: boolean()

Checks if two models are compatible (same dimensions).

default()

@spec default() :: model_id()

Returns the default model ID.

dimensions(model_id)

@spec dimensions(model_id()) :: {:ok, pos_integer()} | {:error, :not_found}

Gets dimension count for a model.

find_by_repo(repo)

@spec find_by_repo(String.t()) :: {:ok, model_info()} | {:error, :not_found}

Finds a model by repository name.

Examples

iex> Registry.find_by_repo("sentence-transformers/all-MiniLM-L6-v2")
{:ok, %{id: :all_minilm_l6_v2, ...}}

get(model_id)

@spec get(model_id()) :: {:ok, model_info()} | {:error, :not_found}

Gets a model by ID.

Examples

iex> Registry.get(:all_minilm_l6_v2)
{:ok, %{id: :all_minilm_l6_v2, ...}}

iex> Registry.get(:invalid)
{:error, :not_found}

get!(model_id)

@spec get!(model_id()) :: model_info()

Gets a model by ID, raises if not found.

recommendations()

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

Returns model recommendations as a formatted string.

valid?(model_id)

@spec valid?(model_id()) :: boolean()

Validates if a model ID is valid.