mirror of https://github.com/THUDM/ChatGLM2-6B
				
				
				
			Update README
							parent
							
								
									5486f4f170
								
							
						
					
					
						commit
						9d50b01310
					
				
							
								
								
									
										10
									
								
								README.md
								
								
								
								
							
							
						
						
									
										10
									
								
								README.md
								
								
								
								
							| 
						 | 
				
			
			@ -274,19 +274,11 @@ if __name__ == "__main__":
 | 
			
		|||
 | 
			
		||||
默认情况下,模型以 FP16 精度加载,运行上述代码需要大概 13GB 显存。如果你的 GPU 显存有限,可以尝试以量化方式加载模型,使用方法如下:
 | 
			
		||||
 | 
			
		||||
```python
 | 
			
		||||
# 按需修改,目前只支持 4/8 bit 量化
 | 
			
		||||
model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).quantize(8).cuda()
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
模型量化会带来一定的性能损失,经过测试,ChatGLM2-6B 在 4-bit 量化下仍然能够进行自然流畅的生成。
 | 
			
		||||
 | 
			
		||||
如果你的内存不足,可以直接加载量化后的模型:
 | 
			
		||||
```python
 | 
			
		||||
model = AutoModel.from_pretrained("THUDM/chatglm2-6b-int4",trust_remote_code=True).cuda()
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
<!-- 量化模型的参数文件也可以从[这里](https://cloud.tsinghua.edu.cn/d/674208019e314311ab5c/)手动下载。 -->
 | 
			
		||||
模型量化会带来一定的性能损失,经过测试,ChatGLM2-6B 在 4-bit 量化下仍然能够进行自然流畅的生成。 量化模型的参数文件也可以从[这里](https://cloud.tsinghua.edu.cn/d/674208019e314311ab5c/)手动下载。
 | 
			
		||||
 | 
			
		||||
### CPU 部署
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue