-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed
Description
System Info
transformersversion: 4.37.0- Platform: Linux-4.14.105-1-tlinux3-0013-x86_64-with-glibc2.10
- Python version: 3.8.8
- Huggingface_hub version: 0.20.3
- Safetensors version: 0.4.2
- Accelerate version: 0.23.0
- Accelerate config: not found
- PyTorch version (GPU?): 2.0.1+cu117 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: Yes
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
- installing package
jinja2==3.0.0
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen1.5-72B-Chat")
prompt = "Give me a short introduction to large language model."
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)will raise an error:
.../transformers/tokenization_utils_base.py in _compile_jinja_template(self, chat_template)
1769
1770 if version.parse(jinja2.__version__) <= version.parse("3.0.0"):
-> 1771 raise ImportError(
1772 "apply_chat_template requires jinja2>=3.0.0 to be installed. Your version is " f"{jinja2.__version__}."
1773 )
ImportError: apply_chat_template requires jinja2>=3.0.0 to be installed. Your version is 3.0.0.
There is a logical conflict in the error message, due to line 1770 shows version <= 3.0.0 will raise this ImportError.
Expected behavior
change the if condition to:
if version.parse(jinja2.__version__) < version.parse("3.0.0"):Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels