ColeGuion commited on
Commit
f79dbe4
·
verified ·
1 Parent(s): da4415c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -10,23 +10,18 @@ def format_prompt(message, history):
10
  prompt = "<s>"
11
 
12
  # String to add before every prompt
13
- prompt_prefix = "Please correct the grammar in the following sentence: "
14
- prompt_template = "[INST] " + prompt_prefix + "{} [/INST]"
15
 
16
- # Iterates through every past user input and response to be added to the prompt
17
  print("History Type: {}".format(type(history)))
18
  #history.append("It is my friends house in England.", "It is my friend's house in England.")
 
 
19
  for user_prompt, bot_response in history:
20
- corrected_prompt = prompt_prefix + user_prompt
21
-
22
- #prompt += f"[INST] {corrected_prompt} [/INST]"
23
  prompt += prompt_template.format(user_prompt)
24
  prompt += f" {bot_response}</s> "
25
  #print(f"HISTORIC PROMPT: \n\t[INST] {corrected_prompt} [/INST] {bot_response}</s> ")
26
 
27
- # Also prepend the prefix to the current message
28
- #corrected_message = prompt_prefix + message
29
- #prompt += f"[INST] {corrected_message} [/INST]"
30
  prompt += prompt_template.format(message)
31
  print("\nPROMPT: \n\t" + prompt)
32
 
@@ -52,7 +47,7 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=256
52
 
53
 
54
  additional_inputs=[
55
- gr.Textbox( label="System Prompt", value="You are an expert at English grammar" , max_lines=1, interactive=True, ),
56
  gr.Slider( label="Temperature", value=0.9, minimum=0.0, maximum=1.0, step=0.05, interactive=True, info="Higher values produce more diverse outputs", ),
57
  gr.Slider( label="Max new tokens", value=256, minimum=0, maximum=1048, step=64, interactive=True, info="The maximum numbers of new tokens", ),
58
  gr.Slider( label="Top-p (nucleus sampling)", value=0.90, minimum=0.0, maximum=1, step=0.05, interactive=True, info="Higher values sample more low-probability tokens", ),
 
10
  prompt = "<s>"
11
 
12
  # String to add before every prompt
13
+ prompt_prefix = "Please correct the grammar in the following sentence:"
14
+ prompt_template = "[INST] " + prompt_prefix + " {} [/INST]"
15
 
 
16
  print("History Type: {}".format(type(history)))
17
  #history.append("It is my friends house in England.", "It is my friend's house in England.")
18
+
19
+ # Iterates through every past user input and response to be added to the prompt
20
  for user_prompt, bot_response in history:
 
 
 
21
  prompt += prompt_template.format(user_prompt)
22
  prompt += f" {bot_response}</s> "
23
  #print(f"HISTORIC PROMPT: \n\t[INST] {corrected_prompt} [/INST] {bot_response}</s> ")
24
 
 
 
 
25
  prompt += prompt_template.format(message)
26
  print("\nPROMPT: \n\t" + prompt)
27
 
 
47
 
48
 
49
  additional_inputs=[
50
+ gr.Textbox( label="System Prompt", value="Correct the following sentence to make it grammatically accurate while maintaining the original meaning. Output only the corrected sentence." , max_lines=1, interactive=True, ),
51
  gr.Slider( label="Temperature", value=0.9, minimum=0.0, maximum=1.0, step=0.05, interactive=True, info="Higher values produce more diverse outputs", ),
52
  gr.Slider( label="Max new tokens", value=256, minimum=0, maximum=1048, step=64, interactive=True, info="The maximum numbers of new tokens", ),
53
  gr.Slider( label="Top-p (nucleus sampling)", value=0.90, minimum=0.0, maximum=1, step=0.05, interactive=True, info="Higher values sample more low-probability tokens", ),