File size: 2,289 Bytes
9a2d345 be0043c 8e54fd5 a324022 eda3840 718042f 772bcf5 718042f 8e54fd5 718042f b0adbfb 718042f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import gradio as gr
from gradio.mix import Parallel
from transformers import pipeline
import torch
question = "Zertarako hasi dira ikertzen Londreseko poliziak?"
context = "Londreseko Poliziak ikerketa bat jarri du martxan pandemia garaian Downing Streeten egin diren festen auzia argitzeko. Boris Johnsonek jai horietan parte hartu zuela eta, zalaparta handia piztu da Erresuma Batuan, jendartea haserre dago eta Alderdi Kontserbadorearen baitan ere ika-mika sortu da, lehen ministroak karguak utzi behar duela uste baitute.\nCressida Dick komisario buruak adierazi du Gobernuko kideek azken hiru urteotan pandemiaren kontrako neurriak urratu dituzten ikertuko dutela, eta ikerketa \"inolako beldurrik gabe eta inori mesederik egin gabe\" gauzatuko dutela agindu du.\nHalaber, ikerketan urrats garrantzitsurik ematen dutenean, berehala jakinaraziko dutela erantsi du.\nAtzo telebista britainiar batek jakinarazi zuenez, Boris Johnsonek bere urtebetetze jaia egin zuen Downing Streeteko egoitzan, 2020ko ekainaren 19an, covid-19ari aurre egiteko murrizketak urratuta."
models = ["MarcBrun/ixambert-finetuned-squad","MarcBrun/ixambert-finetuned-squad-eu","MarcBrun/ixambert-finetuned-squad-eu-en"]
pipes = [pipeline("question-answering", model=model) for model in models]
def answer(question, context):
answers = [pipe(question=question, context=context) for pipe in pipes]
return [answer["answer"] for answer in answers]
gr.Interface(answer, inputs=[gr.inputs.Textbox(lines=1, default=question, placeholder="Question Here...", label="Question"),gr.inputs.Textbox(lines=10, default=context, placeholder="Context Here...", label="Context")], outputs=[gr.outputs.Textbox(label="SQuADv1.1"),gr.outputs.Textbox(label="SQuAD-eu"),gr.outputs.Textbox(label="SQuADv1.1 + SQuAD-eu")], title = "Question Answering in Basque", description="This demo compares the outputs of three QA models based on IXAmBERT. Each has been trained on different data: one on SQuADv1.1, another on an experimental version of SQuAD in Basque, and the last on both those datasets. The models mays also be able to answer questions in English and Spanish, because the base model is multilingual, and was pretrained on those 3 languages, but the intention of this demo is to compare performance in Basque.").launch() |