fb700's picture
Update README.md
dffa9c0
|
raw
history blame
2.96 kB

license: apache-2.0 ChatGLM-6B 是开源中英双语对话模型 本次训练基于ChatGLM-6B 的第一代版本,在保留了初代模型对话流畅、部署门槛较低等众多优秀特性的基础之上,本次训练使用了30万条fitness数据,40万条gpt4数据,以及30万条人类反馈数据的微调。 训练后在健康咨询,文档总结 上强于glm2,fp16运行时速度上比原模型提升20%.可以代替原有官方模型,大家可以fp16、int4、int8使用。 协议 本仓库的代码依照 Apache-2.0 协议开源,ChatGLM2-6B 模型的权重的使用则需要遵循 Model License。 授权方式,与原项目一致,未经过chatglm原开发方允许,不得用于商业用途。 在原项目上的训练由智能AI用户[帛凡]于2023年基于ChatGLM独立训练的人工智能助手(严禁售卖或者商业项目,任何通过此项目产生的知识仅用于参考,作者不承担任何责任)。 16G及以上显存用下载压缩包即lora文件使用,可支持ChatGLM原生模型和LoRA微调后的模型 Usage (HuggingFace Transformers) Without textgen, you can use the model like this: First, you pass your input through the transformer model, then you get the generated sentence. Install package: pip install transformers peft

import sys from peft import PeftModel from transformers import AutoModel, AutoTokenizer sys.path.append('..') model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, device_map='auto') model = PeftModel.from_pretrained(model, "model/chatglm_fitness_lora") model = model.half().cuda() # fp16 tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) sents = ['新冠肺炎怎么预防。\n答:'] for s in sents: response = model.chat(tokenizer, s, max_length=128, eos_token_id=tokenizer.eos_token_id) print(response)

output:

模型文件组成: chatglm_fitness_lora ├── adapter_config.json └── adapter_model.bin


16G及以下显存用户下载整个模型,可支持支持fp16、int8、int4 Usage (HuggingFace Transformers) Without textgen, you can use the model like this: First, you pass your input through the transformer model, then you get the generated sentence. Install package: pip install transformers peft

import sys from transformers import AutoModel, AutoTokenizer sys.path.append('..') model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, device_map='auto') #model = model.half().quantize(4).cuda() # int4 #model = model.half().quantize(8).cuda() # int8 #model = model.half().cuda() # fp16 tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) sents = ['新冠肺炎怎么预防。\n答:'] for s in sents: response = model.chat(tokenizer, s, max_length=128, eos_token_id=tokenizer.eos_token_id) print(response)

output: