Search documentation of Ragex

# Ragex.Embeddings.Behaviour behaviour (Ragex v0.4.0)

View Source

Behavior for embedding generators.

Embedding generators convert text into dense vector representations that can be used for semantic similarity search.

## Summary

### Callbacks

dimensions()

Returns the dimensionality of the embeddings generated by this adapter.

embed(text)

Generates an embedding vector for the given text.

embed_batch(texts)

Generates embeddings for multiple texts in a batch.

## Callbacks

# dimensions()

    @callback dimensions() :: pos_integer()

Returns the dimensionality of the embeddings generated by this adapter.

# embed(text)

    @callback embed(text :: String.t()) :: {:ok, [float()]} | {:error, term()}

Generates an embedding vector for the given text.

Returns `{:ok, embedding}` where embedding is a list of floats, or `{:error, reason}` if embedding generation fails.

# embed_batch(texts)

    @callback embed_batch(texts :: [String.t()]) :: {:ok, [[float()]]} | {:error, term()}

Generates embeddings for multiple texts in a batch.

This can be more efficient than calling `embed/1` multiple times. Returns `{:ok, embeddings}` where embeddings is a list of lists of floats, or `{:error, reason}` if embedding generation fails.