ASSERTIFY: Utilizing Large Language Models to Generate Assertions for Production Code

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Torkamani, Mohammad Jalili, Sharma, Abhinav, Mehrotra, Nikita, Purandare, Rahul
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866912132857069568
author Torkamani, Mohammad Jalili
Sharma, Abhinav
Mehrotra, Nikita
Purandare, Rahul
author_facet Torkamani, Mohammad Jalili
Sharma, Abhinav
Mehrotra, Nikita
Purandare, Rahul
contents Production assertions are statements embedded in the code to help developers validate their assumptions about the code. They assist developers in debugging, provide valuable documentation, and enhance code comprehension. Current research in this area primarily focuses on assertion generation for unit tests using techniques, such as static analysis and deep learning. While these techniques have shown promise, they fall short when it comes to generating production assertions, which serve a different purpose. This preprint addresses the gap by introducing Assertify, an automated end-to-end tool that leverages Large Language Models (LLMs) and prompt engineering with few-shot learning to generate production assertions. By creating context-rich prompts, the tool emulates the approach developers take when creating production assertions for their code. To evaluate our approach, we compiled a dataset of 2,810 methods by scraping 22 mature Java repositories from GitHub. Our experiments demonstrate the effectiveness of few-shot learning by producing assertions with an average ROUGE-L score of 0.526, indicating reasonably high structural similarity with the assertions written by developers. This research demonstrates the potential of LLMs in automating the generation of production assertions that resemble the original assertions.
format Preprint
id arxiv_https___arxiv_org_abs_2411_16927
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle ASSERTIFY: Utilizing Large Language Models to Generate Assertions for Production Code
Torkamani, Mohammad Jalili
Sharma, Abhinav
Mehrotra, Nikita
Purandare, Rahul
Software Engineering
Artificial Intelligence
D.2.5; D.2.7; K.6.3
Production assertions are statements embedded in the code to help developers validate their assumptions about the code. They assist developers in debugging, provide valuable documentation, and enhance code comprehension. Current research in this area primarily focuses on assertion generation for unit tests using techniques, such as static analysis and deep learning. While these techniques have shown promise, they fall short when it comes to generating production assertions, which serve a different purpose. This preprint addresses the gap by introducing Assertify, an automated end-to-end tool that leverages Large Language Models (LLMs) and prompt engineering with few-shot learning to generate production assertions. By creating context-rich prompts, the tool emulates the approach developers take when creating production assertions for their code. To evaluate our approach, we compiled a dataset of 2,810 methods by scraping 22 mature Java repositories from GitHub. Our experiments demonstrate the effectiveness of few-shot learning by producing assertions with an average ROUGE-L score of 0.526, indicating reasonably high structural similarity with the assertions written by developers. This research demonstrates the potential of LLMs in automating the generation of production assertions that resemble the original assertions.
title ASSERTIFY: Utilizing Large Language Models to Generate Assertions for Production Code
topic Software Engineering
Artificial Intelligence
D.2.5; D.2.7; K.6.3
url https://arxiv.org/abs/2411.16927