CoT fine-tuning attack
19
stars
3
commits
Jupyter Notebook
primary language
Aug 31, 2026
updated
This repository includes scripts for dataset preparation, evaluation & fine-tuning (10, 20, 50, 200) datasets, model fine-tuning using PEFT techniques (like LoRA), and tools for generating and evaluating potentially harmful outputs from language models.
prepDataset.py Preprocesses raw datasets into instruction-style formats tailored for specific model architectures (e.g., Mistral, DeepSeek-R1). Easily customizable.
harmfulLora.py Fine-tunes models based on config.json using:
loadModel.py Loads and tests inference of fine-tuned models in server environments. Useful for deployment validation.
config.json (user-provided)
Central configuration file defining:
convertGGUF.py Converts fine-tuned models to GGUF format (e.g., for use with llama.cpp) via the unsloth library.
configuation.py Reads and parses the central config.json into usable Python objects.
dataSampling.py Used to generate fine-tuning and evaluation subsets from raw datasets.
responseSeparation.py Splits generated responses into reasoning steps (e.g., "think") and final answers, saving them into distinct columns.
scoreExtraction.py Parses judgment scores from LLM evaluators and saves structured results.
datacleaning.py Temporary cleaning utility – not directly related to the main pipeline.
textCompletetionHarmful.py Uses the fine-tuned (attacked) model to generate potentially harmful outputs. Helps evaluate adversarial vulnerability.
textCompletetionHarmless.py Uses the base (unmodified) model to generate outputs for comparison in safety benchmarking.
outputClassifyHarmBench.py Applies HarmBench classifiers to generated outputs to determine harmfulness and attack success rates.
gptJudger.py Uses OpenAI APIs to assign harmfulness scores via LLM-based judging (Gemini, Gork, Chatgpt, DeepSeekV3, DeepSeeekR1).
config.json file with all required settings (see template or examples).prepDataset.py to format your dataset.harmfulLora.py.If you find this repository or our paper useful in your research, please consider citing our work:
@inproceedings{xu2026reasoning,
title={Reasoning That Leaks, Fine-Tuning That Amplifies: Exposing the Hidden Threats of Chain-of-Thought Models},
author={Xu, Zhiyuan and Gardiner, Joseph and Belguith, Sana},
booktitle={Proceedings of the ACM Asia Conference on Computer and Communications Security},
pages={439--455},
year={2026}
}
3 commits
Jupyter Notebook
81.7%
Python
18.3%
CoT fine-tuning attack
19
stars
3
commits
Jupyter Notebook
primary language
Aug 31, 2026
updated
This repository includes scripts for dataset preparation, evaluation & fine-tuning (10, 20, 50, 200) datasets, model fine-tuning using PEFT techniques (like LoRA), and tools for generating and evaluating potentially harmful outputs from language models.
prepDataset.py Preprocesses raw datasets into instruction-style formats tailored for specific model architectures (e.g., Mistral, DeepSeek-R1). Easily customizable.
harmfulLora.py Fine-tunes models based on config.json using:
loadModel.py Loads and tests inference of fine-tuned models in server environments. Useful for deployment validation.
config.json (user-provided)
Central configuration file defining:
convertGGUF.py Converts fine-tuned models to GGUF format (e.g., for use with llama.cpp) via the unsloth library.
configuation.py Reads and parses the central config.json into usable Python objects.
dataSampling.py Used to generate fine-tuning and evaluation subsets from raw datasets.
responseSeparation.py Splits generated responses into reasoning steps (e.g., "think") and final answers, saving them into distinct columns.
scoreExtraction.py Parses judgment scores from LLM evaluators and saves structured results.
datacleaning.py Temporary cleaning utility – not directly related to the main pipeline.
textCompletetionHarmful.py Uses the fine-tuned (attacked) model to generate potentially harmful outputs. Helps evaluate adversarial vulnerability.
textCompletetionHarmless.py Uses the base (unmodified) model to generate outputs for comparison in safety benchmarking.
outputClassifyHarmBench.py Applies HarmBench classifiers to generated outputs to determine harmfulness and attack success rates.
gptJudger.py Uses OpenAI APIs to assign harmfulness scores via LLM-based judging (Gemini, Gork, Chatgpt, DeepSeekV3, DeepSeeekR1).
config.json file with all required settings (see template or examples).prepDataset.py to format your dataset.harmfulLora.py.If you find this repository or our paper useful in your research, please consider citing our work:
@inproceedings{xu2026reasoning,
title={Reasoning That Leaks, Fine-Tuning That Amplifies: Exposing the Hidden Threats of Chain-of-Thought Models},
author={Xu, Zhiyuan and Gardiner, Joseph and Belguith, Sana},
booktitle={Proceedings of the ACM Asia Conference on Computer and Communications Security},
pages={439--455},
year={2026}
}
3 commits
Jupyter Notebook
81.7%
Python
18.3%