Downloads · 30 days
15
0% of all-time downloads
p208p2002/chatglm3-6b-chat-template
chatglm3-6b-chat-template is a machine learning model from p208p2002. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
此版本與 THUDM/ChatGLM3-6B 無異, 僅對tokenizer增加了tokenizer.chatemplate和specialtokens。
Downloads · 30 days
15
0% of all-time downloads
All-time downloads
5.4K
Public
Parameters
6.2B
25 GB on disk
Likes
1
Public
Click a slice to open those files.
.bin12.5 GB · 50%
From the Hugging Face model README
此版本與 THUDM/ChatGLM3-6B 無異,
僅對tokenizer增加了tokenizer.chat_emplate和special_tokens。
修改後的版本能使tokenizer運用 hf tokenizer 的.apply_chat_template,統一API用法。
修正已經同步提交至THUDM/chatglm3-6b並且等待合併:
from transformers import AutoTokenizer,AutoModelForCausalLM
model_id_or_path = "p208p2002/chatglm3-6b-chat-template"
tokenizer = AutoTokenizer.from_pretrained(model_id_or_path,trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id_or_path,device_map="auto",trust_remote_code=True)
inputs = tokenizer.apply_chat_template([
{"role":"system","content":"你是一位樂於助人、尊重他人且誠實的助理。請始終以最有幫助的方式回答問題。如果你對某個問題不知道答案,請不要提供虛假信息。"},
{"role":"user","content":"如何減緩地球暖化?"}
],add_generation_prompt=True,tokenize=True,return_tensors="pt")
out = model.generate(inputs,max_new_tokens=256)
print(tokenizer.decode(out[0]))