hussamalafandi commited on
Commit
5d74cf2
·
1 Parent(s): 5d13c4b

Add top-p parameter to respond function and update ChatInterface

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -11,6 +11,7 @@ def respond(
11
  system_message: str,
12
  max_new_tokens: int,
13
  temperature: float,
 
14
  ) -> str:
15
  """
16
  Respond to user input using the model.
@@ -18,6 +19,7 @@ def respond(
18
  # Set the model parameters
19
  model.temperature = temperature
20
  model.max_output_tokens = max_new_tokens
 
21
 
22
  history_langchain_format = []
23
  # Add the dialog history to the history
@@ -31,7 +33,7 @@ def respond(
31
  # Combine the system message, history, and user input into a single list
32
  model_input = [SystemMessage(content=system_message)] + \
33
  history_langchain_format + [HumanMessage(content=user_input)]
34
-
35
  response = model.invoke(model_input)
36
  return response.content
37
 
@@ -49,6 +51,13 @@ demo = gr.ChatInterface(
49
  step=1, label="Max new tokens"),
50
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7,
51
  step=0.1, label="Temperature"),
 
 
 
 
 
 
 
52
  ],
53
  )
54
 
 
11
  system_message: str,
12
  max_new_tokens: int,
13
  temperature: float,
14
+ top_p: float,
15
  ) -> str:
16
  """
17
  Respond to user input using the model.
 
19
  # Set the model parameters
20
  model.temperature = temperature
21
  model.max_output_tokens = max_new_tokens
22
+ model.top_p = top_p
23
 
24
  history_langchain_format = []
25
  # Add the dialog history to the history
 
33
  # Combine the system message, history, and user input into a single list
34
  model_input = [SystemMessage(content=system_message)] + \
35
  history_langchain_format + [HumanMessage(content=user_input)]
36
+
37
  response = model.invoke(model_input)
38
  return response.content
39
 
 
51
  step=1, label="Max new tokens"),
52
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7,
53
  step=0.1, label="Temperature"),
54
+ gr.Slider(
55
+ minimum=0.1,
56
+ maximum=1.0,
57
+ value=0.95,
58
+ step=0.05,
59
+ label="Top-p (nucleus sampling)",
60
+ ),
61
  ],
62
  )
63