-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add MetaLadder adapter for enhanced mathematical reasoning #8020
base: main
Are you sure you want to change the base?
Conversation
This commit implements the MetaLadder approach from Lin et al. (2025) for improving mathematical reasoning through analogical learning and problem restatement. Key features include: problem type identification, meta problem generation, problem restatement, shortcut/full path options, LRU caching, and optimizer integration.
To further clarify the value proposition of the MetaLadder adapter, I want to highlight some key technical aspects: Analogical Learning vs Direct Reasoning Real-world Impact
Performance Economics
Example scenario with 1M problems/month:
Quality Enhancements
The implementation is highly configurable, allowing teams to:
|
- Fix OpenAI API response handling and message formatting - Add comprehensive benchmark suite with detailed logging - Create comparison examples demonstrating improvements - Add detailed documentation comparing approaches - Implement proper error handling and validation - Clean up example structure and improve tests
d7416f6
to
bb75971
Compare
Hybrid Reasoning: Enhancing MetaLadder with Intelligent Approach SelectionI've added significant enhancements to the MetaLadder implementation, focusing on a hybrid reasoning approach that intelligently combines MetaLadder and Chain of Thought methodologies. Key Improvements in This Update
Performance HighlightsIn our testing with the hybrid approach:
Command-line InterfaceThe training script now supports additional parameters:
This hybrid approach represents a significant advancement over both pure MetaLadder and pure Chain of Thought by leveraging the strengths of each method where they perform best. |
Add MetaLadder Adapter for Enhanced Mathematical Reasoning
Overview
This PR adds the MetaLadder adapter to DSPy, implementing the approach from "MetaLadder: Ascending Mathematical Solution Quality via Analogical-Problem Reasoning Transfer" (Lin et al., 2025). The adapter enhances mathematical reasoning through analogical learning and problem restatement, achieving significant improvements over standard Chain-of-Thought methods.
Features
Implementation
The MetaLadder adapter is implemented with the following key components:
Core Classes:
MetaProblem
: Dataclass for storing problem metadataMetaLadderAdapter
: Main adapter implementing the MetaLadder approachKey Methods:
_identify_problem_type
: Determines problem category_generate_meta_problem
: Creates analogous problems_restate_problem
: Reformulates the problemforward
: Main processing pipelinePerformance Optimizations:
Performance Benefits
Based on the paper's methodology, the implementation achieves:
Example Usage
Files Added/Modified
dspy/adapters/metaladder_adapter.py
: Main implementationdspy/adapters/__init__.py
: Added MetaLadder to exportsexamples/metaladder_example.py
: Basic usage exampleexamples/metaladder_full_example.py
: Comprehensive exampletests/adapters/test_metaladder_adapter.py
: Test suitedocs/adapters/metaladder.md
: DocumentationTesting
The implementation includes comprehensive tests covering:
Documentation
Added detailed documentation including:
Conclusion
The MetaLadder adapter provides a powerful enhancement to DSPy's mathematical reasoning capabilities. By implementing the approach from the paper, we enable more effective problem-solving through analogical reasoning and structured reformulation. The implementation is fully tested, documented, and optimized for production use.