Chris STC commited on
Commit
8917797
·
1 Parent(s): 7114baf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -13,13 +13,13 @@ llm2 = Llama(model_path=filename, seed=random.randint(1, 2**31))
13
  title = """<h1 align="center">Chat with awesome WizardLM 7b model!</h1><br>"""
14
  description = "This model is awesome for its size! It is only 20th the size of Chatgpt but is around 90% as good as Chatgpt. However, please don't rely on WizardLM to provide 100% true information as it might be wrong sometimes."
15
 
16
- def bot(user_message, temperature, top_p, repeat_penalty):
17
  tokens3 = llm2.tokenize(user_message.encode())
18
  token4 = llm2.tokenize(b"\n\n### Response:")
19
  tokens = tokens3 + token4
20
 
21
  output = ""
22
- for token in llm2.generate(tokens, top_k=50, top_p=top_p, temp=temperature, repeat_penalty=repeat_penalty):
23
  text = llm2.detokenize([token])
24
  output += text.decode()
25
  if token == llm2.token_eos():
@@ -35,6 +35,7 @@ interface = gr.Interface(
35
  gr.Textbox(label="Your Message", placeholder="Type your message here..."),
36
  gr.Slider(minimum=0, maximum=2, default=1, label="Temperature"),
37
  gr.Slider(minimum=0, maximum=1, default=0.73, label="Top P"),
 
38
  gr.Slider(minimum=0, maximum=2, default=1.1, label="Repeat Penalty")
39
  ],
40
  outputs="text",
 
13
  title = """<h1 align="center">Chat with awesome WizardLM 7b model!</h1><br>"""
14
  description = "This model is awesome for its size! It is only 20th the size of Chatgpt but is around 90% as good as Chatgpt. However, please don't rely on WizardLM to provide 100% true information as it might be wrong sometimes."
15
 
16
+ def bot(user_message, temperature, top_p, top_k, repeat_penalty):
17
  tokens3 = llm2.tokenize(user_message.encode())
18
  token4 = llm2.tokenize(b"\n\n### Response:")
19
  tokens = tokens3 + token4
20
 
21
  output = ""
22
+ for token in llm2.generate(tokens, top_k=top_k, top_p=top_p, temp=temperature, repeat_penalty=repeat_penalty):
23
  text = llm2.detokenize([token])
24
  output += text.decode()
25
  if token == llm2.token_eos():
 
35
  gr.Textbox(label="Your Message", placeholder="Type your message here..."),
36
  gr.Slider(minimum=0, maximum=2, default=1, label="Temperature"),
37
  gr.Slider(minimum=0, maximum=1, default=0.73, label="Top P"),
38
+ gr.Slider(minimum=0, maximum=2048, default=50, label="Top_K"),
39
  gr.Slider(minimum=0, maximum=2, default=1.1, label="Repeat Penalty")
40
  ],
41
  outputs="text",