Skip to content

Commit 0ada85a

Browse files
lvjr3383claude
andcommitted
Add alignment-faking reproducibility audit and fixes
Audited safety-research/open-source-alignment-faking for reproducibility. Found 10 friction points blocking any researcher from running the pipeline out of the box, including 3 hard crashes before a single API call. Fixed all 10 and submitted two upstream PRs: - safety-research/safety-tooling#155 (OpenAI init crash fix) - safety-research/open-source-alignment-faking#2 (setup script + Dockerfile) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 parents  commit 0ada85a

7 files changed

Lines changed: 633 additions & 0 deletions

File tree

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Python
2+
__pycache__/
3+
*.pyc
4+
.venv/
5+
6+
# Secrets
7+
.env
8+
9+
# Experiment outputs
10+
open-source-alignment-faking/outputs/
11+
12+
# macOS
13+
.DS_Store
14+
15+
# Submodule — tracked in its own repo
16+
open-source-alignment-faking/safety-tooling/

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# AI Safety Projects
2+
3+
Personal workspace for AI safety research and tooling contributions.
4+
5+
## Projects
6+
7+
### alignment-faking-audit
8+
9+
Reproducibility audit of Anthropic's alignment faking paper
10+
([safety-research/open-source-alignment-faking](https://github.com/safety-research/open-source-alignment-faking)).
11+
12+
Found 10 friction points blocking any researcher from running the pipeline out of the box,
13+
including 3 hard crashes before a single API call. Fixed all 10 and contributed upstream.
14+
15+
**PRs submitted:**
16+
- [safety-tooling #155](https://github.com/safety-research/safety-tooling/pull/155) — fix startup crash when `OPENAI_API_KEY` is unset
17+
- [open-source-alignment-faking #2](https://github.com/safety-research/open-source-alignment-faking/pull/2) — one-click setup script, `.env.example`, Dockerfile
18+
19+
**Artifacts:** [`alignment-faking-audit/`](alignment-faking-audit/)
20+
- `REPRODUCIBILITY_AUDIT.md` — full audit log with all 10 friction points
21+
- `setup.sh` — one-click setup script
22+
- `.env.example` — annotated API key template
23+
- `Dockerfile` — reproducible container
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# .dockerignore — keep the Docker build context lean
2+
# Exclude large/sensitive directories that don't need to be in the image.
3+
4+
# Python virtual environment (rebuilt inside container)
5+
.venv/
6+
7+
# Experiment outputs (mount as a volume instead)
8+
outputs/
9+
10+
# Secrets (NEVER bake .env into the image)
11+
.env
12+
13+
# Python cache
14+
__pycache__/
15+
*.pyc
16+
*.pyo
17+
*.pyd
18+
.Python
19+
20+
# Git metadata (not needed in the image)
21+
.git/
22+
23+
# Editor/IDE files
24+
.cursor*
25+
.vscode/
26+
*.swp
27+
*.swo
28+
29+
# Jupyter checkpoints
30+
.ipynb_checkpoints/
31+
32+
# macOS
33+
.DS_Store
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## open-source-alignment-faking — API Key Configuration
2+
## Copy this file to .env and fill in your keys before running.
3+
##
4+
## QUICK START — minimum keys needed:
5+
## • Anthropic models only → set ANTHROPIC_API_KEY + OPENAI_API_KEY (see note below)
6+
## • OpenAI models only → set OPENAI_API_KEY + OPENAI_API_KEY1
7+
## • Together/Llama models → set TOGETHER_API_KEY + OPENAI_API_KEY
8+
##
9+
## NOTE on OPENAI_API_KEY (FP-3 workaround):
10+
## The InferenceAPI library initialises an OpenAI client at startup regardless
11+
## of which model you are running. If OPENAI_API_KEY is unset, the process
12+
## crashes immediately with an OpenAIError — even for Anthropic-only runs.
13+
## Set OPENAI_API_KEY to your real key, or to any non-empty placeholder (e.g.
14+
## "not-needed") if you are only running Anthropic/Together models.
15+
##
16+
## NOTE on OPENAI_API_KEY1 vs OPENAI_API_KEY (FP-5):
17+
## The pipeline's ExperimentConfigBase defaults to openai_tag="OPENAI_API_KEY1".
18+
## At startup it copies OPENAI_API_KEY1 → OPENAI_API_KEY. To avoid confusion,
19+
## set both to the same value if you are using OpenAI models.
20+
21+
# ── Required for basic pipeline run ────────────────────────────────────────
22+
23+
# Primary Anthropic key (claude-3-*, claude-3-5-* models)
24+
ANTHROPIC_API_KEY=
25+
26+
# Required at startup even for Anthropic-only runs (see note above).
27+
# Set to your OpenAI key, or to "not-needed" if you have no OpenAI key.
28+
OPENAI_API_KEY=
29+
30+
# The pipeline reads THIS key by default (copied to OPENAI_API_KEY at startup).
31+
# Set to the same value as OPENAI_API_KEY above.
32+
OPENAI_API_KEY1=
33+
34+
# ── Required for other providers ───────────────────────────────────────────
35+
36+
# Together AI (meta-llama/* models via TogetherAI)
37+
TOGETHER_API_KEY=
38+
39+
# Google Gemini API
40+
GOOGLE_API_KEY=
41+
42+
# HuggingFace inference endpoints
43+
HF_TOKEN=
44+
45+
# DeepSeek API
46+
DEEPSEEK_API_KEY=
47+
48+
# GraySwan API
49+
GRAYSWAN_API_KEY=
50+
51+
# ElevenLabs text-to-speech
52+
ELEVENLABS_API_KEY=
53+
54+
# Gemini via Vertex AI (only needed if using Vertex AI, not standard Gemini API)
55+
GOOGLE_PROJECT_ID=
56+
GOOGLE_PROJECT_REGION=
57+
58+
# ── Alternative/extra Anthropic keys ───────────────────────────────────────
59+
60+
# Additional OpenAI keys for multi-org setups
61+
OPENAI_API_KEY2=
62+
63+
# Separate Anthropic key for batch API jobs
64+
ANTHROPIC_BATCH_API_KEY=
65+
66+
# ── Optional: finetuning on RunPod via OpenWeights ─────────────────────────
67+
# (Only needed for experiments/finetuning — not required for the basic pipeline)
68+
# Install separately: pip install git+https://github.com/longtermrisk/openweights
69+
# RUNPOD_API_KEY=
70+
71+
# ── Optional: debugging and caching ────────────────────────────────────────
72+
73+
# Print every prompt and response to console (very verbose)
74+
SAFETYTOOLING_PRINT_PROMPTS=
75+
76+
# Override default directories (defaults are ./outputs/*/prompt-history and ./outputs/*/cache)
77+
PROMPT_HISTORY_DIR=
78+
CACHE_DIR=
79+
80+
# Use Redis instead of file-based caching (requires a running Redis instance)
81+
# See safety-tooling/README.md → Redis Configuration for setup instructions
82+
REDIS_CACHE=
83+
REDIS_PASSWORD=

alignment-faking-audit/Dockerfile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Dockerfile — open-source-alignment-faking
2+
#
3+
# Produces a reproducible environment with all system and Python dependencies
4+
# pre-installed. Fixes FP-1 (SSH submodule), FP-2 (uv PATH), FP-8 (ffmpeg).
5+
#
6+
# PREREQUISITES before building:
7+
# The safety-tooling submodule must be initialised in your local checkout.
8+
# If you cloned with --recurse-submodules and it failed (SSH key issue), run:
9+
#
10+
# git -c submodule.safety-tooling.url=https://github.com/safety-research/safety-tooling.git \
11+
# submodule update --init --recursive
12+
#
13+
# Or just run: bash setup.sh
14+
# Then build: docker build -t alignment-faking .
15+
#
16+
# USAGE:
17+
# # Interactive shell (fill in your real keys):
18+
# docker run --rm -it \
19+
# -e ANTHROPIC_API_KEY=sk-ant-... \
20+
# -e OPENAI_API_KEY=sk-... \
21+
# -e OPENAI_API_KEY1=sk-... \
22+
# -v "$(pwd)/outputs:/workspace/outputs" \
23+
# alignment-faking
24+
#
25+
# # Inside the container, run the pipeline:
26+
# bash experiments/examples/1_run_pipeline.sh claude-3-5-sonnet-20240620
27+
#
28+
# # Or mount a .env file instead of passing -e flags:
29+
# docker run --rm -it \
30+
# --env-file .env \
31+
# -v "$(pwd)/outputs:/workspace/outputs" \
32+
# alignment-faking
33+
34+
FROM python:3.11-slim-bookworm
35+
36+
# ── System dependencies ─────────────────────────────────────────────────────
37+
# ffmpeg : audio processing via pydub (FP-8)
38+
# git : submodule operations and huggingface-hub downloads
39+
# curl : uv installer
40+
# libgl1 : OpenCV (opencv-python) runtime dependency
41+
# libglib2.0-0: OpenCV runtime dependency
42+
RUN apt-get update && apt-get install -y --no-install-recommends \
43+
ffmpeg \
44+
git \
45+
curl \
46+
libgl1 \
47+
libglib2.0-0 \
48+
&& rm -rf /var/lib/apt/lists/*
49+
50+
# ── uv ─────────────────────────────────────────────────────────────────────
51+
# Install uv and add to PATH directly (FP-2: the 'source ~/.local/bin/env'
52+
# trick in the README does not work; we use export PATH instead).
53+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
54+
ENV PATH="/root/.local/bin:$PATH"
55+
56+
# ── Application code ────────────────────────────────────────────────────────
57+
WORKDIR /workspace
58+
59+
# Copy repository (the safety-tooling submodule must already be present
60+
# in your local checkout — see prerequisites above).
61+
COPY . .
62+
63+
# ── Python environment ──────────────────────────────────────────────────────
64+
# Create a venv at /workspace/.venv (FP-7: venv lives at repo root).
65+
RUN uv venv --python 3.11 .venv
66+
67+
# Activate venv for subsequent RUN commands.
68+
ENV VIRTUAL_ENV="/workspace/.venv"
69+
ENV PATH="/workspace/.venv/bin:$PATH"
70+
71+
# Install safety-tooling (editable) then repo requirements.
72+
RUN uv pip install -e safety-tooling
73+
RUN uv pip install -r requirements.txt
74+
75+
# ── Runtime environment ─────────────────────────────────────────────────────
76+
# Make src/ importable as a package.
77+
ENV PYTHONPATH="/workspace"
78+
79+
# API keys should be passed at runtime via --env-file or -e flags, never baked in.
80+
# The pipeline crashes if OPENAI_API_KEY is unset (FP-3); see .env.example for details.
81+
82+
# Default: drop into an interactive bash shell so the researcher can run
83+
# whichever experiment they need.
84+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)