NchuNLP commited on
Commit
96f8069
1 Parent(s): 5acbc26

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: zh
3
+ datasets:
4
+ - Delta Reading Comprehension Dataset
5
+
6
+ ---
7
+ # bert-base-chinese for QA
8
+
9
+ This is the [bert-base-chinese](https://huggingface.co/bert-base-chinese) model, fine-tuned using the DRCD dataset. It's been trained on question-answer pairs for the task of Question Answering.
10
+
11
+ ## Usage
12
+
13
+ ### In Transformers
14
+ ```python
15
+ from transformers import BertTokenizerFast, BertForQuestionAnswering, pipeline
16
+ model_name = "NchuNLP/Chinese-Question-Answering"
17
+ tokenizer = BertTokenizerFast.from_pretrained(model_name)
18
+ model = BertForQuestionAnswering.from_pretrained(model_name)
19
+ # a) Get predictions
20
+ nlp = pipeline('question-answering', model=model, tokenizer=tokenizer)
21
+ QA_input = {
22
+ 'question': '中興大學在哪里?',
23
+ 'context': '國立中興大學(簡稱興大、NCHU),是位於臺中的一所高等教育機構。中興大學以農業科學、農業經濟學、獸醫、生命科學、轉譯醫學、生醫工程、生物科技、綠色科技等研究領域見長 。近年中興大學與臺中榮民總醫院、彰化師範大學、中國醫藥大學等機構合作,聚焦於癌症醫學、免疫醫學及醫學工程三項領域,將實驗室成果逐步應用到臨床上,未來「衛生福利部南投醫院中興院區」將改為「國立中興大學醫學院附設醫院」。興大也與臺中市政府合作,簽訂合作意向書,共同推動數位文化、智慧城市等面相帶動區域發展。'
24
+ }
25
+ res = nlp(QA_input)
26
+ # b) Load model & tokenizer
27
+ model = AutoModelForQuestionAnswering.from_pretrained(model)
28
+ tokenizer = AutoTokenizer.from_pretrained(tokenizer)
29
+ # c) Load API
30
+
31
+ import requests
32
+
33
+ API_URL = "https://api-inference.huggingface.co/models/NchuNLP/Chinese-Question-Answering"
34
+ headers = {"Authorization": "Bearer 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"}
35
+
36
+ def query(payload):
37
+ response = requests.post(API_URL, headers=headers, json=payload)
38
+ return response.json()
39
+
40
+ output = query({
41
+ "inputs": {
42
+ "question": "中興大學在哪里?",
43
+ "context": "國立中興大學(簡稱興大、NCHU),是位於臺中的一所高等教育機構。中興大學以農業科學、農業經濟學、獸醫、生命科學、轉譯醫學、生醫工程、生物科技、綠色科技等研究領域見長 。近年中興大學與臺中榮民總醫院、彰化師範大學、中國醫藥大學等機構合作,聚焦於癌症醫學、免疫醫學及醫學工程三項領域,將實驗室成果逐步應用到臨床上,未來「衛生福利部南投醫院中興院區」將改為「國立中興大學醫學院附設醫院」。興大也與臺中市政府合作,簽訂合作意向書,共同推動數位文化、智慧城市等面相帶動區域發展。"
44
+ },
45
+ })
46
+
47
+ print(output)
48
+ ```
49
+
50
+ ## Authors
51
+ **Han Cheng Yu:** boy19990222@gmail.com
52
+
53
+ **Yao-Chung Fan:** yfan@nchu.edu.tw
54
+
55
+ ## About us
56
+
57
+ [中興大學自然語言處理實驗室](https://nlpnchu.org/)研究方向圍繞於深度學習技術在文字資料探勘 (Text Mining) 與自然語言處理 (Natural Language Processing) 方面之研究,目前實驗室成員的研究主題著重於機器閱讀理解 (Machine Reading Comprehension) 以及自然語言生成 (Natural Language Generation) 兩面向。
58
+
59
+ ## More Information
60
+
61
+ <p>For more info about Nchu NLP Lab, visit our <strong><a href="https://demo.nlpnchu.org/">Lab Online Demo</a></strong> repo and <strong><a href="https://github.com/NCHU-NLP-Lab">GitHub</a></strong>.