Ahsen Khaliq
Update app.py
c0e18b5
raw
history blame
3.55 kB
import gradio as gr
title = "ProphetNet"
description = "Gradio Demo for ProphetNet. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2001.04063' target='_blank'>ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training</a></p>"
examples = [
["Paris, city and capital of France, situated in the north-central part of the country. People were living on the site of the present-day city, located along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche), by about 7600 BCE. The modern city has spread from the island (the Île de la Cité) and far beyond both banks of the Seine. Paris occupies a central position in the rich agricultural region known as the Paris Basin, and it constitutes one of eight départements of the Île-de-France administrative region. It is by far the country’s most important centre of commerce and culture. Area city, 41 square miles (105 square km); metropolitan area, 890 square miles (2,300 square km). Pop. (2012) city, 2,265,886; (2015 est.) urban agglomeration, 10,858,000. Character of the city For centuries Paris has been one of the world’s most important and attractive cities. It is appreciated for the opportunities it offers for business and commerce, for study, for culture, and for entertainment; its gastronomy, haute couture, painting, literature, and intellectual community especially enjoy an enviable reputation. Its sobriquet “the City of Light” (“la Ville Lumière”), earned during the Enlightenment, remains appropriate, for Paris has retained its importance as a centre for education and intellectual pursuits. Paris’s site at a crossroads of both water and land routes significant not only to France but also to Europe has had a continuing influence on its growth. Under Roman administration, in the 1st century BCE, the original site on the Île de la Cité was designated the capital of the Parisii tribe and territory. The Frankish king Clovis I had taken Paris from the Gauls by 494 CE and later made his capital there. Under Hugh Capet (ruled 987–996) and the Capetian dynasty the preeminence of Paris was firmly established, and Paris became the political and cultural hub as modern France took shape. France has long been a highly centralized country, and Paris has come to be identified with a powerful central state, drawing to itself much of the talent and vitality of the provinces.","prophetnet-large-uncased"]
]
io1 = gr.Interface.load("huggingface/microsoft/prophetnet-large-uncased")
io2 = gr.Interface.load("huggingface/microsoft/prophetnet-large-uncased-squad-qg")
io3 = gr.Interface.load("huggingface/microsoft/prophetnet-large-uncased-cnndm")
def inference(text, model):
if model == "prophetnet-large-uncased":
outtext = io1(text)
elif model == "prophetnet-large-uncased-squad-qg":
outtext = io2(text)
else:
outtext = io3(text)
return outtext
gr.Interface(
inference,
[gr.inputs.Textbox(label="Input", lines=10),gr.inputs.Dropdown(choices=["prophetnet-large-uncased","prophetnet-large-uncased-squad-qg","prophetnet-large-uncased-cnndm"], type="value", default="prophetnet-large-uncased", label="model")
],
gr.outputs.Textbox(label="Output"),
examples=examples,
article=article,
title=title,
description=description).launch(enable_queue=True, cache_examples=True)