Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,14 +13,14 @@ samples = [['أنت'
|
|
13 |
,0.92],['.',0.99]]
|
14 |
notes = """
|
15 |
- Enter a short prompt or select (click) one of the examples and click SEND
|
16 |
-
- Adjust temperture
|
17 |
- Clear and enter new prompt or select another example and SEND to regenerate
|
18 |
- The '.' means start a new line from no prompt (your prompt need not be long)
|
19 |
- Be patient: this runs on CPU (free tier)
|
20 |
- Feedback (Twitter): @akhooli (https://twitter.com/akhooli/status/1611025232201977859)
|
21 |
"""
|
22 |
-
def sayPoetry(prompt, temp=0.95):
|
23 |
-
gen = pipe(prompt, max_length=96, temperature = temp)[0]["generated_text"]
|
24 |
poetry =""
|
25 |
for line in gen.split('.')[:-1]:
|
26 |
poetry += line + "\n"
|
@@ -28,7 +28,10 @@ def sayPoetry(prompt, temp=0.95):
|
|
28 |
poetry = gr.Interface(fn=sayPoetry,
|
29 |
inputs=[
|
30 |
gr.inputs.Textbox(label="Enter short prompt or select from examples:", placeholder="أنا الذي"),
|
31 |
-
gr.inputs.Slider(0.80, 1.0, step=0.01,default=0.95, label='control temperature')
|
|
|
|
|
|
|
32 |
],
|
33 |
outputs=[gr.outputs.Textbox(label="Generated Poetry:")],
|
34 |
|
|
|
13 |
,0.92],['.',0.99]]
|
14 |
notes = """
|
15 |
- Enter a short prompt or select (click) one of the examples and click SEND
|
16 |
+
- Adjust parameters (temperture, top k, top p and penalty) through the slider (keep close to default values).
|
17 |
- Clear and enter new prompt or select another example and SEND to regenerate
|
18 |
- The '.' means start a new line from no prompt (your prompt need not be long)
|
19 |
- Be patient: this runs on CPU (free tier)
|
20 |
- Feedback (Twitter): @akhooli (https://twitter.com/akhooli/status/1611025232201977859)
|
21 |
"""
|
22 |
+
def sayPoetry(prompt, temp=0.95, topk = 50, topp = 0.92, penalty=1.0):
|
23 |
+
gen = pipe(prompt, max_length=96, temperature = temp, top_k=topk, top_p=topp, repetition_penalty=penalty)[0]["generated_text"]
|
24 |
poetry =""
|
25 |
for line in gen.split('.')[:-1]:
|
26 |
poetry += line + "\n"
|
|
|
28 |
poetry = gr.Interface(fn=sayPoetry,
|
29 |
inputs=[
|
30 |
gr.inputs.Textbox(label="Enter short prompt or select from examples:", placeholder="أنا الذي"),
|
31 |
+
gr.inputs.Slider(0.80, 1.0, step=0.01,default=0.95, label='control temperature'),
|
32 |
+
gr.inputs.Slider(20, 100, step=1,default=50, label='control top k'),
|
33 |
+
gr.inputs.Slider(0.80, 1.0, step=0.01,default=1.0, label='control top p'),
|
34 |
+
gr.inputs.Slider(0.89, 1.0, step=0.01,default=1.20, label='control penalty'),
|
35 |
],
|
36 |
outputs=[gr.outputs.Textbox(label="Generated Poetry:")],
|
37 |
|