dar-tau commited on
Commit
1d42cd5
·
verified ·
1 Parent(s): d768ac5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -8,11 +8,10 @@ import torch
8
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
9
  from dataclasses import dataclass
10
 
11
- torch.set_grad_enabled(False)
12
- model_name = "TheBloke/OpenHermes-2.5-Mistral-7B-GPTQ"
13
- token = os.environ['hf_token']
14
- pipe = pipeline("text-generation", model=model_name, device="cuda")
15
- generate_kwargs = {'max_new_tokens': 20}
16
 
17
 
18
  system_prompt = '''You are given a partial input text for another AI chat interface.
@@ -26,7 +25,7 @@ Answers should be only the completions themselves. If you have nothing as a comp
26
  '''
27
 
28
 
29
- extra_prompts = '''
30
  Examples:
31
  (1)
32
  User: "Help me write a sentiment analysis pipeline"
@@ -41,6 +40,14 @@ User: "Help me find a present for my"
41
  Assistant: "girlfriend;mother;father;friend"
42
  '''
43
 
 
 
 
 
 
 
 
 
44
  # '''
45
  # You will now get a blank message from the user and then after your answer, the user will give you the text to complete:
46
  # Example:
 
8
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
9
  from dataclasses import dataclass
10
 
11
+
12
+ chatml_template = """{% for message in messages %}
13
+ {{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}
14
+ {% endfor %}"""
 
15
 
16
 
17
  system_prompt = '''You are given a partial input text for another AI chat interface.
 
25
  '''
26
 
27
 
28
+ extra_prompt = '''
29
  Examples:
30
  (1)
31
  User: "Help me write a sentiment analysis pipeline"
 
40
  Assistant: "girlfriend;mother;father;friend"
41
  '''
42
 
43
+ # setup
44
+ torch.set_grad_enabled(False)
45
+ model_name = "TheBloke/OpenHermes-2.5-Mistral-7B-GPTQ"
46
+ token = os.environ['hf_token']
47
+ pipe = pipeline("text-generation", model=model_name, device="cuda")
48
+ pipe.tokenizer.chat_template = chatml_template # TheBloke says this is the right template for this model
49
+ generate_kwargs = {'max_new_tokens': 20}
50
+
51
  # '''
52
  # You will now get a blank message from the user and then after your answer, the user will give you the text to complete:
53
  # Example: