Command-line interface for the SynthLang framework using DSPy
Project description
SynthLang CLI
A powerful command-line interface for the SynthLang framework, providing advanced prompt engineering, framework translation, and optimization capabilities using DSPy.
What is SynthLang?
Reduce AI costs by up to 95% with SynthLang's efficient prompt optimization. Experience up to 1100% faster processing while maintaining effectiveness.
Transform your AI interactions with mathematically-structured prompts. Symbolic Scribe brings academic rigor to prompt engineering, helping you create more precise, reliable, and powerful AI interactions. SynthLang is a revolutionary framework for prompt engineering and language model optimization. It introduces a structured, mathematical approach to prompt design that makes prompts more consistent, measurable, and effective. The framework uses a unique symbolic notation system that bridges natural language and computational thinking.
Core Concepts
-
Symbolic Notation: A sophisticated system that uses mathematical symbols to represent different aspects of prompt engineering:
- ↹ (Input): Represents data ingestion and parameter definition
- ⊕ (Process): Denotes transformations and computational operations
- Σ (Output): Specifies result formats and expectations
- These symbols create a standardized way to express prompt logic
-
Compositional Design: A modular approach to prompt engineering that:
- Breaks down complex prompts into smaller, manageable components
- Enables reuse of common prompt patterns
- Facilitates testing and optimization of individual components
- Allows for easy composition of complex workflows
-
Measurable Quality: A comprehensive metrics system that:
- Evaluates prompt effectiveness using quantitative measures
- Tracks performance across multiple dimensions
- Provides actionable feedback for improvement
- Enables data-driven optimization
-
Evolutionary Optimization: An advanced genetic algorithm system that:
- Automatically improves prompts through successive generations
- Uses mutation and crossover operations
- Selects the best-performing variants
- Adapts to specific use cases and requirements
-
Framework Translation: A sophisticated translation system that:
- Converts between different prompt engineering approaches
- Maintains semantic equivalence
- Optimizes for target framework characteristics
- Preserves intent and functionality
How It Works
SynthLang transforms natural language prompts into a structured format through a multi-step process:
-
Input (↹):
- Defines data sources and their characteristics
- Specifies input parameters and their types
- Establishes validation rules
- Sets up preprocessing requirements
-
Process (⊕):
- Details transformation steps
- Defines computational operations
- Specifies conditional logic
- Establishes processing pipelines
-
Output (Σ):
- Describes expected result formats
- Specifies success criteria
- Defines error handling
- Sets quality thresholds
-
Operators:
- Mathematical symbols for relationship definition:
- (+) Addition/Combination
- (>) Greater than/Progression
- (<) Less than/Regression
- (^) Power/Amplification
- Mathematical symbols for relationship definition:
-
Joins (•):
- Connect related concepts
- Establish hierarchical relationships
- Define concept groupings
- Create logical bridges
Metrics & Performance
SynthLang evaluates prompts across multiple dimensions with sophisticated scoring systems:
Clarity Score (0-1)
Measures the structural quality of prompts:
- Symbol Usage Correctness: Evaluates proper application of symbolic notation
- Structure Adherence: Assesses compliance with SynthLang patterns
- Concept Separation: Measures clear delineation between components
- Line Length Optimization: Analyzes prompt formatting efficiency
Specificity Score (0-1)
Evaluates the precision of prompt instructions:
- Operator Precision: Measures accuracy of mathematical operators
- Join Relationships: Assesses the quality of concept connections
- Transformation Clarity: Evaluates process step definitions
- Parameter Definition: Analyzes input/output specifications
Consistency Score (0-1)
Measures prompt reliability and standardization:
- Symbol Alignment: Evaluates symbolic notation consistency
- Format Compliance: Assesses adherence to style guidelines
- Terminology Usage: Measures vocabulary standardization
- Pattern Adherence: Analyzes structural consistency
Task Completion Score (0-1)
Evaluates practical effectiveness:
- Test Case Success: Measures performance on standard tests
- Output Matching: Evaluates result accuracy
- Error Handling: Assesses robustness
- Edge Case Coverage: Analyzes comprehensive handling
Features
-
🔄 Framework Translation:
- Converts natural language to SynthLang format
- Preserves semantic meaning
- Optimizes structure
- Maintains context
- Supports multiple frameworks
- Provides bidirectional translation
-
⚡ Prompt Optimization:
- Enhances prompts using DSPy techniques
- Improves efficiency
- Reduces token usage
- Maintains accuracy
- Implements best practices
- Provides optimization suggestions
-
🧬 Evolutionary Algorithms:
- Evolves prompts through genetic algorithms
- Implements mutation strategies
- Uses crossover techniques
- Selects optimal variants
- Adapts to requirements
- Tracks evolutionary history
-
📊 Performance Metrics:
- Tracks clarity scores
- Measures specificity
- Evaluates consistency
- Analyzes effectiveness
- Provides detailed reports
- Suggests improvements
-
🎯 Task-Based Testing:
- Evaluates against test cases
- Measures success rates
- Tracks performance
- Identifies weaknesses
- Suggests improvements
- Maintains test history
-
🔍 Smart Classification:
- Categorizes prompts
- Analyzes patterns
- Identifies similarities
- Groups related prompts
- Suggests optimizations
- Maintains taxonomies
-
🛠️ Extensible Architecture:
- Supports custom modules
- Enables pipeline creation
- Allows framework extension
- Facilitates integration
- Provides plugin system
- Enables customization
Benefits
-
Improved Efficiency:
- Streamline prompt engineering workflow
- Reduce development time
- Optimize resource usage
- Automate repetitive tasks
- Enhance productivity
-
Better Results:
- Generate more effective prompts
- Improve consistency
- Enhance reliability
- Reduce errors
- Optimize performance
-
Rapid Iteration:
- Quick experimentation
- Fast optimization
- Efficient testing
- Easy refinement
- Continuous improvement
-
Quality Metrics:
- Quantitative feedback
- Performance tracking
- Quality assurance
- Progress monitoring
- Improvement suggestions
-
Framework Integration:
- Seamless tool integration
- Easy adoption
- Flexible deployment
- Extensible design
- Broad compatibility
-
DSPy Powered:
- Advanced language model techniques
- State-of-the-art optimization
- Efficient processing
- Robust performance
- Continuous updates
Installation
pip install synthlang
Basic Usage
- Translate Natural Language to SynthLang
synthlang translate "Analyze customer feedback and generate sentiment insights"
- Optimize a Prompt
synthlang optimize "path/to/prompt.txt" --iterations 5
- Evolve Prompts
synthlang evolve "initial_prompt" --generations 10 --population 5
- Classify Prompts
synthlang classify "prompt_text" --labels "task,query,instruction"
Advanced Usage
Custom Evolution Parameters
synthlang evolve "prompt" \
--generations 20 \
--population 10 \
--mutation-rate 0.3 \
--tournament-size 3 \
--fitness-type hybrid
Test-Driven Optimization
synthlang optimize "prompt" \
--test-cases tests.json \
--target-score 0.95 \
--max-iterations 50
Batch Processing
synthlang batch-translate prompts.txt \
--output translated/ \
--format json \
--parallel 4
Environment Configuration
Create a .env file:
OPENAI_API_KEY=your_key_here
SYNTHLANG_MODEL=gpt-4o-mini
SYNTHLANG_TEMPERATURE=0.7
Examples
Framework Translation
# Input
synthlang translate "Get news articles about AI and analyze their sentiment"
# Output
↹ news•ai
⊕ fetch => articles
⊕ analyze => sentiment
Σ results + metrics
Prompt Evolution
# Start with basic prompt
synthlang evolve "Summarize text" \
--test-cases summary_tests.json \
--generations 5
# Evolution produces optimized versions:
# Generation 1: "Extract key points and create concise summary"
# Generation 2: "Identify main themes and synthesize core message"
# Generation 3: "Analyze content, extract insights, generate summary"
Classification Pipeline
# Classify multiple prompts
synthlang classify-batch prompts.txt \
--labels "query,task,instruction,conversation" \
--output classifications.json
Metrics Analysis
# Get detailed metrics for a prompt
synthlang analyze "prompt.txt" --detailed
# Output
{
"clarity_score": 0.95,
"specificity_score": 0.87,
"consistency_score": 0.92,
"task_score": 0.89,
"overall_quality": 0.91
}
Development
- Clone the repository:
git clone https://github.com/ruvnet/SynthLang.git
cd SynthLang/cli
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
Credits
SynthLang CLI is part of the SynthLang Framework created by @ruvnet.
- Framework: SynthLang
- Creator: @ruvnet
- Documentation: synthlang.org
- License: MIT
Contributing
Contributions are welcome! Please check out our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 synthlang-0.1.3.tar.gz.
File metadata
- Download URL: synthlang-0.1.3.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4f9d3727f7944ec76ad45be5b32fd0d551d652e1252304286151088f9083411
|
|
| MD5 |
3814d4fe9c3e51eb96753dde2f1d72f4
|
|
| BLAKE2b-256 |
5f9f5de03d1ee65d2daa2cd3aaba9fb80f8336c92244449a4ad2a8a11ed69536
|
File details
Details for the file synthlang-0.1.3-py3-none-any.whl.
File metadata
- Download URL: synthlang-0.1.3-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fdbc99f5ed9285f9bd2f6fb037040a63e1a64f8a4d7d5993e7ee79e789d7938
|
|
| MD5 |
85f47a349e188ecbf735f9bada5c5dd8
|
|
| BLAKE2b-256 |
0cb63a4476fde0e85f10977ce5331a4e498e43c1a453b6056fe5a2993855b3dd
|