[Paper Review] How Effective are Large Language Models in Generating Software Specifications?
The study empirically evaluates 15 LLMs for generating software specifications from documentation using few-shot learning and different prompts, finding open-source StarCoder often rivals or surpasses traditional methods, with prompt design and failure analysis guiding future work.
Software specifications are essential for many Software Engineering (SE) tasks such as bug detection and test generation. Many existing approaches are proposed to extract the specifications defined in natural language form (e.g., comments) into formal machine readable form (e.g., first order logic). However, existing approaches suffer from limited generalizability and require manual efforts. The recent emergence of Large Language Models (LLMs), which have been successfully applied to numerous SE tasks, offers a promising avenue for automating this process. In this paper, we conduct the first empirical study to evaluate the capabilities of LLMs for generating software specifications from software comments or documentation. We evaluate LLMs performance with Few Shot Learning (FSL) and compare the performance of 13 state of the art LLMs with traditional approaches on three public datasets. In addition, we conduct a comparative diagnosis of the failure cases from both LLMs and traditional methods, identifying their unique strengths and weaknesses. Our study offers valuable insights for future research to improve specification generation.
Motivation & Objective
- Assess whether LLMs can generate software specifications from comments or documentation with few-shot learning.
- Compare LLM performance to traditional rule-based approaches on standard specification datasets.
- Investigate how prompt construction strategies and model choice affect results and costs.
- Diagnose failure modes to identify strengths, weaknesses, and avenues for improvement.
- Provide guidance for future research and practical model selection for specification generation.
Proposed method
- Collect datasets of software documentation with ground-truth specifications (Jdoctor-data and DocTer-data).
- Apply few-shot learning by constructing prompts with a small set of in-context examples (leave-one-out cross-validation).
- Test two prompt construction strategies: random retrieval and semantics-based retrieval (semantic similarity via RoBERTa).
- Evaluate multiple LLMs (15 models) across datasets, focusing on accuracy, precision, recall, and F1 as applicable; use manual post-processing for Jdoctor-data where necessary.
- Compare LLM performance to Jdoctor and DocTer baseline methods.
- Analyze failure cases to contrast strengths/weaknesses of LLMs versus traditional methods.
Experimental results
Research questions
- RQ1RQ1: How do LLMs with FSL compare with traditional rule-based approaches for extracting software specifications?
- RQ2RQ2: How do different prompt construction strategies affect LLM performance?
- RQ3RQ3: What are the unique strengths and weaknesses of LLMs versus traditional approaches based on failure analysis?
- RQ4RQ4: How do different LLMs compare in terms of performance and cost for generating software specifications?
Key findings
- With 10–60 randomly chosen examples, LLMs (StarCoder) achieve comparable or better results than traditional methods (DocTer is 2.2% higher or Jdoctor is 5.6% higher).
- Advanced prompt construction further widens the performance gap in favor of LLMs (5.1–10.0%).
- LLMs and traditional methods fail for different reasons; traditional methods often produce empty specifications, while LLMs produce ill-formed or incomplete ones (53–60% of unique LLM failures due to ineffective prompts and missing domain knowledge).
- Open-source StarCoder is highly competitive, offering strong performance, open access, and long prompt support; GPT-3 Davinci is less desirable due to size and cost.
- Across 15 LLMs, most models match or exceed traditional methods; StarCoder emerges as the most competitive overall.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.