LLMEmbedder

class LLMEmbedder(client: LLMEmbeddingProvider, model: LLModel) : Embedder(source)

Implementation of the Embedder interface that uses Ollama models for embedding text.

Constructors

Link copied to clipboard
constructor(client: LLMEmbeddingProvider, model: LLModel)

Functions

Link copied to clipboard
open override fun diff(embedding1: Vector, embedding2: Vector): Double

Calculates the difference between two embeddings using cosine distance. Cosine distance is defined as 1 - cosine similarity. The result is a value between 0 and 1, where 0 means the embeddings are identical.

Link copied to clipboard
open suspend override fun embed(text: String): Vector

Embeds the given text using the Ollama model.