Skip to content
axxbetadocs
nextv0.2.26
GitHub
These are the docs of main, not released yet. See the docs of v0.2.26, the latest release.

Core

View .mdOpen in Claude

Stub the models your apps and services run themselves (embedded models): an image classifier on a phone, a model a service loads with ONNX Runtime. A stub is a model in the real one’s format, with its inputs and outputs, whose answers are its mappings: the app’s runtime loads it as it loads the real model, and an input like one of the mappings’ gets that mapping’s answer. A stub is a few kilobytes and answers at once, the same every time, where a real model fills a simulator’s or an emulator’s memory and answers as it likes. Models a service reaches over HTTP are WireMock’s: see the model mocks of the WireMock image.

A stub’s directory has its model’s contract, contract.json, what the app relies on from the model: axx models contract <model> writes it from the real model, once, and the project keeps it, so no test needs the real model. Its mappings folder has the mappings, as WireMock’s has its stubs: each JSON file a mapping, or several under mappings. A mapping’s input is a picture (image) or a tensor’s values (tensor), and its output the answer, in the terms of the model’s task (a classifier’s label and score) or as the outputs’ values (tensors). An input matches the mapping whose input it is most like, when it is alike enough (the contract’s match.similarity), and the default mapping ("default": true) answers the others.

axx models build <stub> -o <file> writes the stub, which the app’s test build ships in place of the real model: an Android app’s test assets, an iOS app’s test target, a service’s test image. Stubs are written in the real model’s format: ONNX, TFLite (LiteRT), Core ML, ExecuTorch, TensorFlow (SavedModel and TensorFlow.js), Keras, TorchScript, MNN, ncnn, OpenVINO, GGUF (llama.cpp), safetensors (transformers), LiteRT-LM, CTranslate2 (faster-whisper), whisper.cpp and OpenAI Whisper; Tesseract; Piper; and Apple’s Foundation Models, whose stub is a Swift type an app’s test build gives its sessions. A pack adds formats, tasks and kinds of input of its own: see the stubs guide.

Add it to a project with axx pack add models-core.

When the {word} app's microphone hears the {string} file

The app’s microphone hears a recording (a WAV file). Recordings wait, in order, until the app listens: the app’s platform speech stub answers the mapping the recording matches (Axx matches it as the stub’s keys were made), and a web page’s own microphone (getUserMedia) records it. The file’s name selects no answer.

Parameter Takes For example
{word} one word, with no spaces parcels, PX-4101
{string} text in double or single quotes, which the step leaves out "Get a quote", 'Express'

Example:

When the courier app's microphone hears the "recordings/door.wav" file

Since 0.2.0.

Then [[within {duration} ]]the {word} app's speaker plays the {string} file

Check that the app has spoken a recording (a WAV file): an utterance of its speech has the recording’s sound. The app speaks with a voice stub, which speaks a mapping’s recording for a text that has the mapping’s key: the file is the recording the app’s words are spoken as. The app’s platform pack hears its speech (models-linux: speech-dispatcher’s, in the desktops Axx runs; models-windows: SAPI’s). The check waits for it: 10 seconds, or within {duration}.

Parameter Takes For example
{duration} a duration in seconds (s) or minutes (m) 5s, 2m
{word} one word, with no spaces parcels, PX-4101
{string} text in double or single quotes, which the step leaves out "Get a quote", 'Express'

Variants, the parts in [[...]] said or left out:

  • the {word} app's speaker plays the {string} file
  • within {duration} the {word} app's speaker plays the {string} file

Example:

Then within 10s the depot app's speaker plays the "recordings/handover-rules.wav" file

Since 0.2.0.

What the pack adds to Axx’s command line, in a project that uses it.

Command
axx models contract Write a model’s contract, what a stub of it keeps to
axx models build Build a stub, a model of its contract that answers its mappings