Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sNeuron-TST (hate-speech TST fork)

My working copy of the official sNeuron-TST code — Style-Specific Neurons for Steering LLMs in Text Style Transfer (Lai et al., EMNLP 2024). I used it as a baseline for our paper LLM in the Loop: Creating the ParaDeHate Dataset for Hate Speech Detoxification, where we needed to compare against existing style-transfer methods on hate-speech detoxification (rewriting toxic text into a neutral style while preserving meaning). That meant running the neuron-identification + DoLa decoding pipeline on our hate-speech data.

Getting it to run on a current environment took a few fixes, which are the point of this repo.

What I changed

  • Fixed a broken import that stops the repo from loading. Our/dola.py imported LLamaQaStoppingCriteria from transformers.generation.stopping_criteria, which isn't part of the public transformers API and raises ImportError on current releases. I define the class locally instead (same \nQ: stop behaviour). Submitted upstream: wenlai-lavine/sNeuron-TST#6.
  • Python 3.11 compatibility — worked around the fake_tensor path that breaks under 3.11.
  • np.logtorch.log in the relative-top filter, to keep everything on one device/dtype.
  • Added a Hate_Speech pipeline — dataset split (data_pre/Hate_Speech), activation storage, neuron identification, and a select-mode run so the method can be evaluated on hate-speech data.

Auth

The dataset/model loaders read a Hugging Face token from the environment rather than hardcoding one:

export HF_TOKEN=hf_your_token_here

Layout

Files live under src/ (the pipeline stages from the original README: activation.py, identify.py, Analysis/select_neurons.py, Our/run_gen_dola.py). See src/README.md for the original authors' pipeline description.

Credit

All credit for the method and the original implementation goes to the upstream authors. This is a research fork; expect rough edges around the experiment scripts.

About

sNeuron-TST adapted as a baseline for the ParaDeHate hate-speech detoxification paper (arXiv:2506.01484), with fixes to run on modern transformers (upstreamed in wenlai-lavine/sNeuron-TST#6).

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages