slush0 commited on
Commit
c461bd0
·
1 Parent(s): eec2373

Basics works, but still WIP; separators and examples need to be updated from bloom to llama2-related models.

Browse files
Files changed (3) hide show
  1. chat.py +8 -16
  2. chat_client.py +2 -2
  3. prompt.py +18 -8
chat.py CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
6
 
7
  import chat_client
8
 
9
- CHAT_URL = "ws://chat.petals.dev/api/v2/generate"
10
  #CHAT_URL='ws://localhost:8000/api/v2/generate'
11
 
12
  EMPTY_STATE = {
@@ -143,7 +143,7 @@ def _generate(
143
  temperature=temperature,
144
  top_k=top_k,
145
  top_p=top_p,
146
- extra_stop_sequences=seq,
147
  ):
148
 
149
  if not state["generate"]:
@@ -207,17 +207,17 @@ def reset(state):
207
  # ---------------------------------------------------------
208
  # Defining Gradio layout
209
  with gr.Blocks() as iface_chat:
210
- gr.Markdown("""**Let's talk to Bloom in a chat!**""")
211
 
212
  with gr.Row():
213
  model = gr.Radio(
214
- ["petals-team/StableBeluga2", "meta-llama/Llama-2-70b-chat-hf", "bigscience/bloomz"], value="petals-team/StableBeluga2", label="Use model"
215
  )
216
 
217
  # Additional ending sequence, at which generation shoud stop
218
  endseq = gr.CheckboxGroup(
219
  ["Human:", "AI:", "\\n", "</s>", "? (question mark)", ". (dot)"],
220
- value=["Human:", "AI:", "\\n", "</s>"],
221
  label="Extra end sequences",
222
  )
223
 
@@ -299,17 +299,9 @@ with gr.Blocks() as iface_chat:
299
  "AI has instant access to an online encyclopedia containing all the facts about the world "
300
  "and answers any question in detail. AI never says common misconceptions, "
301
  "outdated information, lies, fiction, myths, jokes, or memes.</s>\n"
302
- "Human: Hi!</s>\n"
303
- "AI: Hi! How can I help you?</s>\n"
304
- "Human: What's the capital of Portugal?</s>\n"
305
- "AI: The capital of Portugal is Lisbon (or Lisboa in Portuguese) with "
306
- "a population of approximately 547,000 people.</s>\n"
307
- "Human: Why cats meow?</s>\n"
308
- "AI: Cats meow as a way of communicating with humans or other cats. "
309
- "They may meow to get attention, express hunger or thirst, "
310
- "indicate pain or discomfort, seek affection, or simply to say hello.",
311
  "Could you remind me please who was Neil Armstrong?",
312
- "bloomz",
313
  True,
314
  0,
315
  0.9,
@@ -321,7 +313,7 @@ with gr.Blocks() as iface_chat:
321
  "Human: Ahoj!</s>\n"
322
  "AI: Ahoj! Jak ti mohu pomoci?",
323
  "Můžeš mi prosím připomenout, kdo byl Neil Armstrong?",
324
- "bloomz",
325
  True,
326
  0,
327
  0.9,
 
6
 
7
  import chat_client
8
 
9
+ CHAT_URL = "wss://chat.petals.dev/api/v2/generate"
10
  #CHAT_URL='ws://localhost:8000/api/v2/generate'
11
 
12
  EMPTY_STATE = {
 
143
  temperature=temperature,
144
  top_k=top_k,
145
  top_p=top_p,
146
+ stop_sequences=seq,
147
  ):
148
 
149
  if not state["generate"]:
 
207
  # ---------------------------------------------------------
208
  # Defining Gradio layout
209
  with gr.Blocks() as iface_chat:
210
+ gr.Markdown("""**Let's talk to AI in a chat!**""")
211
 
212
  with gr.Row():
213
  model = gr.Radio(
214
+ ["stabilityai/StableBeluga2", "meta-llama/Llama-2-70b-chat-hf", "bigscience/bloomz"], value="stabilityai/StableBeluga2", label="Use model"
215
  )
216
 
217
  # Additional ending sequence, at which generation shoud stop
218
  endseq = gr.CheckboxGroup(
219
  ["Human:", "AI:", "\\n", "</s>", "? (question mark)", ". (dot)"],
220
+ value=["Human:", "AI:", "</s>"],
221
  label="Extra end sequences",
222
  )
223
 
 
299
  "AI has instant access to an online encyclopedia containing all the facts about the world "
300
  "and answers any question in detail. AI never says common misconceptions, "
301
  "outdated information, lies, fiction, myths, jokes, or memes.</s>\n"
302
+ "AI: Hi! How can I help you?</s>\n",
 
 
 
 
 
 
 
 
303
  "Could you remind me please who was Neil Armstrong?",
304
+ "stabilityai/StableBeluga2",
305
  True,
306
  0,
307
  0.9,
 
313
  "Human: Ahoj!</s>\n"
314
  "AI: Ahoj! Jak ti mohu pomoci?",
315
  "Můžeš mi prosím připomenout, kdo byl Neil Armstrong?",
316
+ "stabilityai/StableBeluga2",
317
  True,
318
  0,
319
  0.9,
chat_client.py CHANGED
@@ -58,8 +58,8 @@ class ModelClient(object):
58
  break
59
 
60
  def main():
61
- client = ModelClient("ws://localhost:8000/api/v2/generate")
62
- #client = ModelClient("ws://chat.petals.dev/api/v2/generate")
63
  client.open_session("stabilityai/StableBeluga2", 128)
64
 
65
  if len(sys.argv) > 1:
 
58
  break
59
 
60
  def main():
61
+ #client = ModelClient("ws://localhost:8000/api/v2/generate")
62
+ client = ModelClient("wss://chat.petals.dev/api/v2/generate")
63
  client.open_session("stabilityai/StableBeluga2", 128)
64
 
65
  if len(sys.argv) > 1:
prompt.py CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
4
 
5
  import chat_client
6
 
7
- CHAT_URL = "ws://chat.petals.dev/api/v2/generate"
8
  #CHAT_URL='ws://localhost:8000/api/v2/generate'
9
 
10
 
@@ -137,13 +137,13 @@ with gr.Blocks() as iface_prompt:
137
 
138
  with gr.Row():
139
  model = gr.Radio(
140
- ["petals-team/StableBeluga2", "codellama/CodeLlama-34b-Instruct-hf", " meta-llama/Llama-2-70b-chat-hf", "meta-llama/Llama-2-70b-hf", "bigscience/bloomz", "bigscience/bloom"], value="stabilityai/StableBeluga2", label="Use model"
141
  )
142
 
143
  # Additional ending sequence, at which generation shoud stop
144
  endseq = gr.CheckboxGroup(
145
  ["\\n", "</s>", "? (question mark)", ". (dot)"],
146
- value=["\\n", "</s>"],
147
  label="Extra end sequences",
148
  )
149
 
@@ -215,7 +215,17 @@ with gr.Blocks() as iface_prompt:
215
  examples=[
216
  [
217
  "The SQL command to extract all the users whose name starts with A is: ",
218
- "bloom-7b1",
 
 
 
 
 
 
 
 
 
 
219
  False,
220
  0,
221
  0,
@@ -224,7 +234,7 @@ with gr.Blocks() as iface_prompt:
224
  ],
225
  [
226
  "The Spanish translation of thank you for your help is: ",
227
- "bloom-7b1",
228
  False,
229
  0,
230
  0,
@@ -238,7 +248,7 @@ with gr.Blocks() as iface_prompt:
238
  "AI: Hi! How can I help you?</s>\n"
239
  "Human: What's the capital of Portugal?</s>\n"
240
  "AI: ",
241
- "bloomz",
242
  True,
243
  0,
244
  0.9,
@@ -249,7 +259,7 @@ with gr.Blocks() as iface_prompt:
249
  "Here is a very polite and formal e-mail writing to staff that they are fired because of late delivery of the project and higher costs:\n"
250
  "Dear staff,\n"
251
  "it is with utmost ",
252
- "bloom",
253
  True,
254
  0,
255
  0.9,
@@ -258,7 +268,7 @@ with gr.Blocks() as iface_prompt:
258
  ],
259
  [
260
  "Lorem ipsum dolor sit amet, ",
261
- "petals-team/StableBeluga2",
262
  True,
263
  0,
264
  0.9,
 
4
 
5
  import chat_client
6
 
7
+ CHAT_URL = "wss://chat.petals.dev/api/v2/generate"
8
  #CHAT_URL='ws://localhost:8000/api/v2/generate'
9
 
10
 
 
137
 
138
  with gr.Row():
139
  model = gr.Radio(
140
+ ["stabilityai/StableBeluga2", "meta-llama/Llama-2-70b-chat-hf", "bigscience/bloomz", "bigscience/bloom"], value="stabilityai/StableBeluga2", label="Use model"
141
  )
142
 
143
  # Additional ending sequence, at which generation shoud stop
144
  endseq = gr.CheckboxGroup(
145
  ["\\n", "</s>", "? (question mark)", ". (dot)"],
146
+ value=["</s>"],
147
  label="Extra end sequences",
148
  )
149
 
 
215
  examples=[
216
  [
217
  "The SQL command to extract all the users whose name starts with A is: ",
218
+ "stabilityai/StableBeluga2",
219
+ False,
220
+ 0,
221
+ 0,
222
+ 1,
223
+ False,
224
+ ],
225
+ [
226
+ "// Returns every other value in the list as a new list.\n"
227
+ "def every_other(l):\n",
228
+ "stabilityai/StableBeluga2",
229
  False,
230
  0,
231
  0,
 
234
  ],
235
  [
236
  "The Spanish translation of thank you for your help is: ",
237
+ "stabilityai/StableBeluga2",
238
  False,
239
  0,
240
  0,
 
248
  "AI: Hi! How can I help you?</s>\n"
249
  "Human: What's the capital of Portugal?</s>\n"
250
  "AI: ",
251
+ "stabilityai/StableBeluga2",
252
  True,
253
  0,
254
  0.9,
 
259
  "Here is a very polite and formal e-mail writing to staff that they are fired because of late delivery of the project and higher costs:\n"
260
  "Dear staff,\n"
261
  "it is with utmost ",
262
+ "stabilityai/StableBeluga2",
263
  True,
264
  0,
265
  0.9,
 
268
  ],
269
  [
270
  "Lorem ipsum dolor sit amet, ",
271
+ "stabilityai/StableBeluga2",
272
  True,
273
  0,
274
  0.9,