When Prompt Engineering Meets Software Engineering: CNL-P as Natural and Robust "APIs'' for Human-AI Interaction

📅 2025-08-09
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Natural language (NL) prompts suffer from semantic ambiguity and inconsistent execution when interacting with large language models (LLMs). Method: This paper proposes Controlled Natural Language for Prompting (CNL-P), a structured prompt language inspired by software engineering principles, featuring formal syntax, semantic constraints, and verifiability. It introduces static analysis and syntactic checking into prompt engineering—novel in this domain—by developing an NL→CNL-P automatic transpiler and an integrated linting toolchain. Contribution/Results: CNL-P is formally defined as a new generation of “semantic API” for human-AI interaction, enabling structured prompt modeling, static verification, and execution consistency guarantees. Experiments demonstrate that CNL-P significantly improves LLM response quality, cross-task stability, and prompt reusability, while lowering the barrier to effective prompt engineering and advancing reliable, natural-language–based programming paradigms.

Technology Category

Application Category

📝 Abstract
With the growing capabilities of large language models (LLMs), they are increasingly applied in areas like intelligent customer service, code generation, and knowledge management. Natural language (NL) prompts act as the ``APIs'' for human-LLM interaction. To improve prompt quality, best practices for prompt engineering (PE) have been developed, including writing guidelines and templates. Building on this, we propose Controlled NL for Prompt (CNL-P), which not only incorporates PE best practices but also draws on key principles from software engineering (SE). CNL-P introduces precise grammar structures and strict semantic norms, further eliminating NL's ambiguity, allowing for a declarative but structured and accurate expression of user intent. This helps LLMs better interpret and execute the prompts, leading to more consistent and higher-quality outputs. We also introduce an NL2CNL-P conversion tool based on LLMs, enabling users to write prompts in NL, which are then transformed into CNL-P format, thus lowering the learning curve of CNL-P. In particular, we develop a linting tool that checks CNL-P prompts for syntactic and semantic accuracy, applying static analysis techniques to NL for the first time. Extensive experiments demonstrate that CNL-P enhances the quality of LLM responses through the novel and organic synergy of PE and SE. We believe that CNL-P can bridge the gap between emerging PE and traditional SE, laying the foundation for a new programming paradigm centered around NL.
Problem

Research questions and friction points this paper is trying to address.

Reducing ambiguity in natural language prompts for LLMs
Integrating software engineering principles into prompt design
Automating conversion and validation of structured prompts
Innovation

Methods, ideas, or system contributions that make the work stand out.

CNL-P combines PE best practices with SE principles
Introduces precise grammar and strict semantic norms
NL2CNL-P tool converts natural language to CNL-P
🔎 Similar Papers
Zhenchang Xing
Zhenchang Xing
Senior Principal Research Scientist, CSIRO's Data61 & Australian National University
software engineeringhuman-computer-interactionresponsible AI
Y
Yang Liu
Jiangxi Provincial Key Laboratory for High Performance Computing, State International Science & Technology Cooperation Base of Networked Supporting Software, Language Intelligence Research Center, Jiangxi Normal University
Zhuo Cheng
Zhuo Cheng
CMU
system
Qing Huang
Qing Huang
Chinese Academy of Science
Material Editing
Dehai Zhao
Dehai Zhao
CSIRO
Software engineering
Daniel Sun
Daniel Sun
Institute of AI, Newcastle University, UK and UGAiForge
C
Chenhua Liu
Jiangxi Normal University