ai-cfia / ai-cfia/fertiscan-pipeline

As a developer, I want a reproducible and systematic way to optimize our DSPy modules using our dataset.

Aberta
#90 0 comentários 0 reações 1 responsável Reivindicada por @Endlessflow Ver no GitHub
Linguagem predominante
Python
Estrelas
1
Forks
1
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

## Context
As we reach an initial working state with the work on the evaluation of our DSPy module and have aquired a minimal dataset of labeled examples, we can now explore one of the main two vectors of improvement for our pipeline: using various DSPy optimizers to enhance the performance of our DSPy module.

There are three major ways DSPy helps us improve our modules, in increasing order of complexity:
- Example injection: This is the simplest method and involves teaching the LLM by appending a few demonstrations of the desired outcome to the prompt.
- Prompt optimization: As the name implies, this aims to optimize the prompt we use to make the instructions we give to the model clearer.
- Fine-tuning: When working with open models (e.g., Deepseek :eyes:), DSPy also allows us to fine-tune the weights of the LLM directly.

Our most prudent course of action is to gradually progress from simple to complex optimizations while monitoring results with our Evaluation function.

From the documentation, here are the main optimizers we are considering and the recommended breakpoints for the size of the training set:

Example injection optimizers:
> - If you have very few examples (around 10), start with BootstrapFewShot.
> - If you have more data (50 examples or more), try BootstrapFewShotWithRandomSearch.

Prompt optimization optimizers:
> - If you prefer to do instruction optimization only (i.e., you want to keep your prompt 0-shot), use MIPROv2 configured for 0-shot optimization to optimize.

Prompt + Example injection optimizers:
> - If you’re willing to use more inference calls to perform longer optimization runs (e.g., 40 trials or more), and have enough data (e.g., 200 examples or more to prevent overfitting), then try MIPROv2.

Fine tunning optimizer:
> - If you have been able to use one of these with a large LM (e.g., 7B parameters or above) and need a very efficient program, fine-tune a small LM for your task with BootstrapFinetune.

It is important to note that a significant bottleneck we face at the moment is the size of our training set. Currently, we have 35 examples divided between training and evaluation (with a suggested 20/80 split, that is 7 examples for training and 28 for evaluation). This is barely enough to start using the first optimizer, `BootstrapFewShot`. To address this scaling issue, work wiwll need to be done in parallel to create a data flywheel that will allow us to scale our training data from user data.

In the meantime, our task is to prepare scripts that will allow us to take in the training data and systematically use each of the three main optimizers (`BootstrapFewShot`, `BootstrapFewShotWithRandomSearch`, `MIPROv2`) to create an optimized and packaged `main_module`.

## Acceptance Criteria
- Create a script for each optimizer that takes in the path to the CSV containing our examples and, after running the optimizer, saves the resulting module.
- Decide on the saving paradigm to use (saving state vs. saving whole modules). Refer to: [Saving and Loading your DSPy Programs](https://dspy.ai/tutorials/saving/?h=saving) for more info.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.