💻 项目代码库 • 🐦 推特 • 📃 [GLM@ACL 22] [代码库] • 📃 [GLM-130B@ICLR 23] [代码库]
📍体验更大规模的ChatGLM模型,请访问chatglm.cn
优化示例代码,新增NPU加速支持;
调整依赖库配置;
Updated examples with NPU support;
Modified dependencies;
ChatGLM3-6B 作为ChatGLM系列的最新一代开源模型,在延续前两代模型对话流畅、部署便捷等优势的同时,具备以下显著特性:
ChatGLM3-6B is the newest open-source model in the ChatGLM series. While maintaining the advantages of smooth conversation and easy deployment from its predecessors, it introduces remarkable features:
pip install protobuf transformers==4.30.2 cpm_kernels torch>=2.0 gradio mdtex2html sentencepiece accelerate openmind通过以下代码即可调用 ChatGLM3-6B 模型生成对话内容:
You can generate dialogue responses by executing the following code snippet with the ChatGLM3-6B model:
from openmind import is_torch_npu_available, AutoTokenizer, AutoModel
if is_torch_npu_available():
device = "npu:0"
elif torch.cuda.is_available():
device = "cuda:0"
else:
device = "cpu"
tokenizer = AutoTokenizer.from_pretrained("PyTorch-NPU/chatglm3_6b", trust_remote_code=True)
model = AutoModel.from_pretrained("PyTorch-NPU/chatglm3_6b", trust_remote_code=True, device_map=device).half()
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
print(response)关于更多使用指南,包括如何运行命令行与网页版演示程序,以及通过模型量化技术优化显存占用,请参阅我们的 Github 项目库。
本代码仓库遵循 Apache-2.0 开源协议,ChatGLM3-6B 模型权重的使用需遵守 模型许可协议。
若您认为我们的研究成果对您有所裨益,敬请引用以下论文。
@article{zeng2022glm,
title={Glm-130b: An open bilingual pre-trained model},
author={Zeng, Aohan and Liu, Xiao and Du, Zhengxiao and Wang, Zihan and Lai, Hanyu and Ding, Ming and Yang, Zhuoyi and Xu, Yifan and Zheng, Wendi and Xia, Xiao and others},
journal={arXiv preprint arXiv:2210.02414},
year={2022}
}@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}
}