Skip to content

tom-doerr/mnist_dspy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

350 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

πŸ”’ MNIST Classification with DSPy

Repository's starts Issues License
Latest commit GitHub repository size

MNIST digit classification using DSPy framework with support for various LLM backends. Configure optimizers and training iterations for optimal performance.

output.mp4

πŸš€ Features

  • DSPy-powered MNIST classification with support for multiple LLM backends
  • Flexible optimizer selection (MIPROv2, BootstrapFewShot)
  • Configurable training iterations and worker threads
  • Model selection (supports any LLM compatible with DSPy)
  • Response caching for faster iterations

πŸ“¦ Installation

git clone https://github.com/tom-doerr/mnist_dspy.git
cd mnist_dspy
pip install -r requirements.txt

🧠 Project Structure

mnist_dspy/
β”œβ”€β”€ mnist_trainer.py    # Main training script with optimizer selection
β”œβ”€β”€ mnist_data.py       # MNIST data loading and preprocessing
└── mnist_dspy.py       # DSPy model definitions

🏁 Basic Usage

Train a model with specific optimizer and iterations:

# Use MIPROv2 optimizer with light optimization
python mnist_trainer.py --optimizer MIPROv2 --iterations 1 --model your-llm-model --auto light

# Use MIPROv2 with medium optimization and caching disabled
python mnist_trainer.py --optimizer MIPROv2 --iterations 1 --model your-llm-model --auto medium --no-cache

# Use BootstrapFewShot optimizer with custom number of workers
python mnist_trainer.py --optimizer BootstrapFewShot --iterations 1 --model your-llm-model --num-workers 50

πŸ”§ Configuration Options

  • --optimizer: Choose between 'MIPROv2' or 'BootstrapFewShot' (default: MIPROv2)
  • --iterations: Number of optimization iterations (default: 1)
  • --model: Model identifier for your LLM
  • --auto: Optimization intensity for MIPROv2 ['light', 'medium', 'heavy'] (default: light)
  • --num-workers: Number of worker threads (default: 100)
  • --no-cache: Disable LLM response caching

πŸ“Š Data Processing

The trainer:

  • Uses a subset of MNIST data for faster experimentation
  • Processes 10,000 training examples
  • Evaluates on 200 test examples
  • Supports multi-threaded evaluation

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors