Instructions to use kabing/gpt2-medium-cbctg-prior with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kabing/gpt2-medium-cbctg-prior with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- README.md +96 -0
- acd/best_lora_adapter.pt +3 -0
- acd/config.json +59 -0
- acd/full_model_best.pt +3 -0
- acd/label_prior.pt +3 -0
- acd/label_prior_factorized.pt +3 -0
- hold-out/best_lora_adapter.pt +3 -0
- hold-out/config.json +59 -0
- hold-out/full_model_best.pt +3 -0
- hold-out/label_prior.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model: gpt2-medium
|
| 4 |
+
tags:
|
| 5 |
+
- controllable-text-generation
|
| 6 |
+
- concept-bottleneck
|
| 7 |
+
- compositional-generalization
|
| 8 |
+
- lora
|
| 9 |
+
library_name: peft
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# gpt2-medium-cbctg-prior
|
| 13 |
+
|
| 14 |
+
Concept-bottleneck controllable-generation modules for **GPT-2 Medium (355M)**, from
|
| 15 |
+
the paper "The Illusion of Control: Why Bare Classifier Inversion Silently Fails in Concept-Bottleneck Text Generation" (EMNLP 2026).
|
| 16 |
+
|
| 17 |
+
Matched-backbone comparison against the CompMCTG baselines (Section 7.1), all of which use GPT-2-Medium. Reported over three training seeds.
|
| 18 |
+
|
| 19 |
+
This repository contains **only our own trained parameters**: the per-axis
|
| 20 |
+
concept encoder MLPs, the per-axis classifier heads, the concept injector,
|
| 21 |
+
the LoRA adapter, and the post-hoc label prior. No base-model weights are
|
| 22 |
+
included; download **[gpt2-medium](https://huggingface.co/gpt2-medium)** separately.
|
| 23 |
+
|
| 24 |
+
## Contents
|
| 25 |
+
|
| 26 |
+
Each split directory holds one trained checkpoint.
|
| 27 |
+
|
| 28 |
+
| Path | Description |
|
| 29 |
+
|---|---|
|
| 30 |
+
| `hold-out/` | Fyelp Hold-Out idx=-0 split (39 seen / 1 unseen configuration) |
|
| 31 |
+
| `acd/` | Fyelp ACD split (half of all configurations held out) |
|
| 32 |
+
|
| 33 |
+
Within each split directory:
|
| 34 |
+
|
| 35 |
+
| File | Description |
|
| 36 |
+
|---|---|
|
| 37 |
+
| `config.json` | Architecture and training configuration |
|
| 38 |
+
| `full_model_best.pt` | Concept encoder MLPs, classifier heads, injector, internal prior |
|
| 39 |
+
| `best_lora_adapter.pt` | LoRA adapter weights (rank 8, alpha 16); optimiser state stripped |
|
| 40 |
+
| `label_prior.pt` | Post-hoc label-conditioned prior $g_\gamma$ (the paper's recommended z-source) |
|
| 41 |
+
| `retrieval_prior.pt` | Nearest-seen-configuration retrieval baseline (Appendix L), where available |
|
| 42 |
+
| `label_prior_flow.pt` | Conditional normalising-flow baseline (Appendix K), where available |
|
| 43 |
+
| `label_prior_factorized.pt` | Factorised per-axis prior (Appendix N), where available |
|
| 44 |
+
| `clsinv_reg_*.pt` | Manifold-regulariser statistics for the inversion sweeps (Appendix I), where available |
|
| 45 |
+
|
| 46 |
+
## Architecture
|
| 47 |
+
|
| 48 |
+
- **Concept code**: 4 axes (cuisine, gender, sentiment, tense), 32 dimensions per axis
|
| 49 |
+
- **Injector**: AdaLN-zero, injected at every block
|
| 50 |
+
- **Generator**: GPT-2 Medium (355M) with LoRA (rank 8, alpha 16) on the attention projections
|
| 51 |
+
- **Prior** $g_\gamma$: one hidden layer, 128 GELU units, fitted post-hoc in under 30 seconds
|
| 52 |
+
|
| 53 |
+
## Usage
|
| 54 |
+
|
| 55 |
+
Clone the code repository and point the generation script at a downloaded
|
| 56 |
+
checkpoint directory:
|
| 57 |
+
|
| 58 |
+
```bash
|
| 59 |
+
git clone https://github.com/BiancaBing/cbctg-illusion-of-control
|
| 60 |
+
cd cbctg-illusion-of-control
|
| 61 |
+
|
| 62 |
+
huggingface-cli download kabing/gpt2-medium-cbctg-prior --local-dir ckpt/gpt2-medium-cbctg-prior
|
| 63 |
+
|
| 64 |
+
python evaluation/generate_v3.py \
|
| 65 |
+
--checkpoint ckpt/gpt2-medium-cbctg-prior/hold-out/full_model_best.pt \
|
| 66 |
+
--data_dir data/fyelp_hold-out_idx0_4ax \
|
| 67 |
+
--output_dir out/ \
|
| 68 |
+
--model_name gpt2-medium-cbctg-prior_prior \
|
| 69 |
+
--z_source prior \
|
| 70 |
+
--prior_path ckpt/gpt2-medium-cbctg-prior/hold-out/label_prior.pt
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Swap `--z_source prior` for `oracle` (reference-text encoding) or `mode_b`
|
| 74 |
+
(classifier inversion) to reproduce the other two protocols compared in the
|
| 75 |
+
paper. Full reproduction instructions are in the code repository.
|
| 76 |
+
|
| 77 |
+
## Licence
|
| 78 |
+
|
| 79 |
+
GPT-2 Medium is released under the MIT License.
|
| 80 |
+
|
| 81 |
+
Our released parameters (encoder MLPs, classifier heads, injector, LoRA
|
| 82 |
+
adapter, label prior) are made available for research use under the same
|
| 83 |
+
terms as the corresponding base model.
|
| 84 |
+
|
| 85 |
+
## Citation
|
| 86 |
+
|
| 87 |
+
```bibtex
|
| 88 |
+
@inproceedings{bing2026illusion,
|
| 89 |
+
title = {The Illusion of Control: Why Bare Classifier Inversion
|
| 90 |
+
Silently Fails in Concept-Bottleneck Text Generation},
|
| 91 |
+
author = {Bing, Qi and Shao, Xiaowei},
|
| 92 |
+
booktitle = {Proceedings of the 2026 Conference on Empirical Methods in
|
| 93 |
+
Natural Language Processing (EMNLP)},
|
| 94 |
+
year = {2026}
|
| 95 |
+
}
|
| 96 |
+
```
|
acd/best_lora_adapter.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb0661db0a1fcf6a095d6728c416117e8cbff974617a86017eff834a6ca86577
|
| 3 |
+
size 1590414
|
acd/config.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backbone": "gpt2-medium",
|
| 3 |
+
"dataset": "fyelp_acd_idx0_4ax_full",
|
| 4 |
+
"data_dir": "E:\\research\\cbm\\project\\data\\fyelp_acd_idx0_4ax_full",
|
| 5 |
+
"axis_names": [
|
| 6 |
+
"cuisine",
|
| 7 |
+
"gender",
|
| 8 |
+
"sentiment",
|
| 9 |
+
"tense"
|
| 10 |
+
],
|
| 11 |
+
"num_axes": 4,
|
| 12 |
+
"num_classes_per_axis": 5,
|
| 13 |
+
"concept_dim": 32,
|
| 14 |
+
"epochs": 25,
|
| 15 |
+
"batch_size": 16,
|
| 16 |
+
"lr": 5e-05,
|
| 17 |
+
"lora_lr": 2e-05,
|
| 18 |
+
"lora_rank": 8,
|
| 19 |
+
"lora_alpha": 16,
|
| 20 |
+
"noise_sigma": 0.01,
|
| 21 |
+
"gen_warmup_epochs": 10,
|
| 22 |
+
"scheduler": "cosine",
|
| 23 |
+
"grad_clip": 1.0,
|
| 24 |
+
"per_axis_injection": false,
|
| 25 |
+
"injection_scale": 1.0,
|
| 26 |
+
"inject_every_n": 1,
|
| 27 |
+
"gate_init": 0.0,
|
| 28 |
+
"injector_type": "adaln",
|
| 29 |
+
"quantize": false,
|
| 30 |
+
"bf16": true,
|
| 31 |
+
"fp32_small_modules": true,
|
| 32 |
+
"max_seq_len": 128,
|
| 33 |
+
"seed": 42,
|
| 34 |
+
"device": "cuda:0",
|
| 35 |
+
"run_timestamp": "20260515_171809",
|
| 36 |
+
"run_name": "gpt2-medium__fyelp_acd_idx0_4ax_full__adaln-e1__4axis__e25_s42_20260515_171809",
|
| 37 |
+
"label_maps": {
|
| 38 |
+
"cuisine": {
|
| 39 |
+
"american": 0,
|
| 40 |
+
"asian": 1,
|
| 41 |
+
"bar": 2,
|
| 42 |
+
"dessert": 3,
|
| 43 |
+
"mexican": 4
|
| 44 |
+
},
|
| 45 |
+
"gender": {
|
| 46 |
+
"female": 0,
|
| 47 |
+
"male": 1
|
| 48 |
+
},
|
| 49 |
+
"sentiment": {
|
| 50 |
+
"negative": 0,
|
| 51 |
+
"positive": 1
|
| 52 |
+
},
|
| 53 |
+
"tense": {
|
| 54 |
+
"past": 0,
|
| 55 |
+
"present": 1
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
"lambda3_final": 0.5
|
| 59 |
+
}
|
acd/full_model_best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a99899d3995ef5260720f16e5347a8718b9bdcc63432666373fc84065189d206
|
| 3 |
+
size 229275784
|
acd/label_prior.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51a1717c5f7d5cb68076888405ae6fc4a8ab51330d13d7ac187165377d18d7ee
|
| 3 |
+
size 75056
|
acd/label_prior_factorized.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e98bb08db1262a58248d24b3c5d21acc2ce27b1592604172a3b19db87c769c47
|
| 3 |
+
size 32726
|
hold-out/best_lora_adapter.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:18a02db8f1167e6df129710421eccf6a5d2e3507c36a9d629ed463ff5342f079
|
| 3 |
+
size 1590414
|
hold-out/config.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backbone": "gpt2-medium",
|
| 3 |
+
"dataset": "fyelp_hold-out_idx0_4ax_full",
|
| 4 |
+
"data_dir": "E:\\research\\cbm\\project\\data\\fyelp_hold-out_idx0_4ax_full",
|
| 5 |
+
"axis_names": [
|
| 6 |
+
"cuisine",
|
| 7 |
+
"gender",
|
| 8 |
+
"sentiment",
|
| 9 |
+
"tense"
|
| 10 |
+
],
|
| 11 |
+
"num_axes": 4,
|
| 12 |
+
"num_classes_per_axis": 5,
|
| 13 |
+
"concept_dim": 32,
|
| 14 |
+
"epochs": 25,
|
| 15 |
+
"batch_size": 16,
|
| 16 |
+
"lr": 5e-05,
|
| 17 |
+
"lora_lr": 2e-05,
|
| 18 |
+
"lora_rank": 8,
|
| 19 |
+
"lora_alpha": 16,
|
| 20 |
+
"noise_sigma": 0.01,
|
| 21 |
+
"gen_warmup_epochs": 10,
|
| 22 |
+
"scheduler": "cosine",
|
| 23 |
+
"grad_clip": 1.0,
|
| 24 |
+
"per_axis_injection": false,
|
| 25 |
+
"injection_scale": 1.0,
|
| 26 |
+
"inject_every_n": 1,
|
| 27 |
+
"gate_init": 0.0,
|
| 28 |
+
"injector_type": "adaln",
|
| 29 |
+
"quantize": false,
|
| 30 |
+
"bf16": true,
|
| 31 |
+
"fp32_small_modules": true,
|
| 32 |
+
"max_seq_len": 128,
|
| 33 |
+
"seed": 42,
|
| 34 |
+
"device": "cuda:0",
|
| 35 |
+
"run_timestamp": "20260515_214922",
|
| 36 |
+
"run_name": "gpt2-medium__fyelp_hold-out_idx0_4ax_full__adaln-e1__4axis__e25_s42_20260515_214922",
|
| 37 |
+
"label_maps": {
|
| 38 |
+
"cuisine": {
|
| 39 |
+
"american": 0,
|
| 40 |
+
"asian": 1,
|
| 41 |
+
"bar": 2,
|
| 42 |
+
"dessert": 3,
|
| 43 |
+
"mexican": 4
|
| 44 |
+
},
|
| 45 |
+
"gender": {
|
| 46 |
+
"female": 0,
|
| 47 |
+
"male": 1
|
| 48 |
+
},
|
| 49 |
+
"sentiment": {
|
| 50 |
+
"negative": 0,
|
| 51 |
+
"positive": 1
|
| 52 |
+
},
|
| 53 |
+
"tense": {
|
| 54 |
+
"past": 0,
|
| 55 |
+
"present": 1
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
"lambda3_final": 0.5
|
| 59 |
+
}
|
hold-out/full_model_best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f5dc5c3a1bc774532f2395d3e5632b539034fac1688e6fdfac071223c241b7c2
|
| 3 |
+
size 229275784
|
hold-out/label_prior.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54a1b8fa8c01474eee2785f960f8d471e2301ee9095430663165fe028a794e42
|
| 3 |
+
size 75120
|