type ProgressCallback = (completed: number, total: number) => boolean | void The same verbs run on the calling thread with no receiver, and block on an executor through on:
const here = model.textEncode(["a small red panda"], arena);
const there = model.on(executor).textEncode(["a small red panda"], arena);API
Types
ProgressCallbackHears a long call's advance; answering false stops it with cancelled.
MoodWhat an executor does with its threads or streams once it goes idle.
enum Mood Values
Parked | "parked" | Idle threads sleep; the next call pays a wake-up. |
|---|---|---|
Spinning | "spinning" | Idle threads stay hot, trading power for the next call's latency. |
AnswerHow a receiver hands back what its verbs answer: as is, or as a Deferred of it.
type Answer<Receiving, Answered> = Receiving extends "deferred" ? Deferred<Answered> : Answered ClassModelOnThe verbs of one model, blocking on one executor: model.on(executor).10
class ModelOn extends ModelVerbs<"blocking"> Every call starts after every earlier submission to that executor, and returns with its outputs written.
ModelOnMade by model.on(executor), never directly.
new ModelOn(
compiled: CompiledModel,
executor: Executor | undefined,
) *× 2Reports the model's geometry and placement in one call.
Inherited from ModelVerbs
describe(): Answer<Receiving, ModelDescription> Calls uform_model_describe.
text*× 2Encodes texts through one forward; every UTF-8 byte is a token.
Inherited from EncodeVerbs
textEncode(
texts: readonly (string | Uint8Array)[] | Tape<Uint8Array>,
arena: Arena,
config: EncodeConfig = {},
): Answer<Receiving, Encoded> Calls uform_text_encode.
Parameters
textsreadonly (string | Uint8Array)[] | Tape<Uint8Array> | Strings, UTF-8 bytes already encoded, or a tape of them. | |
|---|---|---|
arenaArena | The memory the outputs land in, rewound by the call. | |
configEncodeConfig | The surfaces, their scalar, and a progress handler. |
Returns
arena.text*× 2Scores each item's legal choices through one forward, a softmax over them alone at the item's group's calibrated inverse temperature; a model without the byte decoder reports unsupported.
Inherited from EncodeVerbs
textChoose(
texts: readonly (string | Uint8Array)[] | Tape<Uint8Array>,
choices: readonly (string | Uint8Array)[] | Tape<Uint8Array>,
arena: Arena,
config: ChooseConfig = {},
): Answer<Receiving, Chosen> Calls uform_text_choose.
Parameters
textsreadonly (string | Uint8Array)[] | Tape<Uint8Array> | The states, each ending where its choice goes. | |
|---|---|---|
choicesreadonly (string | Uint8Array)[] | Tape<Uint8Array> | Each item's legal choices, one byte each, like "yn". | |
arenaArena | The memory the probabilities land in, rewound by the call. | |
configChooseConfig | The question types and a progress handler. |
Returns
arena.image*× 2Decodes and encodes JPEG, PNG or WebP files; the browser build reports unsupported.
Inherited from EncodeVerbs
imageEncode(
images: readonly Uint8Array[] | Tape<Uint8Array>,
arena: Arena,
config: EncodeConfig = {},
): Answer<Receiving, Encoded> Calls uform_image_encode.
Parameters
imagesreadonly Uint8Array[] | Tape<Uint8Array> | One encoded file per item, or a tape of them. | |
|---|---|---|
arenaArena | The memory the outputs land in, rewound by the call. | |
configEncodeConfig | The surfaces, their scalar, and a progress handler. |
imageEncode*× 2Encodes decoded images, resized on the executor's side.
Inherited from EncodeVerbs
imageEncodePixels(
images: readonly Pixels[],
arena: Arena,
config: EncodeConfig = {},
): Answer<Receiving, Encoded> Calls uform_image_encode_pixels.
Parameters
imagesreadonly Pixels[] | ImageData, or RGB or RGBA bytes with their width and height. | |
|---|---|---|
arenaArena | The memory the outputs land in, rewound by the call. | |
configEncodeConfig | The surfaces, their scalar, and a progress handler. |
video*× 2Decodes and encodes MP4 or WebM clips; the browser build reports unsupported.
Inherited from EncodeVerbs
videoEncode(
videos: readonly Uint8Array[] | Tape<Uint8Array>,
arena: Arena,
config: EncodeConfig = {},
): Answer<Receiving, Encoded> Calls uform_video_encode.
Parameters
videosreadonly Uint8Array[] | Tape<Uint8Array> | One encoded file per item, or a tape of them. | |
|---|---|---|
arenaArena | The memory the outputs land in, rewound by the call. | |
configEncodeConfig | The surfaces, their scalar, and a progress handler. |
audio*× 2Decodes and encodes WAV, FLAC, MP3 or Opus files; the browser build reports unsupported.
Inherited from EncodeVerbs
audioEncode(
recordings: readonly Uint8Array[] | Tape<Uint8Array>,
arena: Arena,
config: EncodeConfig = {},
): Answer<Receiving, Encoded> Calls uform_audio_encode.
Parameters
recordingsreadonly Uint8Array[] | Tape<Uint8Array> | One encoded file per item, or a tape of them. | |
|---|---|---|
arenaArena | The memory the outputs land in, rewound by the call. | |
configEncodeConfig | The surfaces, their scalar, and a progress handler. |
audioEncode*× 2Encodes decoded mono recordings, resampled to the model's rate where sampleRate differs.
Inherited from EncodeVerbs
audioEncodeSamples(
recordings: readonly Float32Array[] | Tape<Float32Array>,
sampleRate: number,
arena: Arena,
config: EncodeConfig = {},
): Answer<Receiving, Encoded> Calls uform_audio_encode_samples.
Parameters
recordingsreadonly Float32Array[] | Tape<Float32Array> | One run of samples per item, or a tape of them. | |
|---|---|---|
sampleRatenumber | Samples per second shared by every recording. | |
arenaArena | The memory the outputs land in, rewound by the call. | |
configEncodeConfig | The surfaces, their scalar, and a progress handler. |
executorThe executor the verbs run on; absent runs them on the calling thread.
ClassModelDeferredOnThe verbs of one model, submitted to one executor and answered as Deferred calls: model.deferred(executor).2
class ModelDeferredOn extends ModelVerbs<"deferred"> A verb borrows its arena until final, and waits into the same views a blocking call answers.
ModelDeferredOnMade by model.deferred(executor), never directly.
new ModelDeferredOn(compiled: CompiledModel, executor: Executor) executorThe executor the verbs run on; absent runs them on the calling thread.
ClassTrainerDeferredOnThe trainer's verbs, submitted to its executor and answered as Deferred (*) calls: trainer.deferred().3
class TrainerDeferredOn extends TrainerVerbs<"deferred"> TrainerDeferredOnMade by trainer.deferred(), never directly.
new TrainerDeferredOn(
compiled: CompiledTrainer,
executor: Executor,
) stepApplies one optimizer step over this process's items and every peer's.
Inherited from TrainerVerbs
step(
batch: TrainerBatch,
config: TrainerStepConfig = {},
): Answer<Receiving, Stepped> Calls uform_trainer_step.
Parameters
batchTrainerBatch | This process's items, their modalities, bags and relations. | |
|---|---|---|
configTrainerStepConfig | Where the scored embeddings land. |
saveWrites the weights and the step as a safetensors checkpoint; only process zero writes.
Inherited from TrainerVerbs
save(path: string): Answer<Receiving, void> Calls uform_trainer_save.
Parameters
pathstring | The destination, written whole and renamed into place. |
|---|
ClassDeferredA call submitted by a deferred receiver, final once its executor finishes it.4
class Deferred<T> implements PromiseLike<T>, Disposable It keeps everything the library reads or writes alive until then - the outcome, the inputs, the
outputs and every handle it names - so none of them is collected under the call. status polls
without blocking, wait blocks and answers, and await runs that wait on the libuv pool; both
answer the same cached result, or throw the same failure, however often they are asked. On the
WebAssembly backend the call is final once submitted.
const encoded = await call; // or: call.wait()
DeferredMade by a verb of a deferred receiver, never directly.
new Deferred(call: CompiledDeferred, answer: (raw: never) => T) waitBlocks the calling thread until the call is final, then answers its result or throws its failure.
thenWaits off the calling thread, which is what await reaches for.
then<Fulfilled = T, Rejected = never>(
onFulfilled?: ((value: T) => Fulfilled | PromiseLike<Fulfilled>) | null,
onRejected?: ((reason: unknown) => Rejected | PromiseLike<Rejected>) | null,
): Promise<Fulfilled | Rejected> Calls uform_outcome_wait on the libuv pool.