czq commited on
Commit
712bf3c
·
1 Parent(s): ce47d6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -70,6 +70,7 @@ def main(question, context):
70
  # 编码输入
71
  text = question + " [SEP] " + context
72
  inputs = tokenizer(text, max_length=4096, truncation=True, return_tensors="pt")
 
73
  # inputs.to('cuda')
74
  # 预测答案
75
  outputs = model(**inputs)
@@ -79,11 +80,13 @@ def main(question, context):
79
  # 解码答案
80
  is_impossible = null_scores.argmax().item()
81
  if is_impossible:
 
82
  return "No Answer"
83
  else:
84
  answer_start = torch.argmax(start_scores)
85
  answer_end = torch.argmax(end_scores) + 1
86
  answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(inputs['input_ids'][0][answer_start:answer_end]))
 
87
  return answer
88
 
89
 
 
70
  # 编码输入
71
  text = question + " [SEP] " + context
72
  inputs = tokenizer(text, max_length=4096, truncation=True, return_tensors="pt")
73
+ print(question)
74
  # inputs.to('cuda')
75
  # 预测答案
76
  outputs = model(**inputs)
 
80
  # 解码答案
81
  is_impossible = null_scores.argmax().item()
82
  if is_impossible:
83
+ print('No Answer')
84
  return "No Answer"
85
  else:
86
  answer_start = torch.argmax(start_scores)
87
  answer_end = torch.argmax(end_scores) + 1
88
  answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(inputs['input_ids'][0][answer_start:answer_end]))
89
+ print(answer)
90
  return answer
91
 
92