Add chat template

#6
by Rocketknight1 HF staff - opened

This PR adds a chat template allowing for easy formatting. You can test it with these quick demos:

from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("gg-hf/shieldgemma-2b", revision="pr/6")

guideline = "Don't commit crimes"

one_turn_chat = [{"role": "user", "content": "Hi there."}]

two_turn_chat = one_turn_chat + [{"role": "assistant", "content": "Assistant response."}]

print(tokenizer.apply_chat_template(one_turn_chat, guideline=guideline, tokenize=False))

print(tokenizer.apply_chat_template(two_turn_chat, guideline=guideline, tokenize=False))
Google org

LGTM

RyanMullins changed pull request status to merged

Sign up or log in to comment