0
該語料庫包含從網(wǎng)站Insurance Library 收集的問題和答案。
據(jù)我們所知,這是保險領(lǐng)域首個開放的QA語料庫:
該語料庫的內(nèi)容由現(xiàn)實世界的用戶提出,高質(zhì)量的答案由具有深度領(lǐng)域知識的專業(yè)人士提供。 所以這是一個具有真正價值的語料,而不是玩具。
在上述論文中,語料庫用于答復(fù)選擇任務(wù)。 另一方面,這種語料庫的其他用法也是可能的。 例如,通過閱讀理解答案,觀察學(xué)習(xí)等自主學(xué)習(xí),使系統(tǒng)能夠最終拿出自己的看不見的問題的答案。
數(shù)據(jù)集分為兩個部分“問答語料”和“問答對語料”。問答語料是從原始英文數(shù)據(jù)翻譯過來,未經(jīng)其他處理的。問答對語料是基于問答語料,又做了分詞和去標去停,添加label。所以,"問答對語料"可以直接對接機器學(xué)習(xí)任務(wù)。如果對于數(shù)據(jù)格式不滿意或者對分詞效果不滿意,可以直接對"問答語料"使用其他方法進行處理,獲得可以用于訓(xùn)練模型的數(shù)據(jù)。
歡迎任何進一步增加此數(shù)據(jù)集的想法。
語料地址
https://github.com/Samurais/insuranceqa-corpus-zh
在Python環(huán)境中,可以使用pip安裝
兼容py2, py3
pip install --upgrade insuranceqa_data
問題 | 答案 | 詞匯(英語) | |
訓(xùn)練 | 12,889 | 21,325 | 107,889 |
驗證 | 2,000 | 3354 | 16,931 |
測試 | 2,000 | 3308 | 16,815 |
每條數(shù)據(jù)包括問題的中文,英文,答案的正例,答案的負例。案的正例至少1項,基本上在1-5條,都是正確答案。答案的負例有200條,負例根據(jù)問題使用檢索的方式建立,所以和問題是相關(guān)的,但卻不是正確答案。
{
"INDEX": {
"zh": "中文",
"en": "英文",
"domain": "保險種類",
"answers": [""] # 答案正例列表
"negatives": [""] # 答案負例列表
},
more ...
}
訓(xùn)練:corpus/pool/train.json.gz
驗證:corpus/pool/valid.json.gz
測試:corpus/pool/test.json.gz
答案:corpus/pool/answers.json 一共有 27,413 個回答,數(shù)據(jù)格式為 json:
{
"INDEX": {
"zh": "中文",
"en": "英文"
},
more ...
}
問答對
格式 INDEX ++$++ 保險種類 ++$++ 中文 ++$++ 英文
corpus/pool/train.txt.gz, corpus/pool/valid.txt.gz, corpus/pool/test.txt.gz.
答案
格式 INDEX ++$++ 中文 ++$++ 英文
corpus/pool/answers.txt.gz
語料庫使用gzip進行壓縮以減小體積,可以使用zmore, zless, zcat, zgrep等命令訪問數(shù)據(jù)。
zmore pool/test.txt.gz
import insuranceqa_data as insuranceqa
train_data = insuranceqa.load_pool_train()
test_data = insuranceqa.load_pool_test()
valid_data = insuranceqa.load_pool_valid()# valid_data, test_data and train_data share the same propertiesfor x in train_data: print('index %s value: %s ++$++ %s ++$++ %s' % \
(x, d[x]['zh'], d[x]['en'], d[x]['answers'], d[x]['negatives']))
answers_data = insuranceqa.load_pool_answers()for x in answers_data: print('index %s: %s ++$++ %s' % (x, d[x]['zh'], d[x]['en']))
使用"問答語料",還需要做很多工作才能進入機器學(xué)習(xí)的模型,比如分詞,去停用詞,去標點符號,添加label標記。所以,在"問答語料"的基礎(chǔ)上,還可以繼續(xù)處理,但是在分詞等任務(wù)中,可以借助不同分詞工具,這點對于模型訓(xùn)練而言是有影響的。為了使數(shù)據(jù)能快速可用,insuranceqa-corpus-zh提供了一個使用HanLP分詞和去標,去停,添加label的數(shù)據(jù)集,這個數(shù)據(jù)集完全是基于"問答語料"。
import insuranceqa_data as insuranceqa
train_data = insuranceqa.load_pairs_train()
test_data = insuranceqa.load_pairs_test()
valid_data = insuranceqa.load_pairs_valid()# valid_data, test_data and train_data share the same propertiesfor x in test_data: print('index %s value: %s ++$++ %s ++$++ %s' % \
(x['qid'], x['question'], x['utterance'], x['label']))
vocab_data = insuranceqa.load_pairs_vocab()
vocab_data['word2id']['UNKNOWN']
vocab_data['id2word'][0]
vocab_data['tf']
vocab_data['total']
vocab_data包含word2id(dict, 從word到id), id2word(dict, 從id到word),tf(dict, 詞頻統(tǒng)計)和total(單詞總數(shù))。 其中,未登錄詞的標識為UNKNOWN,未登錄詞的id為0。
train_data, test_data 和 valid_data 的數(shù)據(jù)格式一樣。qid 是問題Id,question 是問題,utterance 是回復(fù),label 如果是 [1,0] 代表回復(fù)是正確答案,[0,1] 代表回復(fù)不是正確答案,所以 utterance 包含了正例和負例的數(shù)據(jù)。每個問題含有10個負例和1個正例。
train_data含有問題12,889條,數(shù)據(jù) 141779條,正例:負例 = 1:10 test_data含有問題2,000條,數(shù)據(jù) 22000條,正例:負例 = 1:10 valid_data含有問題2,000條,數(shù)據(jù) 22000條,正例:負例 = 1:10
句子長度:
max len of valid question : 31, average: 5(max)
max len of valid utterance: 878(max), average: 165(max)
max len of test question : 33, average: 5
max len of test utterance: 878, average: 161
max len of train question : 42(max), average: 5
max len of train utterance: 878, average: 162
vocab size: 24997
可將本語料庫和以下開源碼配合使用
DeepQA2: https://github.com/Samurais/DeepQA2
InsuranceQA TensorFlow: https://github.com/l11x0m7/InsuranceQA
Chatbot Retrieval: https://github.com/dennybritz/chatbot-retrieval
聲明1 : insuranceqa-corpus-zh
本數(shù)據(jù)集使用翻譯 insuranceQA而生成,代碼發(fā)布證書 GPL 3.0。數(shù)據(jù)僅限于研究用途,如果在發(fā)布的任何媒體、期刊、雜志或博客等內(nèi)容時,必須注明引用和地址。
InsuranceQA Corpus, Hai Liang Wang, https://github.com/Samurais/insuranceqa-corpus-zh, 07 27, 2017
任何基于insuranceqa-corpus衍生的數(shù)據(jù)也需要開放并需要聲明和“聲明1”和“聲明2”一致的內(nèi)容。
聲明2 : insuranceQA
此數(shù)據(jù)集僅作為研究目的提供。如果您使用這些數(shù)據(jù)發(fā)表任何內(nèi)容,請引用我們的論文:
Applying Deep Learning to Answer Selection: A Study and An Open Task。Minwei Feng, Bing Xiang, Michael R. Glass, Lidan Wang, Bowen Zhou @ 2015
“TensorFlow & 神經(jīng)網(wǎng)絡(luò)算法高級應(yīng)用班”開課了!
最受歡迎的谷歌TensorFlow 框架,ThoughtWorks大牛教你玩轉(zhuǎn)深度學(xué)習(xí)!
課程鏈接:http://www.mooc.ai/course/82
加入AI慕課學(xué)院人工智能學(xué)習(xí)交流QQ群:624413030,與AI同行一起交流成長
相關(guān)文章:
基于 AI-DR 來談, AI 醫(yī)療影像該如何落地?
機器學(xué)習(xí)如何“著陸”醫(yī)療行業(yè)?三位行業(yè)專家談關(guān)鍵四點
雷峰網(wǎng)特約稿件,未經(jīng)授權(quán)禁止轉(zhuǎn)載。詳情見轉(zhuǎn)載須知。