zhangbl6618/RAG-Responsibility-Attribution
GitHub: zhangbl6618/RAG-Responsibility-Attribution
该项目是两篇论文的官方实现,旨在对RAG系统中的投毒知识进行责任归因与攻击溯源。
Stars: 20 | Forks: 1
# 检索增强生成中投毒知识的责任归因
## 简介
本仓库是论文《谁教导了谎言?检索增强生成中投毒知识的责任归因》(IEEE Symposium on Security and Privacy 2026)和《对检索增强生成的投毒攻击溯源》(The Web Conference 2025)的官方实现。
## 设置
1. 请运行以下命令来设置环境:
```
conda env create my_custom_env python=3.12
conda activate my_custom_env
pip install -r requirements.txt
```
2. 收集错误生成事件
错误生成事件采用特定的 JSON 格式,通常由攻击模拟生成。对于每个错误生成事件,它应包含问题、上下文、RAG 响应和检索分数等信息。示例提供在 `attack_feedback/PRAGB/*.json` 中。
3. 设置 OpenAI API Key
确保您的 OpenAI API key 已设置为环境变量。
```
export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
export OPENAI_API_URL="YOUR_OPENAI_BASE_URL" # Optional, if using a custom endpoint
```
## 用法
### RAGOrigin
```
python RAGOrigin/main.py \
--dataset "NQ" \
--attack_retriever "e5" \
--attack_LLM "gpt-4o-mini" \
--judge_LLM "gpt-4o-mini" \
--attack_method "PRAGB" \
--attack_M 5 \
--top_K 5 \
--trace_method "RAGOrigin" \
--proxy_model "meta-llama/Llama-3.1-8B" \
--variant 0 \
--normalize_method "z_score_normalize" \
--feedback_root_dir "attack_feedback" \
--feedback_scope_dir "attack_feedback_scope" \
--result_root_dir "result" \
--test_version "v1" \
--cuda_device 0
```
### RAGForensics
```
python RAGForensics/main.py \
--dataset "NQ" \
--attack_retriever "e5" \
--attack_LLM "gpt-4o-mini" \
--trace_LLM "gpt-4o-mini"
--attack_method "PRAGB" \
--attack_M 5 \
--top_K 5 \
--feedback_root_dir "attack_feedback" \
--result_root_dir "result" \
--test_version "v1" \
```
## 引用
我们归因框架的引用:
```
@inproceedings{zhang2026ragorigin,
title={Who Taught the Lie? Responsibility Attribution for Poisoned Knowledge in Retrieval-Augmented Generation},
author={Zhang, Baolei and Xin, Haoran and Chen, Yuxi and Liu, Zhuqing and Yi, Biao and Li, Tong and Nie, Lihai and Liu, Zheli and Fang, Minghong},
booktitle={IEEE Symposium on Security and Privacy},
year={2026}
}
@inproceedings{zhang2025traceback,
title={Traceback of Poisoning Attacks to Retrieval-Augmented Generation},
author={Zhang, Baolei and Xin, Haoran and Fang, Minghong and Liu, Zhuqing and Yi, Biao and Li, Tong and Liu, Zheli},
booktitle={The Web Conference},
year={2025}
}
```
标签:AI安全, Chat Copilot, DLL 劫持, Petitpotam, 人工智能, 凭据扫描, 大语言模型, 密钥管理, 数据投毒攻击, 检索增强生成, 溯源分析, 用户模式Hook绕过, 逆向工具