我们论文《Poisoning Attacks on the PGM-index》的官方代码。
git clone [REPOSITORY LINK]
cd pgm-index-poisoning
git submodule update --init --recursive
./scripts/build.sh
需要 CMake(见依赖项)。输出文件位于 build/ 目录下(默认情况下二进制文件在 build/bin 中)。
./scripts/download_alex_dataset.sh # ALEX
./scripts/download_mgbench.sh # mgbench
./scripts/download_sosd_datasets.sh # SOSD
./scripts/preprocess_alex_dataset.sh # ALEX
./scripts/preprocess_mgbench.sh # mgbench
./scripts/generate_synthetic_dataset.sh # synthetic
每次运行通过 ./scripts/run_experiment.sh <config.json> 传入一个 JSON 配置。示例:
4.1 最大化最大误差(例如 n=16,连续方法)
./scripts/run_experiment.sh "configs/experiments/poison_attack/maximize_maxerror_consec/baseline_n16.json"
4.2 最小化被覆盖的合法键(例如 epsilon=2,连续方法)
./scripts/run_experiment.sh "configs/experiments/poison_attack/minimize_segment_length/baseline_epsilon2.json"
4.3 最大化 m_opt(PGM-index 示例)
./scripts/run_experiment.sh "configs/experiments/poison_attack/inject_poisons_to_minimize_segment_length_swing_lambda_with_theta/baseline.json"
4.4 m_opt 的上界(实例相关示例)
./scripts/run_experiment.sh "configs/experiments/upper_bound/fix_w_per_block/baseline.json"
4.5 运行所有实验(批量)
运行 scripts/run_all_experiment.sh 中列出的全部实验配置(编辑该文件可更改实验集合)。
./scripts/run_all_experiment.sh
在仓库根目录下执行:
./scripts/plot.sh
./scripts/print_table.sh
图表和日志写入 fig/ 目录。请先安装 Python 依赖:pip install -r requirements.txt。
g++、make 和 CMake(构建脚本使用 CMake 配置,并通过 cmake --build 构建,通常会调用 Make)。requirements.txt 中的包(绘图/表格脚本)。./scripts/run_experiment.sh 解析实验 JSON 所需。构建镜像一次:
./docker_build.sh
docker_run.sh — 交互式容器:将仓库挂载到 /workspace,分配 8 个 CPU(0–7),进入 bash 以便手动构建和运行命令。docker_run_all.sh — 分离式运行:在容器内执行 ./scripts/run_all_experiment.sh(8 个 CPU),并将标准输出写入 results/run_all.log。docker_run_all_single_cpu.sh — 与 docker_run_all.sh 相同,但仅使用一个 CPU 并设置 OMP_NUM_THREADS=1 以进行单线程运行。三者均使用镜像 pgm_poisoning:latest,并采用与脚本中相同的权限/卷设置。
| 路径 | 作用 |
|---|
src/ | C++ 源码(攻击、PGM 基准测试、工具、上界)。 |
configs/experiments/ | 实验 JSON 配置(poison_attack/、upper_bound/ 等目录下)。 |
scripts/ | 构建、数据、run_experiment.sh、run_all_experiment.sh、plot.sh、print_table.sh。 |
third_party/ | Git 子模块(PGM-index、FITing-Tree、RadixSpline)。 |
data/、results/、fig/ | 数据、运行输出以及生成的图表/表格日志。 |
plot/ | Python 绘图和表格打印脚本。 |