LangGPT: Rethinking Structured Reusable Prompt Design Framework for LLMs from the Programming Language
Ming Wang, Yuanzhong Liu, Xiaoyu Liang, Songlian Li, Yijie Huang, Xiaoming Zhang, Sijia Shen, Chaofeng Guan, Daling Wang, Shi Feng, Huaiwen Zhang, Yifei Zhang, Minghui Zheng, Chi Zhang
TL;DR
Prompt design for LLMs remains fragmented and difficult for non-AI experts. LangGPT introduces a dual-layer, programming-language inspired framework to improve generalization, reusability, and iterative updating. The framework structures prompts as modules and internal elements, with inherent and extension modules, and provides Markdown/JSON representations for reuse. Empirical results show LangGPT improves task performance across multiple LLMs and benchmarks, with a positive user survey indicating ease of use and a case study illustrating richer, more nuanced responses; limitations include reduced gains for low-performance models and future work on tool integration and optimization.
Abstract
LLMs have demonstrated commendable performance across diverse domains. Nevertheless, formulating high-quality prompts to instruct LLMs proficiently poses a challenge for non-AI experts. Existing research in prompt engineering suggests somewhat scattered optimization principles and designs empirically dependent prompt optimizers. Unfortunately, these endeavors lack a structured design template, incurring high learning costs and resulting in low reusability. In addition, it is not conducive to the iterative updating of prompts. Inspired by structured reusable programming languages, we propose LangGPT, a dual-layer prompt design framework as the programming language for LLMs. LangGPT has an easy-to-learn normative structure and provides an extended structure for migration and reuse. Experiments illustrate that LangGPT significantly enhances the performance of LLMs. Moreover, the case study shows that LangGPT leads LLMs to generate higher-quality responses. Furthermore, we analyzed the ease of use and reusability of LangGPT through a user survey in our online community.
