CodeInsight: A Curated Dataset of Practical Coding Solutions from Stack Overflow
Paper · 2024 · Nathanaël Beau and Benoit Crabbé
Summary
A developer looking for a short piece of Python code often starts with a question about something concrete, such as how to select the largest values in an array. A forum answer may solve the problem while leaving its assumptions scattered across prose, code, and examples. CodeInsight turns questions like these into programming tasks that a code generator can attempt and a test suite can check. Each example contains a short request, a reference Python function, and tests for the expected behavior. The collection is designed for both fine-tuning, which adapts an existing generator to a task, and evaluation on held-out examples.
The authors begin with material from Stack Overflow, including questions previously collected in CoNaLa. They select requests with a realistic purpose, an identifiable solution, and behavior that can be checked by running the code. Python specialists then rewrite the request to match the function, standardize the argument names, and test the reference implementation. The resulting dataset contains 3,409 examples drawn from 2,702 distinct problem statements. It includes everyday Python operations as well as tasks using Pandas, NumPy, and regular expressions. Labels for features such as conditional logic, list operations, and multiple imports allow the authors to examine which kinds of tasks each system completes.
In the prompting experiments, a short instruction to return the result helps some systems more than a longer instruction placed before the task. In the final held-out evaluation after fine-tuning, CodeLLaMa reaches 53.1% pass@1, Starcoder reaches 52.5%, and Mistral reaches 38.4%. Pass@1 counts a generated function as successful when its single attempt passes every test attached to the example. The category breakdown reveals difficulties that the overall scores obscure, including regular-expression tasks and tasks whose reference solutions require multiple imports.
The authors also ask whether rewriting public questions reduces the likelihood that a generator can reproduce familiar answers from its training. On 812 paired examples, GPT-4’s score for resemblance to the reference code falls after curation, while its generated functions still pass 64% of the unit tests on the rewritten examples, as the paper reports that result. The rewrite changes the wording, the function interface, and sometimes the required behavior. The comparison establishes sensitivity to those changes and leaves open whether any given solution was recalled or constructed for the task.
Deep dive: CodeInsight: A Curated Dataset of Practical Coding Solutions from Stack Overflow
CodeInsight turns Stack Overflow questions into testable Python tasks and measures how well code generators solve them with prompting and fine-tuning. · about 33 minutes to read
The problem and its context
What a developer asks for
CodeInsight addresses a particular kind of assistance in code and programming languages. A developer can often describe an operation without knowing which function or library call implements it. An array already exists and the developer wants some of its largest values. A dataframe has an index that needs to be reset. A string needs to be split while keeping the punctuation that divides it. Each request can arise inside a larger program, but the immediate question concerns a local operation with a result the developer can use.
A Stack Overflow thread can answer such a question through a mixture of explanation, runnable code, fragments, and recommendations. The reader may need to infer what form the inputs take, choose among alternative answers, or adapt code written around particular example values. That flexibility serves the conversation. It complicates a dataset whose input must specify a task and whose evaluator must be able to check the generated answer consistently.
The correspondence between question and solution is especially important. The authors describe a popular Pandas question about iterating over rows whose accepted line of advice is to avoid iteration. In the forum, it makes sense to explain a different way of approaching the underlying work. For the dataset, pairing the literal request with code that takes a different approach can leave the intended operation ambiguous. An annotator would need to determine which part of the discussion specifies a task and whether the code actually performs it.
The paper’s conception of practical programming is therefore selective. It aims to capture requests that developers might ask as they write code and that can be expressed as a short Python function. The fixed function interface makes the answer callable. The short statement gives the generator enough information to attempt the operation. The tests give the evaluator observable conditions for accepting the attempt. These requirements explain both the use of Stack Overflow and the substantial filtering applied to it.
What earlier datasets measured
The authors situate their work among earlier evaluation benchmarks for generating code from text. They group HumanEval, MBPP, and APPS around relatively self-contained programming challenges. These benchmarks provide test-based ways to assess generated programs, and the CodeInsight paper ties APPS in particular to competition problems. Its interest lies in a different kind of input, a developer’s request for a short solution to a problem encountered during ordinary work. The paper discusses HumanEval alongside the study of code generation that introduced it. The corresponding discussions of MBPP and APPS draw on Program Synthesis with Large Language Models and Measuring Coding Challenge Competence With APPS.
Another line of work starts from programming material that people wrote for other purposes. CoNaLa identifies Stack Overflow requests that can be paired with Python code, so it offers examples close to the kind of question CodeInsight wants. Its evaluation in the paper’s comparison uses BLEU, a measure based on resemblance between a generated answer and a reference. CoNaLa consequently supplies both a source collection and a useful example of a different way to score a solution. The authors build on its identification of aligned question–code pairs. CoNaLa’s mining study describes that earlier work.
The comparison also includes collections with executable tests. DS-1000 draws on Stack Overflow for data science problems, and its longer descriptions can retain more of the context surrounding a request. DSP draws on notebooks. ODEX covers code generation with execution-based assessment and appears in the paper’s comparison as another collection sourced from Stack Overflow. These datasets help locate CodeInsight along several dimensions at once. A collection can have practical origins, use executable checks, carry substantial context, or provide examples for training. The authors’ design combines practical origins and runnable tests with a deliberately concise specification and a curated training portion. Execution-Based Evaluation for Open-Domain Code Generation is the work associated with ODEX.
In the paper’s account, the growth of evaluation-oriented datasets leaves a separate need for examples suitable for adapting an existing generator. A training example has to demonstrate the desired mapping from request to code. A test example has to specify enough behavior for an evaluator to judge a fresh answer. CodeInsight uses the same curated format for both purposes, so the experimental convention can be learned from examples and measured on a held-out portion.
What counts as a correct answer
A reference solution illustrates how to implement an operation. Its spelling is only one possible implementation. Different variable names, a different way to traverse a sequence, or a library helper that performs the same computation can all yield code with the required behavior. A text score rewards resemblance to the reference. The paper retains such scores for comparison and makes execution the primary check.
Execution shifts attention to which inputs the tests use and which outputs they expect. A generated function may look very close to the reference while making a subtle error in a keyword argument or regular expression. Another function may look different and still pass every case. Test design determines which distinctions become visible. This makes the act of constructing a benchmark inseparable from the act of specifying the task.
The paper adds a diagnostic goal to that design. An overall execution score can rank systems on a collection, but it gives little information about the requests behind their failures. CodeInsight attaches labels to characteristics of the reference code and reports scores for packages represented in the dataset. A reader can then ask whether a weak overall result is accompanied by difficulty on tasks with multiple imports, conditional statements, or a particular library. The categories provide observable groupings for analysis. Their relationship to the difficulty of a task remains a question for the experiments.
The method, step by step
Finding questions with a concrete operation
The authors first look for questions of the how-to kind. A how-to request asks what code will accomplish a recognizable task. A post centered on diagnosis, API design advice, or the details of an unusual application may still be valuable to developers while resisting conversion into an isolated input–output exercise. The earlier CoNaLa work gives the authors an initial way to locate promising posts. It estimates that 36% of Python-tagged questions on Stack Overflow have the how-to form.
CoNaLa supplies 2,379 examples that had already received manual attention and approximately 600,000 unrefined examples ranked by their suitability as how-to pairs. The authors take the 2,379 reviewed examples and the 3,121 highest-ranked unrefined examples. The ranking narrows the source to plausible candidates. Human filtering still has to determine whether a particular answer can be turned into an executable task with an adequately specified request.
The authors also explicitly seek questions involving Pandas, NumPy, and regular expressions, called Regex in parts of the paper. They remove redundancies, use votes and views to screen for community engagement, and look for accepted answers. They take the age of posts into account in a weighted ranking because an older post has had more time to accumulate attention. The paper gives the rationale for the ranking and describes the inputs to it. It reports 600 candidates apiece for the targeted Pandas, NumPy, and Regex groups in its filtering breakdown, and 7,300 raw examples overall.
Each source addresses a different part of the selection problem. CoNaLa provides candidate pairs already chosen for a plausible relationship between a request and an answer. The package-focused search gives particular topics more coverage. The engagement signals identify material that has been seen or judged useful by the community. Each signal is a way to decide what to examine. The subsequent checks establish whether the post can support a CodeInsight example.
From a Stack Overflow question to a tested example
The steps in order.
Deciding what can be tested
The filter starts with the practical relevance of the request. A task should arise in recognizable programming work and contain enough specificity for a concrete solution. The answer also needs an identifiable code segment. A discussion can include several partial sketches or suggestions whose behavior depends on intervening prose. In that case, an annotator must be able to isolate the implementation with confidence before the example can move forward.
A viable pair also needs semantic alignment. The code should implement the operation the rewritten question will ask for. A piece of code can be relevant to the discussion while answering a different question from the one stated in the title. The Pandas iteration example illustrates why a community-endorsed answer still requires checking. The practical lesson of a thread and the operation its code performs can be different.
Execution adds a further condition. The solution has to run in the designated environment so that the reference and later generated answers can be exercised against tests. The authors exclude tasks that require opening or saving files. They describe an image feature extraction question as relevant to developers yet difficult to support because the evaluation would need image inputs and processing. A question about a narrowly specified class can introduce a similar burden through application details that must be carried into the benchmark.
The appendix gives a positive example involving the largest values in a NumPy array. The reference uses argpartition, and the authors view the task as a good fit because the operation is clear, the answer is directly responsive, and its behavior can be tested. The example also shows why a practical task can be short. The user’s difficulty lies in knowing how to express a useful operation with a library call, even when the final implementation takes little code.
A rejected example asks about sorting a list by several attributes in mixed order. Its ranking makes the question look promising, but the authors judge that details of the particular class dominate the proposed solution. The difficulty is in separating a general sorting operation from the structure of the original application. A borderline case asks about converting date text to a datetime value. The authors explain that a more precise task can be formulated by specifying ISO format and the intended comparison. Such a rewrite requires the annotator to understand both the original problem and the assumptions introduced by the narrower formulation.
The filter leaves 2,707 distinct problems, about 37% of the 7,300 raw examples. Of the 5,500 candidates from CoNaLa, 1,993 survive. The package-focused groups retain 294 Pandas, 242 NumPy, and 178 Regex problems from their respective groups of 600. These counts describe the filtering stage. The final dataset counts examples after annotation, when a problem can acquire more than one implementation and some filtered material may fail to yield a finished item. The paper reports 2,702 distinct problem statements in the completed collection and gives no item-by-item account of the transition from the filtered set.
Making a function and a specification agree
The annotator begins by extracting a working solution from the discussion. When the thread supports several valid answers, the procedure allows supplementary examples associated with the same intent. That is why an example and a distinct problem statement are different counting units. A problem states what needs to be done. An example pairs a statement with a particular curated implementation and tests.
The annotator wraps the solution in a Python function called test. The common name fixes the entry point the evaluation will call. The argument names follow a normalization scheme. An array uses the arri pattern, a dataframe uses dfi, a string uses stri, and a list uses lsti. The letter i indicates the argument’s place among the elements of its kind as represented by the standardized name. The appendix also gives patterns for dictionaries, matrices, integers, and generic variables. The generic vari can be used where a more specific label would also be possible.
A reference snippet from a forum may contain literal values or use names meaningful only in that thread. Turning it into a function gives the operation an explicit interface. The benchmark can call it with multiple inputs, and the generator can see which values it may use in its answer. A name that signals a dataframe or a string can carry information about the argument as well as identify it. That information belongs to the evaluated input, since the authors supply the associated function header to the generator.
Next, the annotator rewrites the natural language request around the extracted behavior. The text should use the same argument names as the function, describe what the code does, and preserve the details needed to implement it. The paper’s average description lengths reflect the choice to express each problem compactly. The description and header work together. The header specifies the entry point and available parameters, while the prose specifies the operation.
This alignment can involve more than editorial changes. A date conversion may need a format that the original thread left to context. A request that gets its meaning from a concrete example may need to say explicitly what property of that example matters. The annotator has to decide how much of the thread belongs in the function’s contract. As the paper’s error analysis shows, a missed decision about what to do with an old dataframe index can survive into the finished example.
Rewriting also serves the authors’ goal of reducing resemblance to material that a generator might have encountered in training. A normalized argument name, a function wrapper, and a new description change the surface form of an example. The underlying programming operation can remain recognizable, as it should for a benchmark of practical solutions. Whether the rewriting reduces answer recall in a particular case is a separate empirical question.
Writing tests and applying labels
The annotation procedure calls for 3 distinct tests per function. The authors describe cases involving normal behavior, an edge case, and an error situation. The ordinary case establishes the main operation. The edge case exercises behavior near the boundary of expected inputs. An error case can check what happens when an assumption about the input fails. The annotator runs the tests against the reference function before moving to the next example.
The reported average for the finished dataset is 3.0 ± 0.4 unit tests per example. That measured spread matters when distinguishing the annotation recipe from the released collection. In the fine-tuning experiments, the authors specify a pool in which each included item has at least three tests. The curation recipe gives a practical target, and the experimental inclusion rule supplies a threshold for the subset used in the split study.
The labeling work was done by five data science professionals with at least five years of experience each. The procedure sets a maximum of 20 minutes for an example. The authors report an average of twelve minutes and a collective effort of over 540 hours. That time includes transforming a source answer into a function, making the specification correspond to the interface, and writing checks for the expected behavior. The finished 3,409 examples demonstrate what can be produced under that procedure. The time limit also explains why questions that require extensive reconstruction are poor candidates.
For diagnosis, automated labels describe the reference code. The paper defines 10 categories, each of which applies independently to an example. ASSIGN indicates a variable assignment, BUILTIN a call to a Python built-in, COND a conditional, and LOOP a loop. STR signals a string operation and LIST a list method. MULTILINE applies to code longer than two lines. MULTIPLETASK applies when at least three other labels hold, >THREE VARS when a function takes more than three parameters, and COMPLEXTASK when the code has at least two imports.
An item can satisfy several of these definitions. A function can use a conditional and a list method, span multiple lines, and carry further labels because of those features. The categories allow the authors to compare examples with a feature to those without it and to report execution results for different slices of the test set. They describe the reference as written, so an alternative implementation of the same task may use different constructs.
Presenting the task to a generator
The evaluation supplies the natural language intent and the associated function header. The requested output is a completion that can be executed as a function. After generation, the authors automatically identify the end of the function when possible and extract the code to run. This procedure tests a bounded completion under a supplied interface. Some of the work of using a forum answer, such as deciding what parameters a utility function should expose, has already been done in curation.
The prompt comparison changes the text surrounding the task. The first added instruction introduces the generator’s role and asks for code that returns a result. The second places a shorter return instruction at the end of the intent. The core request and its associated header still specify the operation. The variants test how output changes when the need for a returned value is made explicit in different ways.
Fine-tuning changes the generator through exposure to part of the annotated collection. The authors use LoRA, a method that learns a limited set of adaptations to an existing system. They specify its rank in the fine-tuning configuration.
r = 16
The symbol r is the rank of the LoRA adaptation. The equals sign sets its value to 16 for the reported run configuration.
α = 16
The symbol α is LoRA’s scaling parameter. The equals sign assigns it the value 16. These expressions give the paper’s settings. The authors describe generation and scoring procedurally and refer to earlier work for the text metrics.
The configuration uses a dropout rate of 0.05 in the LoRA layer and omits bias adjustments. The batch size is 128, with 100 warmup steps and 400 training steps in total. The paper gives the learning rate and names AdamW as the optimizer, the rule used to update the trainable parameters.
Learning rate = 3 × 10⁻⁵
The learning rate controls the size of the optimizer’s updates. The equals sign gives the configured value, and × multiplies 3 by 10 raised to the power −5. Training uses FP16, the paper’s half-precision computation setting, on an A100 GPU with 40GB of memory.
The authors describe a pool of 3,094 items for their partitioning study, with at least three tests per item. They compare train–test allocations of 20-80, 40-60, 60-40, and 80-20 for CodeLLaMa. Each allocation is evaluated with five different seeds, which are settings that govern the experiment’s random choices. The final benchmark results use the 40-60 allocation. The paper makes the CodeInsight data and benchmark available through its project repository.
Experiments and results
What is in the collection
The full CodeInsight collection contains 3,409 examples. In the paper’s main descriptive comparison, a problem statement averages 12.6 ± 4.3 words and a reference sample averages 4.6 ± 2.3 lines of code. Those figures are about the full collection. The paper’s separate comparison of test sets reports 12.6 words for the average CodeInsight problem statement and 4.7 lines for the average code sample. The split matters when using these figures to describe the material a particular experiment measures.
Pandas and NumPy are prominent. The package statistics list 819 Pandas and 591 NumPy items. The regular-expression group, identified as Re in the package statistics, has 241 items. The no-import group has 415 in the full collection’s package breakdown. The paper also names libraries such as Itertools, Collections, and Operator, and reports 78 distinct packages in its remaining package group. These are counts for annotated examples. The earlier source counts describe how candidates were obtained, so they answer a different question about the dataset.
The authors compare the collection with DS-1000 to show what concise specifications look like beside fuller descriptions. DS-1000 has 1,000 evaluation items in this comparison, with an average problem length of 140.0 words and an average implementation length of 3.6 lines. CodeInsight’s much shorter problem statements coexist with reference samples of a comparable order of length. A longer description can reflect the context needed to understand the request rather than the amount of executable code in its answer. Conversely, brevity in the request can be achieved by embedding decisions about scope and interface in curation.
The authors supplement line counts with the depth of an abstract syntax tree, or AST. This is a tree representation of the grammatical structure of code. A deeply nested expression or block can add levels to the tree even when the printed code fits onto a few lines. The full-dataset average depth reported in the main comparison is 8.6 ± 1.5 for CodeInsight and 8.5 for DS-1000. The Pandas figures are 8.7 ± 1.4 for CodeInsight and 10.7 for DS-1000. These measurements describe the structure of the reference implementations. They leave room for concise programs that make demanding choices about library behavior and longer programs that follow a straightforward sequence.
The paper’s test-set comparison reports 3.0 average test cases for CodeInsight, 2.1 for DSP, 1.8 for ODEX, and 1.6 for DS-1000. The authors explain that data science benchmarks may use fewer tests that involve richer objects, such as matrices, classifiers, or dataframes. A count of tests gives the number of checks the reference function faces. The input types, expected behavior, and variation among those checks determine what the evaluation can detect. The paper also reports higher average counts for HumanEval and APPS, at 7.7 and 13.2 respectively, which situates CodeInsight’s test design within its practical-task scope.
How the answers are scored
The main score is pass@1. For each example the system produces a single code completion. The evaluator runs the function against its associated unit tests and awards success when every test passes. The percentage is the share of examples on which that happens. In the prompt table, the paper describes the percentage in terms of all tests passed and identifies it as pass@1. A function that passes some tests and fails another can still yield a failure for the example, so the distinction between success per example and success per test matters.
The evaluation also uses BLEU and codeBLEU, which compare a generated answer with reference code. BLEU was introduced for evaluating machine translation and here supplies a measure of textual resemblance. The paper uses codeBLEU as a companion measure aimed at code. These scores and execution answer related questions about the same output. An incorrect argument can affect the result of running a function while leaving most of its text unchanged. A working alternative can use a different expression from the reference and receive a different resemblance score. The original BLEU study supplies the paper’s reference for that metric.
The pretrained baselines are Mistral 7B, CodeLLaMa 13B, and Starcoder 15B. The paper uses them to see how generators with different sizes and training emphases respond to the same curated task. Its comparison is between the named systems as tested. A ranking among them supplies information about those configurations, with size and training history varying together. The paper draws on the studies of Mistral 7B and Code Llama to identify the corresponding baselines.
Prompting on the full dataset
The prompting experiment starts from the intent and function header with no extra instruction. Mistral reaches 4.7% pass@1 across the full collection, CodeLLaMa 44.7%, and Starcoder 45.1%. The authors observe that generated functions frequently omit an explicit return. Mistral in particular ends with a print statement in 25% of the cases the authors discuss in this setting. A developer reading the output can see a displayed result, but a caller of the benchmark function needs the result as a returned value. The tests make that difference consequential.
The first prompt adds a general description of the code generation task and an instruction to return the result. Mistral moves to 4.9% pass@1. CodeLLaMa records 40.3%, and Starcoder stays at 45.1%. The second prompt gives a brief return instruction after the intent. That setting yields 10.1% for Mistral, 48.1% for CodeLLaMa, and 46.8% for Starcoder. The brief suffix is the highest-scoring of the tested settings for each system. The longer prefix has mixed effects.
Prompt settings on the full CodeInsight dataset by pass@1
The short return instruction yields the highest score for each system.
The numbers
| System or setting | pass@1 % |
|---|---|
| Mistral without added instruction | 4.7 |
| Mistral with first prompt | 4.9 |
| Mistral with second prompt (this paper) | 10.1 |
| CodeLLaMa without added instruction | 44.7 |
| CodeLLaMa with first prompt | 40.3 |
| CodeLLaMa with second prompt | 48.1 |
| Starcoder without added instruction | 45.1 |
| Starcoder with first prompt | 45.1 |
| Starcoder with second prompt | 46.8 |
The short suffix addresses a known mismatch between the generated code and the format the tests need to call. The resulting score still depends on all the behavior exercised by the test cases. A generator can produce a proper return statement and calculate the wrong value. The table therefore shows the combined effect of the prompt on accepted solutions, with the discussion of print statements offering context for one observed failure pattern.
How the training allocation affects scores
The authors next compare the allocations for adapting CodeLLaMa. At 20-80, mean pass@1 is 48.9 ± 0.6%, mean BLEU is 50.0 ± 0.2, and mean codeBLEU is 42.5 ± 0.1. These are means and standard deviations across the runs with different seeds. The two text measures and the execution measure all give their lowest means among the fine-tuning allocations at this setting.
At 40-60, mean pass@1 is 52.6 ± 0.8%, BLEU is 58.1 ± 0.4, and codeBLEU is 48.8 ± 0.4. At 60-40, mean pass@1 is 53.4 ± 1.0%, BLEU is 57.9 ± 0.8, and codeBLEU is 48.8 ± 0.7. At 80-20, mean pass@1 is 53.1 ± 1.7%, BLEU is 57.9 ± 1.4, and codeBLEU is 48.6 ± 1.2. The paper reports similar averages for the settings with larger training portions and observes that the smaller training portion approaches the results of prompting alone.
CodeLLaMa mean pass@1 across CodeInsight train–test allocations
Mean execution accuracy changes little across the allocations with larger training portions.
The numbers
| System or setting | pass@1 % |
|---|---|
| 20-80 | 48.9 |
| 40-60 | 52.6 |
| 60-40 (this paper) | 53.4 |
| 80-20 | 53.1 |
The highest mean pass@1 in the split study belongs to 60-40. The authors select 40-60 as the final configuration because it retains a larger portion of the annotated examples for evaluation while delivering a similar mean. Their stated aim is to make good use of the written unit tests as an evaluation resource. This choice concerns the design of the dataset’s final split. The same table also shows that the ranking by mean BLEU differs from the ranking by mean pass@1.
The prompting and fine-tuning scores describe different setups. Prompting uses the full collection without task-specific adaptation. The split study evaluates a generator trained on one portion of the eligible examples and tested on another. The paper treats the higher fine-tuning scores as evidence that the training set is useful, while the difference in evaluation pools affects how precisely a score can be attributed to adaptation alone.
Final held-out results
The final 40-60 test set has 1860 items in the paper’s baseline table. CodeLLaMa records 53.1% pass@1, Starcoder 52.5%, and Mistral 38.4%. The 53.1% for CodeLLaMa is the result reported on this final test set. The 52.6 ± 0.8% figure for the 40-60 setting summarizes the separate split study across seeds. Each figure has its own role in the evaluation.
Fine-tuned baselines on the final CodeInsight 40-60 test set by pass@1
CodeLLaMa and Starcoder finish close together, with Mistral scoring lower.
The numbers
| System or setting | pass@1 % |
|---|---|
| Mistral 7B | 38.4 |
| Starcoder 15B | 52.5 |
| CodeLLaMa 13B (this paper) | 53.1 |
The package rows show where the relative ordering changes. On the 458 Pandas items in the final test table, Starcoder reaches 56.0%, CodeLLaMa 55.2%, and Mistral 44.8%. On the 335 NumPy items, the corresponding scores are 53.6%, 52.8%, and 43.2%. The positions of the two highest-scoring systems here differ from their ordering on the full test set. That is possible because the overall score reflects additional packages and task types.
For the 133 Regex items in the final test table, Starcoder records 37.5%, CodeLLaMa 38.3%, and Mistral 26.2%. Each system scores lower on this group than on its Pandas or NumPy groups. Regular expressions add a notation whose details matter to the behavior of a Python function. The appendix gives an example where the intended treatment of separators depends on whether part of a pattern is captured. That kind of error helps explain what can go wrong in this slice, while the scores summarize the whole group.
Starcoder and CodeLLaMa also have similar scores across several reference-code labels, alongside more visible changes in particular subsets. On the 692 items labeled MULTIPLETASK, Starcoder records 44.5%, CodeLLaMa 42.2%, and Mistral 39.8%. On the 90 COMPLEXTASK items, the respective figures are 35.6%, 34.5%, and 23.1%. On the 47 items with more than three parameters, the figures are 53.5%, 53.1%, and 42.3%. The number of parameters identifies a different property from the number of imports, and their rows give different pictures of performance.
Original and rewritten questions for GPT-4
The contamination experiment starts from 812 examples drawn from the 2,379 manually reviewed CoNaLa examples. The authors evaluate GPT-4 without fine-tuning on the CoNaLa examples and on the annotated CodeInsight counterparts. BLEU is 58.8 on the original CoNaLa form and 47.6 on the rewritten form. For the rewritten items, the paper additionally reports that GPT-4 passed 64% of the unit tests.
The BLEU comparison uses corresponding tasks in different representations. The curation may change the vocabulary in the request, the names in the header, the placement of imports, and the shape of the reference answer. These changes affect the opportunity to reproduce the original code closely. They also affect the references against which resemblance is scored. The observed drop establishes a response to the combined remodeling procedure. The 64% execution result shows that the revised tasks still elicit working code in many cases. The paper reports that figure in terms of unit tests, so it is best read in that form alongside the separate baseline pass@1 scores.
The authors interpret this pattern and their worked examples as evidence that solving the revised task involves useful coding ability even when the answer’s resemblance to the reference changes. They entertain the possibility that the original CoNaLa material was included in GPT-4’s training. The experiment leaves training exposure unobserved, and the tests on the rewritten items cannot establish which source of knowledge produced a particular answer.
What the ablations show
Changes to the request and training setup
The paper’s analyses vary the prompts and how training is allocated, compare items in their original and rewritten forms, and assess performance by category and through specific mistakes. The authors report no ablation that drops each curation step one at a time.
The prompt experiment is most informative when read as a comparison of the actual strings and placements. The general preamble and the short suffix both ask for a returned value. Only the shorter variant consistently yields the best pass@1 observed for each system. Several features of the instruction change together, including its length, its location, and the amount of framing around the task. The experiment shows which whole prompt performed better under these conditions. Separating the influence of wording from placement would require variants that held the other features fixed.
The observed use of print statements explains why the authors chose to intervene. The benchmark calls a function and checks its behavior under tests, so writing a result to the output stream can leave the caller without the value the request is meant to produce. For Mistral, a higher score with the suffix is consistent with better adherence to the function format. The paper reports only a slight increase in return statements under the first prompt and gives overall pass@1 for the variants. The execution figures consequently leave open how much of the movement came from return behavior and how much came from changes to the computations themselves.
The training allocation study measures how the benchmark behaves under several allocations of its eligible data. The smallest training allocation yields lower mean scores, and means change relatively little across the larger allocations. The test portions move with the training portions, so each row reflects both the amount of training material and the set of items used to judge the result. The use of several seeds makes the variation visible. A fixed test set with nested training subsets would answer the narrower question of how additional training examples affect the same evaluation items.
The paper uses the allocation comparison to make a practical choice. With 40-60, a substantial test portion remains available for later breakdowns. The nearby averages under larger training allocations reduce the incentive to reserve more examples for training in this configuration. The reported results concern CodeLLaMa with the selected adaptation procedure and step budget. They leave open how the curve would look under a different generator or training schedule.
What the code categories capture
The descriptive analysis compares each category’s positive examples with the examples for which the label is absent. Built-in functions are common. The appendix counts 2261 examples with BUILTIN and 1141 without it in the labeled dataset statistics. The authors interpret that distribution as evidence that many of the solutions rely on standard Python operations. A score for this group describes a common type of task in the collection. It gives a different view from a score based on a small slice such as a function with many parameters.
Line count and syntax tree depth bring out different aspects of the labels. For COMPLEXTASK examples, which have multiple imports, the appendix reports an average of 7.0 ± 2.8 code lines and a mean AST depth of 10.4 ± 2.3. The corresponding figures for examples without that label are 4.6 ± 1.9 lines and 8.3 ± 1.5 depth. In this group, the additional lines accompany deeper syntax. The label itself also identifies a larger collection of imported functionality in the reference code, which can be relevant to the difficulty of choosing and coordinating library calls.
Having more than three parameters gives a different profile. For >THREE VARS, the appendix reports 5.5 ± 1.2 lines and an AST depth of 8.6 ± 1.4, compared with 4.7 ± 2.0 lines and 8.4 ± 1.5 depth for the rest. The additional arguments coincide with more lines on average and similar tree depth. In the final test results, the many-parameter group has higher pass@1 than COMPLEXTASK for every baseline. Handling several parameters can require careful attention to the interface while leaving the code’s grammatical structure relatively shallow.
The loop category shows a further reason to look beyond length. The paper reports a similar number of lines for loop and non-loop examples and points to the frequent use of list comprehensions, which can express iteration in a short form. The appendix gives 4.8 ± 2.8 average lines for the loop group and 4.6 ± 1.5 for the rest, alongside AST depths of 9.0 ± 1.3 and 8.2 ± 1.5 respectively. A compact expression can still contain nested syntactic structure. The number of printed lines and the structure of those lines are both relevant to the interpretation.
The categories also explain why the authors use overlapping slices. A reference with multiple imports can also contain assignments, conditionals, and list operations. That overlap reflects how code is written and allows several descriptions of the same item. To determine whether the use of imports itself accounts for weaker performance would require controlling the accompanying differences in the tasks. Here the performance slices identify where errors are concentrated and suggest examples worth inspecting.
How particular functions fail
The authors examine a CodeLLaMa answer that exports decision rules from a scikit-learn decision tree. The task asks for a textual version of the tree with specified feature names. The generated function selects the expected library helper, but passes the names as a positional argument. The reference passes them with the appropriate keyword. The generated answer raises a TypeError. The case separates identifying the right operation from knowing precisely how its interface accepts the relevant data. Much of the answer can be recognizable and useful to a human reader while execution reveals an invalid call.
In another example, the request is to split a string while keeping its separators. The generated regular expression uses a split that discards them. The reference captures the separator expression, allowing the split to retain those pieces, and filters out empty results. The difference makes sense at the level of returned values. Recognizing the right Python module and the general operation gets part of the way to a solution, while the regular expression determines whether the function satisfies the defining requirement.
A Pandas example involves resetting a dataframe’s index. The generated function uses reset_index in a way that keeps the old index as a column. The reference and tests expect it to be dropped. The short request leaves that choice open. In this case the execution failure reveals a gap in the specification. The candidate uses a plausible interpretation, and the tests apply a narrower convention than the wording supplies. The authors identify it as an annotation discrepancy.
Together these cases show what the headline measure aggregates. A failed attempt might violate a library’s callable interface, produce the wrong output for a clear requirement, or implement a defensible interpretation of an underspecified request. Each gets the same outcome under pass@1. Reading the associated inputs, expected outputs, and candidate code makes the distinctions available to a researcher trying to understand the score.
What changes when familiar items are rewritten
The GPT-4 appendix pairs original CoNaLa answers with the responses elicited by their CodeInsight versions. One original task asks for a list of integers to become a single integer. GPT-4 introduces an assignment to r, matching a detail present in the reference even though the intent did not require that name. In the rewritten version, the operation is expressed as a function over the standardized list argument. The resulting answer follows the reference implementation and remains appropriate for the request. The authors treat the original naming resemblance as a possible sign of recall and the rewritten result as evidence that the task can still be solved after its presentation changes.
The dictionary sorting example shows another possibility. The original prediction uses k_v, the same uncommon name used in the original reference. For the rewritten problem, the prediction selects itemgetter where the reference uses an anonymous function to extract the sorting key. The paper reports that the alternative passes the tests. This is a concrete case where the generator produces acceptable behavior through a different implementation. A reference resemblance measure and an execution measure can register different aspects of that success.
The date conversion example shows the importance of specifying input format and of interpreting an exact match cautiously. The authors examine how the generated code supplies a date string and format in the original task, then how closely it matches the more explicit revised reference. A precise request can guide a competent implementation, and prior exposure could also contribute to a matching response. The output alone gives limited grounds for choosing between those explanations.
At the aggregate level, the BLEU comparison confirms that the rewriting is substantial enough to change the relationship between predictions and references. At the level of individual answers, the cases show continued agreement, plausible recall cues, and successful implementation variation. Since curation changes several pieces of the evaluation at once, the paired experiment measures their joint effect. It leaves the contribution of each individual change, and of training exposure itself, unresolved.
Limitations
Limits identified by the authors
The authors describe CodeInsight as a dataset for development assistance. This focus restricts what its evaluation represents. The examples concern operations that can be given a compact specification and function interface. Broader coding challenges can involve deciding what problem to solve, identifying dependencies across a codebase, or handling environmental details that a standalone function has already abstracted away. The authors state the limitation broadly as one of coverage within programming work.
They also acknowledge that expert annotations can introduce bias. An annotator decides what counts as a realistic request, which solution can be isolated, how to express it, and which cases verify it. Those decisions are necessary to make the items executable and comparable. They can also favor particular coding approaches or leave other reasonable implementations insufficiently represented. The permission to record alternate solutions helps when a thread clearly supports them. It still depends on a curator identifying the alternatives and being able to include them within the workflow.
Python is another stated boundary. CodeInsight covers a variety of Python packages, but its calling conventions, test design, and many of the task operations are specific to that language and its libraries. The authors also identify changing programming languages and practices as a constraint on how broadly the current collection will remain applicable. The scope of the paper’s results is the dataset and evaluation environment used for the reported experiments.
Limits visible in the design and reporting
The sources and filter shape the meaning of “practical.” CoNaLa contributes posts that were promising as how-to pairs. The targeted searches favor certain packages and use community attention in prioritization. The filtering procedure favors a direct solution, a bounded operation, and an executable test. As a result, the dataset represents selected practical requests amenable to this form of assessment. Its mix of packages and tasks reflects curation goals as well as the source community’s activity. Package frequency in the collection cannot be interpreted as a measure of how frequently developers encounter the underlying problems.
Several decisions make the tasks easier to specify with precision. The evaluator supplies the function header, and the normalized argument names can signal the expected type or role of an input. The generator therefore works with information a developer may need to infer from context when reading an original forum question. The setup also asks for a function that returns a testable result and excludes file input and output. These choices support a tractable benchmark of completing a function from a specification. Generalizing its scores to assistance that must infer the interface or act in a broader environment would require additional evidence.
Execution measures the behavior exercised by the tests. Even a suite with representative ordinary, edge, and error cases covers a finite set of inputs. A function may pass those inputs and behave differently elsewhere. Conversely, a valid implementation under one reading of a request can fail because the reference assumes a different reading. The Pandas index example demonstrates that this latter possibility occurs in the benchmark. Research using the aggregate score should account for both coverage and specification quality when interpreting borderline cases.
The category names also carry a narrower meaning than they might in ordinary discussion. COMPLEXTASK is assigned by import count. MULTIPLETASK is assigned through the presence of other labels. A problem that requires a subtle understanding of one function can fall outside those groups, and a task with several imports can be conceptually straightforward. The comparison by labels is descriptive, and the labels are based on the reference implementation. Their scores can be read as performance on slices defined by these particular rules.
The number of examples also varies widely among slices. The final test set has only 47 examples in the category with more than three parameters, while the Pandas row has 458. The paper gives pass@1 for these slices and shows variability across seeds for the separate split study. It leaves uncertainty for individual category scores unquantified. Close results on a small slice are therefore best presented as the ordering observed in that experiment.
The counting units need care across stages. The paper reports 3,409 completed examples from 2,702 distinct problem statements and describes a fine-tuning pool of 3,094 “unique problems.” The curation procedure explicitly allows more than one example for an intent. The paper leaves unclear how its split procedure treats alternate implementations associated with the same intent. Thus the reported split establishes that examples were allocated for training and evaluation, while the extent to which closely related examples were grouped together is unspecified. Likewise, the appendix’s label statistics give a full count of 3402, whereas the package statistics give 3,409 examples. The paper does not reconcile these totals, so each belongs with its own analysis.
The tests with different training allocations provide evidence about the tuning recipe used in the paper. Their changing evaluation portions limit what can be attributed to training volume by itself. The final results across Mistral, CodeLLaMa, and Starcoder also combine differences in size, pretraining, and adaptation to the benchmark. The authors suggest that Mistral’s weaker performance on complex tasks and Regex could relate to its pretraining focus. The comparison leaves that explanation as a hypothesis. The observed result is that the systems respond differently under the same benchmark design.
Finally, the contamination experiment has an important measurement limit. A system could reproduce a public answer because it saw the exact example, because many similar examples exist, or because a conventional solution has few natural forms. GPT-4’s training exposure is treated as a possibility in the paper. The change in BLEU can arise from differences in the function wrapper, the reference style, or the behavior specified by the revision. It can also reflect diminished opportunities to copy the original answer. The experiment demonstrates that scores and individual outputs change under remodeling, while the causal role of prior exposure remains unknown.
What came after
BOLT: Benchmarking Open-World Learning for Text Classification cites CodeInsight and addresses open-world learning for text classification. CodeInsight pairs a written request with a Python function whose behavior can be exercised. BOLT’s title places its evaluation in classification, where the task concerns assigning labels to text. The citation establishes a connection between benchmark studies in those different settings. Its purpose and any reuse of CodeInsight’s data, curation process, or evaluation method are unspecified.
Cite
Cite as Nathanaël Beau and Benoit Crabbé. 2024. CodeInsight: A Curated Dataset of Practical Coding Solutions from Stack Overflow. Findings of the Association for Computational Linguistics: ACL 2024.
@inproceedings{beau2024codeinsight,
title = {{CodeInsight: A Curated Dataset of Practical Coding Solutions from Stack Overflow}},
author = {Nathanaël Beau and Benoit Crabbé},
booktitle = {Findings of the Association for Computational Linguistics: ACL 2024},
year = {2024},
doi = {10.18653/v1/2024.findings-acl.354},
url = {https://doi.org/10.18653/v1/2024.findings-acl.354}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/beau-2024-codeinsight-curated-dataset-practical-coding/