MiniGPT-4 模型学习与实战:第1节

1. 环境搭建

建议一定要安装miniconda,不然各种报错…

conda create -n py310_chat python=3.10 # 创建新环境
source activate py310_chat # 激活环境
pip install fschat # 安装fschat包
git clone https://github.com/lm-sys/FastChat.git
cd FastChat
pip install -e .
git lfs install
# 如果载好了应该是>>>Git LFS initialized.

2. 权重合成

由于Vicuna 是基于LLaMA模型的,为了符合LLaMA 模型license授权,仅发布了 delta 权重,所以我们需要将原始llama-7b模型与delta模型权重合并之后,才能得到vicuna权重。

  • 条件好的,可以使用13bb,我这里一律是7b模型
2.1 原始llama-7b模型权重下载
git lfs install
git clone https://huggingface.co/decapoda-research/llama-7b-hf  # smaller, need 12G gpu memory
#git clone https://huggingface.co/decapoda-research/llama-13b-hf  # more powerful, need at least 24G 
2.2 vicuna-7b-delta权重下载
git clone https://huggingface.co/lmsys/vicuna-7b-delta-v1.1
# or
# git clone https://huggingface.co/lmsys/vicuna-13b-delta-v1.1
2.3 权重合成工具安装
pip install git+https://github.com/lm-sys/FastChat.git@v0.1.10
2.4 合成权重
 python -m fastchat.model.apply_delta --base /mnt/sda/huggingface_weight/llama-7b-hf --target /mnt/sda/huggingface_weight/vicuna/weight2/  --delta /mnt/sda/huggingface_weight/vicuna-7b-delta-v1.1

3. 模型推理

下面的命令要求Vicuna-13B大约有28GB的GPU内存,Vicuna-7B大约有14GB的GPU存储器,

python -m fastchat.serve.cli --model-path /path/to/vicuna/weights 

vicuna本地推理
7b的模型感觉效果一般。 所以有钱买个好显卡还是很重要的,租也行。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值