Guidance vs Dspy

Guidance and Dspy are both popular ml inference & agents tools. This page compares their internal architecture, technology stack, data flow patterns, and system behavior — based on automated structural analysis of their source code. They share 1 technologies including pydantic.

guidance-ai/guidance

21,399
Stars
Jupyter Notebook
Language
9
Components
0.0
Connectivity

stanfordnlp/dspy

33,832
Stars
Python
Language
10
Components
0.0
Connectivity

Technology Stack

Shared Technologies

pydantic

Only in Guidance

llguidance jinja2 numpy transformers openai svelte typescript jupyter-widgets

Only in Dspy

litellm diskcache tenacity json repair regex asyncio optuna cloudpickle

Architecture Layers

Guidance (4 layers)

Grammar DSL
Python decorators and functions that define generation patterns, constraints, and control flow structures that compile to grammar rules
AST & Parser
Abstract syntax tree nodes and a constraint parser that enforces grammar rules in real-time during token generation, including backtracking when constraints are violated
Model Adapters
Backend-specific implementations that interface with different LLM providers and local model libraries, handling tokenization and generation
Visualization
Browser-based widgets that display real-time generation progress, token probabilities, and constraint violations in Jupyter notebooks

Dspy (6 layers)

Signatures
Declarative specifications of input/output contracts — like function signatures but for LM calls, defining what fields to expect and their types
Modules
Composable building blocks that execute signatures — Predict for simple calls, ChainOfThought for reasoning, ReAct for tool use
Adapters
Transform signatures into LM-specific formats and parse responses back — handles chat formatting, JSON schemas, tool calls
Language Models
Unified interface to various LM providers through LiteLLM — handles calls, caching, usage tracking
Optimizers
Automatic prompt and example optimization algorithms — bootstrap learning, genetic evolution, hyperparameter tuning
Evaluation
Metrics and assessment frameworks for measuring program performance and guiding optimization

Data Flow

Guidance (6 stages)

  1. Parse grammar definition
  2. Compile to parser
  3. Generate tokens
  4. Validate constraints
  5. Update model state
  6. Display in notebook

Dspy (7 stages)

  1. Define signature contract
  2. Create module instance
  3. Execute with input data
  4. Format prompt through adapter
  5. Call language model
  6. Parse structured response
  7. Return prediction result

System Behavior

DimensionGuidanceDspy
Data Pools34
Feedback Loops24
Delays34
Control Points56

Code Patterns

Unique to Guidance

grammar compilation real-time constraint enforcement sandboxed visualization backend abstraction tag-based embedding

Unique to Dspy

signature-based programming adapter pattern for lm interfaces module composition meta-learning optimization type-driven custom content context management

When to Choose

Choose Guidance when you need

  • Unique tech: llguidance, jinja2, numpy
  • Simpler system dynamics
View full analysis →

Choose Dspy when you need

  • Unique tech: litellm, diskcache, tenacity
  • Richer system behavior (more feedback loops and control points)
View full analysis →

Frequently Asked Questions

What are the main differences between Guidance and Dspy?

Guidance has 9 components with a connectivity ratio of 0.0, while Dspy has 10 components with a ratio of 0.0. They share 1 technologies but differ in 16 others.

Should I use Guidance or Dspy?

Choose Guidance if you need: Unique tech: llguidance, jinja2, numpy; Simpler system dynamics. Choose Dspy if you need: Unique tech: litellm, diskcache, tenacity; Richer system behavior (more feedback loops and control points).

How does the architecture of Guidance compare to Dspy?

Guidance is organized into 4 architecture layers with a 6-stage data pipeline. Dspy has 6 layers with a 7-stage pipeline.

What technology does Guidance use that Dspy doesn't?

Guidance uniquely uses: llguidance, jinja2, numpy, transformers, openai. Dspy uniquely uses: litellm, diskcache, tenacity, json repair, regex.

Explore the interactive analysis

See the full architecture maps, code patterns, and dependency graphs.

Guidance Dspy

Related ML Inference & Agents Comparisons

Compared on April 20, 2026 by CodeSea. Written by .