Spaces:
Runtime error
Runtime error
Commit
·
3a9c256
1
Parent(s):
d7e0058
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,8 @@ import gradio as gr
|
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 4 |
|
| 5 |
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained('humarin/chatgpt_paraphraser_on_T5_base'
|
| 7 |
-
model = AutoModelForSeq2SeqLM.from_pretrained('humarin/chatgpt_paraphraser_on_T5_base'
|
| 8 |
|
| 9 |
def paraphrase(
|
| 10 |
text,
|
|
@@ -33,7 +33,11 @@ def paraphrase(
|
|
| 33 |
|
| 34 |
res = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def fn(
|
| 39 |
text,
|
|
@@ -52,14 +56,14 @@ demo = gr.Interface(
|
|
| 52 |
fn=fn,
|
| 53 |
inputs=[
|
| 54 |
gr.Textbox(lines=3, placeholder='Enter Text To Paraphrase'),
|
| 55 |
-
gr.Slider(minimum=1, maximum=
|
| 56 |
-
gr.Slider(minimum=1, maximum=
|
| 57 |
-
gr.Slider(minimum=1, maximum=
|
| 58 |
-
gr.Slider(minimum=0.6, maximum=20.1, step=0.5, value=10.1),
|
| 59 |
-
gr.Slider(minimum=0.6, maximum=20.1, step=0.5, value=3.1),
|
| 60 |
-
gr.Slider(minimum=1, maximum=10, step=1, value=2),
|
| 61 |
-
gr.Slider(minimum=0.0, maximum=
|
| 62 |
-
gr.Slider(minimum=32, maximum=512, step=1, value=128),
|
| 63 |
],
|
| 64 |
outputs=['text'],
|
| 65 |
)
|
|
|
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 4 |
|
| 5 |
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained('humarin/chatgpt_paraphraser_on_T5_base')
|
| 7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained('humarin/chatgpt_paraphraser_on_T5_base')
|
| 8 |
|
| 9 |
def paraphrase(
|
| 10 |
text,
|
|
|
|
| 33 |
|
| 34 |
res = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 35 |
|
| 36 |
+
result = ''
|
| 37 |
+
for i, item in enumerate(res):
|
| 38 |
+
result += f'{i+1}. {item}\n'
|
| 39 |
+
|
| 40 |
+
return result
|
| 41 |
|
| 42 |
def fn(
|
| 43 |
text,
|
|
|
|
| 56 |
fn=fn,
|
| 57 |
inputs=[
|
| 58 |
gr.Textbox(lines=3, placeholder='Enter Text To Paraphrase'),
|
| 59 |
+
gr.Slider(minimum=1, maximum=10, step=1, value=5, label='Num Beams', info='This parameter controls the number of possible next tokens that are considered at each step in the beam search algorithm. A higher value will result in more diverse paraphrases, but may also take longer to generate.'),
|
| 60 |
+
gr.Slider(minimum=1, maximum=10, step=1, value=5, label='Num Beam Groups', info='This parameter controls the number of beams that are run in parallel. A higher value will result in faster generation, but may also result in less diversity.'),
|
| 61 |
+
gr.Slider(minimum=1, maximum=10, step=1, value=5, label='Num Return Sequences', info='This parameter controls the number of sequences that are generated at each step in the beam search algorithm. A higher value will produce more results, but may also take longer to generate.'),
|
| 62 |
+
gr.Slider(minimum=0.6, maximum=20.1, step=0.5, value=10.1, label='Repetition Penalty', info='This parameter controls how much the model penalizes itself for generating repeated words or phrases. A higher value will result in more unique paraphrases, but may also result in less accurate paraphrases.'),
|
| 63 |
+
gr.Slider(minimum=0.6, maximum=20.1, step=0.5, value=3.1, label='Diversity Penalty', info='This parameter controls how much the model penalizes itself for generating paraphrases that are similar to each other. A higher value will result in more diverse paraphrases, but may also result in less accurate paraphrases.'),
|
| 64 |
+
gr.Slider(minimum=1, maximum=10, step=1, value=2, label='No Repeat Ngram Size', info='This parameter controls the size of the n-grams that the model is not allowed to repeat. A higher value will result in more unique paraphrases, but may also result in less accurate paraphrases.'),
|
| 65 |
+
gr.Slider(minimum=0.0, maximum=1, step=0.1, value=0.7, label='Temperature', info='This parameter controls how much the model is allowed to deviate from the original text. A higher value will result in more creative paraphrases, but may also result in less accurate paraphrases.'),
|
| 66 |
+
gr.Slider(minimum=32, maximum=512, step=1, value=128, label='Max Length', info='This parameter controls the maximum length of the generated paraphrase. A higher value will result in more detailed paraphrases, but may also take longer to generate.'),
|
| 67 |
],
|
| 68 |
outputs=['text'],
|
| 69 |
)
|