DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines
Not on the map. Why?
Abstract (arXiv)
Chaining language model (LM) calls as composable modules is fueling a new way of programming, but ensuring LMs adhere to important constraints requires heuristic "prompt engineering". We introduce LM Assertions, a programming construct for expressing computational constraints that LMs should satisfy. We integrate our constructs into the recent DSPy programming model for LMs, and present new strategies that allow DSPy to compile programs with LM Assertions into more reliable and accurate systems. We also propose strategies to use assertions at inference time for automatic self-refinement with LMs. We report on four diverse case studies for text generation and find that LM Assertions improve not only compliance with imposed rules but also downstream task performance, passing constraints up to 164% more often and generating up to 37% more higher-quality responses. Our reference implementation of LM Assertions is integrated into DSPy at https://github.com/stanfordnlp/dspy
Key facts. Cited by 27 papers in the map (data through 7 Oct 2026). Builds on 18 of its 38 references that are in the map. First posted on arXiv 20 Dec 2023.
Builds on
18 of 38 references.
References · 18
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2018HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answeringcited by 3,686
- 2023FActScore: Fine-grained Atomic Evaluation of Factual Precision in Long Form Text Generationcited by 1,259
- 2022Interleaving Retrieval with Chain-of-Thought Reasoning for Knowledge-Intensive Multi-Step Questionscited by 911
- 2023DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelinescited by 803
- 2023Enabling Large Language Models to Generate Text with Citationscited by 584
- 2021ColBERTv2: Effective and Efficient Retrieval via Lightweight Late Interactioncited by 464
- 2022Demonstrate-Search-Predict: Composing retrieval and language models for knowledge-intensive NLPcited by 316
- 2017Lexically Constrained Decoding for Sequence Generation Using Grid Beam Searchcited by 234
- 2022Prompting Is Programming: A Query Language for Large Language Modelscited by 110
- 2023Phenomenal Yet Puzzling: Testing Inductive Reasoning Capabilities of Language Models with Hypothesis Refinementcited by 89
6 more
- 2023LLMs cannot find reasoning errors, but can correct them given the error locationcited by 85
- 2023TrueTeacher: Learning Factual Consistency Evaluation with Large Language Modelscited by 82
- 2023Automatic Evaluation of Attribution by Large Language Modelscited by 70
- 2021Baleen: Robust Multi-Hop Reasoning at Scale via Condensed Retrievalcited by 63
- 2023LLMRefine: Pinpointing and Refining Large Language Models via Fine-Grained Actionable Feedbackcited by 39
- 2020Model Assertions for Monitoring and Improving ML Modelscited by 22
Built on by
Citing papers per year: 2024: 9; 2025: 10; 2026: 8.
27 papers.
Sort:
By area:
- 2024TextGrad: Automatic "Differentiation" via Textcited by 250
- 2024RouterBench: A Benchmark for Multi-LLM Routing Systemcited by 222
- 2024Who Validates the Validators? Aligning LLM-Assisted Evaluation of LLM Outputs with Human Preferencescited by 142
- 2026A Survey of Agentic Reasoning for Large Language Models: Towards Recursively Self-Improving and Collective Agentscited by 47
- 2024Aviary: training language agents on challenging scientific taskscited by 23
- 2024StructuredRAG: JSON Response Formatting with Large Language Modelscited by 22
- 2024SPADE: Synthesizing Data Quality Assertions for Large Language Model Pipelinescited by 19
- 2024A Perspective for Adapting Generalist AI to Specialized Medical AI Applications and Their Challengescited by 8
- 2024ChainBuddy: An AI Agent System for Generating LLM Pipelinescited by 6
- 2025ZeroSumEval: An Extensible Framework For Scaling LLM Evaluation with Inter-Model Competitioncited by 5
- 2025ZeroSumEval: Scaling LLM Evaluation with Inter-Model Competitioncited by 5
- 2025Making Prompts First-Class Citizens for Adaptive LLM Pipelinescited by 3
15 more
- 2026Automated QoR improvement in OpenROAD with coding agentscited by 3
- 2025Querying Databases with Function Callingcited by 2
- 2026Reconstructing Item Characteristic Curves using Fine-Tuned Large Language Modelscited by 1
- 2026Probabilistic Programs of Thoughtcited by 1
- 2026Runtime-Structured Task Decomposition for Agentic Coding Systemscited by 1
- 2024Liberal Entity Matching as a Compound AI Toolchaincited by 0
- 2025Semantic Integrity Constraints: Declarative Guardrails for AI-Augmented Data Processing Systemscited by 0
- 2025FoodTaxo: Generating Food Taxonomies with Large Language Modelscited by 0
- 2025Data Diversification Methods In Alignment Enhance Math Performance In LLMscited by 0
- 2025Repairing Language Model Pipelines by Meta Self-Refining Competing Constraints at Runtimecited by 0
- 2025A Large-Scale Dataset and Citation Intent Classification in Turkish with LLMscited by 0
- 2025What Helps Language Models Predict Human Beliefs: Demographics or Prior Stances?cited by 0
- 2026BiomechAgent: AI-Assisted Biomechanical Analysis Through Code-Generating Agentscited by 0
- 2026Harness as an Asset: Enforcing Determinism via the Convergent AI Agent Framework (CAAF)cited by 0
- 2026A Hybrid Dependency-Aware Framework for Task Decomposition and Dynamic Agent Generation in Oracle-to-PostgreSQL Migrationcited by 0
- 2026A Hybrid Dependency-Aware Framework for Task Decomposition and Dynamic Agent Generation in Oracle-to-PostgreSQL Migration13 Sep 2026
- 2026Runtime-Structured Task Decomposition for Agentic Coding Systems14 May 2026
- 2026Probabilistic Programs of Thought19 Apr 2026
- 2026Harness as an Asset: Enforcing Determinism via the Convergent AI Agent Framework (CAAF)18 Apr 2026
- 2026A Survey of Agentic Reasoning for Large Language Models: Towards Recursively Self-Improving and Collective Agents18 Jan 2026
- 2026BiomechAgent: AI-Assisted Biomechanical Analysis Through Code-Generating Agents16 Jan 2026
- 2026Automated QoR improvement in OpenROAD with coding agents9 Jan 2026
- 2026Reconstructing Item Characteristic Curves using Fine-Tuned Large Language Models5 Jan 2026
- 2025What Helps Language Models Predict Human Beliefs: Demographics or Prior Stances?23 Nov 2025
- 2025A Large-Scale Dataset and Citation Intent Classification in Turkish with LLMs26 Sep 2025
- 2025Making Prompts First-Class Citizens for Adaptive LLM Pipelines7 Aug 2025
- 2025Repairing Language Model Pipelines by Meta Self-Refining Competing Constraints at Runtime11 Jul 2025
15 more
- 2025Data Diversification Methods In Alignment Enhance Math Performance In LLMs2 Jul 2025
- 2025FoodTaxo: Generating Food Taxonomies with Large Language Models26 May 2025
- 2025ZeroSumEval: Scaling LLM Evaluation with Inter-Model Competition17 Apr 2025
- 2025ZeroSumEval: An Extensible Framework For Scaling LLM Evaluation with Inter-Model Competition10 Mar 2025
- 2025Semantic Integrity Constraints: Declarative Guardrails for AI-Augmented Data Processing Systems1 Mar 2025
- 2025Querying Databases with Function Calling23 Jan 2025
- 2024Aviary: training language agents on challenging scientific tasks30 Dec 2024
- 2024A Perspective for Adapting Generalist AI to Specialized Medical AI Applications and Their Challenges28 Oct 2024
- 2024ChainBuddy: An AI Agent System for Generating LLM Pipelines20 Sep 2024
- 2024StructuredRAG: JSON Response Formatting with Large Language Models7 Aug 2024
- 2024Liberal Entity Matching as a Compound AI Toolchain17 Jun 2024
- 2024TextGrad: Automatic "Differentiation" via Text11 Jun 2024
- 2024Who Validates the Validators? Aligning LLM-Assisted Evaluation of LLM Outputs with Human Preferences18 Apr 2024
- 2024RouterBench: A Benchmark for Multi-LLM Routing System18 Mar 2024
- 2024SPADE: Synthesizing Data Quality Assertions for Large Language Model Pipelines5 Jan 2024
- 2024Aviary: training language agents on challenging scientific taskscited by 23
- 2024ChainBuddy: An AI Agent System for Generating LLM Pipelinescited by 6
- 2026Automated QoR improvement in OpenROAD with coding agentscited by 3
- 2025Querying Databases with Function Callingcited by 2
- 2026Runtime-Structured Task Decomposition for Agentic Coding Systemscited by 1
- 2026BiomechAgent: AI-Assisted Biomechanical Analysis Through Code-Generating Agentscited by 0
- 2026Harness as an Asset: Enforcing Determinism via the Convergent AI Agent Framework (CAAF)cited by 0
- 2026A Hybrid Dependency-Aware Framework for Task Decomposition and Dynamic Agent Generation in Oracle-to-PostgreSQL Migrationcited by 0
- 2026A Hybrid Dependency-Aware Framework for Task Decomposition and Dynamic Agent Generation in Oracle-to-PostgreSQL Migration13 Sep 2026
- 2026Runtime-Structured Task Decomposition for Agentic Coding Systems14 May 2026
- 2026Harness as an Asset: Enforcing Determinism via the Convergent AI Agent Framework (CAAF)18 Apr 2026
- 2026BiomechAgent: AI-Assisted Biomechanical Analysis Through Code-Generating Agents16 Jan 2026
- 2026Automated QoR improvement in OpenROAD with coding agents9 Jan 2026
- 2025Querying Databases with Function Calling23 Jan 2025
- 2024Aviary: training language agents on challenging scientific tasks30 Dec 2024
- 2024ChainBuddy: An AI Agent System for Generating LLM Pipelines20 Sep 2024
- 2024TextGrad: Automatic "Differentiation" via Textcited by 250
- 2024RouterBench: A Benchmark for Multi-LLM Routing Systemcited by 222
- 2024StructuredRAG: JSON Response Formatting with Large Language Modelscited by 22
- 2024A Perspective for Adapting Generalist AI to Specialized Medical AI Applications and Their Challengescited by 8
- 2025ZeroSumEval: An Extensible Framework For Scaling LLM Evaluation with Inter-Model Competitioncited by 5
- 2025ZeroSumEval: Scaling LLM Evaluation with Inter-Model Competitioncited by 5
- 2025Making Prompts First-Class Citizens for Adaptive LLM Pipelinescited by 3
- 2026Reconstructing Item Characteristic Curves using Fine-Tuned Large Language Modelscited by 1
- 2024Liberal Entity Matching as a Compound AI Toolchaincited by 0
- 2025FoodTaxo: Generating Food Taxonomies with Large Language Modelscited by 0
- 2025Repairing Language Model Pipelines by Meta Self-Refining Competing Constraints at Runtimecited by 0
- 2025A Large-Scale Dataset and Citation Intent Classification in Turkish with LLMscited by 0
12 most cited of 13 All 13 (JSON)
- 2026Reconstructing Item Characteristic Curves using Fine-Tuned Large Language Models5 Jan 2026
- 2025What Helps Language Models Predict Human Beliefs: Demographics or Prior Stances?23 Nov 2025
- 2025A Large-Scale Dataset and Citation Intent Classification in Turkish with LLMs26 Sep 2025
- 2025Making Prompts First-Class Citizens for Adaptive LLM Pipelines7 Aug 2025
- 2025Repairing Language Model Pipelines by Meta Self-Refining Competing Constraints at Runtime11 Jul 2025
- 2025FoodTaxo: Generating Food Taxonomies with Large Language Models26 May 2025
- 2025ZeroSumEval: Scaling LLM Evaluation with Inter-Model Competition17 Apr 2025
- 2025ZeroSumEval: An Extensible Framework For Scaling LLM Evaluation with Inter-Model Competition10 Mar 2025
- 2024A Perspective for Adapting Generalist AI to Specialized Medical AI Applications and Their Challenges28 Oct 2024
- 2024StructuredRAG: JSON Response Formatting with Large Language Models7 Aug 2024
- 2024Liberal Entity Matching as a Compound AI Toolchain17 Jun 2024
- 2024TextGrad: Automatic "Differentiation" via Text11 Jun 2024
12 newest of 13 All 13 (JSON)