nyust-eb210 commited on
Commit
a411c55
1 Parent(s): 20a5e93

update readme

Browse files
Files changed (1) hide show
  1. README.md +3 -3
README.md CHANGED
@@ -34,8 +34,8 @@ Deploy [BERT-DRCD-QuestionAnswering](https://github.com/pleomax0730/BERT-DRCD-Qu
34
  ### In Transformers
35
 
36
  ```python
37
- text = "馬雲是我爸爸。"
38
- query = "我爸爸是誰?"
39
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
40
  tokenizer = BertTokenizerFast.from_pretrained("nyust-eb210/braslab-bert-drcd-384")
41
  model = BertForQuestionAnswering.from_pretrained("nyust-eb210/braslab-bert-drcd-384").to(device)
@@ -50,5 +50,5 @@ answer = "".join(tokenizer.decode(answer).split())
50
  start_prob = torch.max(torch.nn.Softmax(dim=-1)(qa_outputs.start_logits)).item()
51
  end_prob = torch.max(torch.nn.Softmax(dim=-1)(qa_outputs.end_logits)).item()
52
  confidence = (start_prob + end_prob) / 2
53
- print(answer, confidence) # 馬雲, 0.98
54
  ```
 
34
  ### In Transformers
35
 
36
  ```python
37
+ text = "鴻海科技集團是由臺灣企業家郭台銘創辦的跨國企業,總部位於臺灣新北市土城區,主要生產地則在中國大陸,以富士康做為商標名稱。其專注於電子產品的代工服務,研發生產精密電氣元件、機殼、準系統、系統組裝、光通訊元件、液晶顯示件等3C產品上、下游產品及服務。"
38
+ query = "鴻海集團總部位於哪裡?"
39
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
40
  tokenizer = BertTokenizerFast.from_pretrained("nyust-eb210/braslab-bert-drcd-384")
41
  model = BertForQuestionAnswering.from_pretrained("nyust-eb210/braslab-bert-drcd-384").to(device)
 
50
  start_prob = torch.max(torch.nn.Softmax(dim=-1)(qa_outputs.start_logits)).item()
51
  end_prob = torch.max(torch.nn.Softmax(dim=-1)(qa_outputs.end_logits)).item()
52
  confidence = (start_prob + end_prob) / 2
53
+ print(answer, confidence) # 臺灣新北市土城區, 0.92
54
  ```