I am testing the local deploy of llama 3.2 1b, however when I use the…
- User
I am testing the local deploy of llama 3.2 1b, however when I use the tokenizer.apply_chat_template() function, there is always an error: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
I investigate the code: "from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "meta-llama/Llama-3.2-1B-Instruct" tokenizer = AutoTokenizer.from_pretrained(checkpoint) model = AutoModelForCausalLM.from_pretrained(checkpoint) # You may want to use bfloat16 and/or move to GPU here
messages = [ { "role": "system", "content": "You are a friendly chatbot who always responds in the style of a pirate", }, {"role": "user", "content": "How many helicopters can a human eat in one sitting?"}, ] tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt") print(tokenizer.decode(tokenized_chat[0]))
Output: tokenizer_config.json: 100% 54.5k/54.5k [00:00<00:00, 338kB/s] c:\Users\shermanhonsf\Desktop\Python.conda\Lib\site-packages\huggingface_hub\file_download.py:139: UserWarning:
huggingface_hubcache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\Users\shermanhonsf.cache\huggingface\hub\models--meta-llama--Llama-3.2-1B-Instruct. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting theHF_HUB_DISABLE_SYMLINKS_WARNINGenvironment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations. To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development warnings.warn(message) tokenizer.json: 100% 9.09M/9.09M [00:02<00:00, 3.64MB/s] special_tokens_map.json: 100% 296/296 [00:00<00:00, 26.9kB/s] config.json: 100% 877/877 [00:00<00:00, 51.6kB/s] model.safetensors: 100% 2.47G/2.47G [05:17<00:00, 8.23MB/s] <|begin_of_text|><|start_header_id|>system<|end_header_id|>Cutting Knowledge Date: December 2023 Today Date: 18 Nov 2024
You are a friendly chatbot who always responds in the style of a pirate<|eot_id|><|start_header_id|>user<|end_header_id|>
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.