# Quickstart

Arena is AgileRL’s post-training platform for open-weight language and vision-language models. It runs supervised fine-tuning, preference optimisation (DPO), on-policy distillation and reinforcement learning, including multi-turn RL against an environment. You bring the datasets and environments; Arena works out how many GPUs a run needs and how to lay it out on them, on Arena’s GPUs or on a cluster of your own.

Train `Qwen/Qwen3.5-0.8B` with **CISPO** on GSM8K, a dataset of grade-school maths word problems. By the end you have a running experiment whose checkpoints you can deploy as an agent.

CISPO is a reinforcement learning algorithm for problems with a checkable answer. For each question it samples a group of answers, scores each one with your reward function, and pushes the model towards the answers that beat the group average.

## What you need

- An Arena account. Sign up at [arena.agilerl.com](https://arena.agilerl.com). Training spends your organization’s balance; see [Billing](../account/billing.md).
- For the CLI tab: [uv](https://docs.astral.sh/uv/getting-started/installation/). It uses or downloads a supported Python (3.10 to 3.13).
- Some balance and a little time. The example stops after 30 training steps: enough for the reward to start climbing, without paying for a full pass over GSM8K (about 900 steps, several hours on one GPU). Arena shows the estimated time and cost before the run starts, and you can stop it at any point.

The two files this page uses:

- [`gsm8k_cispo.yaml`](/_downloads/b3de7108d540c16690dda685ef21f374/gsm8k_cispo.yaml), the manifest: model, dataset, prompt and algorithm settings.
- [`reward.py`](/_downloads/549fc2d8943f592c34a27a56fb413b12/reward.py), the reward function.

## 1. Sign in

### Web app

Sign in at [arena.agilerl.com](https://arena.agilerl.com). You land on **Home**.

### CLI

```bash
uv tool install agilerl
arena login
```

`uv tool install` puts the `arena` command in its own environment, so it leaves the open-source AgileRL framework (`agilerl` 2.x) alone. If you have `agilerl-arena` installed, remove it first; see [Moving from agilerl-arena](../cli/install.md#moving-from-agilerl-arena). To install without uv, see [Install and sign in](../cli/install.md#install).

`arena login` opens a browser sign-in and saves the session on this machine. Where there is no browser, sign in with an API key instead; see [Install and sign in](../cli/install.md#sign-in-with-an-api-key).

## 2. Create a project

A project holds your experiments.

Project and dataset names are shared across your organization. If a teammate already uses `gsm8k`, add a suffix such as `gsm8k-sam` to both, use those names in place of `gsm8k` in the commands below, and put the dataset name in the manifest’s `environment.dataset` and `environment.name`.

### Web app

Open **Experiments** in the sidebar, click **New project**, name it `gsm8k` and click **Create Project**.

### CLI

```bash
arena projects create gsm8k
arena projects set-default gsm8k
```

With a default project set, later commands don’t need `--project`.

More in [Create a project](../guides/create-a-project.md).

## 3. Register the dataset

Import GSM8K from Hugging Face as a **reasoning** dataset. Each row has a `question` and an `answer`, and the answer ends with the final number after `####`:

```text
question: Natalia sold clips to 48 of her friends in April, and then she sold half as many
          clips in May. How many clips did she sell altogether in April and May?
answer:   Natalia sold 48/2 = 24 clips in May.
          Altogether she sold 48+24 = 72 clips.
          #### 72
```

### Web app

1. Open **Datasets** in the sidebar and click **New dataset**.
2. Name it `gsm8k` and choose **Reasoning** as the **Type**.
3. In **Select dataset**, search for `openai/gsm8k`, pick it, then choose the `main` configuration. Click **Create**.
4. On the dataset page, click **Question** and then the `question` column, then **Answer** and the `answer` column. Click **Confirm Selection**.

### CLI

```bash
arena datasets create gsm8k \
    --category reasoning \
    --hf-dataset openai/gsm8k \
    --hf-config main \
    --hf-split train \
    --column-mapping '{"question": "question", "answer": "answer"}'
```

The mapping keys are Arena’s names; the values are the columns in your data. GSM8K already uses Arena’s names.

Arena imports the dataset in the background. Before you submit a run, wait until `arena datasets list` shows a number in the `rows` column for `gsm8k`. The column stays empty until the import finishes.

```bash
arena datasets list
```

More in [Upload a dataset](../guides/upload-a-dataset.md).

## 4. Read the reward function

The reward function scores every answer the model writes during training. Arena calls `reward_fn` with the model’s `completion` and the row’s `answer` and `question`, and expects a number back.

This one ignores anything inside the model’s thinking block and adds two scores:

- **Correctness**: 1 when the number in the last `<answer>` tag matches the number after `####`.
- **Format**: 1 when the reply ends with one `<answer>` tag that holds only a number.

```python
# Copyright 2026 AgileRL
# SPDX-License-Identifier: Apache-2.0

"""GSM8K reward: the right final number, in the ``<answer>`` tags the prompt asks for."""

import re

ANSWER_BLOCK = re.compile(r"<answer>(.*?)</answer>", re.DOTALL)
NUMBER = re.compile(r"-?\d[\d,]*(?:\.\d+)?")


def final_text(completion: str) -> str:
    """Return the text after the last ``</think>``, or the whole completion when there is none."""
    return completion.rpartition("</think>")[2].strip()


def to_number(text: str) -> float | None:
    """Return the first number in ``text``, ignoring thousands separators."""
    match = NUMBER.search(text)
    return float(match.group(0).replace(",", "")) if match else None


def gold_answer(answer: str) -> float | None:
    """Return a GSM8K row's final answer: the number after ``####``."""
    _, marker, final = answer.rpartition("####")
    return to_number(final) if marker else None


def correctness_reward(text: str, answer: str) -> float:
    """Return 1.0 when the last ``<answer>`` block holds the gold number."""
    blocks = ANSWER_BLOCK.findall(text)
    if not blocks:
        return 0.0
    predicted = to_number(blocks[-1])
    return 1.0 if predicted is not None and predicted == gold_answer(answer) else 0.0


def format_reward(text: str) -> float:
    """Return 1.0 when the text ends with one ``<answer>`` block holding only a number."""
    blocks = ANSWER_BLOCK.findall(text)
    if len(blocks) != 1 or not text.endswith("</answer>"):
        return 0.0
    return 1.0 if NUMBER.fullmatch(blocks[0].strip()) else 0.0


def reward_fn(completion: str, answer: str, question: str) -> float:
    """Score one completion: correctness plus format, at most 2.0.

    Both parts read only the text after the reasoning, so a number the model
    tries while thinking does not count.

    :param completion: The model's turn, reasoning included when it has any.
    :param answer: The row's GSM8K answer, ending ``#### <number>``.
    :param question: The row's question.
    :return: The reward.
    """
    text = final_text(completion)
    return correctness_reward(text, answer) + format_reward(text)
```

The manifest’s prompt asks the model for those `<answer>` tags. A reward that checks for tags the prompt never asks for scores almost every answer 0. [Write prompts and reward functions](../guides/prompts-and-rewards.md) covers what the function receives and how the prompt is built.

## 5. Submit the run

### Web app

1. Open the `gsm8k` project and click **New experiment**. Name it `gsm8k-cispo` and click **Create Experiment**. The experiment wizard opens.
2. On **Environment**, pick the `gsm8k` dataset.
3. Under **Prompts**, expand **System prompt** and enter `Reason step by step. End with the final number in <answer></answer> tags, like <answer>42</answer>.` Set **User prompt** to `{question}`.
4. Under **Reward Function**, replace the code in the editor with `reward.py`, set **Maximum reward** to 2, and click **Validate**. **Next** turns on when **Prompts** and **Reward Function** are both done.
5. On **Agent**, choose **CISPO** and the base model `Qwen/Qwen3.5-0.8B`.
6. On **Training**, enter 30 in **Maximum Number of Training Steps** for a short run, or leave it empty for one full pass over the dataset. Keep the other defaults. The **Training resources** bar shows the GPUs Arena picked, with the estimated time and cost.
7. On **Summary**, click **Train**.

Each step is described in [Train a model](../guides/train-a-model.md).

### CLI

Download the manifest and the reward function into one folder:

```bash
curl -fsSLO https://docs.arena.agilerl.com/_static/examples/gsm8k_cispo.yaml
curl -fsSLO https://docs.arena.agilerl.com/_static/examples/gsm8k-cispo/reward.py
```

Check your balance and the manifest, then submit it with the reward file:

```bash
arena user credits
arena manifest validate gsm8k_cispo.yaml
arena experiments submit gsm8k_cispo.yaml --reward-file reward.py --experiment-name gsm8k-cispo
```

Before the run starts, Arena checks the reward function on a sample answer (see [Validate the reward function](../guides/prompts-and-rewards.md#validate-the-reward-function)), then prints the GPUs it picked with the hourly rate and estimated total for you to confirm. Add `--dry-run` to see that price without submitting. `--yes` skips the confirmation; scripts and CI need it, because the command can’t ask without a terminal. Flags for choosing GPUs yourself are in the [command reference](../cli/command-reference.md).

The manifest:

```yaml
---
algorithm:
    name: CISPO
    batch_size: 8
    beta: 0.0
    lr: 0.000005
    clip_coef: 0.2
    max_grad_norm: 0.1
    update_epochs: 1
    group_size: 8
    temperature: 0.9
    calc_position_embeddings: true

environment:
    name: gsm8k
    env_type: rollout
    dataset: gsm8k
    rubric_file_path: reward.py
    prompt_template:
        system_0: Reason step by step. End with the final number in <answer></answer> tags, like <answer>42</answer>.
        user_1: '{question}'
    chat_template_kwargs:
        enable_thinking: false
    max_reward: 2.0

replay_buffer:
    kind: llm

training:
    max_steps: 30
    metrics_interval: 5
    eval_loop: 1
    evaluation_interval: 50

network:
    pretrained_model_name_or_path: Qwen/Qwen3.5-0.8B
    max_context_length: 1024
    lora_config:
        lora_r: 16
        lora_alpha: 64
        task_type: CAUSAL_LM
```

`environment.dataset` names the dataset you registered, and Arena trains on it. `environment.name` is used only when `dataset` is missing; here it repeats the dataset’s name. `rubric_file_path` names the reward file. `prompt_template` turns each row into the chat the model sees. `network` names the base model and trains a LoRA adapter on top of it. `training.max_steps: 30` stops the run after 30 steps. Remove `max_steps` to train one full pass over the dataset. The [manifest schema](../cli/manifest-schema.md) describes every field.

## 6. Watch it train

### Web app

After **Train**, Arena returns you to the project’s **Experiments** tab. The `gsm8k-cispo` row shows the run’s status. Open the **⋮** menu on the row and choose **View logs** to follow it.

### CLI

```bash
arena experiments status gsm8k-cispo
arena experiments logs gsm8k-cispo --follow
```

`--follow` keeps printing new lines until the run ends. Without it, the command prints the lines so far and exits.

The run takes a little while to start while Arena brings up its GPUs. [Monitor, halt and resume](../guides/monitor-halt-resume.md) explains the statuses and how to stop a run early.

## Next steps

- [Results and checkpoints](../guides/results-and-checkpoints.md): read the reward and accuracy charts and pick a checkpoint.
- [Deploy an agent](../guides/deploy-an-agent.md): serve a checkpoint and send it a maths problem.
- [Write prompts and reward functions](../guides/prompts-and-rewards.md): swap the code check for an LLM judge.
