Declarative Prompt-Programming Framework: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Text replacement - "Category:Quality Gold" to "Category:Quality Silver") |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
** It can typically enable [[Modular Reuse]] through [[import mechanism]]s and [[include directive]]s for [[prompt component]]s. | ** It can typically enable [[Modular Reuse]] through [[import mechanism]]s and [[include directive]]s for [[prompt component]]s. | ||
** It can typically abstract [[Model-Specific Detail]]s, creating a [[model-agnostic representation]] of [[declarative prompt-programming intention]]s. | ** It can typically abstract [[Model-Specific Detail]]s, creating a [[model-agnostic representation]] of [[declarative prompt-programming intention]]s. | ||
** It can typically | ** It can typically enforce [[Output Structure]] through [[schema definition]]s, [[constraint]]s, or [[type system]]s. | ||
** ... | ** ... | ||
** It can often include [[Templating Directive]]s (using systems like [[Jinja2]] or [[Liquid]]) for [[dynamic content generation]]. | ** It can often include [[Templating Directive]]s (using systems like [[Jinja2]] or [[Liquid]]) for [[dynamic content generation]]. | ||
** It can often implement [[Control Flow Construct]]s such as [[declarative prompt-programming loop]]s, [[declarative prompt-programming conditional]]s, and [[declarative prompt-programming function definition]]s. | ** It can often implement [[Control Flow Construct]]s such as [[declarative prompt-programming loop]]s, [[declarative prompt-programming conditional]]s, and [[declarative prompt-programming function definition]]s. | ||
** It can often provide [[Type Checking]] for [[declarative prompt-programming variable]]s to ensure [[data integrity]]. | ** It can often provide [[Type Checking]] for [[declarative prompt-programming variable]]s to ensure [[data integrity]]. | ||
** It can often support [[ | ** It can often support [[Multi-Step Workflow]]s by [[declarative prompt-programming chain]]ing or [[declarative prompt-programming orchestration]]. | ||
** It can often enable [[Collaborative Prompt Development]] through its [[human-readable format]] and [[defined structure]]. | ** It can often enable [[Collaborative Prompt Development]] through its [[human-readable format]] and [[defined structure]]. | ||
** It can often facilitate [[Prompt Versioning]] to track [[declarative prompt-programming evolution]]. | ** It can often facilitate [[Prompt Versioning]] to track [[declarative prompt-programming evolution]]. | ||
** It can often include [[Error Handling Mechanism]]s that manage [[LLM output failure]]s through [[retry logic]] and [[fallback strategy]]. | |||
** It can often provide [[Validation Feedback Loop]]s where [[invalid output]]s trigger [[corrective reprompt]]s. | |||
** ... | ** ... | ||
** It can range from being a [[Simple Declarative Prompt-Programming Framework]] to being a [[Complex Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming feature complexity]]. | ** It can range from being a [[Simple Declarative Prompt-Programming Framework]] to being a [[Complex Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming feature complexity]]. | ||
Line 20: | Line 22: | ||
** It can range from being a [[Lightweight Declarative Prompt-Programming Framework]] to being a [[Comprehensive Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming integration capability]]. | ** It can range from being a [[Lightweight Declarative Prompt-Programming Framework]] to being a [[Comprehensive Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming integration capability]]. | ||
** It can range from being a [[Specialized Declarative Prompt-Programming Framework]] to being a [[Universal Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming model compatibility]]. | ** It can range from being a [[Specialized Declarative Prompt-Programming Framework]] to being a [[Universal Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming model compatibility]]. | ||
** It can range from being a [[Single-Call Declarative Prompt-Programming Framework]] to being a [[Multi-Step Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming orchestration complexity]]. | |||
** It can range from being a [[Code-Embedded Declarative Prompt-Programming Framework]] to being a [[Standalone Declarative Prompt-Programming Framework]], depending on its [[declarative prompt-programming host language relationship]]. | |||
** ... | ** ... | ||
** It can integrate with [[Retrieval-Augmented Generation Pipeline]]s for [[structured document processing]]. | ** It can integrate with [[Retrieval-Augmented Generation Pipeline]]s for [[structured document processing]]. | ||
Line 27: | Line 31: | ||
** It can incorporate [[External Knowledge Source]]s via [[declarative prompt-programming retrieval mechanism]]s. | ** It can incorporate [[External Knowledge Source]]s via [[declarative prompt-programming retrieval mechanism]]s. | ||
** It can work with [[Validation Tool]]s for [[declarative prompt-programming quality assurance]]. | ** It can work with [[Validation Tool]]s for [[declarative prompt-programming quality assurance]]. | ||
** It can integrate with [[CI/CD Pipeline]]s for [[automated prompt testing]] and [[prompt deployment]]. | |||
** It can connect to [[Output Validation System]]s for [[LLM output reliability enhancement]]. | |||
** It can support [[Safe Guardrail Integration]] for [[LLM response filtering]] and [[harmful content prevention]]. | |||
** ... | ** ... | ||
* <B>Examples:</B> | * <B>Examples:</B> | ||
** [[Declarative Prompt-Programming Framework | ** [[Declarative Prompt-Programming Framework Syntax Approach]]es, such as: | ||
*** [[YAML-Based Declarative Prompt-Programming Framework]]s, such as: | *** [[YAML-Based Declarative Prompt-Programming Framework]]s, such as: | ||
**** [[IBM PDL (Prompt Declaration Language)]] using [[YAML]] with [[Jinja2]] for [[templating function]]s | **** [[IBM PDL (Prompt Declaration Language)]] using [[YAML]] with [[Jinja2]] for [[templating function]]s, [[type checking]] via [[JSON Schema]], and [[control flow construct]]s like [[conditional]]s and [[loop]]s. | ||
**** [[ | **** [[Azure Prompt Flow]] representing [[multi-step workflow]]s as [[directed acyclic graph]]s with [[step definition]]s and [[data flow]]s. | ||
**** [[Pathway Templates]] for [[declarative prompt-programming structured workflow]]s. | **** [[Pathway Templates]] for [[declarative prompt-programming structured workflow]]s. | ||
*** [[JSON-Based Declarative Prompt-Programming Framework]]s, such as: | *** [[JSON-Based Declarative Prompt-Programming Framework]]s, such as: | ||
Line 38: | Line 45: | ||
**** [[Prompt Schema]] for [[declarative prompt-programming standardization]]. | **** [[Prompt Schema]] for [[declarative prompt-programming standardization]]. | ||
*** [[DSL-Based Declarative Prompt-Programming Framework]]s, such as: | *** [[DSL-Based Declarative Prompt-Programming Framework]]s, such as: | ||
**** [[LMQL (Language Model Query Language)]] using [[constraint expression]]s with [[where clause]]s to enforce [[output pattern]]s. | |||
**** [[BAML (Basically a Made-up Language)]] implementing [[prompts as function]]s with [[parameter type]]s and [[return type]]s. | |||
**** [[Colang]] in [[NVIDIA NeMo Guardrails]] for [[conversational AI safety]] and [[dialogue flow management]]. | |||
**** [[Impromptu]] for [[model-driven declarative prompt-programming]] with [[platform independence]]. | **** [[Impromptu]] for [[model-driven declarative prompt-programming]] with [[platform independence]]. | ||
**** [[Questo]] for [[declarative query generation]]. | **** [[Questo]] for [[declarative query generation]]. | ||
*** [[Code-Embedded Declarative Prompt-Programming Framework]]s, such as: | |||
**** [[Microsoft Guidance]] with its [[inline control directive]]s for [[stepwise generation control]]. | |||
**** [[DSPy]] providing [[declarative module]]s and [[signature]]s for [[LLM-powered component]]s. | |||
**** [[Marvin AI Functions]] using [[Python decorator]]s and [[type annotation]]s for [[LLM function specification]]. | |||
** [[Declarative Prompt-Programming Framework Complexity Level]]s, such as: | |||
*** [[Comprehensive Declarative Prompt-Programming Framework]]s, such as: | |||
**** [[IBM PDL (Prompt Declaration Language)]] supporting [[full control flow]], [[type checking]], [[model chaining]], and [[function definition]]s. | |||
**** [[Azure Prompt Flow]] with [[enterprise feature]]s for [[LLMOps]], [[experiment tracking]], and [[deployment management]]. | |||
**** [[DSPy]] offering [[teleprompter]]s for [[prompt optimization]] and [[advanced module composition]]. | |||
*** [[Moderate Declarative Prompt-Programming Framework]]s, such as: | |||
**** [[BAML]] balancing [[schema validation]] with [[approachable syntax]] using [[function metaphor]]s. | |||
**** [[LMQL]] focusing on [[constrained generation]] and [[output filtering]]. | |||
**** [[NeMo Guardrails]] specializing in [[conversational safety rule]]s and [[dialogue policy]]. | |||
*** [[Lightweight Declarative Prompt-Programming Framework]]s, such as: | |||
**** [[Marvin AI Functions]] emphasizing [[developer simplicity]] through [[familiar function syntax]]. | |||
**** [[Guardrails (RAIL)]] focusing on [[output validation]] and [[schema conformance]]. | |||
** [[Declarative Prompt-Programming Framework Application Domain]]s, such as: | ** [[Declarative Prompt-Programming Framework Application Domain]]s, such as: | ||
*** [[Controlled Chatbot Declarative Prompt-Programming Framework]]s for [[regulated conversation flow]]. | *** [[General-Purpose Declarative Prompt-Programming Framework]]s for [[cross-domain application]]s, such as: | ||
*** [[RAG Pipeline Declarative Prompt-Programming Framework]]s for [[document retrieval workflow]]. | **** [[IBM PDL]] supporting [[universal usage]] across [[domain]]s. | ||
*** [[Regulated Domain Declarative Prompt-Programming Framework]]s for [[finance]] and [[legal]] applications requiring [[auditability]]. | **** [[DSPy]] enabling [[self-optimizing pipeline]]s for [[diverse task]]s. | ||
*** [[Code Generation Declarative Prompt-Programming Framework]]s for [[structured programming task]]s. | *** [[Specialized Domain Declarative Prompt-Programming Framework]]s, such as: | ||
*** [[Chain-of-Thought Declarative Prompt-Programming Framework]]s for [[multi-step reasoning process]]es. | **** [[Guardrails (RAIL)]] for [[output validation]] and [[schema enforcement]]. | ||
*** [[ReAct Agent Declarative Prompt-Programming Framework]]s for [[reasoning and acting cycle]]s. | **** [[NeMo Guardrails]] for [[conversational AI safety]] and [[topic management]]. | ||
** [[Declarative Prompt-Programming Framework | **** [[Controlled Chatbot Declarative Prompt-Programming Framework]]s for [[regulated conversation flow]]. | ||
*** [[ | **** [[RAG Pipeline Declarative Prompt-Programming Framework]]s for [[document retrieval workflow]]. | ||
**** [[ | **** [[Regulated Domain Declarative Prompt-Programming Framework]]s for [[finance]] and [[legal]] applications requiring [[auditability]]. | ||
**** [[ | **** [[Code Generation Declarative Prompt-Programming Framework]]s for [[structured programming task]]s. | ||
**** [[Chain-of-Thought Declarative Prompt-Programming Framework]]s for [[multi-step reasoning process]]es. | |||
**** [[ReAct Agent Declarative Prompt-Programming Framework]]s for [[reasoning and acting cycle]]s. | |||
** [[Declarative Prompt-Programming Framework Feature Implementation]]s, such as: | |||
*** [[Schema Validation Declarative Prompt-Programming Framework]]s, such as: | |||
**** [[Guardrails (RAIL)]] with [[RAIL specification]]s for [[output validation]] and [[automated retries]]. | |||
**** [[BAML]] using [[type-driven prompt]]s and [[schema-based parsing]]. | |||
*** [[Control Flow Declarative Prompt-Programming Framework]]s, such as: | *** [[Control Flow Declarative Prompt-Programming Framework]]s, such as: | ||
**** [[ | **** [[IBM PDL]] with [[declarative loop]]s, [[conditional branch]]es, and [[function call]]s. | ||
**** [[ | **** [[Microsoft Guidance]] using [[inline directive]]s for [[generation control]]. | ||
*** [[Orchestration-Focused Declarative Prompt-Programming Framework]]s, such as: | |||
**** [[Azure Prompt Flow]] with [[DAG-based workflow]]s and [[step sequencing]]. | |||
**** [[DSPy Module]]s for [[composable pipeline]]s and [[optimized chain]]s. | |||
** ... | ** ... | ||
* <B>Counter-Examples:</B> | * <B>Counter-Examples:</B> | ||
** [[Prompt-Optimization Framework]]s, such as [[ | ** [[Prompt-Optimization Framework]]s, such as [[TextGrad]] and early versions of [[DSPy]], which focus on [[prompt tuning]] and [[automation]] rather than [[declarative structure]] and [[human readability]]. | ||
** [[Imperative Prompt-Programming Framework]]s, which use [[procedural code]] to directly define the [[execution flow]] of [[LLM interaction]]s with emphasis on [[how]] rather than [[what]]. | ** [[Imperative Prompt-Programming Framework]]s, which use [[procedural code]] to directly define the [[execution flow]] of [[LLM interaction]]s with emphasis on [[how]] rather than [[what]]. | ||
** [[Ad-hoc Prompt Design Approach]]es, which lack [[formal structure]], [[schema validation]], and [[reusable component]]s that characterize [[declarative prompt-programming framework]]s. | ** [[Ad-hoc Prompt Design Approach]]es, which lack [[formal structure]], [[schema validation]], and [[reusable component]]s that characterize [[declarative prompt-programming framework]]s. | ||
** [[Template-Only System]]s, which provide basic [[text substitution]] without the full [[declarative prompt-programming capabilities]] like [[schema validation]] and [[control flow]]. | ** [[Template-Only System]]s, which provide basic [[text substitution]] without the full [[declarative prompt-programming capabilities]] like [[schema validation]] and [[control flow]]. | ||
** [[Model-Specific Framework]]s that tightly couple [[prompt design]] to [[specific LLM implementation]]s, lacking the [[model-agnostic abstraction]] of [[declarative prompt-programming framework]]s. | ** [[Model-Specific Framework]]s that tightly couple [[prompt design]] to [[specific LLM implementation]]s, lacking the [[model-agnostic abstraction]] of [[declarative prompt-programming framework]]s. | ||
* <B>See:</B> [[Prompt Engineering]], [[LLM Orchestration Framework]], [[Declarative Programming]], [[YAML Configuration]], [[JSON Schema]], [[Domain-Specific Language]], [[Model-Driven Engineering]], [[Structured Output Generation]], [[Retrieval-Augmented Generation]], [[Chain-of-Thought Prompting]]. | ** [[Raw API Interaction]]s where [[prompt text]] is directly passed to [[LLM API]] without [[intermediate representation]] or [[declarative structure]]. | ||
** [[Hardcoded Prompt System]]s that embed [[prompt string]]s directly in [[application code]], preventing [[separation of concern]]s and [[prompt versioning]]. | |||
* <B>See:</B> [[Prompt Engineering]], [[LLM Orchestration Framework]], [[Declarative Programming]], [[YAML Configuration]], [[JSON Schema]], [[Domain-Specific Language]], [[Model-Driven Engineering]], [[Structured Output Generation]], [[Retrieval-Augmented Generation]], [[Chain-of-Thought Prompting]], [[LLMOps]], [[Prompt Template]], [[Prompt Management]], [[AI Function]], [[Workflow Orchestration]]. | |||
---- | |||
---- | |||
== References == | |||
=== 2025-05-01 === | |||
* Perplexity.ai https://chatgpt.com/share/6813e182-f24c-8012-bb23-c79925fa2b72 | |||
** [[Question]]: Identify and compare existing [[Declarative Prompt Programming Framework|declarative prompt-programming frameworks]] that align with these characteristics—such as using [[Declarative Programming Syntax|declarative syntax]] (YAML, JSON, DSLs), supporting [[Framework Modularity|modularity]], [[Framework Templating|templating]], [[Schema Validation Capability|schema validation]], [[Model Agnostic Abstraction|model-agnostic abstractions]], and [[Collaborative Framework Versioning|collaborative versioning]]. | |||
** [[Answer]]: [[Declarative Prompt Programming Framework|Declarative prompt-programming frameworks]] let [[Framework Developer|developers]] **define [[Prompt Logic|prompt logic]] as [[Configuration Data|data/configuration]]** rather than writing [[Imperative Code|imperative code]]. These [[Framework System|systems]] use formats like [[YAML Format|YAML]], [[JSON Format|JSON]], or [[Domain Specific Language|domain-specific languages]] (DSLs) to specify how an [[Large Language Model|LLM]] should behave, including [[Input Schema|input]]/[[Output Schema|output schemas]], [[Prompt Control Flow|control flow]], and [[Multi Step Interaction|multi-step interactions]]. | |||
*** [[Framework Comparison|Framework Comparisons]]: | |||
**** [[IBM Prompt Declaration Language|IBM PDL (Prompt Declaration Language)]]: | |||
***** Uses [[YAML DSL Format|YAML DSL]] (`.pdl` [[YAML File|YAML files]]) for [[Comprehensive Prompt Workflow|comprehensive prompt workflows]]. | |||
***** Features [[Universal Framework Usage|universal usage]] across domains with [[Framework Modularity|modularity]], [[Templating Capability|templating]], [[Control Flow Structure|loops]], [[Conditional Structure|conditionals]], [[Framework Function|functions]], and [[Type Checked IO|type-checked I/O]]. | |||
***** Provides [[Model Agnostic Support|model-agnostic]] support for any [[LLM Connection|LLM via connectors]]. | |||
**** [[Stanford DSPy Framework|Stanford DSPy]]: | |||
***** Implements a [[Python DSL|Python DSL]] with [[Declarative Module|declarative modules]] in code. | |||
***** Emphasizes [[Self Optimizing Pipeline|self-optimizing pipelines]] and [[Prompt Improvement|improving prompts]] over time. | |||
***** Offers [[Module Composition|modular composition]], [[Automated Optimization|automated optimization]] (teleprompters), and [[Chain Of Thought Module|chain-of-thought modules]]. | |||
***** Works with [[Open Source Model|open-source models]] and [[Commercial API|commercial APIs]] like [[OpenAI Integration|OpenAI]]. | |||
**** [[Microsoft Guidance Framework|Microsoft Guidance]]: | |||
***** Features a [[Templating DSL|templating DSL]] embedded in [[Python Library|Python]] (guidance library). | |||
***** Focuses on [[Single Call Control|single-call orientation]] for controlling one [[Prompt Response Flow|prompt-response flow]]. | |||
***** Provides [[Inline Generation Control|inline control of generation]] with [[If Statement|if]]/[[For Loop|for loops]], [[Choice Selection|choice selection]], and [[Output Formatting|output formatting]] (regex guides). | |||
***** Supports various [[Model Provider|model providers]] through [[Model Abstraction|abstraction]]. | |||
**** [[LMQL Framework|LMQL (Language Model Query Language)]]: | |||
***** Uses a [[Python Embedded DSL|Python-embedded DSL]] with [[Query Clause|query language]] and [[Where Clause|where clauses]]. | |||
***** Specializes in [[Constrained Generation|constrained generation]] for enforcing [[Output Schema|output schemas]]/[[Pattern Enforcement|patterns]]. | |||
***** Enables [[Schema Validation|schema validation]] through [[Where Statement|where statements]] and [[Template System|templates]] with [[Output Constraint|constraint expressions]]. | |||
***** Works with [[Local Model|local HuggingFace models]] with [[Limited API Support|limited support for external APIs]]. | |||
**** [[BAML Framework|BAML (Basically a Made-up Language)]]: | |||
***** Implements a [[Custom Schema DSL|custom schema-driven DSL]] with [[Function Definition Structure|function definitions]] in multiple languages. | |||
***** Designed for [[Reliable AI Agent|reliable AI agents]] & [[AI Workflow|workflows]] with [[Schema Driven Prompt|schema-driven prompts]]. | |||
***** Treats [[Typed Function|prompts as typed functions]] with [[Parameter Type|parameters]] and [[Return Type|return types]]. | |||
***** Includes [[Jinja2 Templating|Jinja2 templating]], [[Type Safety Feature|full type-safety]], [[Retry Mechanism|retries]], and [[Streaming Capability|streaming]]. | |||
***** Provides [[Cross Language Integration|cross-language integration]] ([[Python Integration|Python]], [[JavaScript Integration|JS]], [[Ruby Integration|Ruby]], [[Go Integration|Go]]). | |||
**** [[Guardrails Framework|Guardrails (RAIL by Guardrails AI)]]: | |||
***** Uses [[RAIL Markup|RAIL markup]] ([[XML YAML Hybrid|XML/YAML hybrid]] specification). | |||
***** Focuses on [[Output Validation|output validation]] and [[Output Safety|safety]] for any prompt. | |||
***** Defines [[Output Schema Requirement|output schema and format requirements]] in [[RAIL Specification|RAIL spec]]. | |||
***** Automates [[LLM Reask|re-asking the LLM]] until output meets schema. | |||
***** Offers [[Model Agnostic Guard|model-agnostic guards]] for [[Consistent Output|consistent outputs]] across models. | |||
**** [[NVIDIA NeMo Guardrails|NVIDIA NeMo Guardrails]]: | |||
***** Combines [[YAML Configuration|YAML config]] with [[Colang DSL|Colang DSL]] ([[Policy File|policy files]]). | |||
***** Specializes in [[Conversational AI Safety|conversational AI safety]] and [[Flow Control|flow control]]. | |||
***** Uses [[Rail Rule|rails (rules)]] for [[Input Filtering|input filtering]], [[Response Validation|response validation]], and [[Dialogue Flow Management|dialogue flow management]]. | |||
***** Supports [[Conditional Flow|conditional flows]], [[Multi Turn Dialogue|multi-turn dialogues]], and [[Custom Action Integration|integration of custom actions]]. | |||
***** Integrates with various [[Model API|model APIs]] through [[Connector System|connectors]]. | |||
**** [[Azure Prompt Flow|Azure Prompt Flow]]: | |||
***** Employs [[YAML Flow Definition|YAML]] (flow [[DAG Definition|DAG definition]]). | |||
***** Targets [[LLMOps|LLMOps]] and [[Production Pipeline|production pipelines]]. | |||
***** Defines [[Flow DAG|flows as DAGs]] of [[Flow Step|steps]] ([[LLM Call|LLM calls]], [[Python Function|Python functions]], [[Tool Integration|tools]]) in YAML. | |||
***** Facilitates [[Variable Passing|variables]], [[Step Data Passing|data passing between steps]], and [[CICD Integration|CI/CD integration]]. | |||
***** Works with [[Azure OpenAI|Azure OpenAI]], other [[Provider Connection|providers via "connections"]], and [[Custom Tool|custom tools]]. | |||
**** [[Marvin AI Function|Marvin (AI Functions)]]: | |||
***** Implements [[Python Decorator|Python decorators]] using [[Type Hint|type hints]] & [[Function Docstring|docstrings]]. | |||
***** Takes a [[Function Oriented|function-oriented]] approach to [[Prompt Design|prompt design]]. | |||
***** Uses [[Python Type Annotation|Python type annotations]] and [[Docstring Description|docstring]] to declare what the [[LLM Task|LLM should do]]. | |||
***** Derives [[Schema Type|schema from types]] to ensure [[Output Validity|output validity]]. | |||
***** Works with various [[Model API|model APIs]] through [[Type Independence|type independence]]. | |||
** Citations: | |||
[1] https://www.infoq.com/news/2023/06/guidance-microsoft-language/ | |||
[2] https://www.latent.space/p/guaranteed-quality-and-structure | |||
[3] https://www.restack.io/p/promptflow-answer-yaml-flow-sequence-cat-ai | |||
[4] https://www.datacamp.com/blog/dspy-introduction | |||
[5] https://www.twosigma.com/articles/a-guide-to-large-language-model-abstractions/ | |||
---- | ---- | ||
Line 68: | Line 171: | ||
[[Category:AI Technology]] | [[Category:AI Technology]] | ||
[[Category:Prompt Engineering]] | [[Category:Prompt Engineering]] | ||
[[Category:Quality | [[Category:Quality Silver]] |
Latest revision as of 12:29, 4 June 2025
A Declarative Prompt-Programming Framework is a prompt-programming framework that uses a declarative syntax to express the structure, inputs, outputs, and constraints of LLM interactions while hiding implementation details.
- Context:
- It can typically represent Prompt Design as structured data rather than imperative code, allowing for more systematic and maintainable prompt management.
- It can typically use Declarative Syntax (such as YAML, JSON, or custom DSLs) to express what the LLM interaction should accomplish without specifying how it is executed.
- It can typically provide Prompt Specification documents that are parsed and executed by a runtime interpreter.
- It can typically support Schema Validation for both input and output to reduce prompt failures and ensure data consistency.
- It can typically enable Modular Reuse through import mechanisms and include directives for prompt components.
- It can typically abstract Model-Specific Details, creating a model-agnostic representation of declarative prompt-programming intentions.
- It can typically enforce Output Structure through schema definitions, constraints, or type systems.
- ...
- It can often include Templating Directives (using systems like Jinja2 or Liquid) for dynamic content generation.
- It can often implement Control Flow Constructs such as declarative prompt-programming loops, declarative prompt-programming conditionals, and declarative prompt-programming function definitions.
- It can often provide Type Checking for declarative prompt-programming variables to ensure data integrity.
- It can often support Multi-Step Workflows by declarative prompt-programming chaining or declarative prompt-programming orchestration.
- It can often enable Collaborative Prompt Development through its human-readable format and defined structure.
- It can often facilitate Prompt Versioning to track declarative prompt-programming evolution.
- It can often include Error Handling Mechanisms that manage LLM output failures through retry logic and fallback strategy.
- It can often provide Validation Feedback Loops where invalid outputs trigger corrective reprompts.
- ...
- It can range from being a Simple Declarative Prompt-Programming Framework to being a Complex Declarative Prompt-Programming Framework, depending on its declarative prompt-programming feature complexity.
- It can range from being a Domain-Specific Declarative Prompt-Programming Framework to being a General-Purpose Declarative Prompt-Programming Framework, depending on its declarative prompt-programming application scope.
- It can range from being a Lightweight Declarative Prompt-Programming Framework to being a Comprehensive Declarative Prompt-Programming Framework, depending on its declarative prompt-programming integration capability.
- It can range from being a Specialized Declarative Prompt-Programming Framework to being a Universal Declarative Prompt-Programming Framework, depending on its declarative prompt-programming model compatibility.
- It can range from being a Single-Call Declarative Prompt-Programming Framework to being a Multi-Step Declarative Prompt-Programming Framework, depending on its declarative prompt-programming orchestration complexity.
- It can range from being a Code-Embedded Declarative Prompt-Programming Framework to being a Standalone Declarative Prompt-Programming Framework, depending on its declarative prompt-programming host language relationship.
- ...
- It can integrate with Retrieval-Augmented Generation Pipelines for structured document processing.
- It can connect to LLM API for standardized model interaction.
- It can support Agent Orchestration Systems for multi-step workflow management.
- It can interface with Version Control Systems for declarative prompt-programming history tracking.
- It can incorporate External Knowledge Sources via declarative prompt-programming retrieval mechanisms.
- It can work with Validation Tools for declarative prompt-programming quality assurance.
- It can integrate with CI/CD Pipelines for automated prompt testing and prompt deployment.
- It can connect to Output Validation Systems for LLM output reliability enhancement.
- It can support Safe Guardrail Integration for LLM response filtering and harmful content prevention.
- ...
- Examples:
- Declarative Prompt-Programming Framework Syntax Approaches, such as:
- YAML-Based Declarative Prompt-Programming Frameworks, such as:
- IBM PDL (Prompt Declaration Language) using YAML with Jinja2 for templating functions, type checking via JSON Schema, and control flow constructs like conditionals and loops.
- Azure Prompt Flow representing multi-step workflows as directed acyclic graphs with step definitions and data flows.
- Pathway Templates for declarative prompt-programming structured workflows.
- JSON-Based Declarative Prompt-Programming Frameworks, such as:
- DSL-Based Declarative Prompt-Programming Frameworks, such as:
- LMQL (Language Model Query Language) using constraint expressions with where clauses to enforce output patterns.
- BAML (Basically a Made-up Language) implementing prompts as functions with parameter types and return types.
- Colang in NVIDIA NeMo Guardrails for conversational AI safety and dialogue flow management.
- Impromptu for model-driven declarative prompt-programming with platform independence.
- Questo for declarative query generation.
- Code-Embedded Declarative Prompt-Programming Frameworks, such as:
- Microsoft Guidance with its inline control directives for stepwise generation control.
- DSPy providing declarative modules and signatures for LLM-powered components.
- Marvin AI Functions using Python decorators and type annotations for LLM function specification.
- YAML-Based Declarative Prompt-Programming Frameworks, such as:
- Declarative Prompt-Programming Framework Complexity Levels, such as:
- Comprehensive Declarative Prompt-Programming Frameworks, such as:
- IBM PDL (Prompt Declaration Language) supporting full control flow, type checking, model chaining, and function definitions.
- Azure Prompt Flow with enterprise features for LLMOps, experiment tracking, and deployment management.
- DSPy offering teleprompters for prompt optimization and advanced module composition.
- Moderate Declarative Prompt-Programming Frameworks, such as:
- BAML balancing schema validation with approachable syntax using function metaphors.
- LMQL focusing on constrained generation and output filtering.
- NeMo Guardrails specializing in conversational safety rules and dialogue policy.
- Lightweight Declarative Prompt-Programming Frameworks, such as:
- Marvin AI Functions emphasizing developer simplicity through familiar function syntax.
- Guardrails (RAIL) focusing on output validation and schema conformance.
- Comprehensive Declarative Prompt-Programming Frameworks, such as:
- Declarative Prompt-Programming Framework Application Domains, such as:
- General-Purpose Declarative Prompt-Programming Frameworks for cross-domain applications, such as:
- IBM PDL supporting universal usage across domains.
- DSPy enabling self-optimizing pipelines for diverse tasks.
- Specialized Domain Declarative Prompt-Programming Frameworks, such as:
- Guardrails (RAIL) for output validation and schema enforcement.
- NeMo Guardrails for conversational AI safety and topic management.
- Controlled Chatbot Declarative Prompt-Programming Frameworks for regulated conversation flow.
- RAG Pipeline Declarative Prompt-Programming Frameworks for document retrieval workflow.
- Regulated Domain Declarative Prompt-Programming Frameworks for finance and legal applications requiring auditability.
- Code Generation Declarative Prompt-Programming Frameworks for structured programming tasks.
- Chain-of-Thought Declarative Prompt-Programming Frameworks for multi-step reasoning processes.
- ReAct Agent Declarative Prompt-Programming Frameworks for reasoning and acting cycles.
- General-Purpose Declarative Prompt-Programming Frameworks for cross-domain applications, such as:
- Declarative Prompt-Programming Framework Feature Implementations, such as:
- Schema Validation Declarative Prompt-Programming Frameworks, such as:
- Guardrails (RAIL) with RAIL specifications for output validation and automated retries.
- BAML using type-driven prompts and schema-based parsing.
- Control Flow Declarative Prompt-Programming Frameworks, such as:
- IBM PDL with declarative loops, conditional branches, and function calls.
- Microsoft Guidance using inline directives for generation control.
- Orchestration-Focused Declarative Prompt-Programming Frameworks, such as:
- Schema Validation Declarative Prompt-Programming Frameworks, such as:
- ...
- Declarative Prompt-Programming Framework Syntax Approaches, such as:
- Counter-Examples:
- Prompt-Optimization Frameworks, such as TextGrad and early versions of DSPy, which focus on prompt tuning and automation rather than declarative structure and human readability.
- Imperative Prompt-Programming Frameworks, which use procedural code to directly define the execution flow of LLM interactions with emphasis on how rather than what.
- Ad-hoc Prompt Design Approaches, which lack formal structure, schema validation, and reusable components that characterize declarative prompt-programming frameworks.
- Template-Only Systems, which provide basic text substitution without the full declarative prompt-programming capabilities like schema validation and control flow.
- Model-Specific Frameworks that tightly couple prompt design to specific LLM implementations, lacking the model-agnostic abstraction of declarative prompt-programming frameworks.
- Raw API Interactions where prompt text is directly passed to LLM API without intermediate representation or declarative structure.
- Hardcoded Prompt Systems that embed prompt strings directly in application code, preventing separation of concerns and prompt versioning.
- See: Prompt Engineering, LLM Orchestration Framework, Declarative Programming, YAML Configuration, JSON Schema, Domain-Specific Language, Model-Driven Engineering, Structured Output Generation, Retrieval-Augmented Generation, Chain-of-Thought Prompting, LLMOps, Prompt Template, Prompt Management, AI Function, Workflow Orchestration.
References
2025-05-01
- Perplexity.ai https://chatgpt.com/share/6813e182-f24c-8012-bb23-c79925fa2b72
- Question: Identify and compare existing declarative prompt-programming frameworks that align with these characteristics—such as using declarative syntax (YAML, JSON, DSLs), supporting modularity, templating, schema validation, model-agnostic abstractions, and collaborative versioning.
- Answer: Declarative prompt-programming frameworks let developers **define prompt logic as data/configuration** rather than writing imperative code. These systems use formats like YAML, JSON, or domain-specific languages (DSLs) to specify how an LLM should behave, including input/output schemas, control flow, and multi-step interactions.
- Framework Comparisons:
- IBM PDL (Prompt Declaration Language):
- Uses YAML DSL (`.pdl` YAML files) for comprehensive prompt workflows.
- Features universal usage across domains with modularity, templating, loops, conditionals, functions, and type-checked I/O.
- Provides model-agnostic support for any LLM via connectors.
- Stanford DSPy:
- Implements a Python DSL with declarative modules in code.
- Emphasizes self-optimizing pipelines and improving prompts over time.
- Offers modular composition, automated optimization (teleprompters), and chain-of-thought modules.
- Works with open-source models and commercial APIs like OpenAI.
- Microsoft Guidance:
- Features a templating DSL embedded in Python (guidance library).
- Focuses on single-call orientation for controlling one prompt-response flow.
- Provides inline control of generation with if/for loops, choice selection, and output formatting (regex guides).
- Supports various model providers through abstraction.
- LMQL (Language Model Query Language):
- Uses a Python-embedded DSL with query language and where clauses.
- Specializes in constrained generation for enforcing output schemas/patterns.
- Enables schema validation through where statements and templates with constraint expressions.
- Works with local HuggingFace models with limited support for external APIs.
- BAML (Basically a Made-up Language):
- Implements a custom schema-driven DSL with function definitions in multiple languages.
- Designed for reliable AI agents & workflows with schema-driven prompts.
- Treats prompts as typed functions with parameters and return types.
- Includes Jinja2 templating, full type-safety, retries, and streaming.
- Provides cross-language integration (Python, JS, Ruby, Go).
- Guardrails (RAIL by Guardrails AI):
- Uses RAIL markup (XML/YAML hybrid specification).
- Focuses on output validation and safety for any prompt.
- Defines output schema and format requirements in RAIL spec.
- Automates re-asking the LLM until output meets schema.
- Offers model-agnostic guards for consistent outputs across models.
- NVIDIA NeMo Guardrails:
- Combines YAML config with Colang DSL (policy files).
- Specializes in conversational AI safety and flow control.
- Uses rails (rules) for input filtering, response validation, and dialogue flow management.
- Supports conditional flows, multi-turn dialogues, and integration of custom actions.
- Integrates with various model APIs through connectors.
- Azure Prompt Flow:
- Employs YAML (flow DAG definition).
- Targets LLMOps and production pipelines.
- Defines flows as DAGs of steps (LLM calls, Python functions, tools) in YAML.
- Facilitates variables, data passing between steps, and CI/CD integration.
- Works with Azure OpenAI, other providers via "connections", and custom tools.
- Marvin (AI Functions):
- Implements Python decorators using type hints & docstrings.
- Takes a function-oriented approach to prompt design.
- Uses Python type annotations and docstring to declare what the LLM should do.
- Derives schema from types to ensure output validity.
- Works with various model APIs through type independence.
- IBM PDL (Prompt Declaration Language):
- Framework Comparisons:
- Citations:
[1] https://www.infoq.com/news/2023/06/guidance-microsoft-language/ [2] https://www.latent.space/p/guaranteed-quality-and-structure [3] https://www.restack.io/p/promptflow-answer-yaml-flow-sequence-cat-ai [4] https://www.datacamp.com/blog/dspy-introduction [5] https://www.twosigma.com/articles/a-guide-to-large-language-model-abstractions/