如何配置一个本地fastchat大语言模型?

如何配置一个本地fastchat大语言模型?

  • 原作者:b站【FastChat-Vicuna安装教程】https://www.bilibili.com/video/BV1wV4y1r7X4?vd_source=c93601c725c679f713357b5d98dfa4bd
    本人转载并对其中的代码做了打包归纳,并在部分区域做了归纳补充,方便读者复制粘贴。

模型大概11GB左右,比较吃电脑内存,一定要实现保证模型在电脑上有足够的运行空间。

换源

conda config --set show_channel_urls yes
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/main
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/free
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/r
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/msys2
conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/msys2/
conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/bioconda/
conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/menpo/
conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.aliyun.com/anaconda/cloud/simpleitk/

pip 换源

conda create -n fastchat01 python=3.9 -c conda-forge
conda activate fastchat01
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/

安装 fastchat

pip install fschat==0.2.8
git clone https://kgithub.com/huggingface/transformers.git  # 下载transformersr

pip uninstall protobuf
pip install protobuf==3.20
python C:\Users\27135\Desktop\fastchat\transformers\src\transformers\models\llama\convert_llama_weights_to_hf.py --input_dir C:\Users\27135\Desktop\fastchat\model\LLaMAOriginalWeights\LLaMAOriginalWeights\LLaMA --model_size 7B --output_dir C:\Users\27135\Desktop\fastchat\model\transzformed_models\llama_7B
python -m fastchat.model.apply_delta --base-model-path C:\Users\27135\Desktop\fastchat\model\transzformed_models\llama_7B --target-model-path C:\Users\27135\Desktop\fastchat\model\vicuna-7b --delta-path lmsys/vicuna-7b-delta-v1.1 --low-cpu-mem

(这一步试了100万次,原来要挂梯子)

python -m fastchat.serve.cli --model-path C:\Users\27135\Desktop\fastchat\model\vicuna-7b --device cpu --load-8bit

让大模型在cpu上跑(可以通过修改参数让大模型在GPU上跑,但是需要安装带有CUDA库的pyTorch,如果你的电脑配备英伟达显卡的话建议尝试)

运行效果如下

在这里插入图片描述

hhh乌龙了,实际上它并不能上网。

  • 10
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值