Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ model = model.to(device)
|
|
| 11 |
model.eval()
|
| 12 |
|
| 13 |
# Paraphrasing Function
|
| 14 |
-
def paraphrase_t5(text,
|
| 15 |
if not text.strip():
|
| 16 |
return "⚠️ Please enter some text"
|
| 17 |
|
|
@@ -21,9 +21,8 @@ def paraphrase_t5(text, diversity=0.7, temperature=0.9):
|
|
| 21 |
**inputs,
|
| 22 |
max_new_tokens=256,
|
| 23 |
do_sample=True,
|
| 24 |
-
top_p=
|
| 25 |
temperature=float(temperature), # creativity
|
| 26 |
-
diversity_penalty=float(diversity), # lexical variety
|
| 27 |
num_return_sequences=1
|
| 28 |
)
|
| 29 |
|
|
@@ -34,8 +33,8 @@ iface = gr.Interface(
|
|
| 34 |
fn=paraphrase_t5,
|
| 35 |
inputs=[
|
| 36 |
gr.Textbox(lines=8, placeholder="Paste full text here..."),
|
| 37 |
-
gr.Slider(0.
|
| 38 |
-
gr.Slider(0.
|
| 39 |
],
|
| 40 |
outputs=gr.Textbox(label="Paraphrased & Humanized Text"),
|
| 41 |
title="T5-Base Paraphraser (Humanizer)",
|
|
|
|
| 11 |
model.eval()
|
| 12 |
|
| 13 |
# Paraphrasing Function
|
| 14 |
+
def paraphrase_t5(text, temperature=0.9, top_p=0.92):
|
| 15 |
if not text.strip():
|
| 16 |
return "⚠️ Please enter some text"
|
| 17 |
|
|
|
|
| 21 |
**inputs,
|
| 22 |
max_new_tokens=256,
|
| 23 |
do_sample=True,
|
| 24 |
+
top_p=float(top_p), # nucleus sampling
|
| 25 |
temperature=float(temperature), # creativity
|
|
|
|
| 26 |
num_return_sequences=1
|
| 27 |
)
|
| 28 |
|
|
|
|
| 33 |
fn=paraphrase_t5,
|
| 34 |
inputs=[
|
| 35 |
gr.Textbox(lines=8, placeholder="Paste full text here..."),
|
| 36 |
+
gr.Slider(0.5, 1.5, step=0.1, value=0.9, label="Temperature"),
|
| 37 |
+
gr.Slider(0.6, 1.0, step=0.02, value=0.92, label="Top-p")
|
| 38 |
],
|
| 39 |
outputs=gr.Textbox(label="Paraphrased & Humanized Text"),
|
| 40 |
title="T5-Base Paraphraser (Humanizer)",
|