人机对话之chatglm模型-ptuningv2微调实战

chatglm文本生成入门级教程,其中原理性不在赘述,实操如下:

一. 虚拟环境创建

  1. 建立虚拟环境
    conda create -n xxx python==x.x 其中xxx为你要建立的虚拟环境的名字,自定义即可。pythonx.x为这个环境要使用的python版本。比如建立使用python3.8版本的名字为py38的虚拟环境:conda create -n py38 python3.8
  2. 激活环境
    conda activate xxx 其中xxx为(1)中xxx,即虚拟环境名称。比如:conda activate py38
    在这里插入图片描述
  3. 进入虚拟环境后,安装所需的包,如果网速慢,可以用阿里源或是豆瓣等
    例如
    pip install ultralytics -i https://pypi.tuna.tsinghua.edu.cn/simple
    其他所需命令:
    退出当前虚拟环境:conda deactivate
    下述命令在退出当前虚拟环境才能用:
    删除环境:conda remove -n xxx --all
    查看现有虚拟环境:conda env list
    查看环境中的包:conda list
    建立虚拟环境conda create -n xxx python==x.x安装报错:
    解决办法:
    conda config --show-sources
    修改文件为:
ssl_verify: True
channels:
 4. http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
 5. http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
 6. default
 7. conda-forge
show_channel_urls: True
原有
channels:
 8. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 9. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 10. defaults
show_channel_urls: true

查看gpu使用情况nvidia-smi

二. chatglm-6b模型文件下载

一般是进入huggingface官网下载,但目前官网进不去

  1. 进入虚拟环境

  2. 安装依赖:pip install -U huggingface_hub

  3. export HF_ENDPOINT=https://hf-mirror.com

  4. huggingface-cli download --resume-download --local-dir-use-symlinks False bigscience/bloom-560m --local-dir bloom-560m
    其中bigscience/bloom-560m是需要下载的模型,local-dir是要下载到的本地路径

  5. 可以链接到huggingface官网,查看模型文件、model使用

  6. 清华源模型文件下载地址(只包含bin文件,其他配置没有)

  7. 或者使用modelscope下载

三. chatglm-6b源代码下载

一般要去github上下载,目前同样进不去
git clone https://gitcode.com/THUDM/ChatGLM2-6B.git
或者进入gitcode网站下载

四. 安装模型依赖

下载源代码后,会生成一个chatglm-6b的路径

cd chatglm-6b
pip install -r requirements.txt
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值