vikigitonga11 commited on
Commit
a3286ba
Β·
verified Β·
1 Parent(s): 6c464c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -21,13 +21,15 @@ def generate_paraphrase(text, temperature):
21
  temperature=temperature,
22
  top_k=50,
23
  do_sample=True,
24
- max_new_tokens=1000, # πŸš€ Extended output length
25
  repetition_penalty=1.2, # πŸ”„ Reduces repetition
26
- early_stopping=False # β›” Prevents early cutoff
 
27
  )
28
 
29
- # Ensure correct output formatting
30
- return result[0].get("generated_text", "⚠️ Paraphrasing failed. Please try again.")
 
31
 
32
  except Exception as e:
33
  return f"⚠️ An error occurred: {str(e)}"
@@ -38,16 +40,16 @@ description = """
38
  Enter text and let AI generate a paraphrased version!
39
  - **Creativity (Temperature)** controls how varied the output is.
40
  - **Input is limited to 700 words.**
41
- - **Now supports longer paraphrased outputs!**
42
  """
43
 
44
  demo = gr.Interface(
45
  fn=generate_paraphrase,
46
  inputs=[
47
- gr.Textbox(label="Enter text", placeholder="Type your text to paraphrase...", lines=7), # Bigger input box
48
  gr.Slider(0.5, 1.5, value=1.0, step=0.1, label="Creativity (Temperature)"),
49
  ],
50
- outputs=gr.Textbox(label="Paraphrased Text", lines=15), # πŸ”₯ Expands output display
51
  title="πŸ“ AI Paraphraser",
52
  description=description,
53
  theme="huggingface",
 
21
  temperature=temperature,
22
  top_k=50,
23
  do_sample=True,
24
+ max_new_tokens=1500, # πŸš€ Allows much longer outputs
25
  repetition_penalty=1.2, # πŸ”„ Reduces repetition
26
+ early_stopping=False, # β›” Prevents early cutoff
27
+ num_return_sequences=1 # βœ… Ensures a single, complete paraphrase
28
  )
29
 
30
+ # Extract and format output properly
31
+ paraphrased_text = result[0].get("generated_text", "⚠️ Paraphrasing failed. Please try again.").strip()
32
+ return paraphrased_text
33
 
34
  except Exception as e:
35
  return f"⚠️ An error occurred: {str(e)}"
 
40
  Enter text and let AI generate a paraphrased version!
41
  - **Creativity (Temperature)** controls how varied the output is.
42
  - **Input is limited to 700 words.**
43
+ - **Now supports much longer paraphrased outputs!**
44
  """
45
 
46
  demo = gr.Interface(
47
  fn=generate_paraphrase,
48
  inputs=[
49
+ gr.Textbox(label="Enter text", placeholder="Type your text to paraphrase...", lines=10), # Bigger input box
50
  gr.Slider(0.5, 1.5, value=1.0, step=0.1, label="Creativity (Temperature)"),
51
  ],
52
+ outputs=gr.Textbox(label="Paraphrased Text", lines=20), # πŸ”₯ Expands output display
53
  title="πŸ“ AI Paraphraser",
54
  description=description,
55
  theme="huggingface",