CyberAgentLM3 是一款仅含解码器的语言模型,基于 2.0 万亿 tokens 从头开始预训练而成。 CyberAgentLM3-Chat 是针对对话场景专门优化的微调模型。
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
model = AutoModelForCausalLM.from_pretrained("cyberagent/calm3-22b-chat", device_map="auto", torch_dtype="auto")
tokenizer = AutoTokenizer.from_pretrained("cyberagent/calm3-22b-chat")
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
messages = [
{"role": "system", "content": "あなたは親切なAIアシスタントです。"},
{"role": "user", "content": "AIによって私たちの暮らしはどのように変わりますか?"}
]
input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
output_ids = model.generate(input_ids,
max_new_tokens=1024,
temperature=0.5,
streamer=streamer)CALM3-Chat 采用 ChatML 作为提示词格式。
<|im_start|>system
あなたは親切なAIアシスタントです。<|im_end|>
<|im_start|>user
AIによって私たちの暮らしはどのように変わりますか?<|im_end|>
<|im_start|>assistant@misc{cyberagent-calm3-22b-chat,
title={cyberagent/calm3-22b-chat},
url={https://huggingface.co/cyberagent/calm3-22b-chat},
author={Ryosuke Ishigami},
year={2024},
}