Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from transformers import T5ForConditionalGeneration, AutoTokenizer
|
|
6 |
|
7 |
auth_token = os.environ.get("CLARIN_KNEXT")
|
8 |
|
9 |
-
model_name = "clarin-knext/plt5-large-poquad-ext-qa-autotoken"
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=auth_token)
|
11 |
model = T5ForConditionalGeneration.from_pretrained(model_name, use_auth_token=auth_token)
|
12 |
|
@@ -21,12 +21,12 @@ default_generate_kwargs = {
|
|
21 |
# keywords_pipe = pipeline(model=model, tokenizer=tokenizer, **default_generate_kwargs)
|
22 |
|
23 |
examples = [
|
24 |
-
["
|
25 |
|
26 |
|
27 |
|
28 |
-
def generate(context):
|
29 |
-
context = context
|
30 |
inputs = tokenizer(
|
31 |
context,
|
32 |
max_length=512,
|
@@ -46,8 +46,8 @@ def generate(context):
|
|
46 |
|
47 |
demo = gr.Interface(
|
48 |
fn=generate,
|
49 |
-
inputs=gr.
|
50 |
-
outputs=gr.
|
51 |
examples=examples,
|
52 |
)
|
53 |
|
|
|
6 |
|
7 |
auth_token = os.environ.get("CLARIN_KNEXT")
|
8 |
|
9 |
+
model_name = "clarin-knext/plt5-large-poquad" # "clarin-knext/plt5-large-poquad-ext-qa-autotoken"
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=auth_token)
|
11 |
model = T5ForConditionalGeneration.from_pretrained(model_name, use_auth_token=auth_token)
|
12 |
|
|
|
21 |
# keywords_pipe = pipeline(model=model, tokenizer=tokenizer, **default_generate_kwargs)
|
22 |
|
23 |
examples = [
|
24 |
+
["Jakie miasto jest stolicą Polski?", "Polska ma wiele wspaniałych miast, Wrocław, Poznań czy Gdańsk. Jednak stolicą jest Warszawa."]]
|
25 |
|
26 |
|
27 |
|
28 |
+
def generate(question, context):
|
29 |
+
context = f"question: {question} context: {context} </s>"
|
30 |
inputs = tokenizer(
|
31 |
context,
|
32 |
max_length=512,
|
|
|
46 |
|
47 |
demo = gr.Interface(
|
48 |
fn=generate,
|
49 |
+
inputs=[gr.Textbox(lines=1, label="Question"), gr.Textbox(lines=5, label="Context")],
|
50 |
+
outputs=gr.Textbox(label="Answer"),
|
51 |
examples=examples,
|
52 |
)
|
53 |
|