File size: 1,389 Bytes
4e07a7c
 
378d972
 
 
d6c1f78
378d972
d5db245
378d972
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from transformers import pipeline
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
def query(input_sentence,num,start):
    string3=[]
    for i in range(0,num):
    #intial="""These are the few examples of converting original sentences into paraphrased sentences.\n original: Symptoms of influenza include fever and nasal congestion.\n paraphrase: A stuffy nose and elevated temperature are signs you may have the flu.\n  original: Maintaining a creative work environment is not only beneficial to employees, but also to company profits.\n paraphrase: Having a fertile work environment can increase productivity and profitability.\n """
    full_input=intial+"original:"+input_sentence + "\n paraphrase:"+start
    string1=generator("EleutherAI has", do_sample=True, min_length=len(full_input.split()))[0]['generated_text']
    string2=string1.split('paraphrase:',3)[-1]
    string3.append(string2.split('.',1)[0]+".")
  return '\n\n'.join([i for i in string3[0:]])
title = "Paraphrasing"
description = "Gradio Demo for Paraphrasing"
gr.Interface(fn=query, inputs=[gr.inputs.Textbox(lines=4, label="Input Text (Single Sentence)"),gr.inputs.Slider( minimum=1, maximum=10, step=1, default=4, label="Numbers of Outputs"),gr.inputs.Textbox(lines=1, label="Starting Point (optional)")],outputs=["text"],title=title,description=description,enable_queue=True).launch()