Update app.py
Browse files
app.py
CHANGED
@@ -30,10 +30,16 @@ def paraphrase_text(text):
|
|
30 |
|
31 |
sentences = split_sentences(text)
|
32 |
|
33 |
-
# Apply T5 paraphrasing
|
34 |
paraphrased_results = paraphrase_pipeline(
|
35 |
[f"paraphrase: {sentence} </s>" for sentence in sentences if sentence],
|
36 |
-
max_length=50,
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
)
|
38 |
|
39 |
paraphrased_sentences = [result['generated_text'] for result in paraphrased_results]
|
@@ -44,8 +50,8 @@ demo = gr.Interface(
|
|
44 |
fn=paraphrase_text,
|
45 |
inputs=gr.Textbox(label="Enter text", placeholder="Type your text to paraphrase...", lines=10),
|
46 |
outputs=gr.Textbox(label="Paraphrased Text", lines=10),
|
47 |
-
title="
|
48 |
-
description="Enter text and let AI generate a paraphrased version using
|
49 |
theme="huggingface"
|
50 |
)
|
51 |
|
|
|
30 |
|
31 |
sentences = split_sentences(text)
|
32 |
|
33 |
+
# Apply T5 paraphrasing with more creativity
|
34 |
paraphrased_results = paraphrase_pipeline(
|
35 |
[f"paraphrase: {sentence} </s>" for sentence in sentences if sentence],
|
36 |
+
max_length=50,
|
37 |
+
do_sample=True,
|
38 |
+
temperature=0.9, # Increase randomness
|
39 |
+
top_p=0.92, # Nucleus sampling
|
40 |
+
top_k=50, # Limits next-word options
|
41 |
+
num_return_sequences=2, # Generate 2 variations per sentence
|
42 |
+
batch_size=8 # Faster processing
|
43 |
)
|
44 |
|
45 |
paraphrased_sentences = [result['generated_text'] for result in paraphrased_results]
|
|
|
50 |
fn=paraphrase_text,
|
51 |
inputs=gr.Textbox(label="Enter text", placeholder="Type your text to paraphrase...", lines=10),
|
52 |
outputs=gr.Textbox(label="Paraphrased Text", lines=10),
|
53 |
+
title="🎨 Creative T5 Paraphraser",
|
54 |
+
description="Enter text and let AI generate a more creative paraphrased version using T5!",
|
55 |
theme="huggingface"
|
56 |
)
|
57 |
|