Skip to content

dadadaray/CSPD-code

Repository files navigation

CSPD

Official implementation of the paper:

Chain-Structured Progressive Defense against Multi-Source Adversarial Attacks in Continual Relation Extraction

Continual Relation Extraction (CRE) aims to continuously learn emerging relations while preserving previously acquired knowledge. Existing adversarial defense methods are mainly designed for static settings and struggle to handle multi-source adversarial perturbations in continual learning environments.

In this work, we propose Chain-Structured Progressive Defense (CSPD), a novel defense framework for continual relation extraction under multi-source attacks. CSPD introduces:

  • Zipf-informed Loss Reweighting to prioritize severe adversarial distortions;
  • Prototype-Anchored Alignment to restore feature geometry using stable relation prototypes;
  • Joint Memory Consolidation to balance adversarial robustness and historical memory preservation.

Experiments on FewRel and TACRED demonstrate that CSPD consistently improves robustness while maintaining stability in continual learning scenarios.


Framework Overview

CSPD consists of three collaborative modules:

  1. Zipf-informed Loss Reweighting
  2. Prototype-Anchored Alignment
  3. Joint Memory Consolidation

These modules jointly repair adversarial feature drift while preserving historical knowledge in continual learning.


Environment

Recommended environment:

  • Python >= 3.9
  • PyTorch
  • CUDA (optional, GPU acceleration)

Create environment:

conda env create -f environment.yml
conda activate CSPD

Or install dependencies manually:

pip install -r requirements.txt

Dataset

We conduct experiments on two benchmark datasets:

FewRel

Few-shot relation extraction benchmark:

data/FewRel/

TACRED

Large-scale relation extraction benchmark:

data/TACRED/

Task splits and continual learning task orders are provided in the corresponding directories.


Running Experiments

Run experiments on FewRel:

bash FewRel.sh

Run experiments on TACRED:

bash tacred.sh

Experimental Setting

Backbone models:

  • NaCL
  • EMAR
  • CRL

Attack sources:

Gradient-based attacks:

  • FGSM
  • CW

LLM-based semantic attacks:

  • Paraphrasing
  • Entity Replacement
  • Insertion
  • Targeted Prompting

Evaluation metrics:

  • Robustness (R)
  • Stability (S)
  • Security-weighted Harmonic Mean (H0.5)

Project Structure

CSPD/
│── data/
│   ├── FewRel/
│   └── TACRED/
│
│── models/
│
│── scripts/
│   ├── FewRel.sh
│   └── tacred.sh
│
│── requirements.txt
│── environment.yml
│── README.md

Citation

If you find this repository useful, please cite our work:

@article{yan2026cspd,
  title={Chain-Structured Progressive Defense against Multi-Source Adversarial Attacks in Continual Relation Extraction},
  author={Yan, Rongen and Zhang, Liqiong and Zhong, Weilin and Zhang, Yue and Lan, Shufen and Zhao, Ziling and Xu, Fu},
  note={Under Review},
  year={2026}
}

License

This project is released for academic research purposes only.

About

Chain-Structured Progressive Defense against Multi-Source Adversarial Attacks in Continual Relation Extraction

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors