arrow
Return

Fine-tuning LLMs for answer set programming

delete2026-02-01
delete0
delete
OA
AI
F
Francesco Calimeri
G
Giuseppe Manco
S
Simona Perri
F
Francesco Ricca
DOI:10.1007/s10844-025-01017-4delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Large Language Models (LLMs) have demonstrated impressive capabilities across a wide range of natural language processing tasks, including code generation. While substantial progress has been made in adapting LLMs to generate code for various imperative programming languages, their effectiveness in handling declarative paradigms, such as Answer Set Programming (ASP), remains largely underexplored. This paper takes a step toward bridging that gap by investigating the potential of LLMs for ASP code generation. We begin with a systematic evaluation of several foundational LLMs, moving towards state-of-the-art models. We show that, despite their extensive training, large parameter counts, and significant computational backing, older models exhibit poor performance in generating syntactically and semantically correct ASP programs, while most recent ones mainly achieve impressive results. However, to overcome the need for huge computational power, we introduce LLASP, a fine-tuned, lightweight model specifically trained to encode ASP programs. In this regard, we extensively explore the effectiveness of fine-tuning by curating several dedicated datasets suitable for ASP encoding with increasing levels of complexity. First, we show that LLASP is effective in encoding template-based core problems in ASP; second, that the training strategy can be pushed forward to disregard the need for templating and make the generation prompt-invariant; and lastly, we show that even complex problems can be effectively encoded, beyond core tasks. Experimental results also show that LLASP significantly outperforms both its non-fine-tuned counterparts and most general-purpose LLMs, particularly in terms of semantic correctness, achieving a good trade-off between accuracy and resource-efficiency. Experimental code is publicly available at: https://github.com/EricaCoppolillo/LLASP.
Keywords:
Answer set programming
Large language models
Evaluation
Fine-tuning

Journal

J
Journal of Intelligent Information Systems
IF:
3.4
Papers:
78
Citations:
0

Organization

C
consiglio nazionale delle ricerche (cnr)
Scholars:
6.2W
Papers: 5.7W
Citations: 48
U
university of calabria
Scholars:
1.4K
Papers: 605
Citations: 0
Cited Papers

Cited Papers

err
IF0
err
err0
PREAI
err
errShare
errSave
Understanding the Robustness of Transformer-Based Code Intelligence via Code Transformation: Challenges and Opportunities
err2025-02-01
err0
PREAI
errLi, Yaoxian; Qi, Shiyi; Gao, Cuiyun; Peng, Yun; Lo, David; Lyu, Michael R.; Xu, Zenglin
errShare
errSave
err
IF0
err
err0
PREAI
err
errShare
errSave
CNL2ASP: Converting Controlled Natural Language Sentences into ASP
err2024-03-01
err0
PREAI
errCARUSO,SIMONE; DODARO,CARMINE; MARATEA,MARCO; MOCHI,MARCO; RICCIO,FRANCESCO
errShare
errSave
Design and results of the Fifth Answer Set Programming Competition
err2016-02-01
err85
errOAAI
errCalimeri, Francesco; Gebser, Martin; Maratea, Marco; Ricca, Francesco
errShare
errSave
A Comprehensive Overview of Large Language Models
err2025-08-19
err0
errOAAI
errHumza Naveed; Asad Ullah Khan; Shi Qiu; Muhammad Saqib; Saeed Anwar; Muhammad Usman; Naveed Akhtar; Nick Barnes; Ajmal Mian
errShare
errSave
researcher View more