§ Node
Models are tokenizer-free: text arrives as UTF-8 and every byte is a token. An executor owns the threads, a model owns the weights, and an arena owns the outputs, so one executor serves many models and one arena serves a steady loop without allocating.
import { Executor, Arena, Model, Outputs, Scalar, gpuDevices } from "@unum-cloud/uform";
const executor = Executor.forRam();
const arena = new Arena(executor);
const model = Model.loadRam("model.safetensors", { executor });
const encoded = await model.deferred(executor).textEncode(["a small red panda"], arena); // or: call.wait()
const embedding = encoded.embeddings.row(0); // a Float32Array of the model's dimensions§ Browser
The browser build computes on the calling thread, so every call blocks and a deferred receiver answers a call that is already final. Decode media with the platform, through a canvas or the Web Audio API, then hand the pixels and samples to UForm.
import { initialize, Arena, Model } from "@unum-cloud/uform/wasm";
await initialize(); // loads the uform.mjs and uform.wasm the package ships
const model = Model.loadRamBuffer(await (await fetch(url)).arrayBuffer());
const arena = new Arena();
const context = canvas.getContext("2d");
const pixels = context.getImageData(0, 0, canvas.width, canvas.height);
const encoded = model.imageEncodePixels([pixels], arena);
const texts = model.textEncode(["a small red panda"], arena);A bundler that relocates the module passes its factory or URL to initialize.
Encoded media, VRAM, the mesh and the trainer report unsupported in the browser build.