BramVanroy commited on
Commit
b866915
1 Parent(s): 2a04fd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -25,12 +25,13 @@ def generate(
25
  message: str,
26
  chat_history: list[tuple[str, str]],
27
  max_new_tokens: int = 1024,
28
- temperature: float = 0.06,
29
- top_p: float = 0.95,
30
- top_k: int = 40,
31
- repetition_penalty: float = 1.2,
 
32
  ) -> Iterator[str]:
33
- conversation = []
34
  for user, assistant in chat_history:
35
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
36
  conversation.append({"role": "user", "content": message})
@@ -46,7 +47,7 @@ def generate(
46
  {"input_ids": input_ids},
47
  streamer=streamer,
48
  max_new_tokens=max_new_tokens,
49
- do_sample=True,
50
  top_p=top_p,
51
  top_k=top_k,
52
  temperature=temperature,
@@ -102,8 +103,12 @@ chat_interface = gr.ChatInterface(
102
  minimum=1.0,
103
  maximum=2.0,
104
  step=0.05,
105
- value=1.2,
106
  ),
 
 
 
 
107
  ],
108
  examples=[
109
  ["""Vraagje: welk woord hoort er niet in dit rijtje thuis: "auto, vliegtuig, geit, bus"?"""],
 
25
  message: str,
26
  chat_history: list[tuple[str, str]],
27
  max_new_tokens: int = 1024,
28
+ temperature: float = 1,
29
+ top_p: float = 1.,
30
+ top_k: int = 50,
31
+ do_sample: bool = False,
32
+ repetition_penalty: float = 1.,
33
  ) -> Iterator[str]:
34
+ conversation = [{"role": "system", "content": ""}]
35
  for user, assistant in chat_history:
36
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
37
  conversation.append({"role": "user", "content": message})
 
47
  {"input_ids": input_ids},
48
  streamer=streamer,
49
  max_new_tokens=max_new_tokens,
50
+ do_sample=do_sample,
51
  top_p=top_p,
52
  top_k=top_k,
53
  temperature=temperature,
 
103
  minimum=1.0,
104
  maximum=2.0,
105
  step=0.05,
106
+ value=1.,
107
  ),
108
+ gr.Checkbox(
109
+ label="Do sample",
110
+ value=False,
111
+ )
112
  ],
113
  examples=[
114
  ["""Vraagje: welk woord hoort er niet in dit rijtje thuis: "auto, vliegtuig, geit, bus"?"""],