💻 Github Repo • 🐦 Twitter • 📃 [GLM@ACL 22] [GitHub] • 📃 [GLM-130B@ICLR 23] [GitHub]
📍Experience the larger-scale ChatGLM model at chatglm.cn
ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本,在保留了初代模型对话流畅、部署门槛较低等众多优秀特性的基础之上,ChatGLM2-6B 引入了如下新特性:
ChatGLM2-6B is the second-generation version of the open-source bilingual (Chinese-English) chat model ChatGLM-6B. It retains the smooth conversation flow and low deployment threshold of the first-generation model, while introducing the following new features:
可以通过如下代码调用 ChatGLM-6B 模型来生成对话:
>>> from openmind import AutoTokenizer, AutoModelForCausalLM
>>> tokenizer = AutoTokenizer.from_pretrained("openmind/glm2_6b_ms")
>>> model = AutoModelForCausalLM.from_pretrained("openmind/glm2_6b_ms")
>>> queries = ["你好", "请介绍一下杭州"]
>>> history = []
>>> for query in queries:
>>> prompt = tokenizer.build_prompt(query, history=history)
>>> input_id = tokenizer.encode(prompt)
>>> output = model.generate([input_id], do_sample=False)
>>> response = tokenizer.decode(output)
>>> print(response)
>>> history += [(query, response)]
response1:你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
response2:杭州是中国浙江省省会,位于浙江省东南部,地处浙江省北部,东临东海,南接福建省,北与江苏省毗邻,是中国著名的旅游城市之一。\n\n杭州有着悠久的历史和文化,被誉为“人间天堂”,自东晋以来,杭州一直是政治、经济、文化和交通中心。宋代,杭州成为繁华的商业城市,被誉为“东南第一重镇”。明清时期,杭州成为全国著名的“人间天堂”,吸引了大量商人、文人、官员前来观光、交流。\n\n如今,杭州已成为中国的著名旅游城市之一,被誉为“中国最具魅力的城市”之一。杭州拥有许多著名的景点和美食,如西湖、灵隐寺、千岛湖、宋城等,吸引了大量国内外游客前来观光旅游。此外,杭州还有着发达的经济和优美的自然环境,被誉为“山水甲天下”。关于更多的使用说明,包括如何运行命令行和网页版本的 DEMO,以及使用模型量化以节省显存,请参考我们的 Github Repo。
For more instructions, including how to run CLI and web demos, and model quantization, please refer to our Github Repo.
以 ADGEN (广告生成) 数据集为例,ADGEN 数据集任务为根据输入(content)生成一段广告词(summary)。
{"content": "类型#上衣*版型#宽松*版型#显瘦*图案#线条*衣样式#衬衫*衣袖型#泡泡袖*衣款式#抽绳", "summary": "这件衬衫的款式非常的宽松,利落的线条可以很好的隐藏身材上的小缺点,穿在身上有着很好的显瘦效果。领口装饰了一个可爱的抽绳,漂亮的绳结展现出了十足的个性,配合时尚的泡泡袖型,尽显女性甜美可爱的气息。"}从 Google Drive 或者 Tsinghua Cloud 下载处理好的 ADGEN 数据集,目录结构为
AdvertiseGen
├── train.json
└── dev.jsoncd example
bash msrun.sh "finetune.py --train_dataset /{path}/AdvertiseGen/train.json"cd example
python inference.py本仓库的代码依照 Apache-2.0 协议开源,ChatGLM2-6B 模型的权重的使用则需要遵循 Model License。
如果你觉得我们的工作有帮助的话,请考虑引用下列论文,ChatGLM2-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}
}本模型支持版本为openmind-v0.7,mindformers-1.1.0rc1,MindSpore-2.3.0rc1