Leyo commited on
Commit
e521eb7
1 Parent(s): a50f59f

take off saving

Browse files
Files changed (1) hide show
  1. app_dialogue.py +0 -109
app_dialogue.py CHANGED
@@ -361,79 +361,6 @@ FEATURES = datasets.Features(
361
  }
362
  )
363
 
364
- def flag_dope(
365
- model_selector,
366
- chat_history,
367
- decoding_strategy,
368
- temperature,
369
- max_new_tokens,
370
- repetition_penalty,
371
- top_p,
372
- ):
373
- images = []
374
- conversation = []
375
- for ex in chat_history:
376
- if isinstance(ex[0], dict):
377
- images.append(img_to_bytes(ex[0]["file"]["path"]))
378
- else:
379
-
380
- conversation.append({"User": ex[0], "Assistant": ex[1]})
381
-
382
- data = {
383
- "model_selector": [model_selector],
384
- "images": [images],
385
- "conversation": [conversation],
386
- "decoding_strategy": [decoding_strategy],
387
- "temperature": [temperature],
388
- "max_new_tokens": [max_new_tokens],
389
- "repetition_penalty": [repetition_penalty],
390
- "top_p": [top_p],
391
- }
392
- try:
393
- ds = datasets.load_dataset("HuggingFaceM4/dope-dataset-red-teaming", split="train", token=HF_WRITE_TOKEN)
394
- new_data = datasets.Dataset.from_dict(data, features=FEATURES)
395
- hf_dataset = datasets.concatenate_datasets([ds,new_data])
396
- except Exception:
397
- hf_dataset = datasets.Dataset.from_dict(data, features=FEATURES)
398
- hf_dataset.push_to_hub( "HuggingFaceM4/dope-dataset-red-teaming", split="train", token=HF_WRITE_TOKEN, private=True)
399
-
400
-
401
- def flag_problematic(
402
- model_selector,
403
- chat_history,
404
- decoding_strategy,
405
- temperature,
406
- max_new_tokens,
407
- repetition_penalty,
408
- top_p,
409
- ):
410
- images = []
411
- conversation = []
412
- for ex in chat_history:
413
- if isinstance(ex[0], dict):
414
- images.append(img_to_bytes(ex[0]["file"]["path"]))
415
- else:
416
-
417
- conversation.append({"User": ex[0], "Assistant": ex[1]})
418
-
419
- data = {
420
- "model_selector": [model_selector],
421
- "images": [images],
422
- "conversation": [conversation],
423
- "decoding_strategy": [decoding_strategy],
424
- "temperature": [temperature],
425
- "max_new_tokens": [max_new_tokens],
426
- "repetition_penalty": [repetition_penalty],
427
- "top_p": [top_p],
428
- }
429
- try:
430
- ds = datasets.load_dataset("HuggingFaceM4/problematic-dataset-red-teaming", split="train", token=HF_WRITE_TOKEN)
431
- new_data = datasets.Dataset.from_dict(data, features=FEATURES)
432
- hf_dataset = datasets.concatenate_datasets([ds,new_data])
433
- except Exception:
434
- hf_dataset = datasets.Dataset.from_dict(data, features=FEATURES)
435
- hf_dataset.push_to_hub( "HuggingFaceM4/problematic-dataset-red-teaming", split="train", token=HF_WRITE_TOKEN, private=True)
436
-
437
 
438
  # Hyper-parameters for generation
439
  max_new_tokens = gr.Slider(
@@ -491,8 +418,6 @@ chatbot = gr.Chatbot(
491
  height=450,
492
  )
493
 
494
- # Using Flagging for saving dope and problematic examples
495
- image_flag = gr.Image(visible=False)
496
  with gr.Blocks(
497
  fill_height=True,
498
  css=""".gradio-container .avatar-container {height: 40px width: 40px !important;} #duplicate-button {margin: auto; color: white; background: #f1a139; border-radius: 100vh;}""",
@@ -550,39 +475,5 @@ with gr.Blocks(
550
  top_p,
551
  ],
552
  )
553
- with gr.Group():
554
- with gr.Row():
555
- with gr.Column(scale=1, min_width=50):
556
- dope_bttn = gr.Button("Dope🔥")
557
- with gr.Column(scale=1, min_width=50):
558
- problematic_bttn = gr.Button("Problematic😬")
559
- dope_bttn.click(
560
- fn=flag_dope,
561
- inputs=[
562
- model_selector,
563
- chatbot,
564
- decoding_strategy,
565
- temperature,
566
- max_new_tokens,
567
- repetition_penalty,
568
- top_p,
569
- ],
570
- outputs=None,
571
- preprocess=False,
572
- )
573
- problematic_bttn.click(
574
- fn=flag_problematic,
575
- inputs=[
576
- model_selector,
577
- chatbot,
578
- decoding_strategy,
579
- temperature,
580
- max_new_tokens,
581
- repetition_penalty,
582
- top_p,
583
- ],
584
- outputs=None,
585
- preprocess=False,
586
- )
587
 
588
  demo.launch()
 
361
  }
362
  )
363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
 
365
  # Hyper-parameters for generation
366
  max_new_tokens = gr.Slider(
 
418
  height=450,
419
  )
420
 
 
 
421
  with gr.Blocks(
422
  fill_height=True,
423
  css=""".gradio-container .avatar-container {height: 40px width: 40px !important;} #duplicate-button {margin: auto; color: white; background: #f1a139; border-radius: 100vh;}""",
 
475
  top_p,
476
  ],
477
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
 
479
  demo.launch()