Skip to main content
QUICK REVIEW

[Paper Review] ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generation

Xueying Du, Mingwei Liu|arXiv (Cornell University)|Aug 3, 2023
Software Engineering ResearchComputer Science21 citations
TL;DR

The paper introduces ClassEval, a manually built 100-task Python benchmark for class-level code generation and analyzes 11 state-of-the-art LLMs under three generation strategies, revealing notable gaps between function-level and class-level performance and model-specific strategies.

ABSTRACT

In this work, we make the first attempt to evaluate LLMs in a more challenging code generation scenario, i.e. class-level code generation. We first manually construct the first class-level code generation benchmark ClassEval of 100 class-level Python code generation tasks with approximately 500 person-hours. Based on it, we then perform the first study of 11 state-of-the-art LLMs on class-level code generation. Based on our results, we have the following main findings. First, we find that all existing LLMs show much worse performance on class-level code generation compared to on standalone method-level code generation benchmarks like HumanEval; and the method-level coding ability cannot equivalently reflect the class-level coding ability among LLMs. Second, we find that GPT-4 and GPT-3.5 still exhibit dominate superior than other LLMs on class-level code generation, and the second-tier models includes Instruct-Starcoder, Instruct-Codegen, and Wizardcoder with very similar performance. Third, we find that generating the entire class all at once (i.e. holistic generation strategy) is the best generation strategy only for GPT-4 and GPT-3.5, while method-by-method generation (i.e. incremental and compositional) is better strategies for the other models with limited ability of understanding long instructions and utilizing the middle information. Lastly, we find the limited model ability of generating method-dependent code and discuss the frequent error types in generated classes. Our benchmark is available at https://github.com/FudanSELab/ClassEval.

Motivation & Objective

  • Create a challenging, manually constructed benchmark for class-level Python code generation to assess LLMs in producing interdependent class methods.
  • Ensure high test sufficiency with suites that verify correctness of generated classes via dedicated unit tests.
  • Evaluate a diverse set of LLMs under holistic, incremental, and compositional generation strategies to understand strategy suitability.
  • Analyze error types and model limitations in generating method-dependent or context-rich class code.

Proposed method

  • Manually constructed ClassEval with 100 class-level Python tasks totaling ~412 methods and high test coverage.
  • Class skeletons designed around contract programming principles including class-level imports, constructor, and method contracts.
  • Development of two levels of tests: method-level tests and class-level tests to validate inter-method interactions.
  • Canonical solutions created and verified against comprehensive test suites to ensure high-quality baselines.
  • Evaluation of 11 LLMs with three generation strategies (holistic, incremental, compositional) using Pass@k as the correctness metric.

Experimental results

Research questions

  • RQ1How do LLMs perform on class-level code generation compared to function-level benchmarks like HumanEval?
  • RQ2How do different generation strategies (holistic, incremental, compositional) affect LLM performance on class-level tasks?
  • RQ3To what extent can LLMs generate code that depends on other class contexts within a class?
  • RQ4What are common error types when LLMs generate class-level code and how do they vary by model?

Key findings

  • All LLMs show worse performance on class-level generation than on standalone method-level benchmarks.
  • GPT-4 and GPT-3.5 outperform other models, with Instruct-StarCoder, Instruct-CodeGen, and WizardCoder as strong but similar contenders.
  • Holistic generation is best for GPT-4 and GPT-3.5, while incremental/composiçãoal strategies benefit other models with limited long-instruction and mid-context utilization abilities.
  • A notable portion of methods in ClassEval exhibit dependency on fields or other methods (standalone vs. library/field/method dependencies).
  • The benchmark emphasizes high test sufficiency (statement- and branch-level coverage over 98%) to reliably verify generated class correctness.
  • ClassEval documents frequent error types and discusses the limited ability of some models to generate method-dependent code.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.