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

ไป‹็ป

ChatGLM2-6B ๆ˜ฏๅผ€ๆบไธญ่‹ฑๅŒ่ฏญๅฏน่ฏๆจกๅž‹ ChatGLM-6B ็š„็ฌฌไบŒไปฃ็‰ˆๆœฌ๏ผŒๅœจไฟ็•™ไบ†ๅˆไปฃๆจกๅž‹ๅฏน่ฏๆต็•…ใ€้ƒจ็ฝฒ้—จๆง›่พƒไฝŽ็ญ‰ไผ—ๅคšไผ˜็ง€็‰นๆ€ง็š„ๅŸบ็ก€ไน‹ไธŠ๏ผŒChatGLM2-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 ๆƒ้‡ๅฏนๅญฆๆœฏ็ ”็ฉถๅฎŒๅ…จๅผ€ๆ”พ๏ผŒๅœจๅกซๅ†™้—ฎๅท่ฟ›่กŒ็™ป่ฎฐๅŽไบฆๅ…่ฎธๅ…่ดนๅ•†ไธšไฝฟ็”จใ€‚

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:

  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.'}
}
Downloads last month
561,959
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for zai-org/chatglm2-6b

Adapters
6 models
Quantizations
1 model

Spaces using zai-org/chatglm2-6b 100

Papers for zai-org/chatglm2-6b