File size: 2,194 Bytes
34a404e
 
 
 
 
 
 
 
 
 
 
 
 
0a33eb4
34a404e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
```CODE: 
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="PleIAs/Monad")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
```

ERROR: 
Traceback (most recent call last):
  File "/tmp/PleIAs_Monad_0KIOpHg.py", line 30, in <module>
    pipe(messages)
    ~~~~^^^^^^^^^^
  File "/tmp/.cache/uv/environments-v2/6b3eac4d38bdc7f2/lib/python3.13/site-packages/transformers/pipelines/text_generation.py", line 325, in __call__
    return super().__call__(Chat(text_inputs), **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/.cache/uv/environments-v2/6b3eac4d38bdc7f2/lib/python3.13/site-packages/transformers/pipelines/base.py", line 1467, in __call__
    return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/.cache/uv/environments-v2/6b3eac4d38bdc7f2/lib/python3.13/site-packages/transformers/pipelines/base.py", line 1473, in run_single
    model_inputs = self.preprocess(inputs, **preprocess_params)
  File "/tmp/.cache/uv/environments-v2/6b3eac4d38bdc7f2/lib/python3.13/site-packages/transformers/pipelines/text_generation.py", line 363, in preprocess
    inputs = self.tokenizer.apply_chat_template(
        prompt_text.messages,
    ...<4 lines>...
        **tokenizer_kwargs,
    )
  File "/tmp/.cache/uv/environments-v2/6b3eac4d38bdc7f2/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/6b3eac4d38bdc7f2/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