RLVR training: how to write a coding problem with a checker
For experts4 min read
RLVR training uses problems where a program can decide if an answer is right, so no human has to rate each one. Writing those problems is paid expert work. The craft is a clear statement, a reference solution and a checker that accepts every correct answer and rejects wrong ones.
What RLVR training means
RLVR stands for reinforcement learning with verifiable rewards. The name appears in the Tulu 3 paper, first submitted in November 2024, which describes it as a novel method alongside supervised finetuning and direct preference optimization. The idea is simple. If a program can check whether an answer is right, the model can be rewarded for right answers without a person scoring each one.
Source: Tulu 3: Pushing Frontiers in Open Language Model Post-Training (arXiv)(opens in a new tab)
In the RLVR vs RLHF comparison, RLHF uses human rankings, which suit open questions where quality is a matter of judgment. RLVR suits questions with a right answer, such as code that must pass tests or a maths result with one correct value.
The three parts you write
- A problem statement with exact input and output formats.
- A reference solution you have verified.
- A checker: test cases plus code that runs an answer and returns pass or fail.
Example problem
Statement: 'Given a list of meeting intervals [start, end), where an interval ends at its end time and a meeting starting at that moment can reuse the room, return the minimum number of rooms needed. Read JSON from stdin and print one integer.'
State the convention about touching intervals in the text. If you leave it out, two correct solutions disagree and your checker punishes one of them.
# reference solution: solution.pyimport json, sys def min_rooms(intervals): starts = sorted(a for a, b in intervals) ends = sorted(b for a, b in intervals) rooms = best = j = 0 for s in starts: while ends[j] <= s: # a room is free again j += 1 rooms -= 1 rooms += 1 best = max(best, rooms) return best print(min_rooms(json.load(sys.stdin)))Trace [[0, 30], [5, 10], [15, 20]]. Starts are 0, 5, 15 and ends are 10, 20, 30. At 0 one room is in use, at 5 two, and at 15 the room ending at 10 is freed, so rooms stays at two. The answer is 2. With an empty list the loop never runs and the answer is 0.
The checker
The checker runs a candidate program on each case, with a time limit, and compares the printed result. The subprocess module's run function takes input for stdin, capture_output and text to collect output as a string, and timeout, after which the child process is killed and TimeoutExpired is raised.
import json, subprocess, sys CASES = [ ([[0, 30], [5, 10], [15, 20]], 2), ([[7, 10], [2, 4]], 1), ([[1, 5], [5, 8]], 1), # touching intervals share a room ([], 0),] def passes(path, payload, expected): try: r = subprocess.run([sys.executable, path], input=json.dumps(payload), capture_output=True, text=True, timeout=2) except subprocess.TimeoutExpired: return False return r.returncode == 0 and r.stdout.strip() == str(expected) def score(path): return sum(passes(path, p, e) for p, e in CASES) / len(CASES)Source: Python docs: subprocess(opens in a new tab)
This returns the fraction of cases passed. Some projects want all-or-nothing, so score is 1 only when every case passes. Ask which one the project wants. Partial credit can reward answers that are right only on easy cases.
Make the checker fair
- Accept any correct method. Check the output, not the algorithm.
- Compare numbers with a tolerance when floats are involved. The math module's isclose takes rel_tol and abs_tol, and with the default abs_tol of 0 a comparison against zero only passes for exactly zero.
- Strip trailing whitespace but nothing else, so format errors are still caught.
- Set a time limit generous enough for a correct slow solution and tight enough to reject a brute-force one, if speed matters.
- Test the checker itself with a correct solution, a wrong solution and a crashing one.
Source: Python docs: math.isclose(opens in a new tab)
Cases that make a problem hard to cheat
Include small cases that pin down the spec, edge cases such as the empty list, and larger cases that break the naive method. Keep some cases hidden from the statement. If a model could pass by printing the sample output, add a case where the sample answer is wrong.
Common mistakes
- Ambiguous statements that allow two right answers.
- A reference solution that is wrong on an edge case nobody tested.
- A checker that depends on a specific operating system, path or locale.
- Output formats that allow harmless variation, such as spacing in JSON, but are compared as raw text.
- Cases generated by the reference solution and never reviewed by hand.
Check before you submit
- Solve the problem a second way, by brute force, and compare outputs on random small inputs.
- Give the statement to a colleague who has not seen your solution and see whether they write the same function.
- Run the checker against deliberately wrong answers and confirm each one fails.
Curatrain lists problems a program can check (RLVR) among the work its experts do, and tests engineering skills at graded levels. Experts are matched only to jobs whose tests they have passed. Sign up free at curatrain.com/login.