Skip to content

wannabeyourfriend/weak-to-strong-generalization

Repository files navigation

Weak-to-Strong Generalization

Python Version License

Exploring weak-to-strong generalization with in-context learning

📖 Notion Result Documentation


image image image image image

Setup

Install Dependencies

This project uses uv for fast and reliable dependency management.

uv sync

cp .env.example .env

Edit .env and add your API keys:

OPENAI_API_KEY=your_openai_api_key_here
API_KEY=your_api_key_here

Install PRM800K Grader

Install the prm800k grader for evaluation:

git clone https://github.com/openai/prm800k.git
cd prm800k
pip install -e .

Usage

🧹 Clean the MATH Dataset

Use the cleaning script to prepare the MATH dataset's train split. This aligns the training data with the MATH test dataset format.


🔬 Experiments

The main script provides several experiment types to explore weak-to-strong generalization:

🎯 Single Experiment

Run a single weak-to-strong in-context learning experiment:

uv run python main.py \
  --experiment single \
  --weak_model gpt-4o-mini \
  --strong_model gpt-5-mini \
  --num_few_shot 5 \
  --test_size 200

Parameters:

  • --weak_model: The weaker model to use for generating examples
  • --strong_model: The stronger model to evaluate
  • --num_few_shot: Number of few-shot examples
  • --test_size: Number of test samples

📊 Model Comparison

Compare multiple models' zero-shot behavior on the MATH test dataset:

  1. First, modify src/weak2strong/config.py to add the models you want to compare
  2. Run the comparison experiment:
uv run python main.py --experiment comparison --test_size 500

🚀 Batch Experiments

Use run.py to run multiple experiments with different parameters:

uv run python run.py

This will automatically run experiments with various few-shot values and save comprehensive results.


About

Natural Language Processing Test Project `In Context Learning: Generalization from Weak to Strong`

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages