How scale3-labs/dspy-examples works
Project Type and Purpose
• This is an open-source collection of AI program examples built on the DSPy framework.
• Its purpose is to demonstrate how to assemble, configure, and run various DSPy “programs” (pipelines of LLM-driven steps) with minimal boilerplate.
File Structure
• Top level:
• README.md, LICENSE, requirements.txt
• src/ – contains one subdirectory per example
• Under src/:
• receipt_processing/, self_optimizing_chat/, simple_miprov2/, structured_output/, summarization/, vision_lm/
• Within each example directory:
• One or more programs/ or standalone files (main.py, program.py)
• Typical program subfolder includes: dataset(.jsonl), program.py, signatures.py, run.py.
Extract Insights from the README
• Confirms each “program” is an independent DSPy pipeline with:
– dataset: input data
– program.py: pipeline steps
– signatures.py: interface definitions
– run.py: CLI entrypoint
• Notes that “compound systems” may chain multiple DSPy programs together.
Main Components
a. Core DSPy Runtime
• The library providing orchestration, signature enforcement, and LLM integration.
b. Example Modules (six main examples)
• receipt_processing
• self_optimizing_chat
• simple_miprov2
• structured_output
• summarization
• vision_lm
c. Within Each Example
• Dataset Store (JSONL or other)
• Signatures layer (API contracts for LLM calls)
• Program Logic (program.py)
• Entry Script (run.py or main.py)
d. External Services
• LLM provider (e.g., OpenAI API)
• Any other external data sources (e.g., image storage for vision_lm)
Relationships and Data Flow
• run.py → boots DSPy runtime → loads dataset → invokes program.py
• program.py steps call the LLM via signatures.py contracts
• Output from one program may feed into another for “compound systems”
• Results are returned or written back to disk
Architectural Patterns
• Plugin/Modular: each example is a plugin to the DSPy core
• Pipeline: stepwise transformations, each step defined in code + signature
• Monorepo: shared dependencies (requirements.txt) and conventions
Detail Is Key
• If an example is “compound,” show its internal chaining of DSPy programs.
• Call out shared elements: requirements.txt, LICENSE, and the fact that all examples depend on the same DSPy core.