Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,159 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# Model Card
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
| 19 |
|
| 20 |
-
- **Developed by:** [More Information Needed]
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
|
| 32 |
-
- **
|
| 33 |
-
- **
|
| 34 |
-
- **
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
### Direct Use
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
Use the code below to get started with the model.
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
[More Information Needed]
|
| 83 |
|
| 84 |
-
### Training Procedure
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
|
|
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
|
| 95 |
-
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
|
| 101 |
-
[More Information Needed]
|
| 102 |
|
| 103 |
## Evaluation
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
|
| 127 |
### Results
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
|
| 175 |
**BibTeX:**
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
**APA:**
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- generation
|
| 5 |
+
- safety
|
| 6 |
+
- model-editing
|
| 7 |
+
- editing
|
| 8 |
+
- activation-steering
|
| 9 |
+
- activation-editing
|
| 10 |
+
- dpo
|
| 11 |
+
- rlhf
|
| 12 |
+
- profs
|
| 13 |
+
- detox
|
| 14 |
+
- toxicity
|
| 15 |
+
- iclr
|
| 16 |
+
- iclr2025
|
| 17 |
+
license: mit
|
| 18 |
+
language:
|
| 19 |
+
- en
|
| 20 |
+
base_model:
|
| 21 |
+
- facebook/opt-6.7b
|
| 22 |
---
|
| 23 |
|
| 24 |
+
# Model Card
|
| 25 |
|
| 26 |
+
This model accompanies the paper [Model Editing as a Robust and Denoised Variant of DPO: A Case Study on Toxicity](https://arxiv.org/abs/2405.13967)
|
| 27 |
+
published at ICLR 2025 (previously released under the preprint title “DeTox: Toxic Subspace Projection for Model Editing”; both refer to the same work).
|
| 28 |
|
| 29 |
+
ProFS (Projection Filter for Subspaces) is a tuning-free alignment method that removes undesired behaviors—such as toxicity—by identifying and projecting out harmful subspaces in model weights.
|
| 30 |
|
| 31 |
+
**Key Features:**
|
| 32 |
|
| 33 |
+
- Training-free & plug-and-play: edits weights directly, no gradient steps or architectural changes needed.
|
| 34 |
+
- Data-efficient: achieves strong alignment effects using only hundreds (not thousands) of preference pairs.
|
| 35 |
+
- Label-robust: maintains performance even under substantial label noise, since projection directions remain stable.
|
| 36 |
+
- Fast & lightweight: produces an edited model that runs at the same inference speed as the base model.
|
| 37 |
+
- Theoretically grounded: shown to be a denoised, single-step approximation of Direct Preference Optimization (DPO)—bridging editing-based and tuning-based alignment.
|
| 38 |
|
| 39 |
+
<div align="center">
|
| 40 |
+
<img src="https://github.com/Uppaal/detox-edit/blob/main/ProFS Method.png" width="450"/>
|
| 41 |
+
<i><b>Figure.</b> Schematic of ProFS (previously called DeTox). Toxic directions (in red) are projected out of the model’s MLP-value matrices, leaving other representational directions intact. </i>
|
| 42 |
+
</div>
|
| 43 |
|
|
|
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
## Model Details
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
- **Model type:** Edited Causal Language Model (LLM)
|
| 49 |
+
- **Base model:** [`facebook/opt-6.7b`](https://huggingface.co/facebook/opt-6.7b)
|
| 50 |
+
- **Language(s) (NLP):** English
|
| 51 |
+
- **License:** MIT
|
| 52 |
+
- **Repository:** [GitHub](https://github.com/Uppaal/detox-edit)
|
| 53 |
+
- **Paper:** [Model Editing as a Robust and Denoised variant of DPO: A Case Study on Toxicity](https://arxiv.org/abs/2405.13967)
|
| 54 |
|
| 55 |
## Uses
|
| 56 |
|
|
|
|
|
|
|
| 57 |
### Direct Use
|
| 58 |
+
ProFS-edited GPT-2 can be used for:
|
| 59 |
+
- Safe text generation and alignment research
|
| 60 |
+
- Studying lightweight alignment via model editing rather than fine-tuning
|
| 61 |
+
- Interpretability studies of activation subspaces and toxicity directions
|
| 62 |
|
| 63 |
+
### Downstream Use
|
| 64 |
+
ProFS serves as a reproducible starting point for work on:
|
| 65 |
+
- Safety alignment without gradient updates
|
| 66 |
+
- Robustness to label noise and limited data regimes
|
| 67 |
+
- Educational demonstrations of representation-level interventions
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
### Out-of-Scope Use
|
| 70 |
+
Not a fully aligned conversational model.
|
| 71 |
+
Not evaluated for fairness or demographic bias beyond toxicity.
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
## How to Get Started with the Model
|
| 76 |
|
| 77 |
Use the code below to get started with the model.
|
| 78 |
|
| 79 |
+
```
|
| 80 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 81 |
+
model_id = "Uppaal/opt-6.7b-ProFS-toxicity"
|
| 82 |
|
| 83 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 84 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 85 |
|
| 86 |
+
prompt = "The internet has changed the way people communicate by"
|
| 87 |
+
out = model.generate(**tokenizer(prompt, return_tensors="pt"), max_new_tokens=20)
|
| 88 |
+
print(tokenizer.decode(out[0], skip_special_tokens=True))
|
| 89 |
+
```
|
| 90 |
|
|
|
|
| 91 |
|
|
|
|
| 92 |
|
| 93 |
+
## Training (Editing) Details
|
| 94 |
|
| 95 |
+
### Data
|
| 96 |
+
We use the pairwise toxicity preference dataset introduced by [Lee et al. (2024)](https://arxiv.org/abs/2401.01967).
|
| 97 |
|
| 98 |
+
- Non-toxic sequences: sampled from WikiText-2.
|
| 99 |
+
- Toxic counterparts: generated using the Plug-and-Play Language Model (PPLM) method to inject toxic content.
|
| 100 |
+
- Data format: (toxic, non-toxic) sentence pairs.
|
| 101 |
+
- Sample size: 500 pairs for ProFS editing (compared to 2,000 pairs used for DPO fine-tuning).
|
| 102 |
|
| 103 |
+
### Preprocessing
|
| 104 |
|
| 105 |
+
No preprocessing or filtering was applied beyond tokenization by the base model tokenizer.
|
| 106 |
|
| 107 |
+
### Editing Hyperparameters
|
| 108 |
|
| 109 |
+
- Top-k singular vectors:
|
| 110 |
+
- GPT-2: k = 2
|
| 111 |
+
- Mistral, Mistral-SFT, OPT, GPT-J: k = 10
|
| 112 |
+
- Selected via ScreeNot and validated with cross-validation.
|
| 113 |
+
- Edited layers:
|
| 114 |
+
- GPT-2 / GPT-J: layers 11–24
|
| 115 |
+
- Mistral, Mistral-SFT, OPT: layers 15–L
|
| 116 |
+
- Projection step: edit applied once to the MLP-Value matrices only.
|
| 117 |
+
- Centering: mean vector of non-toxic embeddings removed before SVD to preserve syntactic knowledge.
|
| 118 |
|
|
|
|
| 119 |
|
|
|
|
| 120 |
|
| 121 |
## Evaluation
|
| 122 |
|
| 123 |
+
### Metrics and Testing Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
+
- Perplexity (fluency): evaluated on the WikiText-2 dev split.
|
| 126 |
+
- Toxicity: measured on the [Real Toxicity Prompts](https://huggingface.co/datasets/allenai/real-toxicity-prompts) challenge subset. Scored using [Detoxify](https://github.com/unitaryai/detoxify). Lower Detoxify score = lower toxicity.
|
| 127 |
+
- Capability (for larger models): zero-shot accuracy across 7 EleutherAI LM Harness tasks: BoolQ, RTE, HellaSwag, WinoGrande, ARC-Easy, ARC-Challenge, and OpenBookQA.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
### Results
|
| 130 |
+
| **Model** | **Method** | **Toxicity ↓** | **Perplexity ↓** | **Capability ↑** |
|
| 131 |
+
|:-----------|:------------|:---------------|:-----------------|:-----------------|
|
| 132 |
+
| **GPT-2 Medium** | Original | 48.00 (0.00) | 29.70 (0.00) | – |
|
| 133 |
+
| | DPO | 36.36 (0.58) | 29.86 (0.22) | – |
|
| 134 |
+
| | **ProFS** | **26.83 (0.89)** | 32.50 (0.28) | – |
|
| 135 |
+
| **Mistral 7B** | Original | 42.45 (0.00) | 7.49 (0.00) | 64.23 |
|
| 136 |
+
| | DPO | 36.42 (0.62) | 7.52 (0.26) | 65.32 |
|
| 137 |
+
| | **ProFS** | **30.40 (0.71)** | 7.99 (0.21) | 63.59 |
|
| 138 |
+
| **Mistral-SFT 7B** | Original | 33.45 (0.00) | 8.22 (0.00) | 63.59 |
|
| 139 |
+
| | DPO | 23.96 (0.50) | 8.38 (0.34) | 63.66 |
|
| 140 |
+
| | **ProFS** | **26.03 (1.25)** | 8.83 (0.57) | 63.23 |
|
| 141 |
+
| **OPT 6.7B** | Original | 46.47 (0.00) | 14.67 (0.00) | 51.57 |
|
| 142 |
+
| | DPO | 45.31 (0.74) | 14.37 (0.61) | 51.55 |
|
| 143 |
+
| | **ProFS** | **43.49 (1.38)** | 13.83 (0.46) | 51.80 |
|
| 144 |
+
| **GPT-J 6B** | Original | 45.31 (0.00) | 13.24 (0.00) | 51.92 |
|
| 145 |
+
| | DPO | 43.67 (1.11) | 13.96 (0.53) | 52.46 |
|
| 146 |
+
| | **ProFS** | **37.36 (2.28)** | 14.53 (0.30) | 52.48 |
|
| 147 |
+
## Citation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
**BibTeX:**
|
| 150 |
|
| 151 |
+
@inproceedings{uppaalmodel,
|
| 152 |
+
title={Model Editing as a Robust and Denoised variant of DPO: A Case Study on Toxicity},
|
| 153 |
+
author={Uppaal, Rheeya and Dey, Apratim and He, Yiting and Zhong, Yiqiao and Hu, Junjie},
|
| 154 |
+
booktitle={The Thirteenth International Conference on Learning Representations}
|
| 155 |
+
}
|
| 156 |
|
| 157 |
**APA:**
|
| 158 |
|
| 159 |
+
Uppaal, R., Dey, A., He, Y., Zhong, Y., & Hu, J. Model Editing as a Robust and Denoised variant of DPO: A Case Study on Toxicity. In The Thirteenth International Conference on Learning Representations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|