lamhieu commited on
Commit
c0121ac
·
1 Parent(s): 66ae6a4

chore: allow set temperature to zero

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -305,11 +305,16 @@ def generate(
305
  streamer=streamer,
306
  max_new_tokens=max_new_tokens,
307
  do_sample=True,
308
- top_p=top_p,
309
- top_k=top_k,
310
  temperature=temperature,
311
  repetition_penalty=repetition_penalty,
312
  )
 
 
 
 
 
 
 
313
  t = Thread(target=model.generate, kwargs=generate_kwargs)
314
  t.start()
315
 
@@ -336,7 +341,7 @@ chat_interface = gr.ChatInterface(
336
  ),
337
  gr.Slider(
338
  label="Temperature",
339
- minimum=0.1,
340
  maximum=2.0,
341
  step=0.1,
342
  value=0.4,
 
305
  streamer=streamer,
306
  max_new_tokens=max_new_tokens,
307
  do_sample=True,
 
 
308
  temperature=temperature,
309
  repetition_penalty=repetition_penalty,
310
  )
311
+ if temperature == 0:
312
+ generate_kwargs["do_sample"] = False
313
+ else:
314
+ generate_kwargs["temperature"] = temperature
315
+ generate_kwargs["top_p"] = top_p
316
+ generate_kwargs["top_k"] = top_k
317
+
318
  t = Thread(target=model.generate, kwargs=generate_kwargs)
319
  t.start()
320
 
 
341
  ),
342
  gr.Slider(
343
  label="Temperature",
344
+ minimum=0.0,
345
  maximum=2.0,
346
  step=0.1,
347
  value=0.4,