ColeGuion commited on
Commit
e53bb43
·
verified ·
1 Parent(s): 0f7bbc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -17
app.py CHANGED
@@ -9,28 +9,20 @@ client = InferenceClient(
9
  def format_prompt(message, history):
10
  prompt = "<s>"
11
  for user_prompt, bot_response in history:
12
- #prompt += f"[INST] {user_prompt} [/INST]"
13
- #prompt += f" {bot_response}</s> "
14
- #prompt += f"[INST] You are a helpful assistant who restates the exact prompt before each response. {user_prompt} [/INST]"
15
  prompt += f"[INST] {user_prompt} [/INST]"
16
- prompt += f" The instruction is: 'Instruction'. The answer is: {bot_response}</s> "
17
  prompt += f"[INST] {message} [/INST]"
18
  return prompt
19
 
20
  def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
 
 
21
  temperature = float(temperature)
22
  if temperature < 1e-2:
23
  temperature = 1e-2
24
  top_p = float(top_p)
25
 
26
- generate_kwargs = dict(
27
- temperature=temperature,
28
- max_new_tokens=max_new_tokens,
29
- top_p=top_p,
30
- repetition_penalty=repetition_penalty,
31
- do_sample=True,
32
- seed=42,
33
- )
34
 
35
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
36
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
@@ -88,11 +80,7 @@ additional_inputs=[
88
 
89
  examples=[['Give me the grammatically correct version of the sentence: "We shood buy an car"', None, None, None, None, None, ],
90
  ["Give me an example exam question testing students on square roots on basic integers", None, None, None, None, None,],
91
- ["Would this block of HTML code run?\n```\n\n```", None, None, None, None, None,],
92
- ["I have chicken, rice, and bell peppers in my kitchen. Can you suggest an easy recipe I can make with these ingredients?", None, None, None, None, None,],
93
- ["Can you explain how the QuickSort algorithm works and provide a Python implementation?", None, None, None, None, None,],
94
- ["What are some unique features of Rust that make it stand out compared to other systems programming languages like C++?", None, None, None, None, None,],
95
- ]
96
 
97
  gr.ChatInterface(
98
  fn=generate,
 
9
  def format_prompt(message, history):
10
  prompt = "<s>"
11
  for user_prompt, bot_response in history:
 
 
 
12
  prompt += f"[INST] {user_prompt} [/INST]"
13
+ prompt += f" {bot_response}</s> "
14
  prompt += f"[INST] {message} [/INST]"
15
  return prompt
16
 
17
  def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
18
+ dashes = "-"*100 + "\n"
19
+ print(dashes + "\n\nHELLO THIS IS COLE\n\n\n" + dashes)
20
  temperature = float(temperature)
21
  if temperature < 1e-2:
22
  temperature = 1e-2
23
  top_p = float(top_p)
24
 
25
+ generate_kwargs = dict(temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty, do_sample=True, seed=42,)
 
 
 
 
 
 
 
26
 
27
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
28
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
 
80
 
81
  examples=[['Give me the grammatically correct version of the sentence: "We shood buy an car"', None, None, None, None, None, ],
82
  ["Give me an example exam question testing students on square roots on basic integers", None, None, None, None, None,],
83
+ ["Would this block of HTML code run?\n```\n\n```", None, None, None, None, None,], ]
 
 
 
 
84
 
85
  gr.ChatInterface(
86
  fn=generate,