ColeGuion commited on
Commit
bdc235c
·
verified ·
1 Parent(s): f7657a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -27,6 +27,12 @@ def format_prompt(message, history):
27
 
28
  return prompt
29
 
 
 
 
 
 
 
30
  def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
31
  print("\n\nSystem Prompt: '{}'".format(system_prompt))
32
  temperature = float(temperature)
@@ -36,7 +42,8 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=256
36
 
37
  generate_kwargs = dict(temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty, do_sample=True, seed=42,)
38
 
39
- formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
 
40
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
41
  output = ""
42
 
 
27
 
28
  return prompt
29
 
30
+ def format_my_prompt(user_input):
31
+ # Formatting the prompt as per the new template
32
+ prompt = f"<s> [INST] Please correct the grammatical errors in the following sentence: {user_input} [/INST] Model answer</s> [INST] Return only the grammatically corrected sentence. [/INST]"
33
+ return prompt
34
+
35
+
36
  def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
37
  print("\n\nSystem Prompt: '{}'".format(system_prompt))
38
  temperature = float(temperature)
 
42
 
43
  generate_kwargs = dict(temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty, do_sample=True, seed=42,)
44
 
45
+ #formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
46
+ formatted_prompt = format_my_prompt(prompt)
47
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
48
  output = ""
49