VictorSanh commited on
Commit
8fd442d
1 Parent(s): cb3f587

Update visualization

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app_dialogue.py +9 -2
README.md CHANGED
@@ -2,7 +2,7 @@
2
  title: IDEFICS Playground
3
  emoji: 🐨
4
  colorFrom: red
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.40.1
8
  app_file: app_dialogue.py
 
2
  title: IDEFICS Playground
3
  emoji: 🐨
4
  colorFrom: red
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.40.1
8
  app_file: app_dialogue.py
app_dialogue.py CHANGED
@@ -21,7 +21,9 @@ MODELS = [ # TODO uncomment
21
  ]
22
 
23
  API_PATHS = {
24
- "HuggingFaceM4/idefics-9b-instruct": "https://api-inference.huggingface.co/models/HuggingFaceM4/idefics-9b-instruct",
 
 
25
  "HuggingFaceM4/idefics-80b-instruct": (
26
  "https://api-inference.huggingface.co/models/HuggingFaceM4/idefics-80b-instruct"
27
  ),
@@ -411,7 +413,7 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
411
  repetition_penalty = gr.Slider(
412
  minimum=0.0,
413
  maximum=5.0,
414
- value=1.1,
415
  step=0.01,
416
  interactive=True,
417
  label="Repetition penalty",
@@ -540,6 +542,11 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
540
  acc_text += text_token
541
  last_turn = chat_history.pop(-1)
542
  last_turn[-1] += acc_text
 
 
 
 
 
543
  chat_history.append(last_turn)
544
  yield "", None, chat_history
545
  acc_text = ""
 
21
  ]
22
 
23
  API_PATHS = {
24
+ "HuggingFaceM4/idefics-9b-instruct": (
25
+ "https://api-inference.huggingface.co/models/HuggingFaceM4/idefics-9b-instruct"
26
+ ),
27
  "HuggingFaceM4/idefics-80b-instruct": (
28
  "https://api-inference.huggingface.co/models/HuggingFaceM4/idefics-80b-instruct"
29
  ),
 
413
  repetition_penalty = gr.Slider(
414
  minimum=0.0,
415
  maximum=5.0,
416
+ value=1.0,
417
  step=0.01,
418
  interactive=True,
419
  label="Repetition penalty",
 
542
  acc_text += text_token
543
  last_turn = chat_history.pop(-1)
544
  last_turn[-1] += acc_text
545
+ if last_turn[-1].endswith("\nUser"):
546
+ # Safeguard: sometimes (rarely), the model won't generate the token `<end_of_utterance>` and will go directly to generating `\nUser:`
547
+ # It will thus stop the generation on `\nUser:`. But when it exits, it will have already generated `\nUser`
548
+ # This post-processing ensures that we don't have an additional `\nUser` wandering around.
549
+ last_turn[-1] = last_turn[-1][:-5]
550
  chat_history.append(last_turn)
551
  yield "", None, chat_history
552
  acc_text = ""