zai-org / chatglm2-6b

huggingface.co
Total runs: 442.1K
24-hour runs: 2.2K
7-day runs: -1.5K
30-day runs: -4.8K
Model's Last Updated: August 04 2024

Introduction of chatglm2-6b

Model Details of chatglm2-6b

ChatGLM2-6B

💻 Github Repo • 🐦 Twitter • 📃 [GLM@ACL 22] [GitHub] • 📃 [GLM-130B@ICLR 23] [GitHub]

👋 Join our Slack and WeChat

📍Experience the larger-scale ChatGLM model at chatglm.cn

介绍

ChatGLM 2 -6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本,在保留了初代模型对话流畅、部署门槛较低等众多优秀特性的基础之上,ChatGLM 2 -6B 引入了如下新特性:

  1. 更强大的性能 :基于 ChatGLM 初代模型的开发经验,我们全面升级了 ChatGLM2-6B 的基座模型。ChatGLM2-6B 使用了 GLM 的混合目标函数,经过了 1.4T 中英标识符的预训练与人类偏好对齐训练, 评测结果 显示,相比于初代模型,ChatGLM2-6B 在 MMLU(+23%)、CEval(+33%)、GSM8K(+571%) 、BBH(+60%)等数据集上的性能取得了大幅度的提升,在同尺寸开源模型中具有较强的竞争力。
  2. 更长的上下文 :基于 FlashAttention 技术,我们将基座模型的上下文长度(Context Length)由 ChatGLM-6B 的 2K 扩展到了 32K,并在对话阶段使用 8K 的上下文长度训练,允许更多轮次的对话。但当前版本的 ChatGLM2-6B 对单轮超长文档的理解能力有限,我们会在后续迭代升级中着重进行优化。
  3. 更高效的推理 :基于 Multi-Query Attention 技术,ChatGLM2-6B 有更高效的推理速度和更低的显存占用:在官方的模型实现下,推理速度相比初代提升了 42%,INT4 量化下,6G 显存支持的对话长度由 1K 提升到了 8K。
  4. 更开放的协议 :ChatGLM2-6B 权重对学术研究 完全开放 ,在填写 问卷 进行登记后 亦允许免费商业使用

ChatGLM 2 -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:

  1. Stronger Performance : Based on the development experience of the first-generation ChatGLM model, we have fully upgraded the base model of ChatGLM2-6B. ChatGLM2-6B uses the hybrid objective function of GLM , and has undergone pre-training with 1.4T bilingual tokens and human preference alignment training. The evaluation results show that, compared to the first-generation model, ChatGLM2-6B has achieved substantial improvements in performance on datasets like MMLU (+23%), CEval (+33%), GSM8K (+571%), BBH (+60%), showing strong competitiveness among models of the same size.
  2. Longer Context : Based on FlashAttention technique, we have extended the context length of the base model from 2K in ChatGLM-6B to 32K, and trained with a context length of 8K during the dialogue alignment, allowing for more rounds of dialogue. However, the current version of ChatGLM2-6B has limited understanding of single-round ultra-long documents, which we will focus on optimizing in future iterations.
  3. More Efficient Inference : Based on Multi-Query Attention technique, ChatGLM2-6B has more efficient inference speed and lower GPU memory usage: under the official implementation, the inference speed has increased by 42% compared to the first generation; under INT4 quantization, the dialogue length supported by 6G GPU memory has increased from 1K to 8K.
  4. More Open License : ChatGLM2-6B weights are completely open for academic research, and free commercial use is also allowed after completing the questionnaire .
软件依赖
pip install protobuf transformers==4.30.2 cpm_kernels torch>=2.0 gradio mdtex2html sentencepiece accelerate
代码调用

可以通过如下代码调用 ChatGLM-6B 模型来生成对话:

>>> from transformers import AutoTokenizer, AutoModel
>>> tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True)
>>> model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).half().cuda()
>>> model = model.eval()
>>> response, history = model.chat(tokenizer, "你好", history=[])
>>> print(response)
你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
>>> response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
>>> print(response)
晚上睡不着可能会让你感到焦虑或不舒服,但以下是一些可以帮助你入睡的方法:

1. 制定规律的睡眠时间表:保持规律的睡眠时间表可以帮助你建立健康的睡眠习惯,使你更容易入睡。尽量在每天的相同时间上床,并在同一时间起床。
2. 创造一个舒适的睡眠环境:确保睡眠环境舒适,安静,黑暗且温度适宜。可以使用舒适的床上用品,并保持房间通风。
3. 放松身心:在睡前做些放松的活动,例如泡个热水澡,听些轻柔的音乐,阅读一些有趣的书籍等,有助于缓解紧张和焦虑,使你更容易入睡。
4. 避免饮用含有咖啡因的饮料:咖啡因是一种刺激性物质,会影响你的睡眠质量。尽量避免在睡前饮用含有咖啡因的饮料,例如咖啡,茶和可乐。
5. 避免在床上做与睡眠无关的事情:在床上做些与睡眠无关的事情,例如看电影,玩游戏或工作等,可能会干扰你的睡眠。
6. 尝试呼吸技巧:深呼吸是一种放松技巧,可以帮助你缓解紧张和焦虑,使你更容易入睡。试着慢慢吸气,保持几秒钟,然后缓慢呼气。

如果这些方法无法帮助你入睡,你可以考虑咨询医生或睡眠专家,寻求进一步的建议。

关于更多的使用说明,包括如何运行命令行和网页版本的 DEMO,以及使用模型量化以节省显存,请参考我们的 Github Repo

For more instructions, including how to run CLI and web demos, and model quantization, please refer to our Github Repo .

Change Log
  • v1.0
协议

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

引用

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

If you find our work helpful, please consider citing the following paper.

@misc{glm2024chatglm,
      title={ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools}, 
      author={Team GLM and Aohan Zeng and Bin Xu and Bowen Wang and Chenhui Zhang and Da Yin and Diego Rojas and Guanyu Feng and Hanlin Zhao and Hanyu Lai and Hao Yu and Hongning Wang and Jiadai Sun and Jiajie Zhang and Jiale Cheng and Jiayi Gui and Jie Tang and Jing Zhang and Juanzi Li and Lei Zhao and Lindong Wu and Lucen Zhong and Mingdao Liu and Minlie Huang and Peng Zhang and Qinkai Zheng and Rui Lu and Shuaiqi Duan and Shudan Zhang and Shulin Cao and Shuxun Yang and Weng Lam Tam and Wenyi Zhao and Xiao Liu and Xiao Xia and Xiaohan Zhang and Xiaotao Gu and Xin Lv and Xinghan Liu and Xinyi Liu and Xinyue Yang and Xixuan Song and Xunkai Zhang and Yifan An and Yifan Xu and Yilin Niu and Yuantao Yang and Yueyan Li and Yushi Bai and Yuxiao Dong and Zehan Qi and Zhaoyu Wang and Zhen Yang and Zhengxiao Du and Zhenyu Hou and Zihan Wang},
      year={2024},
      eprint={2406.12793},
      archivePrefix={arXiv},
      primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'}
}

Runs of zai-org chatglm2-6b on huggingface.co

442.1K
Total runs
2.2K
24-hour runs
4.5K
3-day runs
-1.5K
7-day runs
-4.8K
30-day runs

More Information About chatglm2-6b huggingface.co Model

chatglm2-6b huggingface.co

chatglm2-6b huggingface.co is an AI model on huggingface.co that provides chatglm2-6b's model effect (), which can be used instantly with this zai-org chatglm2-6b model. huggingface.co supports a free trial of the chatglm2-6b model, and also provides paid use of the chatglm2-6b. Support call chatglm2-6b model through api, including Node.js, Python, http.

chatglm2-6b huggingface.co Url

https://huggingface.co/zai-org/chatglm2-6b

zai-org chatglm2-6b online free

chatglm2-6b huggingface.co is an online trial and call api platform, which integrates chatglm2-6b's modeling effects, including api services, and provides a free online trial of chatglm2-6b, you can try chatglm2-6b online for free by clicking the link below.

zai-org chatglm2-6b online free url in huggingface.co:

https://huggingface.co/zai-org/chatglm2-6b

chatglm2-6b install

chatglm2-6b is an open source model from GitHub that offers a free installation service, and any user can find chatglm2-6b on GitHub to install. At the same time, huggingface.co provides the effect of chatglm2-6b install, users can directly use chatglm2-6b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

chatglm2-6b install url in huggingface.co:

https://huggingface.co/zai-org/chatglm2-6b

Url of chatglm2-6b

chatglm2-6b huggingface.co Url

Provider of chatglm2-6b huggingface.co

zai-org
ORGANIZATIONS

Other API from zai-org

huggingface.co

Total runs: 1.9M
Run Growth: -1.4M
Growth Rate: -72.24%
Updated:September 11 2026
huggingface.co

Total runs: 1.9M
Run Growth: -106.5K
Growth Rate: -5.66%
Updated:January 29 2026
huggingface.co

Total runs: 1.6M
Run Growth: 1.3M
Growth Rate: 100.00%
Updated:September 07 2026
huggingface.co

Total runs: 1.3M
Run Growth: -706.1K
Growth Rate: -53.41%
Updated:September 01 2026
huggingface.co

Total runs: 941.9K
Run Growth: -1.8M
Growth Rate: -188.05%
Updated:September 01 2026
huggingface.co

Total runs: 669.0K
Run Growth: 626.7K
Growth Rate: 98.61%
Updated:September 04 2026
huggingface.co

Total runs: 250.3K
Run Growth: -212.3K
Growth Rate: -80.46%
Updated:April 16 2026
huggingface.co

Total runs: 203.0K
Run Growth: -733.7K
Growth Rate: -269.02%
Updated:April 05 2026
huggingface.co

Total runs: 97.0K
Run Growth: -187.4K
Growth Rate: -184.31%
Updated:August 11 2025
huggingface.co

Total runs: 87.1K
Run Growth: -1.8K
Growth Rate: -2.07%
Updated:March 13 2025
huggingface.co

Total runs: 84.0K
Run Growth: 3.7K
Growth Rate: 4.86%
Updated:January 29 2026
huggingface.co

Total runs: 80.8K
Run Growth: -43.5K
Growth Rate: -54.00%
Updated:August 11 2025
huggingface.co

Total runs: 78.8K
Run Growth: 8.0K
Growth Rate: 9.73%
Updated:May 13 2026
huggingface.co

Total runs: 77.4K
Run Growth: -82.6K
Growth Rate: -105.42%
Updated:December 10 2025
huggingface.co

Total runs: 76.3K
Run Growth: -8.1K
Growth Rate: -10.65%
Updated:December 05 2024
huggingface.co

Total runs: 58.9K
Run Growth: -63.5K
Growth Rate: -108.01%
Updated:August 11 2026
huggingface.co

Total runs: 44.9K
Run Growth: -82.9K
Growth Rate: -182.81%
Updated:October 25 2025
huggingface.co

Total runs: 22.0K
Run Growth: -2.3K
Growth Rate: -10.22%
Updated:November 23 2024
huggingface.co

Total runs: 20.5K
Run Growth: -62.9K
Growth Rate: -303.60%
Updated:March 03 2025
huggingface.co

Total runs: 20.1K
Run Growth: -20.8K
Growth Rate: -100.51%
Updated:April 14 2025
huggingface.co

Total runs: 18.3K
Run Growth: -9.7K
Growth Rate: -52.88%
Updated:September 30 2025
huggingface.co

Total runs: 15.4K
Run Growth: -2.5K
Growth Rate: -16.41%
Updated:November 23 2024
huggingface.co

Total runs: 14.0K
Run Growth: -13.3K
Growth Rate: -93.35%
Updated:December 23 2025
huggingface.co

Total runs: 14.0K
Run Growth: 13.0K
Growth Rate: 96.42%
Updated:September 04 2026
huggingface.co

Total runs: 13.1K
Run Growth: 2.5K
Growth Rate: 18.98%
Updated:December 09 2025
huggingface.co

Total runs: 9.8K
Run Growth: 1.4K
Growth Rate: 14.29%
Updated:January 15 2026
huggingface.co

Total runs: 7.9K
Run Growth: -3.6K
Growth Rate: -45.43%
Updated:October 16 2025
huggingface.co

Total runs: 7.1K
Run Growth: -7.1K
Growth Rate: -99.58%
Updated:April 22 2025
huggingface.co

Total runs: 6.2K
Run Growth: -1.7K
Growth Rate: -28.22%
Updated:March 11 2025
huggingface.co

Total runs: 5.3K
Run Growth: -1.9K
Growth Rate: -36.13%
Updated:January 27 2025
huggingface.co

Total runs: 3.9K
Run Growth: -5.3K
Growth Rate: -142.00%
Updated:December 09 2025
huggingface.co

Total runs: 3.1K
Run Growth: 1.1K
Growth Rate: 36.55%
Updated:August 04 2024
huggingface.co

Total runs: 2.9K
Run Growth: -1.6K
Growth Rate: -53.96%
Updated:October 25 2025
huggingface.co

Total runs: 1.8K
Run Growth: 773
Growth Rate: 47.25%
Updated:August 12 2025
huggingface.co

Total runs: 679
Run Growth: 309
Growth Rate: 44.98%
Updated:March 02 2023
huggingface.co

Total runs: 587
Run Growth: -31
Growth Rate: -5.27%
Updated:August 11 2025
huggingface.co

Total runs: 433
Run Growth: -1.2K
Growth Rate: -294.09%
Updated:January 02 2025
huggingface.co

Total runs: 419
Run Growth: 244
Growth Rate: 59.51%
Updated:October 20 2023
huggingface.co

Total runs: 322
Run Growth: 76
Growth Rate: 23.60%
Updated:December 10 2024
huggingface.co

Total runs: 321
Run Growth: -419
Growth Rate: -137.38%
Updated:October 25 2025
huggingface.co

Total runs: 300
Run Growth: 144
Growth Rate: 47.37%
Updated:March 02 2023
huggingface.co

Total runs: 277
Run Growth: 70
Growth Rate: 25.27%
Updated:November 20 2023
huggingface.co

Total runs: 258
Run Growth: 111
Growth Rate: 44.22%
Updated:October 20 2023
huggingface.co

Total runs: 249
Run Growth: 107
Growth Rate: 43.85%
Updated:October 20 2023