devendergarg14 commited on
Commit
b929154
·
1 Parent(s): 5c5c2d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -2,14 +2,14 @@ from transformers import pipeline
2
  import gradio as gr
3
  generator = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B')
4
  def query(input_sentence,num,start):
5
- string3=[]
6
  for i in range(0,num):
7
  intial="""These are the few examples of converting original sentences into paraphrased sentences.\n original: The gray clouds were a warning of an approaching storm.\n paraphrase: The coming storm was foretold by the dark clouds.\n original: Giraffes like Acacia leaves and hay, and they can consume 75 pounds of food a day.\n paraphrase: A giraffe can eat up to 75 pounds of Acacia leaves and hay daily.\n """
8
  full_input=intial+"original:"+input_sentence + "\n paraphrase:"+start
9
- string1=generator(full_input, do_sample=True,max_length= len(full_input.split())+70,min_length=len(full_input.split())+70,temperature=0.65+i*0.05)[0]['generated_text']
10
- string2=string1.split('paraphrase:',3)[-1]
11
- string3.append(string2.split('.',1)[0]+".")
12
- return '\n\n'.join([i for i in string3[0:]])
13
  title = "Paraphrasing"
14
  description = "Gradio Demo for Paraphrasing with GPT-NEO. Simply add one line sentence in the Input. It is possible to control the start of output paraphrased sentences using optional Starting Point Input."
15
  article = "<div style='text-align: center;'><a href='https://github.com/EleutherAI/gpt-neo'>GPT-NEO GitHub</a> | <center><img src='https://visitor-badge.glitch.me/badge?page_id=devendergarg14_Paraphrasing_with_GPT_Neo' alt='visitor badge'></center></div>"
 
2
  import gradio as gr
3
  generator = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B')
4
  def query(input_sentence,num,start):
5
+ paraphrase_final=[]
6
  for i in range(0,num):
7
  intial="""These are the few examples of converting original sentences into paraphrased sentences.\n original: The gray clouds were a warning of an approaching storm.\n paraphrase: The coming storm was foretold by the dark clouds.\n original: Giraffes like Acacia leaves and hay, and they can consume 75 pounds of food a day.\n paraphrase: A giraffe can eat up to 75 pounds of Acacia leaves and hay daily.\n """
8
  full_input=intial+"original:"+input_sentence + "\n paraphrase:"+start
9
+ output=generator(full_input, do_sample=True,max_length= len(full_input.split())+70,min_length=len(full_input.split())+70,temperature=0.65+i*0.05)[0]['generated_text']
10
+ paraphrase_text=output.split('paraphrase:',3)[-1]
11
+ paraphrase_final.append( paraphrase_text.split('.',1)[0]+".")
12
+ return '\n\n'.join([i for i in paraphrase_final[0:]])
13
  title = "Paraphrasing"
14
  description = "Gradio Demo for Paraphrasing with GPT-NEO. Simply add one line sentence in the Input. It is possible to control the start of output paraphrased sentences using optional Starting Point Input."
15
  article = "<div style='text-align: center;'><a href='https://github.com/EleutherAI/gpt-neo'>GPT-NEO GitHub</a> | <center><img src='https://visitor-badge.glitch.me/badge?page_id=devendergarg14_Paraphrasing_with_GPT_Neo' alt='visitor badge'></center></div>"