Spaces:
Runtime error
Runtime error
Commit
·
282bf30
1
Parent(s):
c26d24a
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,19 +8,20 @@ API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
|
|
| 8 |
headers = {"Authorization": f"Bearer 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"}
|
| 9 |
|
| 10 |
|
| 11 |
-
def text_generate(prompt, generated_txt):
|
| 12 |
#Prints to debug the code
|
| 13 |
print(f"*****Inside text_generate - Prompt is :{prompt}")
|
| 14 |
json_ = {"inputs": prompt,
|
| 15 |
"parameters":
|
| 16 |
{
|
| 17 |
-
"top_p":
|
| 18 |
-
"top_k":
|
| 19 |
-
"temperature":
|
| 20 |
"max_new_tokens": 250,
|
| 21 |
"return_full_text": True,
|
| 22 |
"do_sample":True,
|
| 23 |
-
"num_beams":
|
|
|
|
| 24 |
},
|
| 25 |
"options":
|
| 26 |
{"use_cache": True,
|
|
@@ -88,9 +89,20 @@ with demo:
|
|
| 88 |
|
| 89 |
with gr.Row():
|
| 90 |
generated_txt = gr.Textbox(lines=7, visible = True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
b1 = gr.Button("Generate Your Story")
|
| 93 |
|
| 94 |
-
b1.click(text_generate, inputs=[input_prompt, generated_txt], outputs=[generated_txt, input_prompt])
|
| 95 |
|
| 96 |
demo.launch(enable_queue=True, debug=True)
|
|
|
|
| 8 |
headers = {"Authorization": f"Bearer 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"}
|
| 9 |
|
| 10 |
|
| 11 |
+
def text_generate(prompt, generated_txt, top_p=0.8, top_k=100, temperature=1.0, num_beams=3, repetition_penalty=3.0):
|
| 12 |
#Prints to debug the code
|
| 13 |
print(f"*****Inside text_generate - Prompt is :{prompt}")
|
| 14 |
json_ = {"inputs": prompt,
|
| 15 |
"parameters":
|
| 16 |
{
|
| 17 |
+
"top_p": top_p,
|
| 18 |
+
"top_k": top_k,
|
| 19 |
+
"temperature": temperature,
|
| 20 |
"max_new_tokens": 250,
|
| 21 |
"return_full_text": True,
|
| 22 |
"do_sample":True,
|
| 23 |
+
"num_beams": num_beams,
|
| 24 |
+
"repetition_penalty": repetition_penalty,
|
| 25 |
},
|
| 26 |
"options":
|
| 27 |
{"use_cache": True,
|
|
|
|
| 89 |
|
| 90 |
with gr.Row():
|
| 91 |
generated_txt = gr.Textbox(lines=7, visible = True)
|
| 92 |
+
|
| 93 |
+
with gr.Row():
|
| 94 |
+
top_p = gr.Slider(label="top_p", minimum=0., maximum=1.0, value=0.8, step=0.1, visible = True)
|
| 95 |
+
with gr.Row():
|
| 96 |
+
top_k = gr.Slider(label="top_k", minimum=1, maximum=500, value=100, step=20, visible = True)
|
| 97 |
+
with gr.Row():
|
| 98 |
+
temperature = gr.Slider(label="temperature", minimum=0., maximum=2.0, value=1.0, step=0.1, visible = True)
|
| 99 |
+
with gr.Row():
|
| 100 |
+
num_beams = gr.Slider(label="num_beams", minimum=1, maximum=6, value=3, step=1, visible = True)
|
| 101 |
+
with gr.Row():
|
| 102 |
+
repetition_penalty = gr.Slider(label="repetition_penalty", minimum=1.0, maximum=6.0, value=3.0, step=1.0, visible = True)
|
| 103 |
|
| 104 |
b1 = gr.Button("Generate Your Story")
|
| 105 |
|
| 106 |
+
b1.click(text_generate, inputs=[input_prompt, generated_txt, top_p, top_k, temperature, num_beams, repetition_penalty], outputs=[generated_txt, input_prompt])
|
| 107 |
|
| 108 |
demo.launch(enable_queue=True, debug=True)
|