DOI: https://doi.org/10.1145/3817608
تاريخ النشر: 2026-05-25
المؤلف: Roman Nekrasov وآخرون
الموضوع الرئيسي: الشبكات العصبية المتقدمة
نظرة عامة
تبحث هذه الدراسة في التحديات والتحسينات في توليد البنية التحتية ككود (IaC) باستخدام نماذج اللغة الكبيرة (LLMs)، مع التركيز بشكل خاص على Terraform. تسلط الدراسة الضوء على انخفاض معدلات النجاح لنماذج LLMs في إنتاج IaC الصحيح والمتوافق مع النوايا، حيث كانت نسبة الأداء الأساسية فقط 27.1%. لمعالجة ذلك، قام المؤلفون بتحسين معيار IaC-Eval الحالي من خلال دمج محاكاة السحابة وتحليل الأخطاء التلقائي، وطوروا تصنيفًا جديدًا للأخطاء يصنف 15 نوعًا من الأخطاء في كود Terraform الذي تم إنشاؤه بواسطة LLM. قاموا بتنفيذ تقنيات حقن المعرفة المختلفة، متقدمين من توليد معزز بالاسترجاع البسيط (RAG) إلى أساليب Graph RAG الأكثر تقدمًا، والتي تضمنت إثراء دلالي ونمذجة الاعتماديات بين الموارد.
تشير النتائج التجريبية إلى أن المعرفة الهيكلية للتكوين تحسن بشكل كبير من الصحة التقنية، حيث حقق Graph RAG معدل نجاح في التحقق الفني بلغ 80.3%، متجاوزًا Naive RAG (70.2%) والقاعدة الأساسية (37.2%). ومع ذلك، تحدد الدراسة “فجوة التوافق في الصحة”، حيث لا تترجم التحسينات في التحقق الفني إلى تحسينات في توافق النوايا، مما يشير إلى أنه بينما يمكن لنماذج LLMs إنتاج كود صحيح تقنيًا، فإنها تواجه صعوبة في تلبية النوايا الدقيقة للمستخدمين. ستركز الأعمال المستقبلية على توسيع الإطار لدعم لغات IaC إضافية واستخدام مصادر متنوعة من المعرفة حول IaC لتعزيز دقة توليد الكود واستراتيجيات الإصلاح.
مقدمة
تناقش مقدمة هذه الورقة البحثية التأثير التحويلي للحوسبة السحابية على إدارة بنية المؤسسات التحتية، خاصة من خلال اعتماد البنية التحتية ككود (IaC). يسمح IaC بتكوين البنية التحتية كبرمجيات، مما يسهل التحكم في الإصدارات والاختبار التلقائي. ومع ذلك، فإن تعقيد IaC، الذي يتميز بالعديد من الموارد القابلة للتكوين واعتمادياتها، يطرح تحديات كبيرة، مما يؤدي إلى تكوينات خاطئة محتملة يمكن أن تؤدي إلى ثغرات أمنية وإخفاقات تشغيلية. لقد أثار ظهور نماذج اللغة الكبيرة (LLMs) اهتمامًا في أتمتة توليد IaC، ومع ذلك، أظهرت المحاولات الأولية نجاحًا محدودًا، حيث حققت النماذج المتقدمة معدلات نجاح تتراوح بين 19-27% في مهام IaC مقارنة بأكثر من 80% في البرمجة العامة.
لمعالجة هذه التحديات، تصيغ الورقة سؤالين بحثيين رئيسيين: (1) تحديد الخصائص وأسباب الأخطاء في IaC الذي تم إنشاؤه بواسطة LLM، تحديدًا في Terraform، و(2) استكشاف كيفية تحسين المعرفة الهيكلية للتكوين لجودة الكود الناتج. يقترح المؤلفون تحليلًا منهجيًا لأنماط الأخطاء وتطوير معايير محسنة لتقييم أداء LLM في توليد IaC. يقدمون تصنيفًا ثنائي الأبعاد للأخطاء ويستكشفون طرقًا مختلفة لحقن المعرفة التكوينية في عملية التوليد، بما في ذلك أساليب توليد معززة بالاسترجاع (RAG) وGraph RAG. تهدف الدراسة إلى تحسين معدلات النجاح في الصحة التقنية وتوافق النوايا، مما يوضح في النهاية ضرورة وجود قاعدة معرفة هيكلية لتوليد IaC موثوق. تشير النتائج إلى أنه بينما تحسن حقن المعرفة الخاصة بالمجال الأداء بشكل كبير، إلا أنها تتطلب التزامًا مستمرًا للحفاظ على مصدر معرفة موثوق.
طرق
تستخدم الدراسة تصميمًا تجريبيًا مقارنًا للتحقيق في تأثير حقن المعرفة التكوينية على جودة كود Terraform الذي تم إنشاؤه بواسطة نماذج اللغة الكبيرة (LLM). في البداية، يتم مقارنة اثنين من بنى توليد معززة بالاسترجاع (RAG) الأساسية لتحديد قاعدة أساسية، بعد ذلك يتم تحسين البنية الأكثر فعالية بشكل تكراري من خلال طرق مختلفة لحقن المعرفة التكوينية. يعزل كل تجربة متغيرات محددة مع الحفاظ على الاتساق عبر الظروف، ملتزمًا بالممارسات المعمول بها في دراسات تحسين المعرفة القائمة على RAG والرسوم البيانية. يسمح هذا النهج التدريجي بتحديد التحسينات التي تحسن بشكل كبير من جودة توليد الكود دون تأثيرات متداخلة من التدخلات المتزامنة.
يتم تطبيق إجراء تجريبي موحد عبر جميع التدخلات، مما يضمن تقييم كل طريقة تحت ظروف قابلة للمقارنة باستخدام معيار تحقق محدد. يتم تأكيد اتساق طول السياق بين الأساليب الأساسية (Naive RAG وGraph RAG) من خلال تحليل اختبار t، مما يشير إلى عدم وجود فرق ذو دلالة إحصائية. تشمل عملية التقييم كل من التحقق الفني للصحة النحوية والتحقق من النوايا للصحة الدلالية، مع إجراء اختبارات فرضية إحصائية عند مستوى دلالة قدره $\alpha = 0.05$. يتم استخدام اختبار McNemar لتقييم النتائج الثنائية، ويتم تطبيق تصحيح بونفيروني لمقارنات متعددة. بالإضافة إلى ذلك، يتم استخدام نهج مجموعة مطابقة للتحقق من النوايا لتقليل انحياز الاختيار، بينما يتم الإبلاغ عن تحليل نوع الخطأ وتحليل رموز السياق بشكل وصفي لتقديم رؤى حول تأثيرات طرق حقن المعرفة المختلفة. ستقوم مخططات الفرق الحرج (CD) بتمثيل التصنيفات والأداء والعلاقات الإحصائية بين الطرق بصريًا.
النتائج
تحدد هذه القسم نتائج نهج جديد للبحث الدلالي يعرف باسم الاسترجاع الموجه بالرسوم البيانية (G-Retrieval)، الذي يعزز استرجاع المعرفة التكوينية الهيكلية. تتكون العملية من مرحلتين: تعكس المرحلة الأولى طريقة Naive RAG من خلال تضمين استفسارات المستخدم واسترجاع أفضل 5 قطع وثائق مشابهة. ومع ذلك، بدلاً من استخدام هذه القطع مباشرة، يقوم G-Retrieval باستخراج أسماء الموارد الفريدة من البيانات الوصفية لتحديد نقاط الدخول ذات الصلة في رسم بياني للمعرفة.
في المرحلة الثانية، يتم إجراء تنقل هيكلي لرسم بياني المعرفة باستخدام استعلام Cypher مصمم لاستخراج رسم فرعي أدنى يركز على كل عقدة مورد Terraform. يلتقط هذا الاستعلام العناصر الأساسية للتكوين، بما في ذلك الحجج المطلوبة والاختيارية، والكتل الضرورية، ومثال استخدام رئيسي، مع تنفيذ التحكم في العمق لإدارة التعقيد. تحول مرحلة التوليد المعزز بالرسوم البيانية (G-Generation) هذه العناصر الرسومية إلى تنسيق نصي خطي مناسب لمعالجة نماذج اللغة الكبيرة (LLM). تحافظ هذه التحويلات على العلاقات الهيكلية وتنظم المعلومات بشكل هرمي، مع إعطاء الأولوية للعناصر المطلوبة وتحسين كثافة المعلومات من خلال تقنيات مثل التباعد المتسق ودمج التسميات الزائدة.
المناقشة
في هذا القسم، يناقش المؤلفون التحديات والتقدم في استخدام نماذج اللغة الكبيرة (LLMs) لتوليد البنية التحتية ككود (IaC)، مع التركيز بشكل خاص على التعقيدات الفريدة التي تطرحها الطبيعة التصريحية للغات IaC. يسلطون الضوء على الأعمال الأولية، مثل Ansible Wisdom وDocCGen، التي أظهرت أن التدريب المسبق الخاص بالمجال واستراتيجيات التوجيه الهيكلي يمكن أن تعزز من صحة تكوينات IaC الناتجة. ومع ذلك، لا تزال هذه الأساليب تواجه مشكلات كبيرة، بما في ذلك الوعي بالنموذج، وحساسية التوجيه، وصعوبة التحقق من الصحة من خلال مقاييس التقييم التقليدية مثل درجات BLEU. يؤكد المؤلفون على الحاجة إلى معيار مخصص، IaC-Eval، الذي يقيم كل من الصحة النحوية والتوافق الوظيفي مع نية المستخدم، مما يكشف عن فجوة أداء كبيرة في نماذج LLM الحالية، مثل GPT-4، التي حققت فقط 19.36% دقة في هذا المعيار.
يقترح المؤلفون تحسينات على إطار عمل IaC-Eval، حيث يقدمون خط أنابيب تقييم تلقائي ووحدة تحليل أخطاء شاملة تصنف الإخفاقات إلى تصنيف ثنائي الأبعاد. يصنف هذا التصنيف الأخطاء بناءً على مرحلة التحقق (مثل انتهاكات النحو، عدم تطابق المخطط) والمشكلات الأساسية في التوليد (مثل عدم الدقة الواقعية، وعدم الاكتمال). يهدف التطوير المنهجي لهذا التصنيف إلى توفير رؤى أعمق حول سلوك LLM وتحسين عملية التوليد لـ IaC. من خلال معالجة قيود المعايير الحالية ودمج نهج هيكلي لتحليل الأخطاء، يهدف المؤلفون إلى تعزيز موثوقية وفعالية نماذج LLM في توليد تكوينات IaC دقيقة وقابلة للنشر.
القيود
تسلط قسم القيود في معيار IaC-Eval الضوء على عدة قيود قد تعيق التجارب الفعالة. أولاً، تعتمد المعايير على تفاعلات مباشرة مع واجهة برمجة تطبيقات AWS، مما يعقد الإدارة بسبب مشكلات المصادقة والاعتماديات، مما يؤثر بدوره على إمكانية التكرار. بالإضافة إلى ذلك، فإن التواصل المستمر مع واجهة برمجة التطبيقات يعرض لخطر توفير موارد غير مقصودة خلال مراحل التطوير والاختبار. كشفت تقييمات نصوص Terraform “الحقيقية” المقدمة عن مشكلات كبيرة، حيث نجح فقط 89% في اجتياز مرحلة `terraform init` ونجح 59% فقط في التحقق من `terraform plan`، ويرجع ذلك أساسًا إلى أخطاء نحوية ودلالية وأخطاء حزم مفقودة.
تزيد من تعقيد فائدة المعيار، اعتماده الأولي على إصدار محدد وغير موثق من Open Policy Agent (OPA) مما أدى إلى تحديات في إمكانية التكرار، وحتى بعد التحديث إلى OPA 1.1.0، استمرت الإخفاقات خلال التحقق من تحديد النوايا. كما قدم مستودع GitHub المرافق مشكلات، بما في ذلك صراعات الاعتماديات غير المحلولة، وإشارات الحزم القديمة، ووثائق غير كافية لتكوين البيئة. أخيرًا، تفتقر منهجية التقييم، التي تعتمد فقط على مقاييس النجاح والفشل الثنائية، إلى رؤى حول أنماط الفشل الأساسية أو القيود، مما يتطلب فحصًا يدويًا لفهم طبيعة هذه الإخفاقات. بشكل عام، تشكل هذه القيود تهديدات كبيرة لصلاحية وعمومية نتائج البحث.
DOI: https://doi.org/10.1145/3817608
Publication Date: 2026-05-25
Author(s): Roman Nekrasov et al.
Primary Topic: Advanced Graph Neural Networks
Overview
This research investigates the challenges and improvements in generating Infrastructure as Code (IaC) using Large Language Models (LLMs), particularly focusing on Terraform. The study highlights the low success rates of LLMs in producing correct and intent-aligned IaC, with baseline performance at only 27.1%. To address this, the authors enhanced the existing IaC-Eval benchmark by incorporating cloud emulation and automated error analysis, and developed a novel error taxonomy categorizing 15 types of errors in LLM-generated Terraform code. They implemented various knowledge injection techniques, progressing from Naive Retrieval-Augmented Generation (RAG) to more advanced Graph RAG approaches, which included semantic enrichment and modeling inter-resource dependencies.
The experimental results indicate that structured configuration knowledge significantly improves technical correctness, with Graph RAG achieving a technical validation success rate of 80.3%, surpassing Naive RAG (70.2%) and the baseline (37.2%). Further enhancements to Graph RAG raised the success rate to 84.2%. However, the study identifies a “Correctness-Congruence Gap,” where improvements in technical validation do not translate to better intent alignment, suggesting that while LLMs can generate technically correct code, they struggle to meet nuanced user intentions. Future work will focus on extending the framework to support additional IaC languages and utilizing diverse sources of IaC knowledge to enhance code generation accuracy and repair strategies.
Introduction
The introduction of this research paper discusses the transformative impact of cloud computing on organizational infrastructure management, particularly through the adoption of Infrastructure-as-Code (IaC). IaC allows for the configuration of infrastructure as software, facilitating version control and automated testing. However, the complexity of IaC, characterized by numerous configurable resources and their dependencies, poses significant challenges, leading to potential misconfigurations that can result in security vulnerabilities and operational failures. The emergence of Large Language Models (LLMs) has prompted interest in automating IaC generation, yet initial attempts have shown limited success, with state-of-the-art models achieving only 19-27% success rates in IaC tasks compared to over 80% in general programming.
To address these challenges, the paper formulates two key research questions: (1) identifying the characteristics and causes of errors in LLM-generated IaC, specifically in Terraform, and (2) exploring how structured configuration knowledge can enhance the quality of generated code. The authors propose a systematic analysis of error patterns and the development of enhanced benchmarks for evaluating LLM performance in IaC generation. They introduce a two-dimensional taxonomy of errors and investigate various methods for injecting configuration knowledge into the generation process, including Retrieval-Augmented Generation (RAG) and Graph RAG approaches. The study aims to improve success rates in technical correctness and intent alignment, ultimately demonstrating the necessity of a structured knowledge base for reliable IaC generation. The findings indicate that while domain-specific knowledge injection significantly improves performance, it requires ongoing commitment to maintain an authoritative knowledge source.
Methods
The research employs a comparative experimental design to investigate the impact of configuration knowledge injection on the quality of Large Language Model (LLM)-generated Terraform code. Initially, two fundamental Retrieval-Augmented Generation (RAG) architectures are compared to establish a baseline, after which the more effective architecture is enhanced iteratively through various configuration knowledge injection methods. Each experiment isolates specific variables while maintaining consistency across conditions, adhering to established practices in RAG and graph-based knowledge enhancement studies. This incremental approach allows for the identification of enhancements that significantly improve code generation quality without confounding effects from simultaneous interventions.
A standardized experimental procedure is applied across all interventions, ensuring that each method is evaluated under comparable conditions using a defined validation benchmark. Context length consistency between the baseline approaches (Naive RAG and Graph RAG) is confirmed through t-test analysis, indicating no statistically significant difference. The evaluation process includes both technical validation for syntactic correctness and intent validation for semantic correctness, with statistical hypothesis tests conducted at a significance level of $\alpha = 0.05$. McNemar’s test is utilized for evaluating binary outcomes, and a Bonferroni correction is applied for multiple comparisons. Additionally, a matched-subset approach is employed for intent validation to mitigate selection bias, while error type analysis and context token analysis are reported descriptively to provide insights into the effects of different knowledge injection methods. Critical Difference (CD) diagrams will visually represent the performance rankings and statistical relationships among the methods.
Results
The section outlines the results of a novel approach to semantic search known as Graph-guided retrieval (G-Retrieval), which enhances the retrieval of structured configuration knowledge. The process consists of two stages: the first stage mirrors the Naive RAG method by embedding user queries and retrieving the top-5 similar documentation chunks. However, instead of using these chunks directly, G-Retrieval extracts unique resource names from the metadata to pinpoint relevant entry points in a knowledge graph.
In the second stage, a structured traversal of the knowledge graph is conducted using a Cypher query designed to extract a minimal subgraph centered on each Terraform resource node. This query captures essential configuration elements, including required and optional arguments, necessary blocks, and a primary usage example, while implementing depth control to manage complexity. The subsequent Graph-Enhanced Generation (G-Generation) phase transforms these graph elements into a linear text format suitable for large language model (LLM) processing. This transformation preserves structural relationships and organizes information hierarchically, prioritizing required elements and optimizing information density through techniques such as consistent indentation and the consolidation of redundant labels.
Discussion
In this section, the authors discuss the challenges and advancements in using large language models (LLMs) for generating Infrastructure as Code (IaC), particularly focusing on the unique complexities posed by the declarative nature of IaC languages. They highlight preliminary works, such as Ansible Wisdom and DocCGen, which have shown that domain-specific pretraining and structured prompt strategies can enhance the correctness of generated IaC configurations. However, these approaches still face significant issues, including schema awareness, prompt sensitivity, and the difficulty of verifying correctness through traditional evaluation metrics like BLEU scores. The authors emphasize the need for a dedicated benchmark, IaC-Eval, which assesses both syntactic correctness and functional alignment with user intent, revealing a substantial performance gap in current LLMs, such as GPT-4, which achieved only 19.36% accuracy on this benchmark.
The authors propose enhancements to the IaC-Eval framework, introducing an automated evaluation pipeline and a comprehensive error analysis module that categorizes failures into a two-dimensional taxonomy. This taxonomy classifies errors based on the validation stage (e.g., syntax violations, schema mismatches) and the underlying generation issues (e.g., factual incorrectness, incompleteness). The systematic development of this taxonomy aims to provide deeper insights into LLM behavior and improve the generation process for IaC. By addressing the limitations of existing benchmarks and incorporating a structured approach to error analysis, the authors aim to advance the reliability and effectiveness of LLMs in generating accurate and deployable IaC configurations.
Limitations
The section on limitations of the IaC-Eval Benchmark highlights several constraints that may impede effective experimentation. Firstly, the benchmark’s reliance on direct AWS API interactions complicates management due to authentication and dependency issues, which in turn affects reproducibility. Additionally, the continuous communication with the API poses a risk of unintentional resource provisioning during the development and testing phases. The evaluation of the provided “ground truth” Terraform scripts revealed significant issues, with only 89% passing the `terraform init` stage and a mere 59% succeeding in the `terraform plan` validation, primarily due to syntactic, semantic, and missing package errors.
Further complicating the benchmark’s utility, its initial dependency on a specific, undocumented version of the Open Policy Agent (OPA) led to reproducibility challenges, and even after updating to OPA 1.1.0, failures persisted during intent specification validation. The accompanying GitHub repository also presented issues, including unresolved dependency conflicts, outdated package references, and insufficient documentation for environment configuration. Lastly, the evaluation methodology, which is based solely on binary pass-fail metrics, lacks insights into the underlying failure patterns or limitations, necessitating manual inspection to understand the nature of these failures. Overall, these limitations pose significant threats to the validity and generalizability of the research findings.
