This repo contains for prompt engineering on the openai/gsm8k math word problems dataset.
- Propmting with the question.
- Basic PE with role setting and simple instructions defining appraoch and required output format.
- Few-Shot Prompting - Enhacing the prompt with a few example question-answer pairs for a few-shot learning approach.
- OPRO - Automated prompt augmentation using OPRO - Optimization by PROmpting, developed by Google DeepMind.
-
Run requirements.txt:
!pip install requirements.txt -
Update environment variables in
.env:- OpenAI API key
-
Update config variables in
config.yaml:hf_data
path_to_save- Path to download the HuggingFace datasetrandom_subset_size- Size of random sample from the dataset
file_paths
hf_data- Path to the dataset pickle filehf_data_subset- Path to the pickle file with sampled data
-
Run
load_hf_data.pyThis will download the gsm8k dataset and store it in
path_to_save -
Run
data_random_sample.pyA subset of 250 question-answer pairs will also be saved in the same directory. This is used for evaluation of prompting techniques.
-
Run
scoring.py- Generates accuracy of GPT-3.5 Turbo answers without any prompt engineering -
Run
scoring_new_prompts.py- Generates accuracy of GPT-3.5 Turbo answers with basic prompt engineering and Few-Shot prompting -
Run
generate_opro_training_examples.py- Generates a set of 30 training question-answer examples for OPRO iterative prompt optimization. -
Run
opro.py- Run OPRO optimization -
Run
opro_scoring.py