ust-zzh commited on
Commit
f134b51
·
verified ·
1 Parent(s): d745f0f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -10
README.md CHANGED
@@ -1,10 +1,53 @@
1
- ---
2
- title: README
3
- emoji: 🚀
4
- colorFrom: yellow
5
- colorTo: blue
6
- sdk: static
7
- pinned: false
8
- ---
9
-
10
- Edit this `README.md` markdown file to author your organization card.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TDDBench: A Benchmark for Training data detection
2
+
3
+ This code is the official implementation of TDDBench.
4
+
5
+ ## Note ⭐⭐⭐
6
+
7
+ We have uploaded the datasets and target models used by TDDBench on [Huggingface](https://huggingface.co/TDDBench) to facilitate a quick evaluation of the Training Data Detection algorithm. This includes 12 datasets and 60 target models, with plans to upload more data and target models in the future.
8
+
9
+ To load an evaluation dataset, you can use the following code:
10
+ ```python
11
+
12
+ # Load dataset
13
+ from datasets import load_dataset
14
+ dataset_name = "student"
15
+ dataset_path = f"TDDBench/{dataset_name}"
16
+ dataset = load_dataset(dataset_path)["train"]
17
+ ```
18
+
19
+ To load a target model, you can use the following code:
20
+ ```python
21
+
22
+ from transformers import AutoConfig, AutoModel
23
+ from hfmodel import MLPConfig, MLPHFModel, WRNConfig, WRNHFModel
24
+
25
+ # Register the MLPConfig and MLPHFModel to automatically load our model architecture.
26
+ AutoConfig.register("mlp", MLPConfig)
27
+ AutoModel.register(MLPConfig, MLPHFModel)
28
+
29
+ # Load target model
30
+ dataset_name = "student" # Training dataset name
31
+ model_name = "mlp" # Target model architecture
32
+ model_idx = 0 # To reduce statistical error, we train five different target models for each model architecture and training dataset.
33
+ model_path = f"TDDBench/{model_name}-{dataset_name}-{model_idx}"
34
+ model = AutoModel.from_pretrained(model_path)
35
+
36
+ # Load training data detection label, 1 means model's training data while 0 means model's non-training data
37
+ config = AutoConfig.from_pretrained(model_path)
38
+ tdd_label = np.array(config.tdd_label)
39
+
40
+ ```
41
+
42
+ The [demo.ipynb](https://github.com/zzh9568/TDDBench/blob/main/demo.ipynb) file in our [release code](https://github.com/zzh9568/TDDBench) hub offers a straightforward example of how to download the target model and dataset from Hugging Face, along with instructions for recording the output loss of the model for both training and non-training data.
43
+
44
+ ### References
45
+
46
+ ```python
47
+ @article{zhu2024tddbench,
48
+ title={TDDBench: A Benchmark for Training data detection},
49
+ author={Zhu, Zhihao and Yang, Yi and Lian, Defu},
50
+ journal={arXiv preprint arXiv:2411.03363},
51
+ year={2024}
52
+ }
53
+ ```