hayas commited on
Commit
ea6ffcd
·
1 Parent(s): feb8b85
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -18,6 +18,8 @@ def run(
18
  message: dict,
19
  history: list[dict],
20
  max_new_tokens: int = 256,
 
 
21
  ) -> Iterator[str]:
22
  if not history and len(message["files"]) == 0:
23
  gr.Warning("Please upload an image.")
@@ -53,8 +55,9 @@ def run(
53
  inputs,
54
  streamer=streamer,
55
  max_new_tokens=max_new_tokens,
56
- temperature=0,
57
- do_sample=False,
 
58
  stopping_criteria=processor.get_stopping_criteria(["\n###"]),
59
  )
60
  t = Thread(target=model.generate, kwargs=generate_kwargs)
@@ -80,7 +83,11 @@ demo = gr.ChatInterface(
80
  type="messages",
81
  multimodal=True,
82
  textbox=gr.MultimodalTextbox(file_types=["image"], file_count="single"),
83
- additional_inputs=[gr.Slider(label="Max new tokens", minimum=10, maximum=1024, step=1, value=256)],
 
 
 
 
84
  examples=examples,
85
  title="sbintuitions/sarashina2-vision-14b",
86
  cache_examples=False,
 
18
  message: dict,
19
  history: list[dict],
20
  max_new_tokens: int = 256,
21
+ temperature: float = 0.7,
22
+ repetition_penalty: float = 1.2,
23
  ) -> Iterator[str]:
24
  if not history and len(message["files"]) == 0:
25
  gr.Warning("Please upload an image.")
 
55
  inputs,
56
  streamer=streamer,
57
  max_new_tokens=max_new_tokens,
58
+ temperature=temperature,
59
+ do_sample=temperature > 0.0,
60
+ repetition_penalty=repetition_penalty,
61
  stopping_criteria=processor.get_stopping_criteria(["\n###"]),
62
  )
63
  t = Thread(target=model.generate, kwargs=generate_kwargs)
 
83
  type="messages",
84
  multimodal=True,
85
  textbox=gr.MultimodalTextbox(file_types=["image"], file_count="single"),
86
+ additional_inputs=[
87
+ gr.Slider(label="Max new tokens", minimum=10, maximum=1024, step=1, value=512),
88
+ gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, step=0.1, value=0.7),
89
+ gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.1, value=1.2),
90
+ ],
91
  examples=examples,
92
  title="sbintuitions/sarashina2-vision-14b",
93
  cache_examples=False,