You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Conformal Policy Control
2
2
3
-
Code for ["Conformal Policy Control"](https://arxiv.org/abs/2603.02196) (ICML 2026 spotlight paper): a framework for enabling AI agents to automatically determine their own "zone of competence," where we can guarantee their behavior will respect a user's risk tolerance, $\alpha$.
3
+
Code for ["Conformal Policy Control"](https://arxiv.org/abs/2603.02196) (ICML 2026 spotlight paper): a framework for enabling AI agents to automatically determine their own "zone of competence," where we can place guarantees on their behavior respecting a user's risk tolerance, $\alpha$.
4
4
5
5
By Drew Prinster, Clara Fannjiang, Ji Won Park, Kyunghyun Cho, Anqi Liu, Suchi Saria, and Samuel Stanton.
6
6
@@ -18,26 +18,28 @@ If you use this code, please our paper:
18
18
19
19
## Overview
20
20
21
-
This project develops **Conformal Policy Control (CPC)**: a method for iteratively improving a language model policy while maintaining formal guarantees on the risk (e.g., rate of infeasible or unsafe outputs) over time. The key idea is to constrain each optimized policy's likelihood ratios relative to a safe reference policy, with the constraint level calibrated via conformal prediction so that risk stays below a user-specified levelalpha.
21
+
This project develops **Conformal Policy Control (CPC)**: a method for iteratively improving a language model policy while maintaining formal guarantees on the risk (e.g., rate of infeasible or unsafe outputs) over time. The key idea is to constrain each optimized policy's likelihood ratios relative to a safe reference policy, with the constraint level calibrated via CPC so that risk stays below a user-specified level, $\alpha$.
22
22
23
23

24
24
25
25
The repository contains four sets of experiments:
26
26
27
-
-**`cpc_llm/`** : The main CPC pipeline for LLMs, applied to the Ehrlich function protein discovery task ([Chen, et al. 2025](https://arxiv.org/abs/2410.22296)). Pre-trains a LM on data from a genetic algorithm, then iteratively generates and scores new samples, trains optimized policies (SFT, DPO, or MARGE), and uses CPC to ensure the improved policies satisfy safety constraints.
28
-
-**`cbo/`** : Constrained Bayesian optimization experiments (in paper appendix). Compares CPC to classic conservative optimization. Simplest initial entrypoint to CPC, runs on single CPU.
27
+
-**`cpc_llm/`** : **The main CPC pipeline for LLMs**, applied to the Ehrlich function synthetic protein discovery task ([Chen, et al. 2025](https://arxiv.org/abs/2410.22296)). Pre-trains a language model on data from a genetic algorithm, then iteratively generates and scores new samples, trains optimized policies (SFT, DPO, or MARGE), and uses CPC to ensure the improved policies satisfy safety constraints.
28
+
-**`cbo/`** : Constrained Bayesian optimization experiments (in paper appendix). Compares CPC to classic conservative optimization. **This is a more accessible initial entrypoint to CPC code (runs on a single CPU).**
29
29
-**`constrained_AL/`** : CPC constrained active learning with Gaussian process surrogates, applied to tabular regression benchmarks.
30
30
-**`QA_expts/`** : Generalized conformal risk control (gCRC) for LLM factuality, controlling false discovery rate (a non-monotonic loss) on medical QA dataset of GPT-3.5-Turbo responses.
31
31
32
32
## Setup
33
33
34
34
Requires Python >= 3.10 and [uv](https://docs.astral.sh/uv/).
35
35
36
+
To install all dependencies (including the `cpc-llm` package in editable mode) and dev tools (pytest), and then activate the environment, run
37
+
36
38
```bash
37
39
uv sync --group dev
38
-
```
39
40
40
-
This installs all dependencies (including the `cpc-llm` package in editable mode) and dev tools (pytest).
|`num_sft_rounds` / `num_dpo_rounds` / `num_marge_rounds`| Number of training iterations per method |
70
+
|`initial_seed` / `last_seed`| Initial / last random seeds (inclusive) to run in loop for repeat trials |
65
71
|`parent_output_dir`| S3 path for outputs (set to `null` for local-only) |
66
72
|`local_output_dir`| Local path for outputs and model checkpoints |
67
73
68
74
### Important notes
69
75
70
76
-**Storage**: The pipeline supports both local and S3 storage. Model checkpoints are copied to S3 and deleted locally after training. Set `parent_output_dir: "null"` to disable S3.
71
-
-**SLURM**: Training, generation, and scoring jobs are launched as SLURM jobs. Configure via `slurm_args` sections in the config.
77
+
-**SLURM**: Training, generation, and scoring jobs are launched as their own SLURM jobs. Configure via `slurm_args` sections in the config.
72
78
-**Resuming**: The pipeline automatically resumes prior runs if launched with the same config. Use `--overwrite=True` to start fresh.
73
79
-**GPU requirements**: Training uses DDP (single-node multi-GPU). You need ~4x the model size in GPU RAM for full-precision training.
74
80
@@ -94,6 +100,7 @@ cpc_llm/ # Main CPC-LLM package (installable)
-**DPO scoring for infeasible prompt sequences**: `DPOTrainerWithLogging` does not count a prompt→response transition from infeasible to feasible as a score improvement, which makes DPO training more permissive of infeasible outputs than originally intended. This does not invalidate the paper's experiments (its main effect is increasing the risk of the unconstrained policy), so it is kept as-is for reproducibility. See the full explanation in [`pref_tuning_trainer.py`](cpc_llm/src/cpc_llm/train/pref_tuning_trainer.py#L123-L141).
0 commit comments