Views
No views yet
t5_base1/: Meta-classifier trained on T5 base model 1t5_base2/: Meta-classifier trained on T5 base model 2t5_base3/: Meta-classifier trained on T5 base model 3t5_base1/: T5 base model 1t5_base2/: T5 base model 2t5_base3/: T5 base model 31import torch
2import torch.nn as nn
3import torch.nn.functional as F
4
5class PEFTGuard_T5(nn.Module):
6 def __init__(self, device, target_number=3):
7 super(PEFTGuard_T5, self).__init__()
8 self.device = device
9 self.input_channel = (target_number) * 2 * 24
10 self.conv1 = nn.Conv2d(self.input_channel, 32, 8, 8, 0).to(self.device)
11 self.fc1 = nn.Linear(256 * 256 * 32, 512).to(self.device)
12 self.fc2 = nn.Linear(512, 128).to(self.device)
13 self.fc3 = nn.Linear(128, 2).to(self.device)
14
15 def forward(self, x):
16 x = x.view(-1, self.input_channel, 2048, 2048)
17 x = self.conv1(x)
18 x = x.view(x.size(0), -1)
19 x = F.leaky_relu(self.fc1(x))
20 x = F.leaky_relu(self.fc2(x))
21 x = self.fc3(x)
22 return x
23
24def load_peftguard_t5(checkpoint_path, device):
25 device = torch.device(device)
26 model = PEFTGuard_T5(device=device)
27 state_dict = torch.load(checkpoint_path, map_location=device)
28 model.load_state_dict(state_dict)
29 model.to(device)
30 model.eval()
31 return model
32
33if __name__ == "__main__":
34 checkpoint_path = "./t5_base1/best_model.pth"
35 device_str = "cuda" if torch.cuda.is_available() else "cpu"
36 model = load_peftguard_t5(checkpoint_path, device_str)
371@inproceedings{PEFTGuard2025,
2 author = {Sun, Zhen and Cong, Tianshuo and Liu, Yule and Lin, Chenhao and
3 He, Xinlei and Chen, Rongmao and Han, Xingshuo and Huang, Xinyi},
4 title = {{PEFTGuard: Detecting Backdoor Attacks Against Parameter-Efficient Fine-Tuning}},
5 booktitle = {2025 IEEE Symposium on Security and Privacy (SP)},
6 year = {2025},
7 pages = {1620--1638},
8 doi = {10.1109/SP61157.2025.00161},
9 url = {https://doi.ieeecomputersociety.org/10.1109/SP61157.2025.00161},
10 publisher = {IEEE Computer Society},
11 address = {Los Alamitos, CA, USA},
12 month = May,
13}