Llm4sEmbeddingModel

org.llm4s.springai.Llm4sEmbeddingModel
See theLlm4sEmbeddingModel companion object
@Experimental
final class Llm4sEmbeddingModel(client: JEmbeddingClient) extends EmbeddingModel

An llm4s embedding client as a Spring AI EmbeddingModel (#2278), so a Spring AI vector store or evaluator embeds through any llm4s embedding provider.

EmbeddingModel model = new Llm4sEmbeddingModel(Llm4s.createEmbeddingClient(config).get());
float[] vector = model.embed("hello");

The request's texts are sent in one llm4s request, as documents; its options are not read (the model is the client's own). The response's metadata names the model that answered. A failure throws the LlmException the client's result holds. dimensions() is the model's declared length when its provider module lists it, and otherwise Spring AI's default, which embeds a test string.

Attributes

Companion
object
Source
Llm4sEmbeddingModel.scala
Graph
Supertypes
trait EmbeddingModel
trait Model[EmbeddingRequest, EmbeddingResponse]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def call(request: EmbeddingRequest): EmbeddingResponse

Attributes

Definition Classes
EmbeddingModel -> Model
Source
Llm4sEmbeddingModel.scala
override def dimensions(): Int

A declared length of 0 is none, as the facade reads it.

A declared length of 0 is none, as the facade reads it.

Attributes

Definition Classes
EmbeddingModel
Source
Llm4sEmbeddingModel.scala
override def embed(document: Document): Array[Float]

Attributes

Definition Classes
EmbeddingModel
Source
Llm4sEmbeddingModel.scala

Inherited methods

def embed(x$0: List[Document], x$1: EmbeddingOptions, x$2: BatchingStrategy): List[Array[Float]]

Attributes

Inherited from:
EmbeddingModel
def embed(x$0: List[String]): List[Array[Float]]

Attributes

Inherited from:
EmbeddingModel
def embed(x$0: String): Array[Float]

Attributes

Inherited from:
EmbeddingModel
def embedForResponse(x$0: List[String]): EmbeddingResponse

Attributes

Inherited from:
EmbeddingModel
def getEmbeddingContent(x$0: Document): String

Attributes

Inherited from:
EmbeddingModel