一句话:提出让 LLM 为每段代码自动选取合适 Schema 并受约束生成的框架,实现多 Schema 合规的声明式代码生成。
企业声明式系统(如 Ansible)通常以 JSON 等语言提供用户接口,并依靠 JSON Schema 校验规则维持系统完整性。然而企业任务往往复杂且横跨多个 Schema,开发者难以挑选正确的 Schema 并为每个任务编写合规代码片段。已有工作表明,LLM 在给定预先已知 Schema 的约束生成下能较好地完成声明式代码生成,但无法应对需要同时生成多段代码、且每段需符合各自 Schema 的真实企业场景。本文提出一个新框架,使 LLM 在生成多段代码片段时,能够为每个片段选择合适的 Schema,并在该 Schema 下进行约束生成。作者称这是首个针对声明式系统这一关键企业问题的研究,并在两个真实用例上给出初步结果,显示任务在语法与语义两个层面的性能均有显著提升,表明该方法有望提升 LLM 在声明式企业系统中的可靠性与可扩展性。
Many enterprise systems including large-scale deployment platforms like Ansible provide a declarative user interface through programming languages like JavaScript Object Notation (JSON). These systems maintain integrity through validation rules, typically enforced via JSON schemas. However, enterprise tasks in these systems are often complex, involving multiple schemas, which makes it challenging for the developers to select the appropriate ones and write schema-compliant code snippets for each task. Recently, Large Language Models (LLMs) have shown promising performance for many declarative code generation tasks when adopted with constrained generation using a pre-known schema. However, to cater to real-world enterprise tasks, each task often requiring multiple code snippets to generate while ensuring compliance with their respective schemas, we introduce a novel framework that allows LLMs to generate multiple code snippets while choosing an appropriate schema for each of the snippets for constrained generation. To the best of our knowledge, we are the first to study this crucial enterprise problem for declarative systems and preliminary results on two real-world use cases demonstrate substantial improvements in both syntactic and semantic task performance. These findings highlight the potential of the approach to enhance the reliability and scalability of LLMs in declarative enterprise systems, indicating a promising direction for future research and development.
DOI 原文 ·
@inproceedings{paperbot9516,
title = {Multiple Schema-Conformant Declarative Code Generation},
author = {Mehant Kammakomati and Srikanth G. Tamilselvam},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00344}
}