
Framework di attacco black-box che dirotta il ragionamento nei sistemi di generazione aumentata da recupero agentici iniettando documenti avvelenati, con supporto per molteplici metodi di attacco e dataset.
Esegui i seguenti comandi dalla directory principale del repository KidnapRAG clonato.
cd KidnapRAG
conda create -n KidnapRAG python=3.10
conda activate KidnapRAG
pip install -r requirements.txt
Quindi, scarica i dataset del corpus 📄 e sposta il dataset ReAct in /KidnapRAG/ReAct e il dataset WebThinker in /KidnapRAG/WebThinker
Esempi su HotpotQA con il modello Llama.
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 supporta Llama-3.3-70B-Instruct e Qwen/Qwen2.5-32B-Instruct.
--dataset supporta hotpotqa, musique e 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 supporta inoltre i seguenti metodi di attacco: naive per Naive Attack, ignore per Ignore Attack, completion_real per Fake Completion Attack, completion_realcmb per Combined Attack, topicattack per TopicAttack, poisonedRAG per PoisonedRAG e paradox per RAG Paradox.
BM, BCM, BCCM, BCCCM, BCCCCM)cd ..
python concat.py --dataset hotpotqa --gen_model llama70b
--gen_model supporta llama70b per Llama-3.3-70B-Instruct e qwen25 per 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
Esempi su HotpotQA con il modello QwQ.
Esegui questa sezione dalla radice del repository KidnapRAG.
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
Argomenti:
./datasets/hotpotqa/hotpotqa_promptinject_select.json: percorso della query./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl: percorso del corpus./results/hotpotqa/clean_qwq.json: percorso dei risultaticd 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 supporta deepseek_32b per lixiaoxi45/WebThinker-R1-32B e qwq per 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
Argomenti:
./datasets/hotpotqa/hotpotqa_promptinject_select.json: percorso della query./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl: percorso del corpus./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl: percorso del corpus avvelenato./results/hotpotqa/BM.json: percorso dei risultati@misc{
}