我在中国大陆如何运行这个项目。(运行指北)
安装基础环境
git clone https://github.com/Unispac/Visual-Adversarial-Examples-Jailbreak-Large-Language-Models.git
cd Visual-Adversarial-Examples-Jailbreak-Large-Language-Models
conda env create -f environment.yml
conda activate minigpt4
- 但是在安装过程中可能出现,pycocotools安装失败和peft安装时删除了已经安装好的PyTorch-1.12.1版本换成了另外版本的PyTorch。 对于这两个问题,我的解决方法是: 首先在environment.yml中注释掉36行(pycocotools)和56行(peft)。 单独安装pycocotools和peft:
pip install pycocotools==2.0.6
# 安装适配PyTorch-1.12.1版本的peft
git clone https://github.com/czczup/peft-torch112.git
cd peft-torch112
pip install -e .
下载运行项目所需的各种权重
一些众所周知的原因,中国大陆的用户无法访问huggingface,因此,不得不下载权重文件到本地。
Vicuna-13B:可以尝试使用modelscope进行下载。
pip install modelscope
modelscope download --model asdf1213812138/vicuna_13B_v0 --local_dir [本地目录]
bert-base-uncased:
modelscope download --model google-bert/bert-base-uncased --local_dir [本地目录]
- 修改minigpt4/models/blip2.py中的31和47行,修改为本地的bert-base-uncased目录
其他的模型权重:
modelscope download --model JyWang6/VAEJ_weights --local_dir [本地目录]
- 修改配置文件 minigpt4/configs/models/minigpt4.yaml,第16行,修改为本地的Vicuna-13B目录。 eval_configs/minigpt4_eval.yaml,第11行,修改为本地的pretrained_minigpt4.pth所在位置。
- 移动权重文件
mv eva_vit_g.pth /root/.cache/torch/hub/checkpoints
mv blip2_pretrained_flant5xxl.pth /root/.cache/torch/hub/checkpoints
运行时可能出现的问题
- No seaborn:
pip install seaborn
- ImportError: libGL.so.1:
pip install opencv-python-headless
- ValueError: Non-consecutive added token '
' found. Should have index 32000 but has index 0 in saved vocabulary
# 进入本地Vicuna-13B目录
mv added_tokens.json added_tokens.json.bak
Thank you dude :)
在运行最后的毒性打分时
python get_metric.py --input result.jsonl --output result_eval.jsonl 代码
perspective_scorer = PerspectiveApiScorer(api_key)与detoxify_scorer = DetoxifyScorer()分别遇到了如下问题:socket.timeout: timed out以及OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like bert-base-uncased is not the path to a directory containing a file named config.json. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.请问您知道如何解决吗qaq
可能是网络的问题,可能你需要配置一下,HF的国内镜像站,具体操作,你可以参考:https://hf-mirror.com/
抱歉,没有及时回复您的提问。
发件人: Doge @.> 发送时间: 2025年5月26日 16:47 收件人: Unispac/Visual-Adversarial-Examples-Jailbreak-Large-Language-Models @.> 抄送: WW @.>; Author @.> 主题: Re: [Unispac/Visual-Adversarial-Examples-Jailbreak-Large-Language-Models] 我在中国大陆如何运行这个项目。(运行指北) (Issue #36)
[https://avatars.githubusercontent.com/u/79989295?s=20&v=4]Doge-e7i left a comment (Unispac/Visual-Adversarial-Examples-Jailbreak-Large-Language-Models#36)https://github.com/Unispac/Visual-Adversarial-Examples-Jailbreak-Large-Language-Models/issues/36#issuecomment-2908989936
在运行最后的毒性打分时
python get_metric.py --input result.jsonl --output result_eval.jsonl 代码 perspective_scorer = PerspectiveApiScorer(api_key) 与 detoxify_scorer = DetoxifyScorer() 分别遇到了如下问题: socket.timeout: timed out 以及 OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like bert-base-uncased is not the path to a directory containing a file named config.json. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'. 请问您知道如何解决吗qaq
― Reply to this email directly, view it on GitHubhttps://github.com/Unispac/Visual-Adversarial-Examples-Jailbreak-Large-Language-Models/issues/36#issuecomment-2908989936, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A44YX2VLS7XAMFODWEP3ZL33ALIL7AVCNFSM6AAAAAB2WJLUJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMBYHE4DSOJTGY. You are receiving this because you authored the thread.Message ID: @.***>