Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built-in apply_chat_template #60

Open
ahuang11 opened this issue Oct 14, 2023 · 2 comments
Open

Use built-in apply_chat_template #60

ahuang11 opened this issue Oct 14, 2023 · 2 comments

Comments

@ahuang11
Copy link
Collaborator

I tried to design my own apply_template function, but I found that there's one from transformers.
https://github.com/holoviz-topics/panel-chat-examples/blob/main/docs/examples/mistral/mistral_with_memory.py

from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
chat = [
  {"role": "system", "content": "You are a helpful bot."},
  {"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!"},
]

print(tokenizer.apply_chat_template(chat, tokenize=False))
@ahuang11
Copy link
Collaborator Author

Something about this isn't supported with ctransformers.

@ahuang11
Copy link
Collaborator Author

ahuang11 commented Nov 1, 2023

Working example in holoviz/panel#5764, but involves transformers lib too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant