Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,13 @@ from transformers import pipeline, set_seed
|
|
5 |
pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
|
6 |
#gc.collect()
|
7 |
samples = [['أنت'
|
8 |
-
,1.0, 50, 1.0, 1.0],['هل غادر'
|
9 |
-
,1.0, 50, 1.0, 1.0 ],['ألا ليت'
|
10 |
-
,1.0, 50, 1.0, 1.0 ],['يا قدس'
|
11 |
-
,1.0, 50, 1.0, 1.0],['عيد بأية حال'
|
12 |
-
,1.0, 50, 1.0, 1.0],['لكل شيء إذا ما'
|
13 |
-
,1.0, 50, 1.0, 1.0 ],['.'
|
14 |
-
,1.0, 50, 1.0, 1.0]]
|
15 |
#samples = [['أنت'
|
16 |
# ,.96],['هل غادر'
|
17 |
# , 1.0],['ألا ليت'
|
@@ -23,6 +23,7 @@ samples = [['أنت'
|
|
23 |
notes = """
|
24 |
- Enter a short prompt or select (click) one of the examples and click SEND
|
25 |
- Adjust parameters (temperture, top k, top p and penalty) through the slider (keep close to default values).
|
|
|
26 |
- Clear and enter new prompt or select another example and SEND to regenerate
|
27 |
- The '.' means start a new line from no prompt (your prompt need not be long)
|
28 |
- Be patient: this runs on CPU (free tier)
|
@@ -41,10 +42,10 @@ def sayPoetry(prompt, temp=1.0, topk = 50, topp = 1.0, penalty=1.0, seed=114):
|
|
41 |
poetry = gr.Interface(fn=sayPoetry,
|
42 |
inputs=[
|
43 |
gr.Textbox(label="Enter short prompt or select from examples:"),
|
44 |
-
gr.Slider(0.
|
45 |
gr.Slider(25, 100, step=1,value=50, label='control top k'),
|
46 |
gr.Slider(0.80, 1.0, step=0.01,value=1.0, label='control top p'),
|
47 |
-
gr.Slider(0.90, 1.
|
48 |
gr.Number(value=139750, precision=0, label='Seed'),
|
49 |
],
|
50 |
outputs=[gr.Textbox(label="Generated Poetry:")],
|
@@ -55,4 +56,4 @@ poetry = gr.Interface(fn=sayPoetry,
|
|
55 |
examples=samples,
|
56 |
cache_examples=False,
|
57 |
article = notes)
|
58 |
-
poetry.launch(show_error = True, debug=True
|
|
|
5 |
pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
|
6 |
#gc.collect()
|
7 |
samples = [['أنت'
|
8 |
+
,1.0, 50, 1.0, 1.0, 114],['هل غادر'
|
9 |
+
,1.0, 50, 1.0, 1.0, 114 ],['ألا ليت'
|
10 |
+
,1.0, 50, 1.0, 1.0, 114 ],['يا قدس'
|
11 |
+
,1.0, 50, 1.0, 1.0, 114],['عيد بأية حال'
|
12 |
+
,1.0, 50, 1.0, 1.0, 114],['لكل شيء إذا ما'
|
13 |
+
,1.0, 50, 1.0, 1.0, 114 ],['.'
|
14 |
+
,1.0, 50, 1.0, 1.0, 114]]
|
15 |
#samples = [['أنت'
|
16 |
# ,.96],['هل غادر'
|
17 |
# , 1.0],['ألا ليت'
|
|
|
23 |
notes = """
|
24 |
- Enter a short prompt or select (click) one of the examples and click SEND
|
25 |
- Adjust parameters (temperture, top k, top p and penalty) through the slider (keep close to default values).
|
26 |
+
- For the same seed (randomness), the same output is regenerated if other parameters are fixed
|
27 |
- Clear and enter new prompt or select another example and SEND to regenerate
|
28 |
- The '.' means start a new line from no prompt (your prompt need not be long)
|
29 |
- Be patient: this runs on CPU (free tier)
|
|
|
42 |
poetry = gr.Interface(fn=sayPoetry,
|
43 |
inputs=[
|
44 |
gr.Textbox(label="Enter short prompt or select from examples:"),
|
45 |
+
gr.Slider(0.70, 1.2, step=0.01,value=1.0, label='control temperature'),
|
46 |
gr.Slider(25, 100, step=1,value=50, label='control top k'),
|
47 |
gr.Slider(0.80, 1.0, step=0.01,value=1.0, label='control top p'),
|
48 |
+
gr.Slider(0.90, 1.50, step=0.01,value=1.0, label='control penalty'),
|
49 |
gr.Number(value=139750, precision=0, label='Seed'),
|
50 |
],
|
51 |
outputs=[gr.Textbox(label="Generated Poetry:")],
|
|
|
56 |
examples=samples,
|
57 |
cache_examples=False,
|
58 |
article = notes)
|
59 |
+
poetry.launch() # show_error = True, debug=True
|