Live demo · Semantic IDs

Serve semantic ID models on Chalk CPUs

This demo shows how to run MiniLM and an RQ-VAE on Chalk CPUs to turn video titles into compact semantic IDs for recommendations. Encode a title to try it, then explore the code to see how it works.

Follow a title from embedding to recommendation tokens

The encoder turns a video title into three discrete tokens used by the recommendation example.

Try this experiment · expected results

  1. 1Encode a title

    Enter a title and inspect its embedding, tokens, and catalog videos sharing the prefix.

    Expected: Nearby semantic codes group related titles; a new title can enter the history immediately.

  2. 2Build a short watch history

    Choose three watched videos and inspect the ten recommendations.

    Expected: The ranked output combines the example’s sequence history and content similarity; shared prefixes are not a quality guarantee.

The catalog uses public video titles from MicroLens-100K.

minilm + rq-vae · 2 vcpuOpen in new tab

Encode a title into discrete tokens, then choose a viewing history and request recommendations. Chalk serves the CPU encoder and recommender.

A new title can become watch history as soon as it is encoded. As a recommendation candidate, it still relies on content similarity: most two-token prefixes contain one video, so unseen prefixes have little transition history.

Built on Chalk

MiniLM embeds each title, the RQ-VAE assigns three tokens, and the recommender ranks videos using content and watch-history transitions. Chalk runs the models and exposes them to applications and feature queries.

  • Serve models on CPUs

    The demo scaling group requests two vCPUs and 4 GiB of memory. Chalk runs the encoder and recommender behind an HTTPS endpoint.

  • Package the serving runtime

    The image definition pins the ONNX runtime and downloads the encoder at build time. Chalk deploys it with the trained codebooks and recommendation tables.

  • Call the encoder from Chalk SQL

    Deploy the encoder as a Chalk function, then use catalog_call to compute semantic IDs from titles in a SQL query.

Deploy your own

Run it on your own

You need uv, Chalk credentials, a Chalk environment, and the MicroLens-100K titles and watch sequences. Prepare the embeddings, trained quantizer and recommendation tables before deploying the demo.

After cloning, check out andy/oracle-gpu-cold-start before running the quickstart's preparation and deploy commands. Pass your API server with --api-server when deploying. To expose the encoder to Chalk SQL, deploy src/deploy_function.py with your environment and API server settings.

chalk-ai/chalk-semantic-ids
git clone https://github.com/chalk-ai/chalk-semantic-ids
cd chalk-semantic-ids

# Or export CHALK_CLIENT_ID and CHALK_CLIENT_SECRET.
chalk login

# Download MicroLens-100K into data/ (see the README), then:
./src/embed_titles.py           # MiniLM title embeddings
./src/train_rqvae.py            # quantizer + semantic IDs
./src/export_numpy_runtime.py   # torch-free encoder
./src/build_recommender.py      # next-video tables

# Builds the image and prints your demo's URL.
./demo/deploy_demo.py --env-id <your-environment-id>

Give new items an ID on day one

Videos, products, listings, or documents. Talk to an engineer about computing semantic IDs next to your data and serving them as features.