← Home

Log diversity per problem, or you'll miss collapse

Shreshth Rajan, June 2026. · Code and tool: SRAG

I trained a code model with a reward for agreeing with its own answers. Over training, its eight answers to each problem became the same answer, and it lost half of the held-out problems it could solve in eight tries. The output diversity I was logging barely moved. Diversity measured within each problem fell to zero, starting a few steps before the drop in solved problems. The code and the monitor I built from this are on GitHub.

You can train a model without an answer key by sampling several answers to each question and rewarding the ones that agree with the rest. Test-time reinforcement learning (test-time RL) does roughly this, using the model's own majority vote as the reward on unlabeled questions.

The obvious failure is that a model which gives the same answer every time gets full reward, whether or not the answer is right. I wanted to see whether the usual training metrics would show that happening.

The model was Qwen2.5-Coder-1.5B, trained on short Python problems with GRPO, which samples a group of answers to each problem and moves the model toward the answers that score above the group's average. For each problem I sampled eight answers and, instead of running the unit tests, scored each answer by how many of the other seven matched it.

This reward is highest when all eight answers agree, and correctness never affects it. GRPO scores each answer by its reward minus the group average, divided by the spread of rewards in the group. Once all eight answers agree, they all get the same reward, every advantage is zero, and the model stops changing.

# the reward, and the advantage GRPO computes from it
def consensus_rewards(samples):                 # eight answers to one problem
    key = [canonical(s) for s in samples]       # ignores formatting differences
    n   = Counter(key)
    return [(n[k] - 1) / (len(samples) - 1) for k in key]

adv = (r - r.mean()) / (r.std() + 1e-6)         # all rewards equal -> std 0 -> no gradient

To measure what the model could actually do, I tested it on held-out problems with real unit tests. pass@1 is the chance that a single sampled answer is correct, and pass@8 is the chance that at least one of eight is. Over training the agreement reward rose to 1.0 and pass@1 stayed flat, but pass@8 fell from 10 of 11 held-out problems to 5.

Agreement reward rises to 1 while the chance one of eight answers is right halves.
The agreement reward rises to 1.0 while held-out pass@8 (at least one of eight answers correct) halves and pass@1 (one answer correct) stays flat.

So a single answer from the model was as likely to be right as before, but its eight tries no longer differed, and by the end they were the same answer eight times.

The output diversity I logged barely moved during all of this. It pools every answer to every problem and measures how different pairs of answers are, and most pairs in that pool come from different problems. So it mostly measures how answers to different problems differ, which collapse doesn't change.

Entropy, a measure of how spread out a set of answers is, makes this precise. It is zero when all the answers are identical and largest when they all differ. For answers \(Y\) to problems \(X\), the entropy of the pooled answers splits into two parts:

$$H(Y) \;=\; \underbrace{H(Y\mid X)}_{\text{within a problem}} \;+\; \underbrace{I(Y;X)}_{\text{between problems}}$$

The first part measures how much the eight answers to one problem differ, and the second measures how much answers differ between problems. Collapse removes the first part. A sorting function and a string parser still look different, so the second part stays large and dominates the total. In my run, entropy within each problem fell to zero. The diversity I logged was based on word overlap rather than entropy, and it fell only from 0.86 to about 0.77.

Per-problem answer variety collapses to zero while pooled variety stays flat.
Answer entropy within each problem falls to zero while pooled diversity, computed from the same answers, falls by about a tenth.

pass@1 misses the collapse for a similar reason. It looks at one answer at a time, and collapse keeps the model's most likely answer while removing the others.

To catch the collapse, group the answers by problem, compute entropy within each group, and average across groups. This uses samples you already have.

pooled    = entropy(Counter(canonical(s) for g in groups for s in g))       # blind
perprompt = mean(entropy(Counter(canonical(s) for s in g)) for g in groups) # sees it

The per-problem number also moved first. It started falling about three steps before held-out pass@8 first dropped, and pooled diversity didn't change until about sixteen steps after that drop.

The spread of rewards within each group, which GRPO already computes, went to zero at the same time. That works here only because the reward is agreement, so equal rewards mean identical answers. With other rewards, equal rewards don't imply identical answers, and per-problem entropy is the number to watch.

If you train a model on its own agreement, log entropy within each problem along with pooled diversity.

Setup. GRPO (group relative policy optimization) on MBPP (short Python problems with unit tests) with Qwen2.5-Coder-1.5B-Instruct, trained through a rank-128 LoRA adapter (a small set of added weights), eight samples per problem, 120 steps, no penalty for moving away from the original model. Held-out pass@k uses real unit tests at sampling temperature 0.6. The self-grading reward counts matches after parsing the code, so formatting differences do not count. Over training the agreement reward rose from 0.14 to 1.0 and pass@1 stayed near 31%. Pooled diversity is the average pairwise difference between answers by word overlap. Entropy within a problem fell from 0.97 to 0 on a 0-to-1 scale. A control run uses the unit-test pass rate as the reward, and its pass@k stays flat. The control also adds a small penalty for moving away from the original model and draws from all difficulty levels, so it differs from the self-graded run in those two settings as well. This is one run with eleven held-out problems. The pass@8 drop is large and one-directional, but the exact warning time is noisy, since pass@8 over eleven problems moves in steps of 9 points. Monitor and experiment, one command to reproduce: github.com/ShreshthRajan/SRAG.


References

  1. Zuo et al. TTRL: Test-Time Reinforcement Learning. arXiv:2504.16084 (2025).
  2. Shafayat et al. Can Large Reasoning Models Self-Train? arXiv:2505.21444 (2025).
  3. Yue et al. Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model? arXiv:2504.13837 (2025).
  4. Wu et al. The Invisible Leash: Why RLVR May Not Escape Its Origin. arXiv:2507.14843 (2025).
  5. Yu et al. DAPO: An Open-Source LLM Reinforcement Learning System at Scale. arXiv:2503.14476 (2025). Patches the same zero-spread case by resampling.
  6. Cui et al. The Entropy Mechanism of Reinforcement Learning for Reasoning Language Models. arXiv:2505.22617 (2025).
  7. Shao et al. DeepSeekMath. arXiv:2402.03300 (2024). Introduces GRPO.
  8. Chen et al. Evaluating Large Language Models Trained on Code. arXiv:2107.03374 (2021). Defines the unbiased pass@k estimator.
  9. Cover and Thomas. Elements of Information Theory. Wiley (2006). Chain rule for the split above.
  10. Shumailov et al. AI Models Collapse When Trained on Recursively Generated Data. Nature 631, 755 (2024).