Skip to main content

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: Uses mathematical symbols (↹, ⊕, Σ) to represent input, process, and output
  • Compositional Design: Break complex prompts into atomic operations
  • Measurable Quality: Quantitative metrics for prompt effectiveness
  • Evolutionary Optimization: Systematic improvement through genetic algorithms
  • Framework Translation: Convert between different prompt engineering approaches

How It Works

SynthLang transforms natural language prompts into a structured format:

  1. Input (↹): Define data sources and parameters
  2. Process (⊕): Specify transformations and operations
  3. Output (Σ): Describe expected results and formats
  4. Operators: Use mathematical symbols (+, >, <, ^) for relationships
  5. Joins (•): Connect related concepts

Metrics & Performance

SynthLang evaluates prompts across multiple dimensions:

Clarity Score (0-1)

  • Symbol usage correctness
  • Structure adherence
  • Concept separation
  • Line length optimization

Specificity Score (0-1)

  • Operator precision
  • Join relationships
  • Transformation clarity
  • Parameter definition

Consistency Score (0-1)

  • Symbol alignment
  • Format compliance
  • Terminology usage
  • Pattern adherence

Task Completion Score (0-1)

  • Test case success
  • Output matching
  • Error handling
  • Edge case coverage

Features

  • 🔄 Framework Translation: Convert natural language to SynthLang format
  • Prompt Optimization: Enhance prompts using DSPy techniques
  • 🧬 Evolutionary Algorithms: Evolve prompts through genetic algorithms
  • 📊 Performance Metrics: Track clarity, specificity, and consistency scores
  • 🎯 Task-Based Testing: Evaluate prompts against specific test cases
  • 🔍 Smart Classification: Categorize and analyze prompts
  • 🛠️ Extensible Architecture: Build custom modules and pipelines

Benefits

  • Improved Efficiency: Streamline prompt engineering workflow
  • Better Results: Generate more effective and consistent prompts
  • Rapid Iteration: Quick experimentation and optimization
  • Quality Metrics: Quantitative feedback on prompt quality
  • Framework Integration: Seamless integration with existing tools
  • DSPy Powered: Leverage advanced language model techniques

Installation

pip install synthlang

Basic Usage

  1. Translate Natural Language to SynthLang
synthlang translate "Analyze customer feedback and generate sentiment insights"
  1. Optimize a Prompt
synthlang optimize "path/to/prompt.txt" --iterations 5
  1. Evolve Prompts
synthlang evolve "initial_prompt" --generations 10 --population 5
  1. 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

  1. Clone the repository:
git clone https://github.com/ruvnet/SynthLang.git
cd SynthLang/cli
  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest

Credits

SynthLang CLI is part of the SynthLang Framework created by @ruvnet.

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

synthlang-0.1.2.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synthlang-0.1.2-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file synthlang-0.1.2.tar.gz.

File metadata

  • Download URL: synthlang-0.1.2.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.1

File hashes

Hashes for synthlang-0.1.2.tar.gz
Algorithm Hash digest
SHA256 981556ebcfa6f4c94e130195d16f9526ce259ad515a130fc4a52aa81b809bbbd
MD5 2a3b609d2a5af95a884c480f679045cd
BLAKE2b-256 3b4a46bd314ebe23a831320de8cf0114fa0df4fef4d0e90507f3b3be69f590cb

See more details on using hashes here.

File details

Details for the file synthlang-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: synthlang-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.1

File hashes

Hashes for synthlang-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 258afac3c9ba76495034c312b3c343947deb782d983fa932c962231935aa072b
MD5 d1a2fe3076c8775541db859b6dddb127
BLAKE2b-256 ac0cb8aeecebaf7e1d624618b565672b967ea113dae75c8432f62ff5f843fe1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page