| ```CODE: |
| # Load model directly |
| from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
| tokenizer = AutoTokenizer.from_pretrained("PleIAs/Monad") |
| model = AutoModelForCausalLM.from_pretrained("PleIAs/Monad") |
| messages = [ |
| {"role": "user", "content": "Who are you?"}, |
| ] |
| inputs = tokenizer.apply_chat_template( |
| messages, |
| add_generation_prompt=True, |
| tokenize=True, |
| return_dict=True, |
| return_tensors="pt", |
| ).to(model.device) |
|
|
| outputs = model.generate(**inputs, max_new_tokens=40) |
| print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) |
| ``` |
|
|
| ERROR: |
| Traceback (most recent call last): |
| File "/tmp/PleIAs_Monad_1hG6LEH.py", line 31, in <module> |
| inputs = tokenizer.apply_chat_template( |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ |
| messages, |
| ^^^^^^^^^ |
| ...<3 lines>... |
| return_tensors="pt", |
| ^^^^^^^^^^^^^^^^^^^^ |
| ).to(model.device) |
| ^ |
| File "/tmp/.cache/uv/environments-v2/b8e73a8c87ba95e6/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 1646, in apply_chat_template |
| chat_template = self.get_chat_template(chat_template, tools) |
| File "/tmp/.cache/uv/environments-v2/b8e73a8c87ba95e6/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 1824, in get_chat_template |
| raise ValueError( |
| ...<4 lines>... |
| ) |
| ValueError: Cannot use chat template functions because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating |
|
|