Customizer

LoRA fine-tune a Llama or Mistral instruct model on the curated company dataset with NeMo Customizer.

Updated CompTech Team

Full fine-tuning copies every weight and needs a large GPU allocation. LoRA trains a small adapter beside a frozen base model. NeMo Customizer runs that job as a microservice: you name the base model, the dataset and the hyperparameters, and a GPU pod does the training.

This lab registers the chat JSONL from Curator and submits a LoRA job for a Llama or Mistral instruct model. The base weights stay put. The artifact you keep is the adapter, under a name Evaluator can call.

Prerequisites

  • NeMo Customizer reachable from the cluster, with a GPU node the job can schedule
  • The Customizer base URL in CUSTOMIZER_BASE_URL
  • train.jsonl in the chat messages format, and a valid.jsonl held out of training
  • Permission to use the base model. Llama and Mistral weights are freely downloadable once you accept the licence

See which configs the cluster actually has

A job names a config, including a version and a GPU suffix. Guessing the string is the usual first failure. List what this Customizer was installed with, and pick a Llama 3.1 or Mistral instruct config whose GPU matches the node.

curl -s "$CUSTOMIZER_BASE_URL/v1/customization/configs" \
  | jq -r '.data[] | .name + "  " + (.target // .training_options[0].training_type // "")'

A config name looks like meta/llama-3.1-8b-instruct@v1.0.0+A100. Yours may differ. Use the name the API returned.

Register the dataset

Upload train.jsonl to the NeMo entity store and create a dataset named company-policy in the default namespace. The job below only stores that name. The file must be the messages format from the Curator lab, one JSON object per line, with system, user and assistant turns. Register valid.jsonl as company-policy-valid the same way, and do not point training at it.

Submit the LoRA job

Two epochs is enough to prove the pipeline on a small policy set. Raise it when the training loss is still falling and the validation answers are still wrong. adapter_dim is the LoRA rank. 8 is a starting point for a narrow task. A larger rank fits more and costs more.

curl -s -X POST "$CUSTOMIZER_BASE_URL/v1/customization/jobs" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "company-policy",
    "project": "lab",
    "config": "meta/llama-3.1-8b-instruct@v1.0.0+A100",
    "dataset": {"name": "company-policy", "namespace": "default"},
    "hyperparameters": {
      "training_type": "sft",
      "finetuning_type": "lora",
      "epochs": 2,
      "batch_size": 8,
      "learning_rate": 0.0001,
      "lora": {"adapter_dim": 8, "adapter_dropout": 0.01}
    },
    "output_model": "company-policy@v1"
  }'

Replace config with one from the list. Watch the job until it completes. The status moves from created, to running, to completed. A failed job's log is on the training pod, which is the first place to look when the loss never prints.

curl -s "$CUSTOMIZER_BASE_URL/v1/customization/jobs/company-policy" | jq '{status, status_details, output_model}'
oc get pods -n nemo -l app.kubernetes.io/component=customizer

The Python client does the same call if you would rather not post JSON:

import os
from nemo_microservices import NeMoMicroservices
client = NeMoMicroservices(base_url=os.environ["CUSTOMIZER_BASE_URL"])
job = client.customization.jobs.create(
    name="company-policy",
    project="lab",
    config="meta/llama-3.1-8b-instruct@v1.0.0+A100",
    dataset={"name": "company-policy", "namespace": "default"},
    hyperparameters={
        "training_type": "sft",
        "finetuning_type": "lora",
        "epochs": 2,
        "batch_size": 8,
        "learning_rate": 0.0001,
        "lora": {"adapter_dim": 8, "adapter_dropout": 0.01},
    },
    output_model="company-policy@v1",
)
print(job.id, job.status)

Serve the adapter

Customizer can deploy the adapter on a NIM when the job's deployment settings have LoRA enabled (NIM_MODEL_PROFILE including the LoRA profile, and a base that matches the config). Otherwise deploy a NIM of the same base model and load company-policy@v1 as a LoRA adapter. Either way the chat endpoint stays OpenAI-compatible:

curl -s http://company-policy-nim:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"company-policy@v1","messages":[{"role":"user","content":"How do I reset my password?"}]}'

Ask a question that is in valid.jsonl and one that is not in the policies at all. The second answer is allowed to be wrong at this stage. Guardrails and retrieval are what stop it. Write down the output_model name and the config you trained. Evaluator refuses to compare runs that do not name both.

What's next

  1. Score this adapter against the untouched base model in Evaluator.
  2. Put Guardrails in front before anyone else calls it.
  3. Facts that were not in train.jsonl still come from Retriever.