//clika-runtime/io.clika.modelverse/EmbeddingModel
EmbeddingModel
[common]
class EmbeddingModel : PreTrainedModel
A text-embedding model: one vector per text, the same length for every text (Capabilities.embeddingDim), so two texts compare by the cosine of their vectors.
Open it with open from a checkpoint the model library's embedding families claim (a family that declares a vector out of text alone). Hand it texts with embed; the vectors arrive through the listener on the model's own worker thread, one request at a time per model. close frees the weights.
Types
| Name | Summary |
|---|---|
| Companion | [common] object Companion |
Properties
| Name | Summary |
|---|---|
| capabilities | [common] val capabilities: Capabilities What the model takes and gives, read when it opened: Capabilities.embeddingDim is the vectors' length. |
| config | [common] open override val config: PretrainedConfig The checkpoint's identity, read when the model opened. |
Functions
| Name | Summary |
|---|---|
| close | [common] open fun close() Free the model. A running request is canceled first and the call waits for it to return; called from inside a listener callback, the free runs right after that callback's request ends instead. Idempotent. |
| embed | [common] fun embed(text: String, listener: EmbeddingListener): EmbeddingHandle Embed one text: embed over a list of one. [common] fun embed(texts: List<String>, listener: EmbeddingListener): EmbeddingHandle Embed texts. Returns at once; the worker runs the request and calls listener on its thread: EmbeddingListener.onEmbeddings with one vector per text, in the texts' order, then EmbeddingListener.onDone with the EmbeddingReport. A text longer than the model's window is cut to it. |
| residency | [common] open override fun residency(): ResidencyReport What the model holds on each device right now (ResidencyReport); a closed model refuses with ModelverseException. |