Introduction
Building applications with Large Language Models (LLMs) is notoriously difficult because of "brittleness." LLMs deal in unstructured text, which often leads to hallucinations or syntax errors in downstream tasks. PDL (Prompt Declaration Language) is a new YAML-based, declarative programming language designed to make LLM interactions less brittle and more manageable. By treating prompts as structured data rather than imperative code, PDL allows developers to build complex AI patterns—like Retrieval-Augmented Generation (RAG) and ReAct agents—while maintaining precise control over the exact text sent to the model.
Problem Statement
Existing solutions for LLM application development fall into two frustrating camps:
- High-level "Bespoke" Frameworks (e.g., LangChain, AutoGen): These offer powerful features but often act as "black boxes," taking control away from the developer and requiring a steep learning curve to understand internal abstractions.
- Low-level Imperative Frameworks (e.g., Guidance, LMQL): These provide control but require writing complex Python or TypeScript code, which can obscure the actual prompt being developed.
The authors argue for a middle ground: a language that is simple and declarative (like a config file) but powerful enough to handle logic, loops, and tool use.
The PDL Language Model
PDL is built on the principle of orthogonality—a small set of simple features that can be composed in infinite ways.
- YAML-Based Syntax: Since YAML is human-readable and JSON-compatible, it’s a natural fit for representing both data and program structure.
- The Block Model: Every PDL program is a sequence of "blocks." Each block (whether it's a model call, a file read, or a piece of Python code) contributes its output to a "background context." This context automatically becomes the prompt for the next LLM call, mimicking how a conversation naturally builds.
- Data-Oriented Logic: PDL blurs the line between code and data. It uses Jinja2 for templating and supports 15 basic block types (including
model,read,if,for, andrepeat). - Type Safety: PDL integrates JSON Schema to allow developers to define expected input/output types, helping catch errors before they propagate through a chain of LLM calls.
Evaluation and Case Studies
The paper demonstrates PDL's utility through several case studies using established benchmarks:
- MBPP (Mostly Basic Python Problems): Used to demonstrate a RAG workflow.
- GSMHard: A more difficult version of the GSM8k grade-school math dataset, used to test "meta-generation" (LLMs generating PDL code).
- SWE-bench Lite: A benchmark for resolving real-world GitHub issues. The authors used a PDL-based agent to test its performance against software engineering tasks.
Key Insights and Results
- Code as Data: Because PDL is valid YAML, LLMs are surprisingly good at generating PDL programs. The authors show that an LLM can generate a PDL "plan" to solve a math problem, which is then executed by the PDL interpreter.
- Dataset Debugging: While testing on GSMHard, the authors used PDL to generate and verify solutions. They discovered that 10% of the GSMHard dataset's ground truth was actually incorrect. The human-readable nature of PDL made it easy to spot these inconsistencies.
- Competitive Performance: A PDL-based agent submitted to the SWE-bench Lite leaderboard resolved 23.7% of instances using only open-source Granite models. This performance is competitive with results typically seen from much larger "frontier" models.
Conclusion and Future Work
PDL offers a declarative path forward for LLM orchestration. While currently supporting Python for arbitrary logic, future work includes expanding language support and integrating "constrained decoding" to force LLMs to output valid JSON in real-time. The declarative nature also enables future "compilers" to optimize LLM calls for speed (via prefix caching) or cost. Security remains a priority, with sandboxing via containers already supported by the interpreter.
Summary updated