Update app.py
Browse files
app.py
CHANGED
@@ -21,13 +21,15 @@ def generate_paraphrase(text, temperature):
|
|
21 |
temperature=temperature,
|
22 |
top_k=50,
|
23 |
do_sample=True,
|
24 |
-
max_new_tokens=
|
25 |
repetition_penalty=1.2, # π Reduces repetition
|
26 |
-
early_stopping=False # β Prevents early cutoff
|
|
|
27 |
)
|
28 |
|
29 |
-
#
|
30 |
-
|
|
|
31 |
|
32 |
except Exception as e:
|
33 |
return f"β οΈ An error occurred: {str(e)}"
|
@@ -38,16 +40,16 @@ description = """
|
|
38 |
Enter text and let AI generate a paraphrased version!
|
39 |
- **Creativity (Temperature)** controls how varied the output is.
|
40 |
- **Input is limited to 700 words.**
|
41 |
-
- **Now supports longer paraphrased outputs!**
|
42 |
"""
|
43 |
|
44 |
demo = gr.Interface(
|
45 |
fn=generate_paraphrase,
|
46 |
inputs=[
|
47 |
-
gr.Textbox(label="Enter text", placeholder="Type your text to paraphrase...", lines=
|
48 |
gr.Slider(0.5, 1.5, value=1.0, step=0.1, label="Creativity (Temperature)"),
|
49 |
],
|
50 |
-
outputs=gr.Textbox(label="Paraphrased Text", lines=
|
51 |
title="π AI Paraphraser",
|
52 |
description=description,
|
53 |
theme="huggingface",
|
|
|
21 |
temperature=temperature,
|
22 |
top_k=50,
|
23 |
do_sample=True,
|
24 |
+
max_new_tokens=1500, # π Allows much longer outputs
|
25 |
repetition_penalty=1.2, # π Reduces repetition
|
26 |
+
early_stopping=False, # β Prevents early cutoff
|
27 |
+
num_return_sequences=1 # β
Ensures a single, complete paraphrase
|
28 |
)
|
29 |
|
30 |
+
# Extract and format output properly
|
31 |
+
paraphrased_text = result[0].get("generated_text", "β οΈ Paraphrasing failed. Please try again.").strip()
|
32 |
+
return paraphrased_text
|
33 |
|
34 |
except Exception as e:
|
35 |
return f"β οΈ An error occurred: {str(e)}"
|
|
|
40 |
Enter text and let AI generate a paraphrased version!
|
41 |
- **Creativity (Temperature)** controls how varied the output is.
|
42 |
- **Input is limited to 700 words.**
|
43 |
+
- **Now supports much longer paraphrased outputs!**
|
44 |
"""
|
45 |
|
46 |
demo = gr.Interface(
|
47 |
fn=generate_paraphrase,
|
48 |
inputs=[
|
49 |
+
gr.Textbox(label="Enter text", placeholder="Type your text to paraphrase...", lines=10), # Bigger input box
|
50 |
gr.Slider(0.5, 1.5, value=1.0, step=0.1, label="Creativity (Temperature)"),
|
51 |
],
|
52 |
+
outputs=gr.Textbox(label="Paraphrased Text", lines=20), # π₯ Expands output display
|
53 |
title="π AI Paraphraser",
|
54 |
description=description,
|
55 |
theme="huggingface",
|