Upload PleIAs_Baguettotron_1.txt with huggingface_hub
Browse files- PleIAs_Baguettotron_1.txt +40 -0
PleIAs_Baguettotron_1.txt
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```CODE:
|
| 2 |
+
# Load model directly
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 4 |
+
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("PleIAs/Baguettotron")
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained("PleIAs/Baguettotron")
|
| 7 |
+
messages = [
|
| 8 |
+
{"role": "user", "content": "Who are you?"},
|
| 9 |
+
]
|
| 10 |
+
inputs = tokenizer.apply_chat_template(
|
| 11 |
+
messages,
|
| 12 |
+
add_generation_prompt=True,
|
| 13 |
+
tokenize=True,
|
| 14 |
+
return_dict=True,
|
| 15 |
+
return_tensors="pt",
|
| 16 |
+
).to(model.device)
|
| 17 |
+
|
| 18 |
+
outputs = model.generate(**inputs, max_new_tokens=40)
|
| 19 |
+
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
ERROR:
|
| 23 |
+
Traceback (most recent call last):
|
| 24 |
+
File "/tmp/PleIAs_Baguettotron_1aOF5lK.py", line 31, in <module>
|
| 25 |
+
inputs = tokenizer.apply_chat_template(
|
| 26 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
|
| 27 |
+
messages,
|
| 28 |
+
^^^^^^^^^
|
| 29 |
+
...<3 lines>...
|
| 30 |
+
return_tensors="pt",
|
| 31 |
+
^^^^^^^^^^^^^^^^^^^^
|
| 32 |
+
).to(model.device)
|
| 33 |
+
^
|
| 34 |
+
File "/tmp/.cache/uv/environments-v2/764d8b6eaf4a560a/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 1646, in apply_chat_template
|
| 35 |
+
chat_template = self.get_chat_template(chat_template, tools)
|
| 36 |
+
File "/tmp/.cache/uv/environments-v2/764d8b6eaf4a560a/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 1824, in get_chat_template
|
| 37 |
+
raise ValueError(
|
| 38 |
+
...<4 lines>...
|
| 39 |
+
)
|
| 40 |
+
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
|