Skip to navigation

CLM-v0.1-8B is a Contrastive Language Model (CLM): two small projection heads (a state head and an action head) on top of a frozen Qwen3-8B encoder. The encoder embeds the state together with a question, and it embeds each option separately. The score of an option is the scaled cosine similarity between the projected state and option embeddings, and a softmax over the options of a question gives its answer distribution. Because options are embedded separately, their embeddings can be cached and reused.

NeMo AutoModel keeps the encoder frozen, because the released heads and the action cache of the Contrastive-LM clm-serve server depend on its exact embedding space. The recipe embeds every unique state and option text once, sharded across all GPUs, and caches the embeddings on disk. It then trains or evaluates only the heads (about 20M parameters) on rank 0.

Post-Train CLM-v0.1-8B

Set up a source checkout of NeMo AutoModel as described in Run Decision Models with NeMo AutoModel. Then, from the repository root, generate the fictional alert-triage records that the example configuration reads. The generator rejects an existing output directory, so skip this step if you already generated data/soc_triage for another decision model:

PYTHONPATH=tutorials/decision_models uv run --no-project python -m decision_tutorial.data \
--output-dir data/soc_triage --seed 7

For the record format, see Prepare Decision Records.

Evaluate the released heads to record the baseline, and then run supervised fine-tuning (SFT):

automodel examples/decision/clm_soc_triage.yaml --nproc-per-node 8 --mode eval --output_dir runs/clm/base
automodel examples/decision/clm_soc_triage.yaml --nproc-per-node 8 --mode train --loss.mode sft --output_dir runs/clm/sft

To continue with reinforcement learning (RL) on the per-option rewards, start from the SFT heads:

automodel examples/decision/clm_soc_triage.yaml --nproc-per-node 8 --mode train --loss.mode rl \
--heads.init_checkpoint runs/clm/sft/heads.pt --optimizer.lr 1.0e-4 --train.epochs 10 \
--train.eval_metric reward --output_dir runs/clm/rl

Each run writes metrics_validation.json and metrics_test.json to its output directory. Training runs also save the heads with the best validation score for train.eval_metric as heads.pt. The RL command sets --train.eval_metric reward, so the RL stage keeps the heads with the best validation reward. If no epoch improves on the starting heads, heads.pt contains the starting heads. The file uses the checkpoint format of the contrastive-lm package, so the Contrastive-LM clm-serve server can load it through the CLM_CKPT environment variable, for example CLM_CKPT=runs/clm/rl/heads.pt clm-serve.

The SFT stage trains on the gold answers with the NeMo AutoModel decision objective: label-smoothed cross-entropy, a Brier term, and a ranked-probability term for ordinal questions. It does not implement the Contrastive-LM fine-tuning objective, which by default trains against annotator distributions (soft targets).

Choose a Workflow

GoalStart Here
Evaluate and fine-tune the released heads, and then continue training with RLUse the recipe configuration.
Run the baseline, SFT, and optional RL stages in a notebookFollow the CLM tutorial notebook.
Train the heads with a contrastive objective on cached featuresFollow the contrastive-heads notebook.

Configuration

SettingConfiguration
StrategyData-parallel embedding on every rank, then head training on rank 0
Processes8 per node in the example commands (--nproc-per-node 8)
Trainable parametersState head, action head, and logit scale (about 20M parameters)
Frozen weightsThe Qwen3-8B encoder
EncodingLast-token pooling, L2 normalization, and a 2,048-token window that keeps the last tokens of longer inputs
Feature cacheencode.cache_dir, on a file system that every rank can access, including ranks on other nodes
SFT objectiveLabel-smoothed cross-entropy, a Brier term, and a ranked-probability term for ordinal questions
RL objectiveExact expected reward (default) or group relative policy optimization (GRPO), selected with loss.rl_objective, with a Kullback-Leibler (KL) penalty to the starting heads and a gold-answer anchor term (loss.anchor_weight)

The cache key covers the encoder and tokenizer names and revisions, the input texts, the truncation, pooling, normalization, attention, and precision settings, and the installed Transformers version. Changing any of them creates a new cache instead of reusing stale embeddings. Set the encoder and tokenizer revisions to full 40-character commit IDs. The recipe rejects other values, such as the branch name main.

Model Reference

Model Architecture

PropertyValue
TaskTyped decision scoring: one probability for every allowed option of every question, from state and option similarity
ArchitectureFrozen Qwen3-8B encoder with two CLM projection heads
Projection headsAbout 20M parameters

Available Models

  • Contrastive-LM/CLM-v0.1-8B: the released projection heads (CLM_v0.1-8B.pt). The recipe loads them at revision e939398d4556fcd9400c76fa8c5a513202f42b0a, and the example configuration pins the Qwen3-8B encoder to revision b968826d9c46dd6066d109eabc6255188de91218.