mlsanityData to 7 Oct 2026

A Comparative Study of DSL Code Generation: Fine-Tuning vs. Optimized Retrieval Augmentation

arXiv 2407.02742 ↗First posted 3 Jul 2024cs.SE cs.AI cs.CLcited by 8

On the map: Retrieval-augmented generation → RAG for code

Abstract (arXiv)

Natural Language to Code Generation has made significant progress in recent years with the advent of Large Language Models(LLMs). While generation for general-purpose languages like C, C++, and Python has improved significantly, LLMs struggle with custom function names in Domain Specific Languages or DSLs. This leads to higher hallucination rates and syntax errors, specially for DSLs having a high number of custom function names. Additionally, constant updates to function names add to the challenge as LLMs need to stay up-to-date. In this paper, we present optimizations for using Retrieval Augmented Generation (or RAG) with LLMs for DSL generation along with an ablation study comparing these strategies. We generated a train as well as test dataset with a DSL to represent automation tasks across roughly 700 APIs in public domain. We used the training dataset to fine-tune a Codex model for this DSL. Our results showed that the fine-tuned model scored the best on code similarity metric. With our RAG optimizations, we achieved parity for similarity metric. The compilation rate, however, showed that both the models still got the syntax wrong many times, with RAG-based method being 2 pts better. Conversely, hallucination rate for RAG model lagged by 1 pt for API names and by 2 pts for API parameter keys. We conclude that an optimized RAG model can match the quality of fine-tuned models and offer advantages for new, unseen APIs.

Key facts. Cited by 8 papers in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 8 of its 21 references that are in the map. First posted on arXiv 3 Jul 2024.

Builds on

8 of 21 references.

References · 8

  1. 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
  2. 2023Toolformer: Language Models Can Teach Themselves to Use Toolscited by 4,072
  3. 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,359
  4. 2022Unnatural Instructions: Tuning Language Models with (Almost) No Human Laborcited by 395
  5. 2023TaskMatrix.AI: Completing Tasks by Connecting Foundation Models with Millions of APIscited by 184
  6. 2017RobustFill: Neural Program Learning under Noisy I/Ocited by 124
  7. 2021Jigsaw: Large Language Models meet Program Synthesiscited by 103
  8. 2023Improving ChatGPT Prompt for Code Generationcited by 28

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 2; 2025: 3; 2026: 3.

8 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024Plan with Code: Comparing approaches for robust NL to DSL generation
  2. 2026Text2DSL: LLM-Based Code Generation for Domain-Specific Languages
  3. 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
  4. 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?
  5. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  6. 2025Evaluating Large Language Models for Functional and Maintainable Code in Industrial Settings: A Case Study at ASML
  7. 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
  8. 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation