Search documentation of Ragex

# Ragex.Embeddings.Registry (Ragex v0.4.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

### Types

model_id()
model_info()

### Functions

all()

Returns all available models.

by_type(type)

Lists models by type.

compatible?(model_id1, model_id2)

Checks if two models are compatible (same dimensions).

default()

Returns the default model ID.

dimensions(model_id)

Gets dimension count for a model.

find_by_repo(repo)

Finds a model by repository name.

get(model_id)

Gets a model by ID.

get!(model_id)

Gets a model by ID, raises if not found.

recommendations()

Returns model recommendations as a formatted string.

valid?(model_id)

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.