Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 2 |
import torch, gradio as gr
|
| 3 |
|
| 4 |
-
# Load Model
|
| 5 |
-
model_name = "
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 8 |
|
|
@@ -11,7 +11,7 @@ model = model.to(device)
|
|
| 11 |
model.eval()
|
| 12 |
|
| 13 |
# Paraphrasing Function
|
| 14 |
-
def
|
| 15 |
if not text.strip():
|
| 16 |
return "⚠️ Please enter some text"
|
| 17 |
|
|
@@ -23,7 +23,7 @@ def paraphrase_flan(text, diversity=0.7, temperature=0.9):
|
|
| 23 |
do_sample=True,
|
| 24 |
top_p=0.92, # nucleus sampling
|
| 25 |
temperature=float(temperature), # creativity
|
| 26 |
-
diversity_penalty=float(diversity), #
|
| 27 |
num_return_sequences=1
|
| 28 |
)
|
| 29 |
|
|
@@ -31,15 +31,15 @@ def paraphrase_flan(text, diversity=0.7, temperature=0.9):
|
|
| 31 |
|
| 32 |
# Gradio UI
|
| 33 |
iface = gr.Interface(
|
| 34 |
-
fn=
|
| 35 |
inputs=[
|
| 36 |
gr.Textbox(lines=8, placeholder="Paste full text here..."),
|
| 37 |
gr.Slider(0.0, 1.0, step=0.1, value=0.7, label="Lexical Diversity"),
|
| 38 |
gr.Slider(0.5, 1.5, step=0.1, value=0.9, label="Temperature")
|
| 39 |
],
|
| 40 |
outputs=gr.Textbox(label="Paraphrased & Humanized Text"),
|
| 41 |
-
title="
|
| 42 |
-
description="
|
| 43 |
)
|
| 44 |
|
| 45 |
iface.launch()
|
|
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 2 |
import torch, gradio as gr
|
| 3 |
|
| 4 |
+
# Load Model (lighter + faster)
|
| 5 |
+
model_name = "humarin/chatgpt_paraphraser_on_T5_base"
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 8 |
|
|
|
|
| 11 |
model.eval()
|
| 12 |
|
| 13 |
# Paraphrasing Function
|
| 14 |
+
def paraphrase_t5(text, diversity=0.7, temperature=0.9):
|
| 15 |
if not text.strip():
|
| 16 |
return "⚠️ Please enter some text"
|
| 17 |
|
|
|
|
| 23 |
do_sample=True,
|
| 24 |
top_p=0.92, # nucleus sampling
|
| 25 |
temperature=float(temperature), # creativity
|
| 26 |
+
diversity_penalty=float(diversity), # lexical variety
|
| 27 |
num_return_sequences=1
|
| 28 |
)
|
| 29 |
|
|
|
|
| 31 |
|
| 32 |
# Gradio UI
|
| 33 |
iface = gr.Interface(
|
| 34 |
+
fn=paraphrase_t5,
|
| 35 |
inputs=[
|
| 36 |
gr.Textbox(lines=8, placeholder="Paste full text here..."),
|
| 37 |
gr.Slider(0.0, 1.0, step=0.1, value=0.7, label="Lexical Diversity"),
|
| 38 |
gr.Slider(0.5, 1.5, step=0.1, value=0.9, label="Temperature")
|
| 39 |
],
|
| 40 |
outputs=gr.Textbox(label="Paraphrased & Humanized Text"),
|
| 41 |
+
title="T5-Base Paraphraser (Humanizer)",
|
| 42 |
+
description="Fast, high-quality paraphrasing on T5-base, tuned for human-like rewrites."
|
| 43 |
)
|
| 44 |
|
| 45 |
iface.launch()
|