Skip to main content

Additional examples

The install root ships the Modelverse examples under examples/src. Each is a standalone find_package(Modelverse CONFIG) project on the public API only, each has its own README.md walk-through, and together they cover the library surface the tutorial meets through the clika-modelverse executable.

Read top to bottom; each row assumes a little of the ones above it.

ExampleWhat it shows
init_modelThe registered catalog and identity resolution: list the families, resolve a model's identity from a local directory or a Hugging Face Hub repo id. The snapshot fetches configs and companions only, so identity costs no weight download.
00_generateThe minimal end-to-end path: explicit snapshot, registry match, generative pipeline, one prompt, text. The program part 4 of the tutorial builds.
01_serveThe OpenAI-compatible server in process: implement the ChatEngine interface, mount it on OpenAiServer, and round-trip one /v1/chat/completions request through the built-in HTTP client. Runs with no arguments and no checkpoint, so it is also the fastest server smoke test.
02_custom_nodeYour own ClikaRT::runtime::Model node composed with the zoo's serving nodes in one pipeline: a synthesized two-layer llama generates and a ~40-line custom node post-processes the reply, with the request surface unchanged. Offline, runs with no arguments. The worked version against a real model is Add your own node to a model pipeline.

Build and run

cmake -S "$MODELVERSE_INSTALL_DIR/examples/src" -B build-examples \
-DModelverse_DIR="$MODELVERSE_INSTALL_DIR/cmake"
cmake --build build-examples
build-examples/init_model # catalog only, offline
build-examples/init_model -r openai/whisper-large-v3-turbo # + identity from Hugging Face
build-examples/00_generate meta-llama/Llama-3.2-1B-Instruct "Once upon a time, in a port town by a cold sea,"
build-examples/01_serve
build-examples/02_custom_node # offline, no arguments

01_serve prints its bound port, answers one request against itself, and exits PASS, which makes it the one to run first when checking a new machine:

serving on 127.0.0.1:41627
HTTP 200
choice: echo: Say hello.
01_serve: PASS

Where models come from, cache placement and the offline path are the same for the examples as for clika-modelverse; the examples' shared README.md restates them next to the code.