Skip to content

Vega

vegaml.load() returns a Vega: one frozen reader, the decision engine, and any heads you have fitted. See the quick start for the shape of a call and an answer.

load

load(repo_or_path: Optional[str] = None, **kw) -> Vega

Load a checkpoint.

With no argument you get the 0.8B, which is the default and the one every published figure measures. load("4b") gets the 4B from the same repository. Anything else is treated as a Hub repository id or a local path. See :meth:Vega.from_pretrained for the other arguments.

Vega

Vega(engine, mode: str = 'auto', band: Optional[Band] = None)

A loaded checkpoint, with both readouts over one set of frozen features.

mode sets the default readout for :meth:decide; "auto" unless you change it.

from_pretrained classmethod

from_pretrained(
    repo_or_path: Optional[str] = None,
    backbone: Optional[str] = None,
    device: Optional[str] = None,
    adapters: str = "auto",
    mode: str = "auto",
    revision: Optional[str] = None,
    token: Union[str, bool, None] = None,
    max_len: Optional[int] = None,
    quantize: Optional[str] = None,
    threads: Optional[int] = None,
) -> "Vega"

Load a checkpoint from the Hub or from a local directory.

token is optional. Left as None it picks up HF_TOKEN from the environment if one is set, which is what makes a private or gated repository load; with nothing set, the public checkpoints load anonymously as before. Pass token=False to ignore the environment.

quantize="int8" loads the reader with dynamic int8 linear layers: a quarter of the weight bytes, for a box that cannot hold the float reader. CPU only, and both what it costs in latency and what it costs in agreement with the float reader are measured rather than assumed; see docs/cpu.md.

threads is the setting that matters on a CPU box, and the right value belongs to the reader. On the shipped Qwen3.5 readers one thread measured 4.9x faster than torch's default of four, with identical answers, because their linear-attention layers run a reference implementation on CPU that does not thread; a plain-transformer reader preferred four on the same box. bench/cpu_path.py sweeps it, docs/cpu.md has our numbers.

set_band

set_band(band) -> 'Vega'

Set the review band every :meth:decide routes against, or None to clear it.

Takes a :class:vegaml.band.Band, a {question_id: threshold} mapping, or one number used as the line for every question. The band marks each answer "auto" or "review" by its confidence, which is the only escalation signal that covers a TTT head (those answers carry no conformal set and no abstain flag at all) and the only one that fires on an engine answer whose conformal set cannot be empty.

features

features(state, question: Mapping)

Pooled frozen features for one (state, question): what both readouts see.

fit

fit(
    examples: Sequence[Tuple],
    questions: Mapping,
    folds: int = 5,
    min_examples: int = 6,
    progress=None,
) -> Dict[str, Dict]

Fit one TTT head per question from labelled examples.

examples is a sequence of (state, {question_id: label}), or (state, {question_id: label}, {question_id: question}) when the question itself differs between examples. The third element matters more often than it looks: a head reads the features of the whole prompt, so if what distinguishes your examples sits in a question's instructions rather than in the state, as it does in most intent classification, then reusing one question for every example hands them all an identical prompt, identical features, and a head fitted on noise. Pass the per-example question and that cannot happen.

Fitting reads the frozen backbone once per example for the head and, when the head beats chance, scores the engine on the same cross-validated examples to check whether mode="auto" should switch. That is seconds on a GPU for a few dozen examples, and it is paid once.

A head whose cross-validated accuracy is at or below chance is not kept: it has learned nothing, and serving it would dress noise up as a sharper answer. A head that beats chance is kept for deliberate mode="ttt", and mode="auto" uses it only when its cross-validated accuracy also beats the engine's own accuracy on the same examples.

progress is called as progress(stage, question_id, done, total) while the rows are read, where stage is "features" or "engine". It exists because reading the rows is the whole cost and it takes minutes: anything with a progress bar in front of a user needs to know how far along it is, and the alternative is a bar that sits at zero for the longest part of the job.

decide

decide(
    state,
    questions: Mapping,
    mode: Optional[str] = None,
    alpha: str = "0.1",
    views: int = 1,
    review_below: Optional[float] = None,
) -> Dict

Answer every question from one read of the state.

With mode="auto", the default, each question is answered by its head when it has one worth using and by the engine otherwise, and every answer carries readout saying which. Fit nothing and this is the engine's own result, unchanged. With "engine" it is always the engine's. With "ttt" every answer comes from a fitted head, and a question without one is an error rather than a silent fall back. With "both" the result carries answers (engine) and ttt side by side.

Every mode returns latency_ms, n_tokens and views. A head reads the frozen backbone too, one pass per question, so its time and tokens are counted with the engine's.

review_below is a one-call review band, overriding :meth:set_band for this call: every answer whose confidence falls below it comes back route="review".

decide_image

decide_image(
    image,
    questions: Mapping,
    mode: Optional[str] = None,
    alpha: str = "0.1",
    risk=None,
    **kw,
) -> Dict

The same typed interface over a picture, through the backbone's frozen vision encoder.

The vision tower is loaded on first use, so a text-only caller never pays for it. The image path runs the engine, so it answers in "engine" shape whatever mode says: a TTT head reads text features and has nothing to say about pixels. Every answer is marked readout: "engine" so a caller reading a mixed result is not misled.

image is a PIL Image, a path to one, or an HxWx3 numpy array.

decide_image_text

decide_image_text(image, questions: Mapping, **kw) -> Dict

Parity check: answer the same questions through the vision path with the image withheld.

Useful for measuring what the picture itself contributed, the way the README's MMMU-Pro "image withheld" row was measured.

decide_audio

decide_audio(
    audio,
    questions: Mapping,
    asr: Optional[str] = None,
    language: Optional[str] = None,
    sampling_rate: Optional[int] = None,
    **kw,
) -> Dict

The same typed interface over speech, through a small local transcriber.

Two honest stages rather than one pretend omni-model: a small speech-recognition checkpoint turns the recording into text, and that text is a state :meth:decide already answers. Because the engine sees text, everything the text path has applies unchanged, fitted heads included, which the image path cannot say. The default transcriber is distil-whisper (166M, English); pass asr="openai/whisper-tiny" (39M) for multilingual traffic or asr="UsefulSensors/moonshine-tiny" (27M) for the smallest front end. It is loaded on first use and reused, so a text-only caller never pays for it.

audio is a path to an audio file, raw file bytes, or a float waveform with sampling_rate= said out loud. The response carries transcript and asr, because a decision made on words the caller never saw cannot be audited: a wrong transcript is the transcriber's error, a wrong answer about a correct transcript is ours.

decide_video

decide_video(
    video,
    questions: Mapping,
    frames: int = 4,
    asr: Optional[str] = None,
    language: Optional[str] = None,
    **kw,
) -> Dict

The same typed interface over a clip: the sound track if it carries speech, frames if not.

The sound track is pulled out at 16 kHz and, when it is loud enough to hold speech, transcribed through :meth:decide_audio; if the transcript holds real words the decision is made on it, so heads and calibration apply as for text. Otherwise frames evenly spaced frames are tiled into one picture and decided through :meth:decide_image, the vision tower's zero-shot readout. out["video"] says which path ran and why.

video is a path or raw file bytes. Decoding needs vegaml[video] (PyAV); the frames path also needs vegaml[vision]. See :mod:vegaml._video.

load_policy

load_policy(path, verify=True)

A trained policy (Embedding Studio's .zip or a saved folder) installed on this model.

See :func:vegaml.policy.load_policy; this is that call with this model already loaded.

attach

attach(backbone: str, texts, out_dir: str, **kw) -> Dict

Attach YOUR OWN frozen reader to the universal engine, from your own text.

Self-supervised: the checkpoint's root reader generates the shared-space targets, so no labels and none of the original training data are needed. Writes a complete model dir that :func:load loads like any shipped reader, the engine unchanged byte for byte. Labels enter only through examples= here or :func:calibrate afterwards. See :mod:vegaml._attach for the full story, including the probe prompts and the hardware it takes (in short: enough GPU memory for the new reader itself).