Elamur Research

Coffee-Gym: An Environment for Evaluating and Improving Natural Language Feedback on Erroneous Code

Paper · 2024 · Hyungjoo Chae, Taeyoon Kwon, Seungjun Moon et al.

Summary

A program can end up working even when the advice used to repair it points to the wrong part of the code. A capable editor may spot the bug independently and fix it. That is a good outcome for someone who wants a working program, but it gives weak evidence about the quality of the advice. Coffee-Gym takes up this measurement problem. The authors want to train systems that explain what went wrong in a program and suggest a repair that another system can carry out.

Coffee supplies the training examples. The authors collected histories from a competitive programming platform, where people sometimes submit several unsuccessful versions before arriving at an accepted solution. They used those histories to create examples of advice leading toward a working program and advice describing a change that still leaves a program wrong. The submissions came from human programmers, while GPT-3.5-Turbo wrote the feedback and proposed inputs for synthetic unit tests. The authors obtained the expected outputs by running accepted solutions.

CoffeeEval, the evaluation component, gives the programming problem, the faulty code and the advice to an editor. It then scores the advice by the share of tests the edited program passes. The crucial design choice is how the editor is trained. It sees useful instructions paired with successful edits and misleading instructions paired with unsuccessful edits. On Coffee’s feedback evaluation split, the resulting evaluator reached a Pearson correlation of 0.149 with the feedback labels, compared with 0.135 for GPT-4-Turbo using G-Eval. When judged by whether the edited code passed every test, GPT-4-Turbo repaired cases with wrong feedback at a rate of 51.8%, compared with 28.4% for the CoffeeEval editor. The authors wanted that tendency to be lower in a system used to judge advice.

The authors then used CoffeeEval to train a feedback generator. Its strongest training setup used proximal policy optimization. Paired with DeepSeek-Coder, the resulting feedback raised Pass@1 from 60.4 to 73.8 on HumanEvalFix and from 33.8 to 47.2 on the held-out Coffee-Test problems. The same setup also improved editing with CodeGemma and OpenCodeInterpreter-DS-Coder. Its standing relative to feedback from GPT-4-Turbo depended on the editor and benchmark. These experiments show that repair outcomes can guide the training of a feedback generator and that the editor used to score advice matters. The authors released the Coffee dataset and a trained checkpoint.

Deep dive: Coffee-Gym: An Environment for Evaluating and Improving Natural Language Feedback on Erroneous Code

Coffee-Gym trains and evaluates written feedback for buggy Python code by testing the repairs an editor makes after reading it. · about 34 minutes to read

The problem and its context

A successful repair can conceal bad advice

The paper opens with a small example from code and programming languages. A function must decide whether distinct entries in a list can add up to zero. The outer loop skips the first entry, so the function never considers combinations that need it. One piece of advice tells the editor to check that the indices are distinct. The loop structure already ensures that condition. Another piece of advice identifies the skipped entry and tells the editor where the search should start. The difference matters because one suggestion addresses the behavior that causes missed answers, while the other can leave that behavior in place.

A person reading the two suggestions can compare them with the program and the problem statement. An experiment that uses an automatic editor has another source of evidence. It can ask the editor to act on each suggestion, then run the edited programs. That procedure seems to give the experiment an observable outcome. Yet an editor that understands the programming problem may diagnose the skipped entry for itself. If it does so under either suggestion, the two runs can produce equally good repairs even though the advice differed in a consequential way.

The reverse is also possible. Good advice can name the right change, and the editor can still implement it badly. Coffee-Gym is built around the idea that the outcome of an edit is informative about the feedback only to the extent that the editor’s response reflects the feedback. Test execution establishes how the resulting program behaves on specified inputs. The design of the editing step determines how much of that result can reasonably be attributed to the advice.

This distinction also explains why the authors separate the system that is useful for evaluation from the editors that they ultimately want to help. In ordinary use, independent knowledge is valuable. An editor that sees through a bad suggestion can save the programmer from an unnecessary change. In evaluation, that same behavior makes correct and incorrect suggestions harder to distinguish. The research problem is to build an editing procedure sensitive enough to advice that test outcomes can serve as supervision for learning to write it.

What earlier repair systems supplied

Earlier work, as the paper describes it, used both execution feedback and natural-language feedback. Execution feedback comes from running the original program. An error message can reveal that execution failed, and test feedback can provide evidence of an incorrect result. Those observations give an editor a concrete symptom. Written feedback can go further by interpreting the symptom in light of the task, identifying a missing part of the algorithm or explaining the intended use of a function. The self-debugging study by Chen and colleagues is among the studies the authors associate with feedback from execution.

Self-Refine illustrates the other route. The system generates feedback and uses that feedback to revise an earlier output. Coffee-Gym’s authors describe it as evidence that written advice from GPT-4 can substantially improve editing, while also emphasizing the difficulty of getting similarly helpful advice from less powerful systems. They cite Reflexion among the related approaches that use feedback expressed in words. OpenCodeInterpreter, another predecessor discussed in the paper, investigated feedback from both execution and natural language and supplied a dataset for learning from feedback.

The authors’ interest in an openly available feedback generator follows from this history. If helpful advice requires a powerful closed service, repeated calls can be costly. Sending proprietary source code to an external service can also limit where a workflow is acceptable. The research question is whether a generator that can be run independently can supply advice of comparable practical value in the kinds of editing tasks the study measures.

A direct training strategy would be to collect examples of advice from a strong system and teach another system to produce similar text. This is supervised fine-tuning. It gives the learner an example of a desirable response for each input. For Coffee-Gym, the input is a programming problem and an erroneous solution, and the response is a feedback message. The authors’ objection concerns the training signal. Reproducing a plausible explanation and helping an editor make a successful correction are distinct tasks. Supervised training from demonstration text observes the former directly. To observe the latter, the procedure must connect the advice to a downstream edit.

Why test-based learning needs an extra step here

The paper draws on the use of preferences and rewards in instruction following with human feedback. In Coffee-Gym, a preference says which of two feedback messages is more useful for the same problem and the same starting code. A reward expresses the quality of an individual message as a score. Both provide a way to train for something beyond similarity to a demonstration, provided that the comparison or score reflects the intended behavior.

The authors identify practical gaps in the available training setup. A pool of machine-generated repairs can miss failures found in human attempts, especially on problems that are already difficult for an automatic solver. A collection of good explanations alone provides little direct evidence about how to distinguish useful guidance from plausible bad advice. A reward must also be cheap enough to use repeatedly during training and reliable enough for repeated optimization to be worthwhile.

Earlier research had already used tests as a source of reward for code generation. The paper’s account of that work clarifies what changes when the item being scored is a feedback message. In code generation, the generated program itself can be executed. Here the generated object is text describing a proposed change. An editor translates that text into code, and only then can execution take place. There is an extra decision maker between the output of the learner and the measurement.

A text judge offers another approach. The paper uses G-Eval as its example. A judge reads the problem, the incorrect program and the proposed feedback, then gives the feedback a rating using a rubric. This approach evaluates the wording and diagnosis directly. CoffeeEval asks instead what a particular editor does with the feedback and how the resulting program behaves. The two approaches answer related questions, and the paper compares them using the same labeled feedback. That comparison matters because the reward is ultimately intended to guide a generator whose output will be used in a real editing step within the experiment.

The method, step by step

Separate writing advice from making the edit

The feedback generator receives a programming problem and a proposed solution that contains an error. It returns a message explaining what needs to change. The editor then sees the same problem, the same starting solution and that message. Its job is to return an edited program. This arrangement lets the researchers exchange the feedback source while keeping the downstream editor fixed. It also lets them compare the behavior of different editors given the same advice.

How Coffee-Gym collects, scores and learns from feedback

The steps in order.

How Coffee-Gym collects, scores and learns from feedbackStep 1: Collect human submission histories ending in accepted code1. Collect human submission histories ending in accepted codeStep 2: Describe successful and unsuccessful edits as feedback2. Describe successful and unsuccessful edits as feedbackStep 3: Generate test inputs and obtain reference outputs3. Generate test inputs and obtain reference outputsStep 4: Train an editor on both kinds of advice4. Train an editor on both kinds of adviceStep 5: Apply candidate feedback to the faulty solution5. Apply candidate feedback to the faulty solutionStep 6: Score the revised code by running tests6. Score the revised code by running testsStep 7: Train the feedback generator using scores or preferences7. Train the feedback generator using scores or preferences

The paper represents the generation of advice as follows.

ĉ = θ(q, y)

Here q is the problem description and y is the defective solution. The symbol θ denotes the feedback generator, and ĉ denotes the feedback it produces. The parentheses show the inputs supplied to the generator. The hat on ĉ distinguishes generated feedback from annotated feedback used as a training target.

The edit is a separate operation.

y′ = ϕ(q, y, ĉ)

Here ϕ denotes the editor and y′ is its proposed revision. The editor receives q, the original problem, y, the starting program, and ĉ, the generated advice. In the description of CoffeeEval and the data collection, the paper frequently uses ỹ for an incorrect program and y∗ for an accepted one. The prime on y′ denotes a new output from the editor, whose correctness still has to be tested.

Recover edits from actual submissions

Coffee starts with an online competitive programming platform. A programmer can submit successive attempts at the same problem, and the platform evaluates them with its hidden tests. The authors select histories that end in an accepted submission and use the earlier unsuccessful attempts as examples of faulty code. They pair each unsuccessful attempt with the accepted endpoint of its own history. This permits the final solution to serve as a reference for several earlier attempts, even if the programmer took intermediate steps between them.

{(q, ỹₖ, yₙ∗)}ₖ₌₁ⁿ⁻¹

The braces enclose the collection of triples drawn from a history. Each triple contains the problem q, an incorrect submission ỹₖ and the final accepted submission yₙ∗. The subscript k identifies the position of an earlier submission, while n is the position of the final one. The indicated range starts at 1 and ends at n − 1, so the accepted endpoint stays fixed while the starting submission changes. The tilde and asterisk distinguish rejected and accepted code.

The authors sample equal numbers of problems across five difficulty levels, spanning beginner through expert tasks. They collect histories from 100 different users to obtain different ways of tackling the same problem. They also filter cases in which different users submitted identical accepted programs, which they regard as likely to include copied solutions that give little evidence of a genuine editing history. Histories where the annotation system fails to identify an error are left out.

A history supplies an association between a failed attempt and an eventual solution, alongside the sequence of edits a person actually submitted. The same accepted solution may differ from one starting attempt in a small output-format change and from another in much more of the implementation. Coffee therefore has examples where the instruction can be very local and examples where the relationship between the failed program and the accepted one calls for a broader explanation. The training procedure uses these actual transitions as the material to describe.

The paper’s example about reporting the positions of letters shows what a local edit looks like. The starting program builds a list of positions, then prints the list directly. The accepted version prints its entries as individual values. Useful feedback identifies the output representation and tells the editor what to change in the print operation. A different suggestion proposes using a dictionary, which diverts attention from the observed failure. An editor can test a change in formatting by running the revised program and comparing the resulting output with the expected one.

Describe a successful edit and an unsuccessful one

For positive feedback, GPT-3.5-Turbo sees the incorrect program and the accepted solution. It writes guidance informed by the difference between them. The generator that Coffee-Gym trains later gets just the problem and the incorrect code at inference time. The accepted code belongs to the annotation process, where its purpose is to make the training target more informative than a diagnosis produced without a reference.

The authors obtain negative feedback by describing transitions from one incorrect submission to the next incorrect submission in the same history. They ask the annotation system to explain how to make the change between those programs while treating the destination as though it were correct for the purpose of writing the instruction. This produces guidance with a concrete target. If the editor carries it out, the resulting program can still fail the task.

That construction gives the negative examples a particular character. An intermediate change can be syntactically valid, relevant to the problem and even an improvement on the earlier attempt. The destination nevertheless remains an unsuccessful solution. A negative label therefore identifies advice associated with an edit that fails to finish the repair. Its language can sound reasonable because it refers to something a programmer really changed. Those properties make it a useful comparison for advice leading to the accepted endpoint.

The preference notation records which response is chosen for a particular input.

c⁺ ≻ c⁻ | q, y

The symbol c⁺ denotes the chosen advice and c⁻ the rejected advice. The relation ≻ means the first is preferred, and the vertical bar indicates that both are being compared for the same problem q and faulty program y. In preferences drawn from the annotated histories, c∗ denotes the advice leading toward accepted code and c̃ the advice describing an unsuccessful change. The paper also builds preferences from sampled feedback, where the choice depends on the scores assigned by CoffeeEval.

For annotation, the authors report top-p sampling with p set to 0.95 and temperature set to 0.7. Top-p sampling limits the candidate continuations to a group that accounts for the specified share of the predicted probability. Temperature changes how concentrated those probabilities are during sampling. The generation limit is 500 tokens, where tokens are the units in which the system reads and writes text. These are settings for producing the feedback annotations. They describe the construction of the training material instead of the settings of every generator in the later experiments.

Build tests whose expected outputs come from accepted programs

The programming platform keeps its own tests private. Coffee-Gym needs tests it can run on newly edited programs, so the authors create a synthetic suite for each problem. GPT-3.5-Turbo proposes inputs. The paper describes a prompt with three demonstrations to guide this generation. The authors run accepted code on the proposed inputs and use the observed outputs as the expected results. When an input causes execution of the reference code to fail, they remove that case.

T = {t₁, t₂, …, tₖ}

Here T is the test suite. Each t with a subscript is an individual test case, beginning with t₁ and ending with tₖ. The ellipsis denotes the cases between those shown, and k is the total number of cases in the suite. A case tᵢ, indexed by i, contains an input xᵢ and an expected output zᵢ.

The main text reports an average of 35.5 tests per problem. The roles of the input generator and the accepted program are deliberately distinct. The generator proposes situations in which to exercise the code. The accepted program determines the answer for those situations. If the system proposing an input also guessed the expected answer, an editor could be penalized for disagreeing with a mistaken guess. Executing a reference removes that particular source of disagreement. The suitability of the proposed inputs still influences which bugs the suite can expose.

The same suite can be used to distinguish different degrees of repair. A program that gets ordinary inputs right and fails on a less usual input has a different test profile from one that fails broadly. This matters when comparing advice. Some unsuccessful suggestions may lead to changes that help on part of the suite. A graded score preserves that information for training, while the final editing benchmarks can require every test to pass.

Teach the evaluator’s editor to act on the advice

CoffeeEval uses DeepSeekCoder-7B as the starting point for its editor. The authors argue that a general coding system has been trained to produce correct code, so it may make a sensible repair even when the feedback points elsewhere. They train the evaluator’s editor on both outcomes from Coffee. With advice describing a successful change, the target is the accepted code. With advice describing an unsuccessful change, the target is the corresponding still-incorrect code.

The paper gives the editor’s untagged loss in the main method and again in the appendix for the second training phase.

L(ϕ) = −∑[(q, y, c∗, y∗) ∈ Dcorrect] log pϕ(y∗ | q, y, c∗)
       −∑[(q, y, c̃, ỹ) ∈ Dwrong] log pϕ(ỹ | q, y, c̃)

Here L(ϕ) is the training loss for editor ϕ. The two ∑ signs indicate sums over the examples specified in brackets. The ∈ sign means that the tuple belongs to the named dataset. Dcorrect is the collection of successful edits, with problem q, starting program y, positive feedback c∗ and accepted target y∗. Dwrong is the collection of unsuccessful edits, with the same kinds of input and a different feedback and target pair. In that pair, c̃ describes the change to ỹ, which remains incorrect. The notation pϕ denotes the probability the editor gives the target sequence, and the vertical bar separates that target from the information supplied to the editor. The logarithm is written log. The minus signs make low probability for a training target contribute a larger loss to be minimized.

The first training phase gives the editor additional information in the target sequence. Accepted code is marked with [Correct], and code that still fails is marked with [Wrong]. The appendix describes the first phase with the following objective.

L(ϕ) = −∑[(q, y, c∗, y∗) ∈ Dcorrect] log pϕ(t∗, y∗ | q, y, c∗)
       −∑[(q, y, c̃, ỹ) ∈ Dwrong] log pϕ(t̃, ỹ | q, y, c̃)

The symbols for loss, probability, the editor, problems, starting code, feedback, targets and data collections have the meanings just given. The additions are t∗, the [Correct] marker, and t̃, the [Wrong] marker. The comma before each target program represents the marker and program as parts of the same target sequence. These markers belong to the editor training targets. Test cases use the separate notation tᵢ, with an index. In the second phase the authors keep the same examples and remove the markers, training with the untagged objective. At evaluation time the editor receives the problem, program and advice, without a correctness label for the advice.

Both phases use the same reported hyper-parameter settings. The authors use QLoRA with 4-bit quantization. This lets them adapt the editor using low-rank trainable components while storing its underlying weights at reduced precision. They report a learning rate of 5e-5, a batch size of 4 and 2 epochs. The low-rank dimension is 64 and the LoRA alpha setting is 16. The reported training hardware is 8 NVIDIA GeForce RTX 3090 GPUs. These details concern the CoffeeEval editor, which supplies the reward. The feedback generator is trained for a different output.

Turn the edit into a score and the score into training data

CoffeeEval applies the trained editor once to the starting program and generated advice for the scoring operation. It runs the proposed revision on the test inputs and compares the program’s outputs with the expected ones. The score is the fraction of cases on which those outputs agree.

CoffeeEval(q, ỹ, ĉ, ϕ, T) = (1/k) ∑ᵢ₌₁ᵏ 𝟙[ϕ(q, ỹ, ĉ)(xᵢ) = zᵢ]

The inputs to CoffeeEval are the problem q, the faulty code ỹ, the generated feedback ĉ, the editor ϕ and the test suite T. The expression ϕ(q, ỹ, ĉ) is the revised program, and the additional parentheses around xᵢ mean to run that program on test input xᵢ. Its result is compared with zᵢ, the expected output for that test. The bold 𝟙 is an indicator, which is 1 when the bracketed equality holds and zero otherwise. The sum runs from the first test through test k. Dividing by k turns the count of successful tests into a share of the suite.

The unit of attribution is the feedback message in its particular editing situation. The reward depends on the same message’s interpretation by ϕ and the behavior of the resulting code over T. A diagnosis that supplies just enough information to fix a problem can receive the same score as a longer explanation if the edits have the same test outcomes. Conversely, a detailed diagnosis that produces a poor revision through this editor receives a low score. That is the operational meaning of helpfulness in the reward calculation.

The authors first initialize the feedback generator by supervised fine-tuning. They train it to assign high probability to the annotated feedback for a problem and faulty program. The accepted code is available when constructing those annotations, but the supervised generation target is the feedback text. The authors then compare different ways of optimizing the initialized generator for useful advice.

In rejection sampling, they draw 10 candidate messages from the supervised generator for a case and score the resulting edits with CoffeeEval. They keep the top-1 message as a new target for supervised training. This turns the reward into a filter on demonstrations. The generator learns from the selected text through the familiar supervised objective.

In direct preference optimization, abbreviated DPO, the generator learns from pairs of responses ranked for the same input. One variant uses the labeled correct and wrong feedback from Coffee. Another samples 10 candidates and pairs the top-1 and bottom-1 according to CoffeeEval. A teacher–student variant treats GPT-3.5-Turbo feedback as preferred and the supervised generator’s answer as rejected. The paper relates that variant to the approach in Zephyr. The variants differ in the evidence used to assign a preference, even though each supplies the learning procedure with a chosen and a rejected response.

With proximal policy optimization, abbreviated PPO, CoffeeEval provides a reward while the feedback generator is being updated. The policy is the generator’s probability distribution over continuations. It can produce feedback, receive a score based on the edit, and change the probabilities of its future outputs. The paper expresses the PPO objective as follows.

Lₚₚₒ(θ) = Êₜ[min(rₜ(θ) Âₜ, clip(rₜ(θ), 1 − ϵ, 1 + ϵ) Âₜ)]

Here Lₚₚₒ(θ) is the objective optimized over feedback policy θ. Êₜ denotes an empirical average over timesteps indexed by t. The ratio rₜ(θ) compares the probability assigned to the sampled action by the current policy with its probability under the old policy, denoted θold in the paper. Âₜ estimates the advantage at that timestep, expressing how favorable the sampled action was relative to the reference used to estimate advantage. Multiplication is indicated by juxtaposition. The clip operation confines the probability ratio to the interval from 1 − ϵ to 1 + ϵ, where ϵ controls the range. The min operation takes the smaller of the unclipped and clipped expressions. That comparison limits the incentive to make large changes based on the sampled experience.

Experiments and results

Can the evaluator distinguish good advice from bad advice?

The first experiment evaluates CoffeeEval itself. Each feedback item on the Coffee evaluation split has a binary label. The positive class is feedback associated with a correct edit. The negative class is feedback associated with an incorrect edit. The evaluator can return a continuous score representing the share of tests passed, and the authors also derive a binary prediction. They count the feedback as positive when the edited program passes every test.

The paper compares two families of baselines. G-Eval asks GPT-4-Turbo or GPT-3.5-Turbo to rate feedback on a scale from 1 to 5 using a rubric for accuracy. The textual input includes the problem and the faulty program, so the judge can compare the suggestion with the code. The Editing baselines use the same general procedure as CoffeeEval, making a revision and testing it, but substitute GPT-4-Turbo, GPT-3.5-Turbo or DeepSeek-Coder-7B as the editor. The authors also include a CoffeeEval editor trained without wrong feedback examples. The latter comparison makes it possible to examine the value of the negative training data within the same evaluation framework.

Several measures describe different aspects of performance. Pearson correlation measures the association between the predicted scores and the reference labels. Mean squared error, abbreviated MSE, averages squared prediction error and favors smaller deviations under the scoring protocol. At the all-tests threshold, the correct-feedback pass rate describes how frequently a useful instruction leads to a fully passing edit. The wrong-feedback pass rate describes how frequently the same outcome occurs under an instruction labeled wrong. Precision is the share of positive predictions that correspond to positive labels. Recall is the share of positive labels recovered by those predictions. F1 combines precision and recall using their harmonic mean.

Feedback evaluation methods on the Coffee evaluation split by Pearson correlation

The editor trained on both feedback labels has the strongest association with the reference labels.

Feedback evaluation methods on the Coffee evaluation split by Pearson correlationG-Eval with GPT-4-Turbo: 0.135G-Eval with GPT-4-Turbo0.135G-Eval with GPT-3.5-Turbo: -0.172G-Eval with GPT-3.5-Turbo-0.172Editing with GPT-4-Turbo: 0.012Editing with GPT-4-Turbo0.012Editing with GPT-3.5-Turbo: 0.101Editing with GPT-3.5-Turbo0.101Editing with DeepSeek-Coder-7B: 0.077Editing with DeepSeek-Coder-7B0.077CoffeeEval without wrong feedback training: 0.085CoffeeEval without wrong feedbacktraining0.085CoffeeEval (this paper): 0.149CoffeeEval (this paper)0.149
The numbers
System or settingPearson correlation
G-Eval with GPT-4-Turbo0.135
G-Eval with GPT-3.5-Turbo-0.172
Editing with GPT-4-Turbo0.012
Editing with GPT-3.5-Turbo0.101
Editing with DeepSeek-Coder-7B0.077
CoffeeEval without wrong feedback training0.085
CoffeeEval (this paper)0.149

On the Coffee evaluation split, CoffeeEval also has the lowest reported MSE, 0.408. G-Eval with GPT-4-Turbo has an MSE of 0.415, and editing with GPT-3.5-Turbo has an MSE of 0.417. The separation between those values and the full evaluator’s result is small. The table establishes the ordering under the paper’s protocol. The reported correlation values also show that agreement between scores and labels leaves substantial room for improvement.

The all-tests threshold exposes a sharper difference in behavior. When GPT-4-Turbo is the editor, the passing rate is 53.0 with correct feedback and 51.8 with wrong feedback. A generally strong editor can therefore yield a successful program in either case. CoffeeEval’s corresponding pass rates are 52.0 and 28.4. Its rate with correct guidance is close to the GPT-4-Turbo editing baseline, while fewer edits made with wrong guidance pass all tests. These results explain how an evaluator with a slightly lower success rate on good advice can still produce a better classification of feedback quality.

The full CoffeeEval editor records precision of 64.7, recall of 52.0 and F1 of 57.7 on this split. The GPT-4-Turbo Editing baseline records precision of 50.6, recall of 53.0 and F1 of 51.8. The comparison is useful because the two systems recover a similar share of labeled positive instances at the chosen threshold. The main difference lies in what happens when the labeled advice is wrong. An evaluator that passes fewer such instances has fewer false positives among its successful edits.

Does the trained feedback improve code repair?

The next experiment asks a different question. The authors use CoffeeEval to train a feedback generator, and then place its advice in front of general code editors. In the main comparisons, the feedback generator is the one trained with PPO. The endpoint is a repair that passes the benchmark tests, regardless of how the editor reached it. The specialized editor used to compute training rewards and the general editors whose performance is reported here have different jobs.

HumanEvalFix is a repair task within HumanEvalPack. Its starting programs are functions derived from HumanEval solutions and altered with human-authored bugs. The description of the broader dataset lists 164 source samples, a total of 984 bugs and six programming languages. The bugs are designed to allow execution while producing an incorrect result on at least one test. Coffee-Gym’s own implementation is in Python, so the multilingual size of the broader benchmark gives context for the resource and does not establish multilingual coverage for the reported approach.

Coffee-Test is the other main benchmark. It contains 180 held-out instances, each with a programming problem, a faulty solution, an accepted solution and tests. The authors collect it using the same general procedure as Coffee and exclude overlapping problems. That split tests new tasks from a familiar collection process. HumanEvalFix tests a different source of bugs. The authors also check for overlap between Coffee and HumanEval, an issue discussed in more detail under limitations.

Both benchmarks use Pass@1. For a single submitted revision, success means passing every test for the problem. The paper’s general formula also describes how to express the expected single-attempt success rate when there are sampled solutions.

Pass@1 = Eₚᵣₒᵦₗₑₘₛ[c/n] × 100

Here Eₚᵣₒᵦₗₑₘₛ means to take the average over the problems. For each problem, n is the number of generated attempts and c is the number of those attempts whose code passes the test suite. In this formula c is a count, while in the method notation it denotes feedback. The ratio c/n gives the estimated probability of success for one sampled attempt. Multiplication by 100 expresses the resulting average as a percentage. CoffeeEval’s reward is a fraction of tests passed by a program. Pass@1 is a rate of programs that meet the full success criterion.

The paper compares editing without added feedback and editing with several kinds of guidance. Execution feedback makes the result of running the starting code available to the editor. Self-feedback gives the editor its own explanation of the problem. OpenCodeInterpreter-DS-Coder supplies feedback to the other open editors, and DeepSeek-Coder is used as the separate open feedback source when OpenCodeInterpreter-DS-Coder edits. The authors also run comparisons with feedback from GPT-3.5-Turbo and GPT-4-Turbo. Keeping the editor fixed within these comparisons makes differences in performance interpretable as differences between feedback arrangements for that editor.

Feedback given to DeepSeek-Coder on Coffee-Test by Pass@1

DeepSeek-Coder repairs the most held-out programs when it receives feedback trained with CoffeeEval.

Feedback given to DeepSeek-Coder on Coffee-Test by Pass@1Without added feedback: 33.8Without added feedback33.8Execution feedback: 38.3Execution feedback38.3Self-feedback: 28.3Self-feedback28.3OpenCodeInterpreter-DS-Coder feedback: 30.5OpenCodeInterpreter-DS-Coder feedback30.5GPT-3.5-Turbo feedback: 35.5GPT-3.5-Turbo feedback35.5GPT-4-Turbo feedback: 44.4GPT-4-Turbo feedback44.4PPO-CoffeeEval feedback (this paper): 47.2PPO-CoffeeEval feedback (this paper)47.2
The numbers
System or settingPass@1 %
Without added feedback33.8
Execution feedback38.3
Self-feedback28.3
OpenCodeInterpreter-DS-Coder feedback30.5
GPT-3.5-Turbo feedback35.5
GPT-4-Turbo feedback44.4
PPO-CoffeeEval feedback (this paper)47.2

With DeepSeek-Coder as the editor on HumanEvalFix, unassisted Pass@1 is 60.4. Execution feedback brings it to 68.3. PPO-CoffeeEval feedback brings it to 73.8, while GPT-4-Turbo feedback gives 74.4. The relative ordering of those last two sources reverses on Coffee-Test. The result is a close comparison with GPT-4-Turbo feedback in this pairing, with the advantage depending on the benchmark.

CodeGemma shows a different pattern. On HumanEvalFix, its Pass@1 is 53.7 without added feedback, 61.6 with execution feedback and 59.7 with PPO-CoffeeEval feedback. GPT-4-Turbo feedback reaches 65.8. On Coffee-Test, CodeGemma starts at 14.4 and reaches 31.1 with the paper’s feedback. GPT-4-Turbo feedback reaches 22.7 on that held-out set. The gains from the trained feedback carry across both benchmarks for this editor, while its ranking relative to execution feedback and GPT-4-Turbo depends on the task set.

With OpenCodeInterpreter-DS-Coder as editor, Pass@1 on HumanEvalFix is 65.8 without added feedback, 70.1 with PPO-CoffeeEval feedback and 72.5 with GPT-4-Turbo feedback. On Coffee-Test, the corresponding values are 30.5, 42.7 and 43.3. In this pairing GPT-4-Turbo feedback stays ahead on both benchmarks. The trained Coffee-Gym feedback also outperforms this editor’s self-feedback on both, which reaches 62.1 on HumanEvalFix and 21.1 on Coffee-Test. That comparison shows that a system’s ability to edit code and its ability to diagnose code in words can differ, even on the same task.

Feedback for CodeGemma on Coffee-Test by Pass@1

The trained feedback provides the largest gain for this editor on the held-out Coffee problems.

Feedback for CodeGemma on Coffee-Test by Pass@1Without added feedback: 14.4Without added feedback14.4Execution feedback: 15.0Execution feedback15.0Self-feedback: 16.6Self-feedback16.6GPT-3.5-Turbo feedback: 22.2GPT-3.5-Turbo feedback22.2GPT-4-Turbo feedback: 22.7GPT-4-Turbo feedback22.7PPO-CoffeeEval feedback (this paper): 31.1PPO-CoffeeEval feedback (this paper)31.1
The numbers
System or settingPass@1 %
Without added feedback14.4
Execution feedback15.0
Self-feedback16.6
GPT-3.5-Turbo feedback22.2
GPT-4-Turbo feedback22.7
PPO-CoffeeEval feedback (this paper)31.1

Across the editors, execution feedback improves on the unassisted results reported in the paper. Self-feedback is less dependable. It increases DeepSeek-Coder’s HumanEvalFix result to 67.7, but with the same editor on Coffee-Test it falls below the unassisted result. For OpenCodeInterpreter-DS-Coder, it falls below the unassisted result on both benchmarks. The comparison also shows why the paper describes the trained feedback as comparable to strong closed alternatives under some conditions. In these rows the closed systems write the advice, and the open editor makes the repair.

The table separately reports GPT-4-Turbo editing directly at 83.5 Pass@1 on HumanEvalFix and 43.8 on Coffee-Test. GPT-3.5-Turbo editing directly gets 75.0 and 32.2, respectively. Those results characterize different editing setups from the rows in which those same systems supply guidance to an open editor. For a reader comparing practical options, both views matter. The feedback rows hold the editor fixed while changing its guidance. The direct-editing rows allow the entire repair procedure to change.

Library-oriented and repeated editing tasks

The authors also evaluate a setting in which generation and editing happen within the same sequence of attempts. OpenCodeInterpreter-DS-Coder generates code, receives feedback and revises. On the HumanEval tasks used for this analysis, successive editing rounds with the trained feedback improve performance in the authors’ reported figure. PPO and DPO give better outcomes than rejection sampling in this setting. That comparison adds evidence about the use of feedback after an initial generated attempt, beyond the main task in which the benchmark supplies an erroneous starting program.

NumpyEval gives another test of transfer, this time to programming tasks involving NumPy. OpenCodeInterpreter-DS-Coder generates and edits the programs in both conditions. When it also supplies its own feedback, Pass@1 is 68.3. With PPO-CoffeeEval feedback, Pass@1 is 70.3. The paper includes examples in which the task is expressed as Python comments, and examples where the feedback itself includes code for a proposed edit. Those cases and the benchmark result establish a limited form of transfer to library-oriented tasks while retaining the same language.

What the ablations show

Negative examples change how the editor uses advice

The most direct ablation removes wrong-feedback examples from the training of the CoffeeEval editor. On the Coffee evaluation split, the editor trained under that condition has Pearson correlation of 0.085 and MSE of 0.418. Its all-tests pass rate on correct feedback is 36.4, and its rate on wrong feedback is 28.4. The full CoffeeEval editor reaches correlation of 0.149 and MSE of 0.408, with pass rates of 52.0 for correct advice and 28.4 for wrong advice.

This comparison shows precisely where the change appears at the all-tests threshold. Exposure to wrong-feedback training is associated with more successful edits when the advice is correct, while the reported pass rate under wrong advice stays at 28.4. The mechanism suggested by the authors is that learning both kinds of transition helps the editor use the feedback more faithfully. The numerical result supports better discrimination and, in this ablation, its clearest threshold effect comes from recovering more genuine positives.

The comparison with ordinary editing supplies a complementary view. GPT-4-Turbo’s near-equal pass rates on correct and wrong feedback show what happens when a competent editor often resolves the task in its own way. The CoffeeEval editor has a much wider separation between those conditions. The distinction between these two comparisons is important. The ablation holds the CoffeeEval design mostly in place while changing its training examples. The comparison with a different editor demonstrates how readily an editing-based measurement can change with the system used to implement it.

Larger suites improve the reward within the tested range

The authors vary the number of test cases used by CoffeeEval and track Pearson correlation and MSE against the feedback labels. The reported figure shows better alignment as more cases are included. A program with a remaining fault may pass a small collection of ordinary inputs. If a larger suite contains a case that exposes the fault, the reward can distinguish that program from an edit that handles both types of input. An editor’s response to the advice can be the same in both runs and still yield a more informative reward under the larger suite.

The authors separately examine whether the synthetic tests catch bugs in programs the platform judged incorrect. They randomly sample 200 incorrect programs from the Coffee evaluation split. For those programs, the mean pass ratio is 0.342, with a standard deviation of 0.370. The median is 0.162 and the maximum is 0.985. Every sampled incorrect program therefore fails at least one synthetic test. The authors also report that the faulty starting programs in Coffee-Test fail at least one test. In an analysis restricted to a single Coffee problem, incorrect solutions have a range of pass ratios, suggesting that the suite can give different amounts of credit to different faulty approaches to the same task.

Together, the analyses examine two properties of the tests. The check on known incorrect programs asks whether the suites catch errors in the benchmark material. The test-count ablation asks whether the resulting scores become better at distinguishing labeled advice as coverage grows. Both properties matter for training. A suite can catch at least one error in every faulty starting program and still assign similar scores to two edited programs that differ in helpful ways.

The source of a preference matters

The training-strategy comparison begins at supervised fine-tuning. On Coffee-Test, the paper reports more helpful feedback from supervised training on Coffee than from supervised training on Code-Feedback. The comparison makes Coffee a credible source of demonstrations before any use of its preferences or reward. Because the datasets differ in several ways at once, the experiment assesses the choice of dataset as a whole. It cannot isolate how much of the result comes from problem difficulty, human submission histories or the form of the feedback annotations.

Among the DPO variants, the one that ranks sampled feedback by CoffeeEval does best in the reported comparison. Training on the correct and wrong pairs supplied by Coffee is close behind. The teacher–student variant performs worse. Its ordering treats the teacher’s response as preferable to the student’s for each case. The authors suggest the student can sometimes offer better feedback, making teacher identity an imperfect guide to which text belongs on the chosen side of a pair. This is an explanation for the observed ordering instead of a direct measurement of how often the teacher loses.

The two stronger preference sources each connect the ranking to something about the proposed edit. Coffee’s annotated pairs distinguish advice leading towards accepted code from advice describing an intermediate unsuccessful change. The score-ranked pairs compare the consequences of candidate messages through the test-running editor. These procedures can choose different messages, but each supplies case-specific evidence for the ranking.

PPO produces the strongest result in the main training-strategy comparison, ahead of DPO and rejection sampling constructed with the same CoffeeEval scoring procedure. Rejection sampling retains the highest-scoring candidate as a demonstration. Score-based DPO keeps the contrast between the highest- and lowest-scoring messages. PPO draws feedback from the evolving generator and applies rewards during its updates. The authors hypothesize that collecting feedback from the changing generator contributes to the result. The comparison establishes the ranking of the tested procedures on Coffee-Test. It changes how examples are obtained and used along with the optimization procedure, so the individual effects of those choices remain unresolved.

The analysis looks at the submitted programs and the advice

The authors use CodeBERT to examine how varied the erroneous programs are. They select Coffee problems with submissions from more than 100 users and compare the wrong programs from people with equally sized samples of wrong answers from ChatGPT and GPT-4. CodeBERT maps each program to an embedding, a numerical representation used to compare programs. The authors calculate cosine similarity for pairs within each source group and summarize the pairwise similarities by problem. In this representation, the incorrect machine-generated programs in the sample generally cluster more tightly than the human submissions do.

Other dataset analyses examine task difficulty. Human submission histories tend to grow longer as platform difficulty increases, indicating more failed attempts in the collected histories. The authors also compare GPT-4’s Pass@1 on Coffee problems with the platform’s human solve-rate metadata. GPT-4 struggles on the tasks in this comparison. The human rate measures successful submissions among submissions made on the platform. Alongside the trace-length analysis, the comparison supports the claim that Coffee contains demanding tasks. The human and automatic scores describe different processes.

The error-type breakdown on HumanEvalFix shows that the trained feedback is particularly effective on missing logic and function misuse. In both categories, a message can add an explanation of how the program should behave or what a function call should do. The paper reports weaker relative performance on value misuse and suggests that the errors in human submission histories and those introduced for a benchmark may be distributed differently. The breakdown identifies where the results vary. Establishing why would require evidence about the actual mix of training errors and the cause of individual edit failures.

The paper also asks people to assess the advice directly. One study concerns the training annotations. Qualified raters score GPT-3.5-Turbo feedback for 100 instances from Coffee’s test split. The reported mean is 3.88 on the rating scale, with a standard deviation of 0.91. That measurement supports using the annotations as generally acceptable demonstrations, while allowing for variation in quality.

A separate study rates generated feedback on identifying the error and proposing an effective correction. The authors report that the PPO-trained feedback is judged more helpful and informative than the alternatives in the comparison. The appendix says they recruit 186 workers who pass a Python qualification test and assign each sample to three raters, using a scale from 1 to 5. There is a discrepancy in the paper about this study’s sample source. The main figure describes the human evaluation as being on HumanEvalFix, while the appendix describes sampling 100 cases from Coffee-Test. The reported direction of the human judgments can be stated, but the benchmark attribution is uncertain.

Limitations

Limits identified by the authors

The authors identify the use of synthetic tests as a limitation of the reward. Accepted code supplies an expected output for each retained input, but the choice of inputs determines what can be detected. A revised program can satisfy all the generated cases and still contain an error on an untested input. The check using incorrect submissions provides evidence about the tested examples. The authors call for more demanding test generation and point to work on rigorous evaluation of generated code as a possible basis.

The editing goal is functional correction. The tests observe a program’s outputs on selected cases. Readability and efficiency are additional concerns the authors identify for future work. A suggested repair can improve test performance while making code harder to read or more expensive to run. The evaluated reward gives positive evidence about behavior covered by the tests. It provides no independent measure of how maintainable or efficient the resulting program is.

Python is the only programming language implemented in Coffee-Gym. The framework’s structure could be applied to another language, and the authors mention Java as a possible direction. The experiments establish performance for the implementation studied. HumanEvalFix’s availability in other languages and the use of Python libraries in the transfer study leave open how much data, training and evaluation work a new language would require.

The authors also use a single size and architecture for their trained feedback generator. They describe the method as applicable to other architectures and suggest testing larger alternatives. The comparisons across editing systems establish a kind of portability for the written feedback, since advice from one generator can help several editors. Changing the generator’s architecture or scale is a separate question, and the reported experiments do not establish how such a change would affect the feedback or the training strategy rankings.

Competition problems are the main source of editing examples. The NumpyEval experiment extends the evidence to tasks that call for library use, and the examples show that the generator can sometimes handle specifications written as code comments. The authors still describe general software engineering as a future direction, potentially requiring training on broader code collections. A library-oriented benchmark gives evidence about tasks in that benchmark. It leaves questions about multi-file repairs, integration with an existing application, and specifications scattered across a project unanswered.

The paper notes the possibility of inaccurate generated explanations and wrong edits. It also discusses harmful or biased generated text and reports removing personal information from the submission data. Its assessment is that risks from generated content were largely mitigated in this setting. The editing and human-evaluation experiments measure the quality of repairs and advice under the reported conditions. They offer limited evidence about how generated advice would behave across other kinds of inputs or how people would rely on it in practice.

Limits visible in the experimental setup

Coffee’s labels derive from the outcomes of programming submissions. That is a practical way to produce a large set of grounded comparisons, but it makes the labels coarser than a complete judgment about the message. A suggestion that describes a real improvement can be labeled wrong if its target program still fails. A suggestion associated with an accepted solution can leave out a useful explanation or mention an incidental change. The human annotation study gives some evidence about the overall quality of the written guidance. It does not turn every individual label into a detailed human judgment.

CoffeeEval also measures advice through a particular trained editor. Training makes its edits more sensitive to the distinction the dataset represents, but the same instruction can land differently with another system or a human programmer. A concise hint may be enough for an experienced reader and insufficient for the evaluator. A fully specified change may score well even when its explanation gives a person little understanding of the underlying cause. The end-to-end comparisons with several editors are evidence of transfer under those conditions. The reward remains a measure of how the specified editor uses the advice on the specified tests.

The modest score correlations place a limit on the interpretation of the reward. CoffeeEval leads the comparison on Pearson correlation and MSE, and the all-tests results reveal a meaningful reduction in false positives against the strongest general editing baseline. The absolute correlation with the binary labels is still weak. There is also a difference of resolution between the quantities being compared. CoffeeEval can recognize a partially successful revision through its pass ratio, while the reference label categorizes the feedback according to an accepted or unsuccessful target edit. A disagreement can therefore reflect the fidelity of the edit, the coverage of the suite or the granularity of the labels.

The method for removing potential contamination is another place where the kind of evidence matters. Coffee-Test is held out by problem. For HumanEval, the appendix describes an analysis of code-line overlap between Coffee and the benchmark and reports that most Coffee solutions contain no lines that appear in the benchmark data. That supports the assessment that direct overlap is limited. The line-based method has little purchase on functionally similar code written in different forms, and it does not determine what the underlying editors encountered during their earlier training.

The authors considered DebugBench and CodeEditorBench and left them out after encountering cases in which reference solutions failed the available evaluation. DebugBench also presented access problems during evaluation, and CodeEditorBench included external dependencies that were unclear in some tasks. These exclusions improve the interpretability of the comparisons they retained. They also narrow the range of debugging environments covered by the main results. The reliable operation of a test harness is a prerequisite for interpreting failures as evidence about feedback, and the study’s results remain conditional on the benchmarks where that prerequisite was met.

Finally, the authors motivate CoffeeEval partly by the recurring cost of using a closed text judge. Their approach replaces such judging calls during reward computation with a trained editor and test execution. Data construction still uses GPT-3.5-Turbo for feedback annotation and test input generation, and running the evaluator requires editing and executing programs. The paper reports the editor’s training settings and the repair results. It does not give a measured end-to-end cost comparison covering annotation, training and reward computation.

What came after

There are no documented follow-up studies to discuss here. The paper proposes stronger test generation, support for more programming languages and evaluation in broader software engineering settings. Those directions remain proposals in the paper.

Cite

Cite as Hyungjoo Chae, Taeyoon Kwon, Seungjun Moon, Yongho Song, Dongjin Kang, Kai Tzu-iunn Ong, Beong-woo Kwak, Seonghyeon Bae, Seung-won Hwang and Jinyoung Yeo. 2024. Coffee-Gym: An Environment for Evaluating and Improving Natural Language Feedback on Erroneous Code. Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2024.emnlp-main.1254

@inproceedings{chae2024coffee,
  title = {{Coffee-Gym: An Environment for Evaluating and Improving Natural Language Feedback on Erroneous Code}},
  author = {Hyungjoo Chae, Taeyoon Kwon, Seungjun Moon, Yongho Song, Dongjin Kang, Kai Tzu-iunn Ong, Beong-woo Kwak, Seonghyeon Bae, Seung-won Hwang and Jinyoung Yeo},
  booktitle = {Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1254},
  url = {https://doi.org/10.18653/v1/2024.emnlp-main.1254}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/chae-2024-coffee-gym-environment-evaluating-improving/