Skip to main content
This quickstart shows you how to train your first LoRA adapter with Serverless Training. You’ll use Serverless RL to train a customer support agent that searches a product knowledge base and answers customer questions, then you’ll send inference requests to the model you trained. The agent in this quickstart supports a fictional smart thermostat. The same pattern applies to any multi-turn agentic task where the model uses tools to gather context before answering: customer support, agentic RAG, deep research, or internal help desks. You don’t need labeled answers or a hand-written reward function. Instead, RULER (Relative Universal LLM-Elicited Rewards) uses an LLM judge to rank the agent’s attempts against each other, and Serverless RL uses those rankings to update a LoRA adapter for the base model.

What you’ll learn

This quickstart shows you how to:
  • Register a trainable model with the W&B training cluster.
  • Define a tool-using rollout for a support agent.
  • Score the agent’s attempts with RULER instead of a hand-written reward function.
  • Run an RL training loop that produces LoRA checkpoints.
  • Send inference requests to your trained model.
Serverless Training provisions and autoscales the GPUs for you: inference requests during rollouts run on Serverless Inference, and training steps run on managed training GPUs. Training is free during the public preview; you pay only for inference usage and artifact storage. For details, see Usage information and limits.

Prerequisites

Before you begin, complete the Serverless Training prerequisites: a W&B account, an API key, and a project. You also need the following:
  • Python 3.10 or later, running in an environment that supports async/await at the top level, such as a Jupyter notebook. To run the code as a script instead, wrap it in a function and call it with asyncio.run().
  • An OpenAI API key. RULER uses an LLM as a judge to rank trajectories; this example uses an OpenAI model as the judge. To use a different judge, pass any LiteLLM-supported model to ruler_score_group.
Install the OpenPipe ART framework, the open source RL training client that Serverless Training uses:
Then set your credentials as environment variables. Replace [YOUR-WANDB-API-KEY] and [YOUR-OPENAI-API-KEY] with your keys:

Register a trainable model

Declare a trainable model and register it with the ServerlessBackend. The backend sends inference and training requests to the W&B training cluster, which autoscales to match your job’s demand. Registration also sets up metric logging to your W&B project.
base_model must be one of the available models. This example uses a 14B model optimized for building agents with fine-tuning.

Create the agent’s environment

The agent answers questions using a small product knowledge base and a single search tool. This example defines the knowledge base inline so the quickstart is self-contained; in a real application, the tool would query your documentation index, help desk, or vector store.
Next, define the questions the agent trains on. RULER compares the agent’s attempts against each other, so the questions don’t need labeled answers:

Define a rollout

A rollout is one complete attempt by the agent to handle a scenario. The rollout function sends the question to the model, executes any tool calls it makes, and returns the full interaction as an art.Trajectory. During training, Serverless RL runs many rollouts in parallel against your model’s current LoRA weights.
A few details matter here:
  • The AsyncOpenAI client points at your model’s Serverless Training inference endpoint (model.inference_base_url), so every rollout uses the latest LoRA weights as training progresses.
  • temperature=1 keeps the agent’s attempts diverse. RULER needs variation within a group of attempts to produce a useful ranking.
  • The trajectory records the entire interaction, including tool calls and tool results, so training can credit the behavior that led to a good answer.

Score trajectories with RULER

Instead of writing a reward function, pass each group of trajectories to RULER. An LLM judge compares the attempts for the same question against each other and scores them from 0 to 1 based on how well each one achieves the goal described in the system prompt. Because the RL algorithm normalizes scores within each group, only the relative ranking matters. Verify that RULER works before you start the training loop:
The debug=True flag prints the judge’s reasoning so you can confirm the rankings make sense for your task before you train on them.

Run the training loop

Each training step gathers a batch of trajectory groups, scores them with RULER, and sends the scored trajectories to the W&B training cluster, which updates your LoRA adapter and saves a checkpoint. Metrics for each step log to your W&B project automatically.
This configuration runs six training steps. While the loop runs, open your support-agent project at wandb.ai to watch reward and training metrics update in real time. Each step also saves a LoRA checkpoint as an artifact in your project.
To trace every message in each rollout, including the judge’s rankings, add Weave to your project: call weave.init(model.project) before the training loop and decorate rollout with @weave.op. Weave records each step of the training loop so you can inspect exactly how your agent’s behavior changes during training.

Use your trained model

Compare the agent’s behavior on the held-out question. Your model’s endpoint continues to serve the latest trained weights, so the same rollout function now runs against your trained LoRA:
Every checkpoint is also deployed automatically for inference, so you can call your trained model from any OpenAI-compatible client using a wandb-artifact model reference and the Serverless Training API:
Replace [YOUR-ENTITY] with your W&B entity (team) name, and choose the checkpoint step you want to serve. To see the checkpoints your training run produced, open the Artifacts tab of your project. For details on constructing endpoints for trained models, see Use your trained models.

Next steps

You trained a LoRA adapter with Serverless RL and served it without managing any infrastructure. To keep going:
  • Scale up the task: Point the search tool at your real documentation or help desk data, expand the question set, and increase the number of epochs and validation checks. The ART·E notebook shows a larger version of this pattern, including periodic validation and checkpoint cleanup.
  • Warm up with SFT: If you have curated example conversations, fine-tune on them first with Serverless SFT, then apply RL for further refinement.
  • Manage storage: Each checkpoint counts toward your artifact storage. Delete low-performing checkpoints with the ART SDK.
  • Go deeper on ART: See the ART documentation for advanced training configuration, validation splits, and additional examples.