Skip to content

DSP (Demonstrate-Search-Predict) Framework Implementations In Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

airsstack/airsdsp

AirsDSP

A Rust implementation of the Demonstrate-Search-Predict (DSP) framework for building sophisticated language model and retrieval model pipelines.

Overview

AirsDSP provides a Rust-native implementation of the DSP framework, originally introduced in December 2022 by Omar Khattab and collaborators at Stanford. The DSP framework addresses fundamental limitations in retrieval-augmented language modeling by enabling the composition of Language Models (LM) and Retrieval Models (RM) in sophisticated, multi-stage pipelines that transcend the simple "retrieve-then-read" paradigm.

The Problem DSP Solves: Traditional retrieve-then-read pipelines treat retrieval and generation as separate, non-interactive stages, failing to leverage intermediate reasoning steps or enable iterative refinement. DSP introduces a compositional architecture where problems are systematically decomposed into smaller transformations that LMs and RMs can handle reliably.

Strategic Positioning: This implementation focuses on the core DSP architectural principles: systematic problem decomposition, natural language interfaces between components, and pipeline-aware processing. While DSPy represents the Python evolution of DSP with automated optimization and compilation features, AirsDSP deliberately maintains fidelity to the original DSP foundation, providing developers with explicit control, transparent execution, and deterministic behavior—a perfect alignment with Rust's philosophy of zero-cost abstractions and predictable performance.

Core Architecture

AirsDSP implements the three fundamental operations that define the DSP framework:

Demonstrate

Enables the system to bootstrap pipeline-aware demonstrations that guide language models through multi-step reasoning processes, rather than just producing final answers.

Search

Provides sophisticated retrieval capabilities that can be strategically placed within program flow, often following prediction steps to retrieve contextually relevant information during multi-step reasoning.

Predict

Leverages language models to generate grounded predictions and text transformations based on context and retrieved information, supporting both intermediate reasoning steps and final output generation.

Key Features

  • Compositional Architecture: Build complex reasoning pipelines by composing the three core DSP operations
  • Natural Language Interfaces: Components communicate through structured text rather than raw embeddings
  • Problem Decomposition: Systematic approach to breaking down knowledge-intensive tasks into manageable transformations
  • Pipeline-Aware Processing: Context-sensitive demonstrations and processing that understand the full pipeline structure
  • Frozen Model Support: Work with existing language and retrieval models without requiring fine-tuning
  • Performance Focused: Rust implementation designed for reliability and performance in production environments

Design Philosophy

AirsDSP adheres to the original DSP framework principles with deliberate architectural choices:

Core Principles from DSP Foundation

  • Systematic Breakdown: Complex problems are decomposed into smaller, reliable transformations
  • Developer as Pipeline Architect: Explicit control over pipeline design and composition
  • Natural Language as Interface Medium: Text-based communication between pipeline components
  • Modular Composition: Components can be composed using standard control flow and logic
  • Frozen Model Utilization: Works with existing LMs and RMs without requiring fine-tuning

Deliberate Differentiation from DSPy

AirsDSP implements the DSP foundation, not the DSPy evolution. This means:

What We Include:

  • Manual, explicit pipeline architecture design
  • Transparent transformation chains with full visibility
  • Deterministic, predictable execution behavior
  • Developer-controlled optimization through architectural choices

What We Deliberately Exclude:

  • Automated compilation and prompt optimization (DSPy feature)
  • Metric-driven parameter tuning (DSPy feature)
  • Declarative transformation graphs with implicit optimization (DSPy feature)
  • Self-improving pipelines through automated search (DSPy feature)

This design philosophy provides developers who value explicit control, transparency, and deterministic behavior with a powerful framework for building knowledge-intensive NLP applications in Rust.

Relationship to DSPy

While DSPy evolved DSP toward automated optimization and compilation, AirsDSP maintains focus on the foundational DSP architecture. This approach provides:

  • Direct implementation of core DSP principles
  • Explicit pipeline control and design
  • Predictable behavior without automated parameter tuning
  • Clear separation between framework logic and optimization concerns

Developers seeking automated optimization features may consider DSPy for Python environments, while those preferring explicit control and Rust performance characteristics will find AirsDSP well-suited to their needs.

Research Foundation

This implementation is based on comprehensive research analysis of the original DSP framework and its evolution:

Primary Research Paper

"Demonstrate-Search-Predict: Composing retrieval and language models for knowledge-intensive NLP"

  • Authors: Omar Khattab, Keshav Santhanam, Xiang Lisa Li, David Hall, Percy Liang, Christopher Potts, Matei Zaharia
  • arXiv ID: arXiv:2212.14024
  • Publication: December 28, 2022 (v1), January 23, 2023 (v2)
  • DOI: 10.48550/arXiv.2212.14024

Performance Benchmarks

The original DSP framework demonstrated significant improvements across knowledge-intensive tasks:

  • vs. Vanilla LMs (GPT-3.5): 37-120% relative gains
  • vs. Standard Retrieve-then-Read: 8-39% relative gains
  • vs. Self-Ask Pipeline: 80-290% relative gains

These benchmarks were achieved across diverse scenarios including open-domain, multi-hop, and conversational question answering settings, establishing new state-of-the-art results for in-context learning on knowledge-intensive tasks.

Framework Evolution Context

AirsDSP's design reflects understanding of the DSP → DSPy evolution:

  • DSP (2022): Framework for manual pipeline construction with explicit control
  • DSPy (2023): Programming model with automated compilation and optimization
  • AirsDSP: Rust implementation of DSP foundation, not DSPy evolution

This deliberate positioning serves developers who prefer manual optimization through architectural design over automated compilation approaches.

Development Status

AirsDSP is currently in early development. The project aims to provide a production-ready Rust implementation of the DSP framework while maintaining fidelity to the original architectural principles.

Installation

Installation instructions will be provided as the project develops toward initial release.

Usage

Usage examples and documentation will be provided as the API stabilizes.

Contributing

Contributions are welcome. Please refer to the contributing guidelines for development setup and submission processes.

License

This project is dual-licensed under the Apache License 2.0 and MIT License. You may choose either license for your use.

Acknowledgments

This project builds upon the foundational research conducted by the Stanford NLP team, particularly the work on the Demonstrate-Search-Predict framework. We acknowledge their significant contributions to advancing the field of language model composition and pipeline design.

About

DSP (Demonstrate-Search-Predict) Framework Implementations In Rust

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •