asd
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 3 |
import spaces
|
|
|
|
| 4 |
device = "cuda"
|
| 5 |
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained("NoaiGPT/777")
|
|
@@ -11,13 +12,15 @@ def generate_title(text):
|
|
| 11 |
input_ids = tokenizer(f'paraphraser: {text}', return_tensors="pt", padding="longest", truncation=True, max_length=64).input_ids.to(device)
|
| 12 |
outputs = model.generate(
|
| 13 |
input_ids,
|
| 14 |
-
num_beams=4
|
| 15 |
num_beam_groups=4,
|
| 16 |
-
num_return_sequences=4
|
| 17 |
-
repetition_penalty=10.0
|
| 18 |
-
diversity_penalty=3.0
|
| 19 |
-
no_repeat_ngram_size=2
|
| 20 |
-
temperature=0.
|
|
|
|
|
|
|
| 21 |
max_length=64
|
| 22 |
)
|
| 23 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
@@ -30,8 +33,8 @@ iface = gr.Interface(
|
|
| 30 |
fn=gradio_generate_title,
|
| 31 |
inputs=gr.Textbox(lines=5, label="Input Text"),
|
| 32 |
outputs=gr.Textbox(lines=10, label="Generated Titles"),
|
| 33 |
-
title="Title Generator",
|
| 34 |
-
description="Generate multiple paraphrased titles from input text using NoaiGPT/777 model."
|
| 35 |
)
|
| 36 |
|
| 37 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 3 |
import spaces
|
| 4 |
+
|
| 5 |
device = "cuda"
|
| 6 |
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained("NoaiGPT/777")
|
|
|
|
| 12 |
input_ids = tokenizer(f'paraphraser: {text}', return_tensors="pt", padding="longest", truncation=True, max_length=64).input_ids.to(device)
|
| 13 |
outputs = model.generate(
|
| 14 |
input_ids,
|
| 15 |
+
num_beams=8, # Increased from 4
|
| 16 |
num_beam_groups=4,
|
| 17 |
+
num_return_sequences=6, # Increased from 4
|
| 18 |
+
repetition_penalty=12.0, # Increased from 10.0
|
| 19 |
+
diversity_penalty=4.0, # Increased from 3.0
|
| 20 |
+
no_repeat_ngram_size=3, # Increased from 2
|
| 21 |
+
temperature=1.1, # Increased from 0.9
|
| 22 |
+
top_k=50, # Added top_k sampling
|
| 23 |
+
top_p=0.95, # Added top_p sampling
|
| 24 |
max_length=64
|
| 25 |
)
|
| 26 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
|
|
| 33 |
fn=gradio_generate_title,
|
| 34 |
inputs=gr.Textbox(lines=5, label="Input Text"),
|
| 35 |
outputs=gr.Textbox(lines=10, label="Generated Titles"),
|
| 36 |
+
title="Diverse Title Generator",
|
| 37 |
+
description="Generate multiple diverse paraphrased titles from input text using NoaiGPT/777 model."
|
| 38 |
)
|
| 39 |
|
| 40 |
iface.launch()
|