Locked History Actions

Diff for "DEPOTx"

Differences between revisions 11 and 18 (spanning 7 versions)
Revision 11 as of 2022-01-21 14:23:46
Size: 3629
Comment:
Revision 18 as of 2022-07-15 20:30:32
Size: 4251
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
DEPOT is a text style transfer framework for replacing vulgar expressions in Polish utterances with their non-vulgar equivalents while preserving the main characteristics of the text. The framework contains three pre-trained language models (GPT-2, GPT-3 and T-5) trained on a newly created parallel corpus of sentences containing vulgar expressions and their equivalents. The resulting models are evaluated by checking style transfer accuracy, content preservation and language quality. DEPOTx is a text style transfer framework for replacing vulgar expressions in Polish utterances with their non-vulgar equivalents while preserving the main characteristics of the text. The framework contains three pre-trained language models (GPT-2, GPT-3 and T-5) trained on a newly created parallel corpus of sentences containing vulgar expressions and their equivalents. The resulting models are evaluated by checking style transfer accuracy, content preservation and language quality.
Line 8: Line 8:
=== Download link ===

 * [[https://drive.google.com/file/d/1aG_zhzJCXikv8_dkppLu_rE48CqJC2pQ/view?usp=sharing|Archive]] (4.1 GB)

=== Contents of the archive ===

 * `data/train_corpus_raw.xlsx` – the corpus of texts, which contain vulgar expressions, their euphemistic substitutes and contexts.
 * `data/train_corpus_preprocessed.tsv` – the preprocessed parallel corpus of vulgar and non-vulgar texts used to train the models.
 * `data/evaluation_corpus.txt` – the corpus used to evaluate the models, originally published by [[https://ksiegarnia.pwn.pl/Slownik-polskich-przeklenstw-i-wulgaryzmow,917947408,p.html|Grochowski (2008)]].
 * `data/evaluation_results_sentences.tsv` – original texts and texts processed by the models.
 * `data/evaluation_results_metrics.tsv` – automatic evaluatoin results.
 * [[attachment:DEPOTx.zip|Data, scripts and examples]] (please see README file for more information)
 * [[http://mozart.ipipan.waw.pl/~cklamra/DEPOTx/models/|Models]] (GPT-2, T5-base, T5-large)
Line 40: Line 30:

== Training details ==

All models have been trained using AdamW optimizer using NVidia P100 GPU.

Following hyperparameter values have been used to fine-tune the models:

=== GPT-2 ===
 * number of epochs: 10
 * batch size: 2
 * learning rate 0.0001
 * epsilon: 1e-8
 * warmup steps: 100

=== GPT-3 ===
 * batch size: 2
 * learning rate multiplier: 0.2
 * number of epochs: 5
 * prompt loss weight: 0.1
 * weight decay: 0

=== T-5 base ===
1st step:
 * num. of epochs: 6
 * batch size: 2
 * learning rate: 0.0005
 * epsilon: 1e-8
 * warmup steps: 100

2nd step:
 * num. of epochs: 6
 * batch size: 2
 * learning rate: 0.00005
 * epsilon: 1e-8
 * warmup steps: 100

=== T-5 large ===
1st step:
 * num. of epochs: 10
 * batch size: 2
 * learning rate: 0.0001
 * epsilon: 1e-8
 * warmup steps: 100

2nd step:
 * num. of epochs: 10
 * batch size: 1
 * learning rate: 0.00002
 * epsilon: 1e-8
 * warmup steps: 100
Line 73: Line 113:
Klamra C., Wojdyga G., Żurowski S., Rosalska P., Kozłowska M., Ogrodniczuk M. (2022). ''Devulgarization of Polish Texts Using Pre-trained Language Models'' (in preparation). Klamra C., Wojdyga G., Żurowski S., Rosalska P., Kozłowska M., Ogrodniczuk M. (2022). [[https://doi.org/10.1007/978-3-031-08754-7_7|Devulgarization of Polish Texts Using Pre-trained Language Models]]. In: Groen, D., de Mulatier, C., Paszynski, M., Krzhizhanovskaya, V.V., Dongarra, J.J., Sloot, P.M.A. (eds) Computational Science – [[https://www.iccs-meeting.org/iccs2022/|ICCS 2022]]. Lecture Notes in Computer Science, vol. 13351, pp. 49--55. Springer, Cham.

Devulgarization of Polish Texts

DEPOTx is a text style transfer framework for replacing vulgar expressions in Polish utterances with their non-vulgar equivalents while preserving the main characteristics of the text. The framework contains three pre-trained language models (GPT-2, GPT-3 and T-5) trained on a newly created parallel corpus of sentences containing vulgar expressions and their equivalents. The resulting models are evaluated by checking style transfer accuracy, content preservation and language quality.

Download

Requirements

Required packages can be installed by running:

pip3 install -r requirements.txt

Additionally, in order to run evaluation scripts, please install Przetak and update the value of the GOPATH variable in evaluation/__init__.py file.

Usage

The notebooks/ directory contains examples of inference and evaluation.

Evaluation might be run from the command line:

python3 -m evaluation -o <original texts> -t <transfered texts>

Training details

All models have been trained using AdamW optimizer using NVidia P100 GPU.

Following hyperparameter values have been used to fine-tune the models:

GPT-2

  • number of epochs: 10
  • batch size: 2
  • learning rate 0.0001
  • epsilon: 1e-8
  • warmup steps: 100

GPT-3

  • batch size: 2
  • learning rate multiplier: 0.2
  • number of epochs: 5
  • prompt loss weight: 0.1
  • weight decay: 0

T-5 base

1st step:

  • num. of epochs: 6
  • batch size: 2
  • learning rate: 0.0005
  • epsilon: 1e-8
  • warmup steps: 100

2nd step:

  • num. of epochs: 6
  • batch size: 2
  • learning rate: 0.00005
  • epsilon: 1e-8
  • warmup steps: 100

T-5 large

1st step:

  • num. of epochs: 10
  • batch size: 2
  • learning rate: 0.0001
  • epsilon: 1e-8
  • warmup steps: 100

2nd step:

  • num. of epochs: 10
  • batch size: 1
  • learning rate: 0.00002
  • epsilon: 1e-8
  • warmup steps: 100

Evaluation

The performance of the models was assessed in three categories using automatic metrics.

  • Style transfer accuracy (STA) was assessed using Przetak

  • Preservation of the content: cosine similarity (CS, sentence embeddings were obtained using SBERT), word overlap (WO) and BLEU

  • Language quality: perplexity (PPL) using papuGaPT-2

Models were evaluated against two baselines:

  • Duplicate: a direct copy of the original text

  • Delete: letters of words recognized by Przetak as vulgar were replaced with asterisks (except for their the first letter)

Overall performance of the models was assessed using geometric mean of CS, STA and PPL scores.

Results

Method

STA

CS

WO

BLEU

PPL

GM

Duplicate

0.38

1.00

1.00

1.00

146.86

1.78

Delete

1.00

0.93

0.84

0.92

246.80

4.14

GPT-2

0.90

0.86

0.71

0.86

258.44

3.71

GPT-3

0.88

0.92

0.79

0.92

359.12

3.58

T-5 base

0.90

0.97

0.85

0.95

187.03

4.10

T-5 large

0.93

0.97

0.86

0.95

170.02

4.31

Licence

CC-BY-NC 4.0

Citation

Klamra C., Wojdyga G., Żurowski S., Rosalska P., Kozłowska M., Ogrodniczuk M. (2022). Devulgarization of Polish Texts Using Pre-trained Language Models. In: Groen, D., de Mulatier, C., Paszynski, M., Krzhizhanovskaya, V.V., Dongarra, J.J., Sloot, P.M.A. (eds) Computational Science – ICCS 2022. Lecture Notes in Computer Science, vol. 13351, pp. 49--55. Springer, Cham.