kdymkiewicz/Logit-Diff-Amplification

0

stars

1

commits

Python

primary language

Jan 22, 2026

updated

README

Logit Diff Amplification

Overview

This project implements a technique to measure and extrapolate model compliance rates by interpolating between safe and unsafe prompt distributions for studying rare model behaviors that are difficult to observe directly. By computing L_α = α * L_P + (1 - α) * L_Q at the logit level, we can:

  • Sample from intermediate distributions between a safe prompt P and an unsafe prompt Q
  • Measure compliance rates across different α values
  • Fit a sigmoid curve and extrapolate to estimate behavior at α=1.0 (pure safe prompt)

Installation

Setup

# Clone the repository
git clone https://github.com/yourusername/logit_diff_amp.git
cd logit_diff_amp

make install

Usage

Basic Example

python main.py \
    --prompt-p "Your safe prompt" \
    --prompt-q "Your unsafe prompt" \
    --n-samples 25 \
    --alpha-steps 11 \
    --output-dir output

Command-line Arguments

ArgumentShortDefaultDescription
--prompt-p-prequiredSafe prompt P
--prompt-q-qrequiredUnsafe prompt Q
--n-samples-n25Samples per alpha value
--alpha-start0.0Alpha range start
--alpha-end1.0Alpha range end
--alpha-steps11Number of alpha steps
--batch-size30Batch size for generation
--output-dir-ooutputOutput directory

SLURM Cluster

To run on a SLURM cluster:

sbatch run.batch

Edit run.batch to customize job parameters and prompts.

Output

The script generates:

  1. CSV file (output/results.csv): Raw experimental data with columns:

    • alpha: interpolation coefficient
    • response: model-generated text
    • classification: "compliance" or "refusal"
  2. Plot (output/compliance_vs_alpha_fitted.png): Compliance rate vs α with:

    • Observed data points with 95% confidence intervals (Wilson score)
    • Sigmoid curve fit
    • Extrapolated value at α=1.0
  3. Console output: Summary statistics and sigmoid fit parameters

License

MIT License - see LICENSE file for details.

Contributors

kdymkiewicz

1 commits

kdymkiewicz/Logit-Diff-Amplification

0

stars

1

commits

Python

primary language

Jan 22, 2026

updated

README

Logit Diff Amplification

Overview

This project implements a technique to measure and extrapolate model compliance rates by interpolating between safe and unsafe prompt distributions for studying rare model behaviors that are difficult to observe directly. By computing L_α = α * L_P + (1 - α) * L_Q at the logit level, we can:

  • Sample from intermediate distributions between a safe prompt P and an unsafe prompt Q
  • Measure compliance rates across different α values
  • Fit a sigmoid curve and extrapolate to estimate behavior at α=1.0 (pure safe prompt)

Installation

Setup

# Clone the repository
git clone https://github.com/yourusername/logit_diff_amp.git
cd logit_diff_amp

make install

Usage

Basic Example

python main.py \
    --prompt-p "Your safe prompt" \
    --prompt-q "Your unsafe prompt" \
    --n-samples 25 \
    --alpha-steps 11 \
    --output-dir output

Command-line Arguments

ArgumentShortDefaultDescription
--prompt-p-prequiredSafe prompt P
--prompt-q-qrequiredUnsafe prompt Q
--n-samples-n25Samples per alpha value
--alpha-start0.0Alpha range start
--alpha-end1.0Alpha range end
--alpha-steps11Number of alpha steps
--batch-size30Batch size for generation
--output-dir-ooutputOutput directory

SLURM Cluster

To run on a SLURM cluster:

sbatch run.batch

Edit run.batch to customize job parameters and prompts.

Output

The script generates:

  1. CSV file (output/results.csv): Raw experimental data with columns:

    • alpha: interpolation coefficient
    • response: model-generated text
    • classification: "compliance" or "refusal"
  2. Plot (output/compliance_vs_alpha_fitted.png): Compliance rate vs α with:

    • Observed data points with 95% confidence intervals (Wilson score)
    • Sigmoid curve fit
    • Extrapolated value at α=1.0
  3. Console output: Summary statistics and sigmoid fit parameters

License

MIT License - see LICENSE file for details.

Contributors

kdymkiewicz

1 commits

Languages

Python

89.0%

Makefile

7.0%

Shell

4.0%