vikigitonga11 commited on
Commit
c5ae324
·
verified ·
1 Parent(s): 0316316

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -30,10 +30,16 @@ def paraphrase_text(text):
30
 
31
  sentences = split_sentences(text)
32
 
33
- # Apply T5 paraphrasing to each sentence
34
  paraphrased_results = paraphrase_pipeline(
35
  [f"paraphrase: {sentence} </s>" for sentence in sentences if sentence],
36
- max_length=50, do_sample=True, batch_size=8, num_return_sequences=1 # Faster settings
 
 
 
 
 
 
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="🚀 Fast & Clean T5 Paraphraser",
48
- description="Enter text and let AI generate a paraphrased version using an optimized T5 model!",
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