怎么看一个网站是不是外包做的,12380举报网站制度建设,彩票网站开发有连带,触摸网站手机ChatGLM3简介和使用 ChatGLM3简介推理代码命令行加载 ChatGLM3
简介
ChatGLM3 是智谱AI和清华大学 KEG 实验室联合发布的新一代对话预训练模型。ChatGLM3-6B 是 ChatGLM3 系列中的开源模型#xff0c;在保留了前两代模型对话流畅、部署门槛低等众多优秀特性的基础上#xf… ChatGLM3简介和使用 ChatGLM3简介推理代码命令行加载 ChatGLM3
简介
ChatGLM3 是智谱AI和清华大学 KEG 实验室联合发布的新一代对话预训练模型。ChatGLM3-6B 是 ChatGLM3 系列中的开源模型在保留了前两代模型对话流畅、部署门槛低等众多优秀特性的基础上ChatGLM3-6B 引入了如下特性 **更强大的基础模型**ChatGLM3-6B-Base 具有在 10B 以下的基础模型中最强的性能。 ModelGSM8KMATHBBHMMLUC-EvalCMMLUMBPPAGIEvalChatGLM2-6B-Base32.46.533.747.951.750.0--Best Baseline10B 以下52.113.145.060.163.562.247.545.8ChatGLM3-6B-Base72.325.766.161.469.067.552.453.7 Model平均SummarySingle-Doc QAMulti-Doc QACodeFew-shotSyntheticChatGLM2-6B-32K41.524.837.634.752.851.347.7ChatGLM3-6B-32K50.226.645.846.156.261.265 更完整的功能支持 ChatGLM3-6B 采用了全新设计的Prompt 格式。 多轮对话同时原生支持工具调用Function Call代码执行Code InterpreterAgent 任务 更全面的开源序列 ModelSeq LengthDownloadChatGLM3-6B8kHuggingFace | ModelScopeChatGLM3-6B-Base8kHuggingFace | ModelScopeChatGLM3-6B-32K32kHuggingFace | ModelScope
推理代码
from modelscope import AutoTokenizer, AutoModel, snapshot_download
model_dir snapshot_download(ZhipuAI/chatglm3-6b, revision master)
tokenizer AutoTokenizer.from_pretrained(model_dir, trust_remote_codeTrue)
model AutoModel.from_pretrained(model_dir, trust_remote_codeTrue).half().cuda()
model model.eval()
response, history model.chat(tokenizer, 你好, history[])
print(response)
response, history model.chat(tokenizer, 晚上睡不着应该怎么办, historyhistory)
print(response)命令行加载
import os
import platform
from transformers import AutoTokenizer, AutoModelmodel_path model/chatglm3_32k/tokenizer AutoTokenizer.from_pretrained(model_path, trust_remote_codeTrue)
model AutoModel.from_pretrained(model_path, trust_remote_codeTrue).cuda()
# 多显卡支持使用下面两行代替上面一行将num_gpus改为你实际的显卡数量
# from utils import load_model_on_gpus
# model load_model_on_gpus(model_path, num_gpus2)
model model.eval()os_name platform.system()
clear_command cls if os_name Windows else clear
stop_stream Falsewelcome_prompt 欢迎使用 ChatGLM3-6B 模型输入内容即可进行对话clear 清空对话历史stop 终止程序def build_prompt(history):prompt welcome_promptfor query, response in history:prompt f\n\n用户{query}prompt f\n\nChatGLM3-6B{response}return promptdef main():past_key_values, history None, []global stop_streamprint(welcome_prompt)while True:query input(\n用户)if query.strip() stop:breakif query.strip() clear:past_key_values, history None, []os.system(clear_command)print(welcome_prompt)continueprint(\nChatGLM, end)current_length 0for response, history, past_key_values in model.stream_chat(tokenizer, query, historyhistory,temperature1,past_key_valuespast_key_values,return_past_key_valuesTrue):if stop_stream:stop_stream Falsebreakelse:print(response[current_length:], end, flushTrue)current_length len(response)print(history)print()# print(past_key_values)if __name__ __main__:main()