---
title: THUDM_chatglm-6b
canonical_url: "https://www.modelscope.cn/models/mindnlp/THUDM_chatglm-6b"
md_url: "https://www.modelscope.cn/models/mindnlp/THUDM_chatglm-6b.md"
repository: mindnlp/THUDM_chatglm-6b
last_updated: 2023-12-17
license: "Apache License 2.0"
model_type:
  - glm
architectures:
  - ChatGLMModel
library_name:
  - mindspore
frameworks:
  - mindspore
language:
  - cn
  - en
domain:
  - nlp
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 1580
stars: 1
tags:
  - "文本生成"
  - text-generation
  - Zhipu.ai
  - mindnlp
  - chatglm-6b
  - "中英"
---

# THUDM_chatglm-6b

> THUDM_chatglm-6b - mindnlp 在 ModelScope 开源的模型。ChatGLM-6B模型介绍 ChatGLM-6B 是一个开源的、支持中英双语问答的对话语言模型，基于 General Language Model (GLM) 架构，具有 62 亿参数。结合模型量化技术，用户可以在消费级的显卡上进行本地部署（INT4 量化级别下最低只需 6GB 显存）。ChatGLM-6B 使用了和 ChatGLM 相同的技术，针对中文问答和对话进行了优化。经过约 1T…

mindnlp/THUDM_chatglm-6b 是 ModelScope 魔搭社区上的机器学习模型，采用 Apache License 2.0 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: mindnlp/THUDM_chatglm-6b
- **License**: Apache License 2.0
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Tags**: 文本生成, text-generation, Zhipu.ai, mindnlp, chatglm-6b, 中英
- **Downloads**: 1580
- **Stars**: 1
- **Last updated**: 2023-12-17

Source: https://www.modelscope.cn/models/mindnlp/THUDM_chatglm-6b

---

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

ChatGLM-6B is an open bilingual language model based on General Language Model (GLM) framework, with 6.2 billion parameters. With the quantization technique, users can deploy locally on consumer-grade graphics cards (only 6GB of GPU memory is required at the INT4 quantization level). ChatGLM-6B uses technology similar to ChatGPT, optimized for Chinese QA and dialogue. The model is trained for about 1T tokens of Chinese and English corpus, supplemented by supervised fine-tuning, feedback bootstrap, and reinforcement learning wit human feedback. With only about 6.2 billion parameters, the model is able to generate answers that are in line with human preference.

### 环境搭建
本模型环境需安装最新版的mindnlp
```
pip install git+https://github.com/mindspore-lab/mindnlp.git
```

### 软件依赖
```
pip install "mindspore>=2.2"
```

### 代码范例


```python
from mindnlp.transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", from_pt=True)
model = AutoModelForSeq2SeqLM.from_pretrained("THUDM/chatglm-6b", from_pt=True).half()
model.set_train(False)

prompt = "你好"
history = []
response, history = model.chat(tokenizer, prompt, history=history)
print(response)
# '你好👋！我是人工智能助手 ChatGLM-6B，很高兴见到你，欢迎问我任何问题。'
```

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