Skip to content

Latest commit

 

History

History

WMDP

README.md

WMDP Evaluation Framework

Two evaluation pipelines for Leak@k in WMDP unlearning assessment.

Overview

Pipeline What it does
Accuracy Generate choices among A/B/C/D then compute leak@k
Generation Generate model responses then evaluate with LLM judge for leak@k

Quickstart

# Set OpenAI key (required for Generation pipeline)
export OPENAI_API_KEY="your-key-here"
export OPENAI_MODEL="gpt-4o"   # default: o3-mini

# Edit parameters in the scripts, then run:
bash run_acc.sh    # Accuracy pipeline
bash run_gen.sh    # Generation pipeline (LLM judge)

Parameters

Edit the variables at the top of each script.

run_acc.sh

Variable Default Description
SEED 50 Random seed
TEMPERATURE 1.0 Sampling temperature
TOP_P 1.0 Top-p sampling
NUM_SAMPLES 200 Number of questions to sample
K_LIST "1,2,4,8,16,32,64,128" Comma-separated k values for answer generation
OUTPUT_DIR "acc_results" Output directory

run_gen.sh

Variable Default Description
SEED 42 Random seed
TEMPERATURE 0.1 Sampling temperature
NUM_SAMPLES 100 Number of questions to sample
K_VALUES "1 2 4 8 16 32 64 128" Space-separated k values for response generation
OUTPUT_DIR "gen_results" Directory for generated responses
EVAL_OUTPUT_DIR "eval_results" Directory for LLM judge results

Changing the Model

Models are configured in the NPO_MODELS and ORIGINAL_MODELS dictionaries at the top of each generate script.

Pipeline Script Dictionaries
Accuracy generate_wmdp_answers_param_unfrozen_new.py NPO_MODELS / ORIGINAL_MODELS (lines 20-25)
Generation generate_wmdp_responses_param_unfrozen.py NPO_MODELS / ORIGINAL_MODELS (lines 18-23)

Each dictionary maps a model nickname to a HuggingFace model path (local directory or HF Hub ID):

NPO_MODELS = {
    "Zephyr-7b": "model_from/huggingface",      # HuggingFace Hub path
    "MyModel-7b":  "./my_npo_model_local",   # Local directory path
}
ORIGINAL_MODELS = {
    "Zephyr-7b": "HuggingFaceH4/zephyr-7b-beta",
}

To use a different model:

  1. Edit both dictionaries in the relevant script so the keys match
  2. The key (e.g. "Zephyr-7b") must be identical in both dictionaries — it's used to pair NPO and original models
  3. Values can be either a HuggingFace Hub identifier or a local path

Pipeline Details

Acuracy: generate_wmdp_answers_param_unfrozen_npo_new.py extracts A/B/C/D answers from NPO and original models, then acc_process.py computes leak@k from the answer distributions.

Generation: generate_wmdp_responses_param_unfrozen.py generates full text responses, then visualization/llmjudge.py scores them via OpenAI API and produces heatmap visualizations.