Top General Performance = Top Domain Performance? DomainCodeBench: A Multi-domain Code Generation Benchmark

Dewu Zheng, Yanlin Wang, Ensheng Shi, Hongyu Zhang, Zibin Zheng, Zhang, Hongyu, Zheng, Zibin

Abstract With the rapid advancement of large language models (LLMs), extensive research has been conducted to investigate the code generation capabilities of LLMs. However, existing efforts primarily focus on general-domain tasks, leaving LLMs' code generation performance in real-world application domains underexplored. This raises a critical question: can a model's general-domain coding ability reliably represent its ability in specialized domains? In this paper, we introduce DomainCodeBench, a multi-domain code generation benchmark designed to systematically evaluate LLMs across 12 software application domains and 15 programming languages. DomainCodeBench contains 2,400 manually verified tasks with ground truth, human-annotated docstrings, and fine-grained dependency information to ensure more coverage of domain-specific challenges. Specifically, we first identify the most popular application domains by topic mining. Then, we curate coding tasks based on commonly used frameworks and platforms in each domain. We obtain several findings through extensive experiments on DomainCodeBench with ten mainstream LLMs. (1) Performance decoupling: experiments reveal that top general-domain models do not consistently excel in specific application domains; (2) Domain-specific weaknesses: LLMs often fail due to domain knowledge gaps and third-party library misusage; (3) Contextual enhancement: we show that augmenting prompts with domain-specific knowledge improves performance by around 38.17%, providing actionable insights for performance optimization.

Introduction

While Large Language Models (LLMs) excel at general coding benchmarks like HumanEval, their ability to write code for specific, real-world application domains remains largely untested. Popular benchmarks mostly ask LLMs to solve isolated, algorithmic problems, such as reversing a string. However, real-world software engineering involves building complex systems like web applications, deep learning models, and smart contracts. These tasks require deep knowledge of specific frameworks (e.g., React, PyTorch, Solidity) and third-party libraries. This paper addresses whether a model's high score on general coding tasks translates to high performance in specialized application domains.

Methodology: DomainCodeBench Construction

To systematically evaluate domain-specific coding, the authors developed DomainCodeBench through a multi-phase process involving domain mining and rigorous task curation.

The DomainCodeBench construction pipeline, including domain mining and benchmark construction phases.
  1. Domain Mining: Using Latent Dirichlet Allocation (LDA) on technical media (Stack Overflow, Hacker News, GitHub), the authors identified 12 prominent application domains, including Blockchain, Robotics, Game Development, and Cloud Services.
  2. Task Curation: High-quality GitHub repositories were selected for these domains. The authors filtered for functions executing domain-specific business logic rather than generic utilities.
  3. Manual Annotation: To mitigate data leakage, human experts manually rewrote docstrings and prompts for all 2,400 tasks using a cross-validation process.
  4. Dependency Extraction: Static analysis tools extracted the context available to a developer, such as local imports, repository-defined APIs, and third-party library signatures.

Benchmark Composition

DomainCodeBench consists of 2,400 manually verified tasks across 12 domains and 15 programming languages. Unlike existing benchmarks that focus on basic programming concepts, DomainCodeBench emphasizes actual application-level development by providing rich, dependency-enriched contexts.

An overview of a task instance in DomainCodeBench, highlighting metadata, docstrings, and dependency information.

Each task instance includes detailed metadata and dependency information, providing the LLM with the necessary background to understand domain-specific requirements and framework-specific API calls.

Key Insights and Experimental Results

Extensive experiments with 10 mainstream LLMs (including GPT-4, CodeLlama, and DeepSeekCoder) yielded several critical findings:

  • Performance Decoupling: General coding ability does not guarantee domain-specific proficiency. Models excelling in HumanEval often struggle with domain-specific frameworks. For instance, models generally performed best in Blockchain but struggled heavily in Web Development.
  • Open-Source Performance: Surprisingly, DeepSeekCoder-33B outperformed GPT-4 in most application domains, suggesting that specialized training mixtures may capture domain nuances more effectively than generalist models.
  • Failure Taxonomy: Failures are rarely due to basic syntax. Instead, LLMs struggle with project-specific background knowledge and the correct invocation of complex third-party APIs.
  • Contextual Enhancement: Augmenting prompts with domain-specific knowledge—specifically "Similar Context" (code snippets performing similar tasks)—improved performance by an average of 38.17%.

Conclusion and Limitations

DomainCodeBench reveals significant performance gaps in current LLMs when applied to specialized domains. While the benchmark uses CodeBLEU for evaluation due to the practical difficulties of setting up execution environments for thousands of diverse libraries, it provides a vital tool for assessing real-world coding capabilities. Future work will focus on expanding the benchmark's scope and exploring execution-based evaluation metrics.

Summary updated

Abstract

With the rapid advancement of large language models (LLMs), extensive research has been conducted to investigate the code generation capabilities of LLMs. However, existing efforts primarily focus on general-domain tasks, leaving LLMs' code generation performance in real-world application domains underexplored. This raises a critical question: can a model's general-domain coding ability reliably represent its ability in specialized domains? In this paper, we introduce DomainCodeBench, a multi-domain code generation benchmark designed to systematically evaluate LLMs across 12 software application domains and 15 programming languages. DomainCodeBench contains 2,400 manually verified tasks with ground truth, human-annotated docstrings, and fine-grained dependency information to ensure more coverage of domain-specific challenges. Specifically, we first identify the most popular application domains by topic mining. Then, we curate coding tasks based on commonly used frameworks and platforms in each domain. We obtain several findings through extensive experiments on DomainCodeBench with ten mainstream LLMs. (1) Performance decoupling: experiments reveal that top general-domain models do not consistently excel in specific application domains; (2) Domain-specific weaknesses: LLMs often fail due to domain knowledge gaps and third-party library misusage; (3) Contextual enhancement: we show that augmenting prompts with domain-specific knowledge improves performance by around 38.17%, providing actionable insights for performance optimization. Our replication package, including the benchmark, source code, and experimental results, is available at https://github.com/DeepSoftwareAnalytics/DomainCodeBench.
BibTeX
@misc{zheng2024top,
  author = {Dewu Zheng and Yanlin Wang and Ensheng Shi and Hongyu Zhang and Zibin Zheng and Zhang, Hongyu and Zheng, Zibin},
  title = {{Top General Performance = Top Domain Performance? DomainCodeBench: A Multi-domain Code Generation Benchmark}},
  year = {2024},
  eprint = {2412.18573},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.18573},
}
Figure