国内中文开源大语言模型的微调和推理——baichuan7B, chatglm2-6B, Qwen-7B-chat
一、baichuan7B
1. 微调:基于nation-gpt-ie.json文件进行微调,微调代码见baichuan_sft.py文件
2. 推断:微调代码见baichuan_infer.py文件,给出一个示例如下
```markdown
if __name__ == '__main__':
# 测试数据
testdata = {
'instruction': '提取实体和关系',
'input': '道教约在南诏时期传入云南,主要分布在昆明、大理、保山、临沧、昭通、丽江等\n地,为汉、白、彝、纳西、瑶等民族部分群众信仰;1950年前,全省有道观40余座,\n'
}
# 将数据转换为输入的形式
instruction = test_dataset['instruction']
input = test_dataset['input']
test_dataset = {'system' : input, 'user' : instruction}
# 推断
baichuan7b_f_infer(baichuan7b_f, test_dataset[0])
```
3. 接口
4.1 激活接口代码见baichuan7b-entrypoint.sh文件
4.2 调用示例见baichuan7b-f-test.py文件,其中接口地址为http://202.121.140.55:7780/predict
给出一个示例如下
```markdown
CUDA_VISIBLE_DEVICES=2,3 gunicorn -w 1 -b 0.0.0.0:7780 baichuan7b-f-api:app --timeout 300
import requests
testdata = {
'instruction': '提取实体和关系',
'input': '道教约在南诏时期传入云南,主要分布在昆明、大理、保山、临沧、昭通、丽江等\n地,为汉、白、彝、纳西、瑶等民族部分群众信仰;1950年前,全省有道观40余座,\n'
}
# 调用baichaun-7B API
print(requests.post('http://202.121.140.55:7780/predict', json=testdata, timeout=300).json())
```
二、chatglm2-6B
1. 微调:基于nation-gpt-ie.json文件进行微调,微调代码见chatglm2_sft.py文件
2. 推断:微调代码见chatglm2_infer.py文件,给出一个示例如下
```markdown
if __name__ == '__main__':
# 测试数据
testdata = {
'instruction': '提取实体和关系',
'input': '道教约在南诏时期传入云南,主要分布在昆明、大理、保山、临沧、昭通、丽江等\n地,为汉、白、彝、纳西、瑶等民族部分群众信仰;1950年前,全省有道观40余座,\n'
}
# 将数据转换为输入的形式
instruction = test_dataset['instruction']
input = test_dataset['input']
test_dataset = {'system' : input, 'user' : instruction}
# 推断
chatglm2_f_infer(chatglm2_f, test_dataset[0])
```
3. 接口
4.1 激活接口代码见chatglm2-entrypoint.sh文件
4.2 调用示例见chatgm2-f-test.py文件,其中接口地址为http://202.121.140.55:7790/predict
给出一个示例如下
```markdown
CUDA_VISIBLE_DEVICES=2,3 gunicorn -w 1 -b 0.0.0.0:7790 baichuan7b-f-api:app --timeout 300
import requests
testdata = {
'instruction': '提取实体和关系',
'input': '道教约在南诏时期传入云南,主要分布在昆明、大理、保山、临沧、昭通、丽江等\n地,为汉、白、彝、纳西、瑶等民族部分群众信仰;1950年前,全省有道观40余座,\n'
}
# 调用chatglm2-6B API
print(requests.post('http://202.121.140.55:7790/predict', json=testdata, timeout=300).json())
```
三、Qwen-7B-chat
1. 微调:基于nation-gpt-ie.json文件进行微调,微调代码见qwen_sft.py文件
2. 推断:微调代码见qwen_infer.py文件,给出一个示例如下
```markdown
if __name__ == '__main__':
# 加载模型
args, remaining_argv = parse_args(qwen_7b_chat_f)
if len(remaining_argv) > 0:
if args.ignore_args_error:
logger.warning(f'remaining_argv: {remaining_argv}')
else:
raise ValueError(f'remaining_argv: {remaining_argv}')
# 测试数据
testdata = {
'instruction': '提取实体和关系',
'input': '道教约在南诏时期传入云南,主要分布在昆明、大理、保山、临沧、昭通、丽江等\n地,为汉、白、彝、纳西、瑶等民族部分群众信仰;1950年前,全省有道观40余座,\n'
}
# 将数据转换为输入的形式
instruction = test_dataset['instruction']
input = test_dataset['input']
test_dataset = {'query': f'{instruction}\n{input}'}
# 推断
qwen_7b_chat_f_infer(args, test_dataset)
```
3. 接口
4.1 激活接口代码见qwen-f-entrypoint.sh文件
4.2 调用示例见qwen-f-test.py文件,其中接口地址为http://202.121.140.55:7800/predict
给出一个示例如下
```markdown
CUDA_VISIBLE_DEVICES=2,3 gunicorn -w 1 -b 0.0.0.0:7800 qwen-f-api:app --timeout 300
import requests
testdata = {
'instruction': '提取实体和关系',
'input': '道教约在南诏时期传入云南,主要分布在昆明、大理、保山、临沧、昭通、丽江等\n地,为汉、白、彝、纳西、瑶等民族部分群众信仰;1950年前,全省有道观40余座,\n'
}
# 调用Qwen-7B-chat API
print(requests.post('http://202.121.140.55:7800/predict', json=testdata, timeout=300).json())
```
没有合适的资源?快使用搜索试试~ 我知道了~
大语言模型的微调和推理baichuan7B, chatglm2-6B, Qwen-7B-chat源码.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共24个文件
py:17个
pyc:6个
md:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 152 浏览量
2024-04-24
21:24:26
上传
评论
收藏 56KB ZIP 举报
温馨提示
详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;详情请查看资源内容中使用说明;
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![exe](https://img-home.csdnimg.cn/images/20210720083343.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 24 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/30cca166a8ba4bd9b70a7e3128b56485_lwx666sl.jpg!1)
熬夜写代码的平头哥
- 粉丝: 4640
- 资源: 7356
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 打包和分发Rust工具.pdf
- SQL中的CREATE LOGFILE GROUP 语句.pdf
- C语言-leetcode题解之第172题阶乘后的零.zip
- C语言-leetcode题解之第171题Excel列表序号.zip
- C语言-leetcode题解之第169题多数元素.zip
- ocr-图像识别资源ocr-图像识别资源
- 图像识别:基于Resnet50 + VGG16模型融合的人体细胞癌症分类模型实现-图像识别资源
- C语言-leetcode题解之第168题Excel列表名称.zip
- C语言-leetcode题解之第167题两数之和II-输入有序数组.zip
- C语言-leetcode题解之第166题分数到小数.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)