1 Star 0 Fork 0

frontcold/ChatGLM-6B-Int4

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
2年前
2年前
2年前
ice_text.model 2.58 MB
2年前
2年前
Loading...
README
Apache-2.0
--- tasks: - chat model-type: - glm domain: - nlp studios: - AI-ModelScope/ChatGLM6B-unofficial frameworks: - pytorch backbone: - transformer customized-quickstart: False finetune-support: False license: Apache License 2.0 language: - cn - en tags: - 文本生成 - text-generation - Zhipu.ai - chatglm-6b - 中英' - int4 widgets: - task: chat version: 1 inputs: - type: text name: text title: 输入文字 validator: max_words: 128 - type: text-list name: history examples: - name: 1 title: 示例1 inputs: - name: text data: 你好 - name: text data: [] inferencespec: cpu: 4 memory: 24000 gpu: 1 gpu_memory: 16000 ---

ChatGLM-6B-Int4模型介绍

ChatGLM-6B 是一个开源的、支持中英双语问答的对话语言模型,基于 General Language Model (GLM) 架构,具有 62 亿参数。结合模型量化技术,用户可以在消费级的显卡上进行本地部署(INT4 量化级别下最低只需 6GB 显存)。ChatGLM-6B 使用了和 ChatGLM 相同的技术,针对中文问答和对话进行了优化。经过约 1T 标识符的中英双语训练,辅以监督微调、反馈自助、人类反馈强化学习等技术的加持,62 亿参数的 ChatGLM-6B 已经能生成相当符合人类偏好的回答。

ChatGLM-6B-INT4 是 ChatGLM-6B 量化后的模型权重。具体的,ChatGLM-6B-INT4 对 ChatGLM-6B 中的 28 个 GLM Block 进行了 INT4 量化,没有对 Embedding 和 LM Head 进行量化。量化后的模型理论上 6G 显存(使用 CPU 即内存)即可推理,具有在嵌入式设备(如树莓派)上运行的可能。

在 CPU 上运行时,会根据硬件自动编译 CPU Kernel ,请确保已安装 GCC 和 OpenMP (Linux一般已安装,对于Windows则需手动安装),以获得最佳并行计算能力。

环境搭建

本模型环境需安装最新版的modelscope

pip install modelscope==1.4.3 -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html 

软件依赖

pip install protobuf transformers==4.27.1 cpm_kernels

代码范例

from modelscope.utils.constant import Tasks
from modelscope.pipelines import pipeline
pipe = pipeline(task=Tasks.chat, model='ZhipuAI/ChatGLM-6B-Int4', model_revision='v1.0.1')
inputs = {'text':'你好', 'history': []}
result = pipe(inputs)
inputs = {'text':'介绍下清华大学', 'history': result['history']}
result = pipe(inputs)
print(result)

协议

本仓库的代码依照 Apache-2.0 协议开源,ChatGLM-6B 模型的权重的使用则需要遵循 Model License。

引用

如果你觉得我们的工作有帮助的话,请考虑引用下列论文:

@inproceedings{
  zeng2023glm-130b,
  title={{GLM}-130B: An Open Bilingual Pre-trained Model},
  author={Aohan Zeng and Xiao Liu and Zhengxiao Du and Zihan Wang and Hanyu Lai and Ming Ding and Zhuoyi Yang and Yifan Xu and Wendi Zheng and Xiao Xia and Weng Lam Tam and Zixuan Ma and Yufei Xue and Jidong Zhai and Wenguang Chen and Zhiyuan Liu and Peng Zhang and Yuxiao Dong and Jie Tang},
  booktitle={The Eleventh International Conference on Learning Representations (ICLR)},
  year={2023},
  url={https://openreview.net/forum?id=-Aw0rrrPUF}
}
@inproceedings{du2022glm,
  title={GLM: General Language Model Pretraining with Autoregressive Blank Infilling},
  author={Du, Zhengxiao and Qian, Yujie and Liu, Xiao and Ding, Ming and Qiu, Jiezhong and Yang, Zhilin and Tang, Jie},
  booktitle={Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  pages={320--335},
  year={2022}
}

欢迎加入我们的微信社区讨论~

wechat

modelhub clone

 git clone https://www.modelscope.cn/ZhipuAI/ChatGLM-6B.git

空文件

简介

暂无描述 展开 收起
README
Apache-2.0
取消

发行版

暂无发行版

贡献者 (5)

全部

语言

近期动态

1年多前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/frontcold/ChatGLM-6B-Int4.git
git@gitee.com:frontcold/ChatGLM-6B-Int4.git
frontcold
ChatGLM-6B-Int4
ChatGLM-6B-Int4
master

搜索帮助