[Paper Review] DSL or Code? Evaluating the Quality of LLM-Generated Algebraic Specifications: A Case Study in Optimization at Kinaxis
The paper introduces EXEOS, an LLM-based pipeline for deriving AMPL or Python specifications from NL descriptions, and empirically shows DSL (AMPL) specifications can match or exceed code quality under structured, iterative refinement across industrial optimization problems.
Model-driven engineering (MDE) provides abstraction and analytical rigour, but industrial adoption in many domains has been limited by the cost of developing and maintaining models. Large language models (LLMs) can help shift this cost balance by supporting direct generation of models from natural-language (NL) descriptions. For domain-specific languages (DSLs), however, LLM-generated models may be less accurate than LLM-generated code in mainstream languages such as Python, due to the latter's dominance in LLM training corpora. We investigate this issue in mathematical optimization, with AMPL, a DSL with established industrial use. We introduce EXEOS, an LLM-based approach that derives AMPL models and Python code from NL problem descriptions and iteratively refines them with solver feedback. Using a public optimization dataset and real-world supply-chain cases from our industrial partner Kinaxis, we evaluate generated AMPL models against Python code in terms of executability and correctness. An ablation study with two LLM families shows that AMPL is competitive with, and sometimes better than, Python, and that our design choices in EXEOS improve the quality of generated specifications.
Motivation & Objective
- Assess whether LLM-generated DSL specifications (AMPL) can achieve parity with or surpass LLM-generated code (Python) in executability and correctness for optimization problems.
- Investigate the impact of NL problem structuring on the quality of generated specifications.
- Evaluate the effect of an iterative refinement loop guided by solver feedback on handling errors.
- Compare reasoning versus instruction-following LLMs in generating executable specifications.
- Examine the role of a separate data-handling step in improving specification quality and executability.
Proposed method
- Propose EXEOS: an LLM-based pipeline that structures NL problem descriptions, transforms associated data, generates or refines formal specifications in AMPL or Python, and iteratively solves with solver feedback.
- Use two datasets (Public and Kinaxis Industry) and two target languages (AMPL and Python) to perform a factorial ablation study across structuring and refinement choices.
- Experiment with four LLMs (two reasoning, two instruction-following) across eight EXEOS variants, totaling 10,560 specification instances.
- Evaluate executability (compile/run success) and correctness (relative error against ground truth) for produced specifications.
- Provide a replication package with code, datasets, and evaluation scripts.

Experimental results
Research questions
- RQ1RQ1: How do LLM-generated AMPL and Python specifications compare in executability and correctness?
- RQ2RQ2: What is the impact of structuring NL problem descriptions on executability and correctness?
- RQ3RQ3: How does the refinement loop affect executability and correctness?
- RQ4RQ4: How do reasoning versus instruction-following LLMs affect outcomes?
- RQ5RQ5: What is the impact of the data transformation step on executability and correctness?
Key findings
- A structuring step prior to generation consistently reduces compilation errors and improves alignment with the intended optimization objective.
- Iterative refinement increases executability by enabling automatic correction of initial failures.
- Generating AMPL models is not systematically worse or better than generating Python code; AMPL often performs on par or better, especially with reasoning LLMs.
- When using structured NL descriptions and iterative refinement, AMPL models achieve higher executability on the public dataset and match Python on Kinaxis Industry data.
- The EXEOS approach with explicit data handling outperforms a baseline that omits a separate data-management step, in terms of executability and correctness.
- Across 66 problems, 8 variants, 4 LLMs, and 5 repeats, the study involved 10,560 specification instances totaling about 484 hours of computation.

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.