Automated Code generation for Information Technology Tasks in YAML through Large Language Models

Saurabh Pujar, Luca Buratti, Xiaojie Guo, Nicolas Dupuis, Burn L. Lewis, Sahil Suneja, Atin Sood, Ganesh Nalawade, Matthew Jones, Alessandro Morari, Ruchir Puri · DOI

TL;DR

This paper introduces "Ansible Wisdom," a novel approach to automatically generate Ansible-YAML code from natural language descriptions. By training large language models on a specialized dataset of Ansible-YAML, the authors demonstrate significant improvements in code generation accuracy, outperforming even larger general-purpose models like Codex. This work paves the way for more efficient IT automation by making it more accessible.

What Problem Does This Paper Address?

Large Language Models (LLMs) have shown remarkable success in generating code for general-purpose programming languages. However, their application to domain-specific languages (DSLs), particularly those crucial for IT automation like Ansible-YAML, has been largely overlooked. Ansible-YAML is widely used for configuring and managing IT infrastructure, but requires significant expertise. This gap limits the adoption of efficient IT automation practices. The paper aims to bridge this gap by developing an LLM-based tool that can generate Ansible-YAML code from natural language prompts, thereby boosting developer productivity and simplifying IT automation.

Methods

The core of this work is the development of "Ansible Wisdom," a transformer-based LLM. The authors leverage existing pre-trained models like CODEGEN and fine-tune them on a custom dataset specifically curated for Ansible-YAML. They also explore training models from scratch. A key methodological contribution is the re-formalization of the code generation problem into a "code completion" task, by treating the natural language description as part of the "name" field in Ansible scripts. This allows the model to better leverage the structure of YAML. Additionally, the paper introduces two novel evaluation metrics, "Ansible Aware" and "Schema Correct," designed to better capture the nuances of Ansible-YAML syntax and structure compared to generic metrics like BLEU.

Datasets

The authors constructed a new dataset for training and fine-tuning. This dataset comprises approximately 1.1 million Ansible task and playbook YAML files, along with 2.2 million generic YAML files. Data was sourced from Ansible Galaxy, GitHub, Google BigQuery, and GitLab. For fine-tuning, they specifically utilized the Ansible Galaxy dataset, which contains a collection of vetted Ansible files.

Key Insights and Ideas

  • Domain-Specific Data is Crucial: Pre-training or fine-tuning LLMs on domain-specific data (Ansible-YAML in this case) significantly enhances their performance on tasks within that domain, even outperforming larger, general-purpose models.
  • YAML's Structure Matters: Re-framing the problem as code completion, by utilizing the natural language description within the "name" field of YAML, proved to be an effective strategy for improving generation quality.
  • Novel Metrics are Necessary: Generic code generation metrics like BLEU are insufficient for evaluating DSLs like Ansible-YAML. The proposed "Ansible Aware" and "Schema Correct" metrics provide a more accurate assessment of the generated code's usability and adherence to the domain's conventions.
  • Smaller, Specialized Models Can Excel: A 350M parameter model trained on specialized data (Wisdom-ANSIBLE-MULTI) can outperform a much larger model like Codex-Davinci-002 (175B parameters) in few-shot settings for Ansible generation.

Key Results

The fine-tuned "Ansible Wisdom" models demonstrated superior performance compared to baseline models like CODEGEN and OpenAI's Codex. Specifically:

  • In few-shot settings, the best performing Wisdom model (WISDOM-ANSIBLE-MULTI) achieved a BLEU score of 46.58 and an Ansible Aware score of 54.51, outperforming CODEGEN-MULTI 6B and Codex-Davinci-002 in several metrics.
  • After fine-tuning, the Ansible-specific model achieved a BLEU score of 66.67, significantly outperforming Codex-Davinci-002 (50.4 BLEU) in few-shot settings.
  • The paper also found that a context window size of 1024 was adequate for achieving good performance, with diminishing returns for larger windows.
  • The proposed prompt formulation method improved performance by up to 10% on BLEU and 26% on Schema Correct compared to a standard prefix-based approach.

Limitations and Future Work

The authors acknowledge several limitations:

  • Playbook Representation: The fine-tuning dataset had a limited representation of full playbooks, with most examples being small tasks. Ansible Blocks, a logical grouping of tasks, were also not specifically addressed.
  • Robustness: Further analysis is needed on the model's sensitivity to prompt variations, indentation, quotes, and case sensitivity.
  • Generalization: The current work focuses on Natural Language to Ansible generation. Future work could expand to more general code completion tasks.

Future work suggested includes expanding the dataset to include more playbooks and Ansible Blocks, conducting more in-depth analysis of prompt sensitivity and robustness, and exploring more general code completion capabilities.

Summary updated

BibTeX
@inproceedings{pujar2023automated,
  author = {Saurabh Pujar and Luca Buratti and Xiaojie Guo and Nicolas Dupuis and Burn L. Lewis and Sahil Suneja and Atin Sood and Ganesh Nalawade and Matthew Jones and Alessandro Morari and Ruchir Puri},
  title = {{Automated Code generation for Information Technology Tasks in YAML through Large Language Models}},
  booktitle = {DAC},
  year = {2023},
  url = {https://openreview.net/forum?id=qeyKfQKIe9k},
}
Figure