BRAID (Bounded Reasoning for Autonomous Inference and Decisions) integration for DSPy framework
Project description
BRAID-DSPy Integration
A Python library that integrates BRAID (Bounded Reasoning for Autonomous Inference and Decisions) architecture into the DSPy framework, enabling structured reasoning through Guided Reasoning Diagrams (GRD) in Mermaid format.
Overview
BRAID-DSPy brings structured reasoning capabilities to DSPy by requiring models to first generate a machine-readable flowchart (GRD) before executing the solution. This separation of planning and execution significantly improves reliability and reduces hallucinations.
Key Features
- Guided Reasoning Diagrams (GRD): Generate Mermaid-format flowcharts that map solution steps
- Two-Phase Reasoning: Separate planning and execution phases for better reliability
- DSPy Integration: Seamlessly integrates with existing DSPy modules and optimizers
- Auditable Reasoning: Visualize and debug reasoning processes through GRD diagrams
- Optimization Support: BRAID-aware optimizers for improving GRD quality
Installation
pip install braid-dspy
Quick Start
import dspy
from braid import BraidReasoning
# Configure DSPy
lm = dspy.OpenAI(model="gpt-4")
dspy.configure(lm=lm)
# Create a BRAID reasoning module
braid = BraidReasoning()
# Use it in your pipeline
result = braid(problem="Solve: If a train travels 120 km in 2 hours, what is its speed?")
print(result.answer)
print(result.grd) # View the reasoning diagram
Documentation
📚 Full documentation is available on Read the Docs (coming soon)
Local documentation:
To build documentation locally:
pip install -e ".[docs]"
cd docs
make html
Examples
Check out the examples directory for:
- Basic usage examples
- GSM8K benchmark integration
- Optimization workflows
License
MIT License - see LICENSE file for details.
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file braid_dspy-0.1.0.tar.gz.
File metadata
- Download URL: braid_dspy-0.1.0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cc9aab1f3b83823ee10b4a428d8e31af42148deaa1bfabd376e07c877beacb0
|
|
| MD5 |
cf8569e447b16d0ecc7a3e3dc519cbbf
|
|
| BLAKE2b-256 |
11083e776d073dd617ce3def5c1b4d17296e1be6245c3d7c2a759cf58bb8f219
|
File details
Details for the file braid_dspy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: braid_dspy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b57558037eae2330f718834b5cca786e1c3533650cab0dd5c393889a430ff71c
|
|
| MD5 |
d775aaffa0e15355e44dc68325afe664
|
|
| BLAKE2b-256 |
167fed319d9d52fccc614bbb469820f5cb1961cf34b99e1f6a6bfbc4bb91a016
|