Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def format_prompt(message, history):
|
|
15 |
return prompt
|
16 |
|
17 |
def generate(
|
18 |
-
prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
19 |
):
|
20 |
temperature = float(temperature)
|
21 |
if temperature < 1e-2:
|
@@ -41,6 +41,30 @@ def generate(
|
|
41 |
yield output
|
42 |
return output
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
additional_inputs=[
|
46 |
gr.Slider(
|
@@ -98,5 +122,10 @@ with gr.Blocks(css=css) as demo:
|
|
98 |
additional_inputs=additional_inputs,
|
99 |
examples=[["What is the secret to life?"], ["Write me a recipe for pancakes."]]
|
100 |
)
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
demo.queue(concurrency_count=75, max_size=100).launch(debug=True)
|
|
|
15 |
return prompt
|
16 |
|
17 |
def generate(
|
18 |
+
prompt, history=[], temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
19 |
):
|
20 |
temperature = float(temperature)
|
21 |
if temperature < 1e-2:
|
|
|
41 |
yield output
|
42 |
return output
|
43 |
|
44 |
+
def foo(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
|
45 |
+
temperature = float(temperature)
|
46 |
+
if temperature < 1e-2:
|
47 |
+
temperature = 1e-2
|
48 |
+
top_p = float(top_p)
|
49 |
+
|
50 |
+
generate_kwargs = dict(
|
51 |
+
temperature=temperature,
|
52 |
+
max_new_tokens=max_new_tokens,
|
53 |
+
top_p=top_p,
|
54 |
+
repetition_penalty=repetition_penalty,
|
55 |
+
do_sample=True,
|
56 |
+
seed=42,
|
57 |
+
)
|
58 |
+
|
59 |
+
formatted_prompt = format_prompt(prompt, [])
|
60 |
+
|
61 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
62 |
+
output = ""
|
63 |
+
|
64 |
+
for response in stream:
|
65 |
+
output += response.token.text
|
66 |
+
yield output
|
67 |
+
return output
|
68 |
|
69 |
additional_inputs=[
|
70 |
gr.Slider(
|
|
|
122 |
additional_inputs=additional_inputs,
|
123 |
examples=[["What is the secret to life?"], ["Write me a recipe for pancakes."]]
|
124 |
)
|
125 |
+
gr.Interface(fn=greet,
|
126 |
+
additional_inputs=additional_inputs,
|
127 |
+
inputs="textbox",
|
128 |
+
outputs="textbox")
|
129 |
+
|
130 |
|
131 |
demo.queue(concurrency_count=75, max_size=100).launch(debug=True)
|