weavel-ai / Ape

Your first AI prompt engineer
https://docs.weavel.ai/sdk-reference/ape-common
MIT License
331 stars 13 forks source link

Feat: add DspyMiproTrainer #37

Closed engineerA314 closed 1 week ago

engineerA314 commented 1 week ago

Description

This pull request introduces a new DspyMiproTrainer and refactors the Evaluate class along with several other trainers. The main changes include:

  1. Refactoring of the Evaluate class in libs/ape-common/ape/common/evaluate/evaluate.py:

    • Simplified constructor and removed dependency on EvaluationConfig
    • Added generate parameter to the constructor
    • Modified __call__ method to use trainset instead of valset
    • Updated evaluation logic to use the new generate method
  2. Addition of DspyMiproTrainer in libs/ape-core/ape/core/v2/trainer/dspy_mipro_trainer.py:

    • Implements a new training strategy using MIPRO (Minimum Prompt Optimization)
    • Includes methods for generating instruction candidates and fewshot demo sets
  3. Updates to existing trainers (ExpelTrainer, FewShotTrainer, OptunaTrainer, TextGradientTrainer):

    • Modified to use trainset instead of valset for evaluation
    • Updated to use the refactored Evaluate class
  4. Addition of a new prompt template gen-fewshot-placeholder.prompt for generating fewshot placeholders in prompts

  5. Minor version bumps in pyproject.toml files for both ape-common and ape-core

These changes aim to improve the flexibility and performance of the training process by introducing a new training strategy and refactoring existing components to work with the updated Evaluate class.

Changes that Break Backward Compatibility

The refactoring of the Evaluate class and changes in trainer implementations may break backward compatibility for code relying on the previous implementations. Specifically:

Documentation

N/A

Created with Palmier

aschung01 commented 1 week ago

@palmier-bot describe