
Black-Box-Angriffsframework, das das Denken in agentischen Retrieval-Augmented-Generation-Systemen durch das Einschleusen vergifteter Dokumente kapert, mit Unterstützung für mehrere Angriffsmethoden und Datensätze.
Führen Sie die folgenden Befehle aus dem übergeordneten Verzeichnis des geklonten KidnapRAG-Repositories aus.
cd KidnapRAG
conda create -n KidnapRAG python=3.10
conda activate KidnapRAG
pip install -r requirements.txt
Laden Sie anschließend die Korpus-Datensätze 📄 herunter und verschieben Sie den ReAct-Datensatz nach /KidnapRAG/ReAct und den WebThinker-Datensatz nach /KidnapRAG/WebThinker
Beispiele auf HotpotQA mit dem Llama-Modell.
cd ReAct/ReAct
CUDA_VISIBLE_DEVICES=0,1,2,3 python attack_react.py --attack_method clean --model_path meta-llama/Llama-3.3-70B-Instruct --seed 1 --dataset hotpotqa
--model_path unterstützt Llama-3.3-70B-Instruct und Qwen/Qwen2.5-32B-Instruct.
--dataset unterstützt hotpotqa, musique und 2wikimultihopqa.
CUDA_VISIBLE_DEVICES=0,1 python generate_attack_doc_kill.py --input_path /KidnapRAG/ReAct/results/adv_targeted_results/hotpotqa_seed1_clean_llama70b.json --gpu_num 2 --dataset hotpotqa --type ours
--type unterstützt zusätzlich die folgenden Angriffsmethoden: naive für Naive Attack, ignore für Ignore Attack, completion_real für Fake Completion Attack, completion_realcmb für Combined Attack, topicattack für TopicAttack, poisonedRAG für PoisonedRAG und paradox für RAG Paradox.
BM, BCM, BCCM, BCCCM, BCCCCM)cd ..
python concat.py --dataset hotpotqa --gen_model llama70b
--gen_model unterstützt llama70b für Llama-3.3-70B-Instruct und qwen25 für Qwen/Qwen2.5-32B-Instruct.
CUDA_VISIBLE_DEVICES=0 python scripts/build_index.py \
--corpus_path /KidnapRAG/ReAct/datasets/hotpotqa/REACT_BM_llama70b.jsonl \
--output_dir /KidnapRAG/ReAct/datasets/hotpotqa/REACT_BM_llama70b \
--model_name intfloat/e5-large-v2
cd ReAct
CUDA_VISIBLE_DEVICES=0,1,2,3 python attack_react.py --attack_method BM --model_path meta-llama/Llama-3.3-70B-Instruct --seed 1 --dataset hotpotqa
Beispiele auf HotpotQA mit dem QwQ-Modell.
Führen Sie diesen Abschnitt aus dem Stammverzeichnis des KidnapRAG-Repositories aus.
cd Webthinker
bash scripts/webthinker/qwq_clean.sh \
./datasets/hotpotqa/hotpotqa_promptinject_select.json \
./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl \
./results/hotpotqa/clean_qwq.json
Argumente:
./datasets/hotpotqa/hotpotqa_promptinject_select.json: Abfragepfad./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl: Korpuspfad./results/hotpotqa/clean_qwq.json: Ergebnisdateipfadcd scripts
CUDA_VISIBLE_DEVICES=0,1 python generate_attack_doc_kill.py --input_path /KidnapRAG/Webthinker/results/hotpotqa/clean_qwq.json --gpu_num 2 --dataset hotpotqa --type ours
BM, BCM, BCCM, BCCCM, BCCCCM)cd ..
python concat.py --dataset hotpotqa --gen_model qwq
--gen_model unterstützt deepseek_32b für lixiaoxi45/WebThinker-R1-32B und qwq für Qwen/QwQ-32B.
bash scripts/webthinker/qwq_attack.sh \
./datasets/hotpotqa/hotpotqa_promptinject_select.json \
./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl \
./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl \
./results/hotpotqa/BM.json
Argumente:
./datasets/hotpotqa/hotpotqa_promptinject_select.json: Abfragepfad./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl: Korpuspfad./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl: Pfad zum vergifteten Korpus./results/hotpotqa/BM.json: Ergebnisdateipfad@misc{
}