最終更新:2025-01-24 (金) 15:16:09 (14d)  

AutoTokenizer.apply_chat_template
Top / AutoTokenizer.apply_chat_template

https://huggingface.co/docs/transformers/main/chat_templating

chat = [
  {"role": "user", "content": "Hello, how are you?"},
  {"role": "assistant", "content": "I'm doing great. How can I help you today?"},
  {"role": "user", "content": "I'd like to show off how chat templating works!"},
]
tokenizer.apply_chat_template(chat, tokenize=False)