Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,16 +17,11 @@ def format_prompt(message, history):
|
|
17 |
def generate(
|
18 |
prompt, history, temperature=0.9, max_new_tokens=4000, top_p=0.95, repetition_penalty=1.0,
|
19 |
):
|
20 |
-
temperature = float(temperature)
|
21 |
-
if temperature < 1e-2:
|
22 |
-
temperature = 1e-2
|
23 |
-
top_p = float(top_p)
|
24 |
-
|
25 |
generate_kwargs = dict(
|
26 |
-
temperature=
|
27 |
max_new_tokens=4000,
|
28 |
-
top_p=
|
29 |
-
repetition_penalty=
|
30 |
do_sample=True,
|
31 |
seed=42,
|
32 |
)
|
@@ -41,37 +36,6 @@ def generate(
|
|
41 |
yield output
|
42 |
return output
|
43 |
|
44 |
-
|
45 |
-
additional_inputs=[
|
46 |
-
gr.Slider(
|
47 |
-
label="Temperature",
|
48 |
-
value=0.9,
|
49 |
-
minimum=0.0,
|
50 |
-
maximum=1.0,
|
51 |
-
step=0.05,
|
52 |
-
interactive=True,
|
53 |
-
info="Higher values produce more diverse outputs",
|
54 |
-
),
|
55 |
-
gr.Slider(
|
56 |
-
label="Top-p (nucleus sampling)",
|
57 |
-
value=0.90,
|
58 |
-
minimum=0.0,
|
59 |
-
maximum=1,
|
60 |
-
step=0.05,
|
61 |
-
interactive=True,
|
62 |
-
info="Higher values sample more low-probability tokens",
|
63 |
-
),
|
64 |
-
gr.Slider(
|
65 |
-
label="Repetition penalty",
|
66 |
-
value=1.2,
|
67 |
-
minimum=1.0,
|
68 |
-
maximum=2.0,
|
69 |
-
step=0.05,
|
70 |
-
interactive=True,
|
71 |
-
info="Penalize repeated tokens",
|
72 |
-
)
|
73 |
-
]
|
74 |
-
|
75 |
css = """
|
76 |
#mkd {
|
77 |
height: 500px;
|
@@ -83,8 +47,7 @@ css = """
|
|
83 |
with gr.Blocks(css=css) as demo:
|
84 |
gr.HTML("<h1><center>Mistral 7B Instruct<h1><center>")
|
85 |
gr.ChatInterface(
|
86 |
-
generate
|
87 |
-
additional_inputs=additional_inputs,
|
88 |
)
|
89 |
|
90 |
demo.queue().launch(debug=True)
|
|
|
17 |
def generate(
|
18 |
prompt, history, temperature=0.9, max_new_tokens=4000, top_p=0.95, repetition_penalty=1.0,
|
19 |
):
|
|
|
|
|
|
|
|
|
|
|
20 |
generate_kwargs = dict(
|
21 |
+
temperature=0.9,
|
22 |
max_new_tokens=4000,
|
23 |
+
top_p=0.9,
|
24 |
+
repetition_penalty=1.0,
|
25 |
do_sample=True,
|
26 |
seed=42,
|
27 |
)
|
|
|
36 |
yield output
|
37 |
return output
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
css = """
|
40 |
#mkd {
|
41 |
height: 500px;
|
|
|
47 |
with gr.Blocks(css=css) as demo:
|
48 |
gr.HTML("<h1><center>Mistral 7B Instruct<h1><center>")
|
49 |
gr.ChatInterface(
|
50 |
+
generate
|
|
|
51 |
)
|
52 |
|
53 |
demo.queue().launch(debug=True)
|