Evelyn18 commited on
Commit
76435b2
1 Parent(s): 02c3f80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -23
app.py CHANGED
@@ -1,26 +1,27 @@
1
- import os
2
- import sys
3
- from transformers import pipeline
4
  import gradio as gr
5
 
6
- model = pipeline('question-answering', model='deepset/tinyroberta-squad2', tokenizer='deepset/tinyroberta-squad2')
 
 
 
 
 
 
 
 
 
7
 
8
- def qa(passage, question):
9
- question = question
10
- context = passage
11
- nlp_input = {
12
- 'question': question,
13
- 'context': context
14
- }
15
-
16
- return model(nlp_input)['answer']
17
-
18
- passage = "The quick brown fox jumped over the lazy dog."
19
- question = "Who jumps over the lazy dog?"
20
-
21
- iface = gr.Interface(qa,
22
- title="Question Answering using RoBERTa",
23
- inputs=[gr.inputs.Textbox(lines=15), "text"],
24
- outputs=["text"],
25
- examples=[["{}".format(passage), "{}".format(question)]])
26
- iface.launch()
 
 
 
 
1
  import gradio as gr
2
 
3
+ title = "RoBERTa, tengo una pregunta"
4
+ description = "Modelo tipo RoBERTa pre-entrenado por BSC-TeMU con la base de datos de la Bibliotecha Nacional de España y fine-tuned con el corpus SQAC (Spanish Question-Answering Corpus)."
5
+ examples = [
6
+ ["¡Hola, mundo! Somos NLP en ES 🤗 la comunidad de hispanohablantes de la iniciativa “Languages at HuggingFace” y queremos democratizar el NLP en nuestro idioma. Somos una red internacional y nuestro objetivo es crear y compartir recursos que posibiliten y aceleren el avance del NLP en español.", "¿Quiénes somos?"]
7
+ ]
8
+ article = """
9
+ <p style="text-align: center">
10
+ NLP en ES 🤗 | <a target=”_blank” href="https://nlp-en-es.org"> nlp-en-es.org </a>
11
+ </p>
12
+ """
13
 
14
+ gr.Interface.load(
15
+ name="huggingface/Evelyn18/roberta-base-bne-ROBERTaBECAS",
16
+ inputs=[gr.inputs.Textbox(label="Contexto", lines=5), gr.inputs.Textbox(label="Pregunta")],
17
+ outputs=gr.outputs.Textbox(label="Respuesta"),
18
+ title=title,
19
+ description=description,
20
+ article=article,
21
+ examples=examples,
22
+ theme="huggingface",
23
+ allow_screenshot=True,
24
+ allow_flagging=True,
25
+ flagging_dir="flagged",
26
+ enable_queue=True
27
+ ).launch()