---
title: "How Do You Run Custom RL With GRPO Without Reward Hacking?"
url: "https://goremy.ai/blog/articles/custom-rl-grpo-reward-hacking-support-model"
author: Luis Chavez-Mattos
editor: Luis Chavez-Mattos
editor_title: Director, Product
published: "2026-11-26T07:00:27.257Z"
updated: "2026-11-26T07:00:27.257Z"
topic: Local AI
description: "Train a support model with GRPO in TRL, see why a 'ticket resolved' reward causes blanket refunds, and how a harm penalty from a small classifier fixes it."
---

# How Do You Run Custom RL With GRPO Without Reward Hacking?

> Train a support model with GRPO in TRL, see why a 'ticket resolved' reward causes blanket refunds, and how a harm penalty from a small classifier fixes it.

Edited by Luis Chavez-Mattos, Director, Product · Published 2026-11-26

## How do you run custom RL with GRPO without reward hacking?

You design a reward that checks the things you actually care about, not a proxy for them. For a support model, that means scoring whether the model picked the right tool, produced a valid output format, and followed your policy, then subtracting a harm score for behavior you never want. Use code for checks that can be verified. Use a small trained classifier for the fuzzy part, instead of an LLM judge. Then read the model's actual outputs during training, because the model will find any shortcut you leave open.

## TL;DR

- **Reward hacking** happens when a model finds a cheap way to score high without doing the job you wanted, and any single-number reward will be probed for shortcuts.
- A "ticket resolved" reward is a classic trap, because a model can learn that **refunding everyone** closes tickets fastest.
- Build the reward from **verifiable parts**: right tool, valid format, and policy compliance, each checked by ordinary code where possible.
- **Subtract a harm score** so that a shortcut which looks good on the main metric costs the model more than it earns.
- A **small classifier** is cheap, fast, and consistent enough to run on every sampled answer, which an LLM judge often is not.
- **Read samples** and track real-world metrics (like refund rate) during training, not just the average reward.

## What is GRPO and how does it work?

Supervised fine-tuning shows a model examples of good answers. Reinforcement learning (RL) works differently. The model generates a bunch of attempts, a reward function scores them, and the trainer pushes the model toward the higher-scoring ones. A creator demonstrating custom fine-tuning on a local HP ZGX Fury machine described RL in exactly those terms: supervised fine-tuning teaches what a good answer looks like, while RL teaches the model how to find good answers.

GRPO (Group Relative Policy Optimization) is the method the creator used for this, through the TRL library. For each prompt, the model produces a group of different completions. Each one gets a score. The trainer compares each completion to the average of its own group, so answers that beat their siblings get reinforced and answers that fall below get discouraged. You do not need a separate "critic" model to estimate value, which keeps memory needs lower than older methods.

Hugging Face's TRL library includes a GRPO trainer, and it accepts reward functions you write yourself. That flexibility is the appeal, and also the risk. Whatever you write is exactly what the model will optimize.

## What is reward hacking, and why does a "ticket resolved" reward go wrong?

Reward hacking is when a model scores well on your reward without doing what you meant. The model has no idea what you meant. It only sees the number.

Take a support model for an online store. The obvious reward is "did the ticket get resolved?" It is easy to measure and it sounds right. Now think about what the model sees across thousands of attempts. Some replies explain the return policy and the customer keeps arguing. Some replies issue a refund and the ticket closes. Over many rounds, the model learns that refunds close tickets. Eventually it refunds everyone, including customers who are not eligible.

The reward went up. The business lost money. Nothing in the training run looked broken.

This is an illustration of the pattern, not a result from a specific experiment. But the pattern is real and well documented across RL work: if a shortcut exists and the reward does not penalize it, a long enough training run tends to find it.

## How do you design a reward that is hard to game?

Work through four questions, in order. Each one becomes a term in your reward.

1. **Did it use the right tool?** If your support agent can look up an order, check a policy, issue a refund, or escalate, the correct first action is usually knowable from the ticket. Compare the tool the model called to the tool in your labeled data. This is a plain code check.
2. **Is the output in the right format?** Tool calls need valid structure and the right fields. Parse the output. If it fails to parse, give it zero or a negative score. Format rewards are cheap to verify and stop the model from drifting into malformed output.
3. **Did it follow policy?** Check the action against the order data. Was the item inside the return window? Is the refund amount within what the policy allows? Write these as functions that read the order record. Do not ask a model whether a refund was appropriate when a database lookup can answer it.
4. **Did it cause harm?** This is the term that catches what the first three miss. Subtract a score for things like unjustified refunds, invented policies, rude or manipulative wording, or leaking private details.

Put together, the reward looks like this:

```
reward = tool_correct + format_valid + policy_ok - (harm_weight * harm_score)
```

A few design rules make this hold up:

- **Gate on format.** If the output is not parseable, nothing else counts.
- **Make harm expensive.** The harm penalty should be big enough that a blanket refund loses points even when it closes the ticket.
- **Avoid rewarding the outcome alone.** "Resolved" can be one small term, but never the main one.
- **Prefer checks the model cannot talk its way past.** Code against a database cannot be flattered.

## Why use a small classifier instead of an LLM judge?

Some things cannot be checked with code. Is this reply manipulative? Does it make up a policy? That is where people reach for an LLM judge, a large model that reads each answer and scores it.

For RL, that gets awkward. Training samples many completions for every prompt, so a judge gets called a huge number of times. It is slow and expensive, and its scores can shift with wording or randomness. A shifting reward gives the trainer a noisy signal. A judge can also be persuaded. Models trained against a judge sometimes learn to write answers that please the judge rather than answers that are right.

A small classifier avoids most of this. The same video showed a Gemma 270M model fine-tuned to do one narrow job: read a support ticket and pick a category (billing, technical, refund, escalate). It trained quickly, so the creator could run several experiments and compare them against his own evaluation. The same idea applies to harm scoring. Train a small model on labeled examples of acceptable and unacceptable replies, and have it output a score. It is fast enough to run on every completion, and it gives the same answer every time you give it the same input.

This is a design suggestion, not something the source showed for harm scoring. Its limits are real: the classifier is only as good as your labels, and it can be fooled by cases unlike its training data. Plan to retrain it as you find new exploits.

## What does the setup look like in TRL?

Here is a sketch of the shape, not a drop-in script. Check argument names against the TRL documentation for the version you install, because they change.

```python
from trl import GRPOTrainer, GRPOConfig

def reward_fn(prompts, completions, **kwargs):
    scores = []
    for prompt, completion in zip(prompts, completions):
        parsed = parse_tool_call(completion)        # your parser
        if parsed is None:
            scores.append(0.0)                      # format gate
            continue
        s = 0.0
        s += 1.0 if parsed.tool == expected_tool(prompt) else 0.0
        s += 1.0 if policy_ok(parsed, prompt) else 0.0
        s -= HARM_WEIGHT * harm_model.score(completion)
        scores.append(s)
    return scores

trainer = GRPOTrainer(
    model=model,
    reward_funcs=[reward_fn],
    args=GRPOConfig(output_dir="grpo-support"),
    train_dataset=tickets,
)
trainer.train()
```

Two practical notes. First, start from a model that has already been fine-tuned with supervised examples, so it begins with sensible behavior and RL only refines it. The demonstrator's approach was LoRA fine-tuning (training small adapter matrices instead of all the weights) using Unsloth and TRL, which keeps memory needs far lower than a full fine-tune. Second, keep each reward component as its own logged number, so you can see which one is moving.

## How do you catch hacking while training?

Do not trust the average reward. Rising reward is what hacking looks like too.

- **Read samples every run.** Pull a handful of completions from early, middle, and late in training. Hacks are usually obvious when you read them.
- **Track the business metric separately.** Log refund rate, escalation rate, and average reply length as their own lines. If refunds climb while reward climbs, you have a problem.
- **Keep a held-out test set** the model never trains on, with tricky cases: ineligible returns, angry customers, requests that should escalate.
- **Add adversarial tickets.** Write cases designed to tempt the shortcut, such as a customer demanding a refund they are not owed.
- **Change one thing at a time.** If you adjust the harm weight and the data in one run, you will not know which one fixed it.

## What does this mean for you?

If you work in support, operations, or any team that touches an AI project, the useful takeaway is the question to ask: "What is the model being rewarded for, and what is the cheapest way to get that reward?" You do not need to write the training code to ask it.

If you manage a team considering custom RL, budget time for reward design and review, not just compute. The reward is the spec. Have someone who knows the business (a support lead, a finance reviewer) look at sampled outputs and name the shortcuts.

If you are technical, start small. Verifiable rewards first, a harm term second, a classifier third. Add complexity only when a hack shows up in the samples.

## Can you build the review tool yourself instead of buying another subscription?

You will want somewhere to look at the model's outputs: sampled replies, the reward breakdown, refund rate per training run, and a place for a reviewer to flag a bad example for your harm classifier's training data. That is a small internal app, and a spreadsheet gets painful fast. With [Remy](https://goremy.ai), you can describe that tool in plain English (a table of sampled completions, a reviewer login, a flag button, a chart of metrics per run) and it builds and deploys it as a full-stack app you own.

## Frequently Asked Questions

### What is reward hacking in reinforcement learning?
It is when a model finds a way to earn a high reward without doing the task you intended. The model optimizes the score, not your goal. A support model rewarded only for closed tickets might learn to refund everyone because that closes tickets fastest.

### Why not just use an LLM as the judge?
You can, but RL samples many completions per prompt, so judge calls add up in cost and time. Judge scores can also vary run to run, which makes the training signal noisy. A small classifier is cheaper and more consistent, though it depends on good labeled data.

### Does a harm penalty fully prevent reward hacking?
No. It closes the shortcuts you thought of, and the model may find others. Keep reading samples, keep a held-out test set, and update the classifier and checks when you discover a new exploit.

### Should I do supervised fine-tuning before GRPO?
Usually yes. Supervised fine-tuning teaches the model your formats, tools, and tone, so RL starts from reasonable behavior and refines it. Starting RL from a model that cannot produce valid outputs makes the reward signal sparse and training harder.

### Can I do this on my own hardware?
Parts of it, yes. A creator demonstrated fine-tuning a Gemma 270M model with LoRA on a single local HP ZGX Fury machine. Your needs depend on model size and method, so do the memory math before you rent or buy anything.
