etomoscow commited on
Commit
d9e54c0
·
verified ·
1 Parent(s): 8d42f90

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -126
README.md CHANGED
@@ -1,199 +1,164 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
 
12
  ## Model Details
13
 
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
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
  ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
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
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
 
 
45
 
46
  ### Downstream Use [optional]
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
- [More Information Needed]
75
 
76
- ## Training Details
 
77
 
78
- ### Training Data
 
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
 
 
 
83
 
84
- ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
 
90
- [More Information Needed]
91
 
 
92
 
93
  #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
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
- <!-- This section describes the evaluation protocols and provides the results. -->
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
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
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
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
 
 
 
 
 
 
 
 
 
134
 
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
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
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  **APA:**
180
-
181
- [More Information Needed]
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
+ license: openrail++
4
+ datasets:
5
+ - s-nlp/pseudoparadetox_llama3_70b_10shot_noabl
6
+ language:
7
+ - en
8
+ base_model:
9
+ - facebook/bart-large
10
+ pipeline_tag: text-generation
11
  ---
12
 
13
+ # Model Card for s-nlp/bart-large-pseudoparadetox-llama3-70b-10shot
 
 
 
 
14
 
15
  ## Model Details
16
 
17
+ This model is a BART-large sequence-to-sequence model fine-tuned for **English Text Detoxification** (style transfer from toxic to neutral). It was trained on the **PseudoParaDetox** dataset, which was synthetically generated using the Llama 3 70B Instruct LLM in a 10-shot setting, leveraging Activation Patching to bypass safety alignment during the data generation phase.
 
 
18
 
19
+ The resulting detoxification model demonstrates high fluency and content preservation scores, outperforming models trained on the original human-annotated ParaDetox dataset in manual human evaluation.
20
 
21
+ - **Developed by:** Daniil Moskovskiy, Sergey Pletenev, and Alexander Panchenko
22
+ - **Model type:** Encoder-Decoder (BART-large)
23
+ - **Language(s) (NLP):** English (en)
24
+ - **License:** OpenRAIL++
25
+ - **Finetuned from model:** `facebook/bart-large`
 
 
26
 
27
  ### Model Sources [optional]
28
 
29
+ - **Repository (Code & Data):** [https://github.com/s-nlp/pseudoparadetox](https://github.com/s-nlp/pseudoparadetox)
30
+ - **Paper:** "LLMs to Replace Crowdsourcing For Parallel Data Creation? The Case of Text Detoxification" (Moskovskiy, Pletenev, \& Panchenko, EMNLP XXXX)
 
 
 
31
 
32
  ## Uses
33
 
 
 
34
  ### Direct Use
35
 
36
+ The model is intended for the automatic rewriting of toxic, offensive, or rude English input text into a polite or neutral tone, while maintaining the original semantic meaning and fluency.
37
 
38
+ * Filtering text for online forums or social media.
39
+ * Enabling polite response generation in conversational agents.
40
+ * Assisting users in editing drafted messages to be more respectful.
41
 
42
  ### Downstream Use [optional]
43
 
44
+ This model can be integrated into larger content moderation pipelines, specifically handling the mitigation step after toxicity detection.
 
 
45
 
46
  ### Out-of-Scope Use
47
 
48
+ The model is trained strictly for English detoxification. It should not be used for:
49
 
50
+ * Generating original, creative content (it is a rewriting model).
51
+ * Detoxification in languages other than English.
52
+ * Censoring legitimate political or critical commentary that does not violate toxicity guidelines (though this is a risk inherent to all detoxification systems).
53
 
54
  ## Bias, Risks, and Limitations
55
 
56
+ This model inherits typical limitations of text style transfer models:
57
 
58
+ * **Semantic Loss (Over-Sanitization):** In attempts to fully remove toxicity, the model may sometimes alter or dilute the core meaning of the original statement, especially when dealing with complex or subtle insults.
59
+ * **Inherent Bias:** The base BART model and the LLM used for data generation (Llama 3) carry pre-existing biases, which may manifest as inconsistent detoxification quality across different demographics or topics.
60
+ * **Data Generation Risk:** The training data was created using an Activation Patching technique to bypass the Llama 3's safety alignment. While this was necessary for generating high-quality parallel data, users should be aware that the training data distribution might reflect content that human annotators typically refuse to handle.
61
 
62
  ### Recommendations
63
 
64
+ We recommend systematic testing on new domain data before deployment. Users should implement a post-processing toxicity classifier to confirm that the detoxified output is truly non-toxic, as detoxification is not guaranteed in 100% of cases.
 
 
65
 
66
  ## How to Get Started with the Model
67
 
68
+ Use the code below to get started with the model:
 
 
69
 
70
+ ```python
71
+ from transformers import pipeline
72
 
73
+ # Note: Replace 'Model ID' with the actual Hugging Face path once available
74
+ detoxifier = pipeline("text2text-generation", model="s-nlp/bart-large-pseudoparadetox-llama3-70b-10shot")
75
 
76
+ toxic_text = "You are dumb idiot!"
77
 
78
+ result = detoxifier(toxic_text, max_length=128)
79
+ print(result[0]['generated_text'])
80
+ # Expected Output: You are wrong! (or similar neutral rewrite)
81
+ ```
82
 
83
+ ## Training Details
84
 
85
+ ### Training Data
86
 
87
+ The model was fine-tuned on **PseudoParaDetox**, a synthetic dataset generated by the Llama 3 70B Instruct model. The source texts were derived from the toxic side of the **ParaDetox** corpus. The generation utilized a 10-shot prompt setup to guide the LLM's rewriting process. This generation was facilitated by an Activation Patching technique to prevent the LLM from refusing to generate detoxified output for highly toxic inputs.
88
 
89
+ ### Training Procedure
90
 
91
+ The BART-large model was fine-tuned using the following key parameters:
92
 
93
  #### Training Hyperparameters
94
 
95
+ - **Optimizer:** AdamW
96
+ - **Learning Rate:** 0.00005
97
+ - **Batch Size:** 32 (with 1 gradient accumulation step)
98
+ - **Epochs:** 5
99
+ - **Precision:** bfloat16
 
 
100
 
101
  ## Evaluation
102
 
103
+ The final model performance was assessed using a combination of automatic metrics (on the ParaDetox test set) and side-by-side comparisons using GPT-4o, followed by manual human evaluation.
104
 
105
  ### Testing Data, Factors & Metrics
106
 
107
  #### Testing Data
108
 
109
+ ParaDetox private test split (671 texts).
 
 
 
 
 
 
 
 
110
 
111
  #### Metrics
112
 
113
+ * **Style Transfer Accuracy (STA)**: Measured by a RoBERTa-based toxicity [classifier](https://huggingface.co/s-nlp/roberta_first_toxicity_classifier). (Higher is better, reflecting successful toxicity removal.)
114
+ * **Semantic Similarity (SIM)**: Measured by [BLEURT score](https://huggingface.co/Elron/bleurt-large-512) between the original and detoxified text.
115
+ * **Fluency (FL)**: Measured by a RoBERTa-based linguistic acceptability [classifier](https://huggingface.co/cointegrated/roberta-large-cola-krishna2020) (CoLA-trained).
116
+ * **Joint Score (J)**: The geometric mean of STA, SIM, and FL.
117
 
118
  ### Results
119
 
120
+ The results below reflect the performance of BART fine-tuned on the Llama 3 70B A.P. 10-shot data, compared against the baseline BART trained on the original human-annotated ParaDetox data.
 
 
 
121
 
122
+ | Metric | BART (Original ParaDetox) | BART (PseudoParaDetox 70B AP 10-shot) |
123
+ | :--- | :--- | :--- |
124
+ | **STA (Auto)** | 0.876 | 0.842 |
125
+ | **SIM (Auto)** | 0.616 | 0.594 |
126
+ | **FL (Auto)** | 0.824 | 0.866 |
127
+ | **Joint Score (J)** | 0.444 | 0.434 |
128
+ | **Manual J Score** | 0.661 | **0.762** |
129
+ | **GPT-4o Win Rate vs. Baseline** | - | **65\%** |
130
 
131
+ #### Summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
+ While automatic metrics show comparable performance, the superior Manual Joint Score (J=0.762) and high GPT-4o side-by-side win rate (65\%) indicate that the data generated using the patched LLM results in subjectively higher-quality detoxification compared to the original crowdsourced data.
134
 
135
  ## Citation [optional]
136
 
 
 
137
  **BibTeX:**
138
+ ```bibtex
139
+ @inproceedings{moskovskiy-etal-2024-llms,
140
+ title = "{LLM}s to Replace Crowdsourcing For Parallel Data Creation? The Case of Text Detoxification",
141
+ author = "Moskovskiy, Daniil and
142
+ Pletenev, Sergey and
143
+ Panchenko, Alexander",
144
+ editor = "Al-Onaizan, Yaser and
145
+ Bansal, Mohit and
146
+ Chen, Yun-Nung",
147
+ booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2024",
148
+ month = nov,
149
+ year = "2024",
150
+ address = "Miami, Florida, USA",
151
+ publisher = "Association for Computational Linguistics",
152
+ url = "https://aclanthology.org/2024.findings-emnlp.839/",
153
+ doi = "10.18653/v1/2024.findings-emnlp.839",
154
+ pages = "14361--14373",
155
+ abstract = "The lack of high-quality training data remains a significant challenge in NLP. Manual annotation methods, such as crowdsourcing, are costly, require intricate task design skills, and, if used incorrectly, may result in poor data quality. From the other hand, LLMs have demonstrated proficiency in many NLP tasks, including zero-shot and few-shot data annotation. However, they often struggle with text detoxification due to alignment constraints and fail to generate the required detoxified text. This work explores the potential of modern open source LLMs to annotate parallel data for text detoxification. Using the recent technique of activation patching, we generate a pseudo-parallel detoxification dataset based on ParaDetox. The detoxification model trained on our generated data shows comparable performance to the original dataset in automatic detoxification evaluation metrics and superior quality in manual evaluation and side-by-side comparisons."
156
+ }
157
+ ```
158
 
159
  **APA:**
160
+ Moskovskiy, D., Pletenev, S., & Panchenko, A. (2024, November). Llms to replace crowdsourcing for parallel data creation? the case of text detoxification. In Findings of the Association for Computational Linguistics: EMNLP 2024 (pp. 14361-14373).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
  ## Model Card Contact
163
 
164
+ [https://huggingface.co/etomoscow]