s-nlp / detox

Models for automatically transforming toxic text to neutral
33 stars 8 forks source link

Understanding of Mathematical Formulation for ParaGeDi #10

Closed ra-MANUJ-an closed 1 year ago

ra-MANUJ-an commented 1 year ago

Hi @avidale it's a little trivial request but can you point out specific part in the code where you're coding the mathematical formula for ParaGeDi model? By this, I mean the following idea: ParaGeDi depends on language model that generates the next token of the paraphrased sentence based on the previously generated tokens and the original sentence, and a "class-conditional" language model that judges whether a next token is of the target style.

avidale commented 1 year ago

Hi @ra-MANUJ-an, Here is the line with the core formula that combines token probabilities: https://github.com/s-nlp/detox/blob/main/emnlp2021/style_transfer/paraGeDi/gedi_adapter.py#L116

And here is the notebook when you can play with ParaGeDi inference by changing the parameters in this formula: https://github.com/s-nlp/detox/blob/main/emnlp2021/style_transfer/paraGeDi/gedi_inference.ipynb

ra-MANUJ-an commented 1 year ago

Hi, thanks a lot for quick response! I was confused about about the implementation of formula.