kwojtasik commited on
Commit
1b276b4
1 Parent(s): b7e14ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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
- ["extract question: Kiedy Arek ma spotkanie dzisiaj? context: Arek ma spotkanie przez cały dzeiń. Bardzo to lubi."]]
25
 
26
 
27
 
28
- def generate(context):
29
- context = context + " </s>"
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.inputs.Textbox(lines=5, label="Input Text"),
50
- outputs=gr.outputs.Textbox(label="Keywords"),
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