saffr0n commited on
Commit
39c0012
1 Parent(s): 273f526

Update apply_chat_template

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -31,6 +31,22 @@ this demo is governed by the original [license](https://huggingface.co/spaces/hu
31
 
32
  SYSTEM_PROMPT = "நீங்கள் உதவிகரமான மற்றும் மரியாதைக்குரிய மற்றும் நேர்மையான AI உதவியாளர்."
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  if not torch.cuda.is_available():
35
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
36
 
@@ -38,6 +54,7 @@ if torch.cuda.is_available():
38
  model_id = "abhinand/tamil-llama-7b-instruct-v0.1"
39
  model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
40
  tokenizer = AutoTokenizer.from_pretrained(model_id)
 
41
  tokenizer.use_default_system_prompt = False
42
 
43
  @spaces.GPU
 
31
 
32
  SYSTEM_PROMPT = "நீங்கள் உதவிகரமான மற்றும் மரியாதைக்குரிய மற்றும் நேர்மையான AI உதவியாளர்."
33
 
34
+ PROMPT_TEMPLATE = """
35
+ ## Instructions:
36
+ {% if messages[0]['role'] == 'system' %}
37
+ {{ messages[0]['content'] + '\n\n' }}
38
+ {% endif %}
39
+
40
+ {% for message in messages %}
41
+ {% if message['role'] == 'user' %}
42
+ {{ '## Input:\n' + message['content'] + '\n'}}
43
+ {% elif message['role'] == 'assistant' %}
44
+ {{ '## Response:\n' + message['content'] + '\n'}}
45
+ {% endif %}
46
+ {% endfor %}
47
+ ## Response:
48
+ """
49
+
50
  if not torch.cuda.is_available():
51
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
52
 
 
54
  model_id = "abhinand/tamil-llama-7b-instruct-v0.1"
55
  model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
56
  tokenizer = AutoTokenizer.from_pretrained(model_id)
57
+ tokenizer.chat_template = PROMPT_TEMPLATE
58
  tokenizer.use_default_system_prompt = False
59
 
60
  @spaces.GPU