Saved in:
| Main Author: | |
|---|---|
| Format: | Recurso digital |
| Language: | |
| Published: |
Zenodo
2025
|
| Online Access: | https://doi.org/10.5281/zenodo.17339105 |
| Tags: |
Add Tag
No Tags, Be the first to tag this record!
|
Table of Contents:
- <h1>Replication Package: Does Model Size Matter? A Comparison of Small and Large Language Models for Requirements Classification</h1> <p>This repository contains the replication package for the research paper:</p> <p><strong>"Does Model Size Matter? A Comparison of Small and Large Language Models for Requirements Classification"</strong></p> <p><em>Mohammad Amin Zadenoori¹, Vincenzo De Martino²³, Jacek Dąbrowski⁴, Xavier Franch³, and Alessio Ferrari⁵</em></p> <p>¹ University of Padova, Italy<br> ² Software Engineering (SeSa) Lab, University of Salerno, Italy<br> ³ Universitat Politècnica de Catalunya, Spain<br> ⁴ Lero, the Research Ireland Centre for Software, University of Limerick, Ireland<br> ⁵ University College Dublin (UCD), Ireland</p> <h2>Abstract</h2> <p><strong>[Context and motivation]</strong> Large language models (LLMs) show promising results in natural language processing (NLP) tasks for requirements engineering (RE). However, their use is limited by high computational cost, data-sharing risks, and dependence on external services. Small language models (SLMs) offer a lightweight, locally deployable alternative.</p> <p><strong>[Question/problem]</strong> However, it remains unclear how well open-source SLMs perform compared to LLMs in RE tasks.</p> <p><strong>[Principal idea/results]</strong> This preliminary study compares eight models, including three LLMs and five SLMs, on the task of requirements classification, using three datasets. We evaluated performance using precision, recall, and F1 metrics to assess their ability to classify functional vs non-functional, functional vs quality, and security vs non-security requirements. Results indicate that LLMs generalize slightly better. The best-performing LLMs achieved approximately 2% higher F1 scores compared to the top-performing SLMs across the evaluated classification tasks, while SLMs have lower computational demands and do not share sensitive data.</p> <p><strong>[Contributions]</strong> Our contribution is twofold: (i) a systematic comparison of five SLMs and three LLMs, and (ii) evidence that SLMs can reliably support RE classification tasks on local infrastructure.</p> <h2>Project Structure</h2> <pre><code>. ├── input/ # Input datasets used in the study │ ├── CPN.csv # Security classification dataset │ └── promise-reclass.csv # PROMISE reclassification dataset ├── output/ # Generated results and metrics │ ├── all_summary_metrics_nfr.csv │ ├── all_summary_metrics_promise_refined.csv │ └── all_summary_metrics_security.csv ├── prompts and descriptions/ # Prompt templates and class descriptions │ └── Prompt and descriptions.md ├── ReqSec.py # Security requirements classification ├── NFR.py # Functional vs Non-Functional classification ├── Promise-reclass.py # F, Q, onlyF, onlyQ classification └── README.md # This file </code></pre> <h2>Research Components</h2> <h3>Models Evaluated</h3> <h4>Small Language Models (SLMs)</h4> <ul> <li>Qwen/Qwen2-7B-Instruct</li> <li>tiiuae/Falcon3-7B-Instruct</li> <li>ibm-granite/granite-3.2-8b-instruct</li> <li>mistralai/Ministral-8B-Instruct-2410</li> <li>meta-llama/Meta-Llama-3-8B-Instruct</li> </ul> <h4>Large Language Models (LLMs)</h4> <ul> <li>Grok-4</li> <li>GPT-5o (using OpenAI API)</li> <li>Claude-4 (using Anthropic API)</li> </ul> <h3>Classification Tasks</h3> <h4>1. Security Requirements Classification (<code>ReqSec.py</code>)</h4> <ul> <li><strong>Task</strong>: Binary classification of requirements as Security vs Non-Security</li> <li><strong>Dataset</strong>: CPN.csv</li> <li><strong>Key Finding</strong>: LLMs achieved ~2% higher F1 scores compared to top SLMs</li> </ul> <h4>2. Functional vs Non-Functional Requirements (<code>NFR.py</code>)</h4> <ul> <li><strong>Task</strong>: Binary classification of requirements as Functional vs Non-Functional</li> <li><strong>Dataset</strong>: promise-reclass.csv</li> <li><strong>Key Finding</strong>: SLMs demonstrated competitive performance with local deployment advantages</li> </ul> <h4>3. Fine-grained Requirements Classification (<code>Promise-reclass.py</code>)</h4> <ul> <li><strong>Task</strong>: Multi-class classification into Functional (F), Quality (Q), Only Functional (onlyF), and Only Quality (onlyQ)</li> <li><strong>Dataset</strong>: promise-reclass.csv</li> <li><strong>Key Finding</strong>: Both SLMs and LLMs effectively handle complex multi-class classification</li> </ul> <h2>Experimental Setup</h2> <h3>Prompting Strategies</h3> <p>Each classification task was evaluated using four prompting methods:</p> <ol> <li><strong>CoT with Few-shot</strong>: Combined approach with examples and reasoning</li> </ol> <h3>Evaluation Metrics</h3> <ul> <li>Precision (P)</li> <li>Recall (R)</li> <li>F1-score</li> </ul> <h3>Key Experimental Features</h3> <ul> <li>Dynamic batching based on GPU memory</li> <li>Majority voting with consensus mechanism</li> <li>Variance checking for prediction stability</li> <li>Comprehensive error handling</li> </ul> <h2>Installation and Setup</h2> <h3>Prerequisites</h3> <pre><code>pip install torch transformers datasets scikit-learn pandas numpy requests openai </code></pre> <h3>Environment Variables</h3> <p>Set the following API keys for LLM integration:</p> <pre><code># For Grok API export GROK_API_KEY="your_grok_api_key" # For Claude API export ANTHROPIC_API_KEY="your_anthropic_api_key" # For OpenAI API (GPT-5o) export OPENAI_API_KEY="your_openai_api_key" # Hugging Face token (for local models) export HF_TOKEN="your_huggingface_token" </code></pre> <h2>Usage</h2> <h3>Reproducing Security Classification Experiments</h3> <pre><code>python ReqSec.py </code></pre> <h3>Reproducing Functional vs Non-Functional Classification</h3> <pre><code>python NFR.py </code></pre> <h3>Reproducing Fine-grained Classification</h3> <pre><code>python Promise-reclass.py </code></pre> <h2>Key Findings Reproduction</h2> <p>The experiments demonstrate that:</p> <ol> <li><strong>LLMs show slightly better generalization</strong> with approximately 2% higher F1 scores across tasks</li> <li><strong>SLMs provide practical alternatives</strong> with local deployment and data privacy advantages</li> <li><strong>Both model types effectively handle</strong> complex requirements classification tasks</li> <li><strong>The performance gap is minimal</strong> for many practical applications</li> </ol> <h2>Output Interpretation</h2> <p>Each script generates comprehensive CSV files containing:</p> <ul> <li>Overall metrics (Precision, Recall, F1)</li> <li>Class-specific performance metrics</li> <li>Timing data for computational efficiency analysis</li> <li>Comparative performance between SLMs and LLMs</li> </ul> <h2>Dataset Information</h2> <h3>CPN.csv</h3> <ul> <li>Security requirements classification dataset</li> <li>Binary labels: Security (1) vs Non-Security (0)</li> </ul> <h3>promise-reclass.csv</h3> <ul> <li>PROMISE requirements repository with reclassified labels</li> <li>Supports multiple classification schemes including functional vs non-functional and quality attributes</li> </ul> <h2> Dataset Attribution</h2> <p>This project uses the following publicly available datasets:</p> <ul> <li><p><strong>PROMISE Dataset</strong><br> Originally provided for the RE'17 Data Challenge by Jane Cleland-Huang and collaborators.</p> <ul> <li>Cleland-Huang, J., Mazrouee, S., Huang, L., & Port, D. (2007). <em>nfr</em> [Data set]. Zenodo. <a href="https://doi.org/10.5281/zenodo.268542">https://doi.org/10.5281/zenodo.268542</a></li> <li>RE'17 Data Challenge: <a href="http://ctp.di.fct.unl.pt/RE2017/pages/submission/data_papers/">http://ctp.di.fct.unl.pt/RE2017/pages/submission/data_papers/</a></li> <li>See also: Sayyad Shirabad, J. & Menzies, T.J. (2005). <em>The PROMISE Repository of Software Engineering Databases</em>. University of Ottawa. <a href="http://promise.site.uottawa.ca/SERepository">http://promise.site.uottawa.ca/SERepository</a></li> </ul> </li> <li><p><strong>Relabeled PROMISE Dataset</strong><br> Provided by Dalpiaz et al. for explainable requirements classification.</p> <ul> <li>Dalpiaz, F., Dell'Anna, D., Aydemir, F. B., & Çevikol, S. (2019). <em>explainable-re/re-2019-materials</em>. Zenodo. <a href="https://doi.org/10.5281/zenodo.3309669">https://doi.org/10.5281/zenodo.3309669</a></li> </ul> </li> <li><p><strong>SecReq Dataset</strong><br> Used for security requirements classification.</p> <ul> <li>Knauss, E., Houmb, S. H., Islam, S., Jürjens, J., & Schneider, K. (2021). <em>SecReq</em> [Data set]. Zenodo. <a href="https://doi.org/10.5281/zenodo.4530183">https://doi.org/10.5281/zenodo.4530183</a></li> </ul> </li> </ul> <h2>Citation</h2> <p>If you use this replication package in your research, please cite our paper:</p> <pre><code>@article{zadenoori2025model, title={Does Model Size Matter? A Comparison of Small and Large Language Models for Requirements Classification}, author={Zadenoori, Mohammad Amin and De Martino, Vincenzo and Dąbrowski, Jacek and Franch, Xavier and Ferrari, Alessio}, journal={Submitted for publication}, year={2025} } </code></pre> <h2>Contact</h2> <p>For questions about this replication package, please contact:</p> <ul> <li>Mohammad Amin Zadenoori: amin.zadenoori@unipd.it</li> </ul>