AutoReqGen: A Pipeline Approach for Automated Requirements Generation from Source Code
摘要
Requirements documentation is essential for effective software development and maintenance, but it is frequently incomplete, outdated, or entirely absent in many projects. This paper introduces AutoReqGen, a novel approach that automatically generates high-quality, human-readable requirements from source code. Our method leverages large language models (GPT-4) in a systematic pipeline combining code analysis, context preparation, generative drafting, and iterative refinement. Unlike prior approaches that use LLMs in a single-pass manner, AutoReqGen employs targeted static analysis to extract key code elements, structures this information to provide optimized context, and implements a validation-refinement loop to systematically improve requirement quality. We evaluate AutoReqGen on 2,637 code-requirement pairs from six diverse software systems, demonstrating significant improvements over baseline approaches. Experimental results show that AutoReqGen achieves a 74.2% improvement in BLEU scores and a 47.6% improvement in METEOR scores compared to basic LLM generation, with particularly strong performance on complex code. Our ablation studies confirm that each component of the pipeline significantly contributes to the overall quality of generated requirements. This work represents an important step toward bridging the gap between implementation and documentation in software projects, enabling more effective maintenance, comprehension, and evolution of software systems.