Rasa_NLU_Chi
1.0.0
透過 MITIE wordrep 工具對中文語料庫進行訓練(訓練需要 2-3 天)
如需培訓,請建立 MITIE Wordrep 工具。請注意,中文語料庫應先標記,然後再輸入工具進行訓練。最匹配使用者案例的閉域語料庫效果最好。
來自中文維基百科轉儲和百度百科的訓練模型可以從中文部落格下載。
應該添加盡可能多的例子。
python setup.py install
修改配置。
目前對於中文我們有兩個管道:
使用MITIE+Jieba(sample_configs/config_jieba_mitie.yml):
language : " zh "
pipeline :
- name : " nlp_mitie "
model : " data/total_word_feature_extractor_zh.dat "
- name : " tokenizer_jieba "
- name : " ner_mitie "
- name : " ner_synonyms "
- name : " intent_entity_featurizer_regex "
- name : " intent_classifier_mitie "
推薦:使用 MITIE+Jieba+sklearn (sample_configs/config_jieba_mitie_sklearn.yml):
language : " zh "
pipeline :
- name : " nlp_mitie "
model : " data/total_word_feature_extractor_zh.dat "
- name : " tokenizer_jieba "
- name : " ner_mitie "
- name : " ner_synonyms "
- name : " intent_entity_featurizer_regex "
- name : " intent_featurizer_mitie "
- name : " intent_classifier_sklearn "
(可選)使用Jieba自訂字典或切換Jieba預設字典:
您可以輸入檔案路徑或目錄路徑作為“user_dicts”值。 (sample_configs/config_jieba_mitie_sklearn_plus_dict_path.yml)
language : " zh "
pipeline :
- name : " nlp_mitie "
model : " data/total_word_feature_extractor_zh.dat "
- name : " tokenizer_jieba "
default_dict : " ./default_dict.big "
user_dicts : " ./jieba_userdict "
# user_dicts: "./jieba_userdict/jieba_userdict.txt"
- name : " ner_mitie "
- name : " ner_synonyms "
- name : " intent_entity_featurizer_regex "
- name : " intent_featurizer_mitie "
- name : " intent_classifier_sklearn "
透過運行訓練模型:
如果您在設定檔中指定專案名稱,這會將您的模型儲存在 /models/your_project_name 中。
否則,您的模型將保存在 /models/default 中
python -m rasa_nlu.train -c sample_configs/config_jieba_mitie_sklearn.yml --data data/examples/rasa/demo-rasa_zh.json --path models
python -m rasa_nlu.server -c sample_configs/config_jieba_mitie_sklearn.yml --path models
$ curl -XPOST localhost:5000/parse -d '{"q":"我发烧了该吃什么药?", "project": "rasa_nlu_test", "model": "model_20170921-170911"}' | python -mjson.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 652 0 552 100 100 157 28 0:00:03 0:00:03 --:--:-- 157
{
"entities": [
{
"end": 3,
"entity": "disease",
"extractor": "ner_mitie",
"start": 1,
"value": "发烧"
}
],
"intent": {
"confidence": 0.5397186422631861,
"name": "medical"
},
"intent_ranking": [
{
"confidence": 0.5397186422631861,
"name": "medical"
},
{
"confidence": 0.16206323981749196,
"name": "restaurant_search"
},
{
"confidence": 0.1212448457737397,
"name": "affirm"
},
{
"confidence": 0.10333600028547868,
"name": "goodbye"
},
{
"confidence": 0.07363727186010374,
"name": "greet"
}
],
"text": "我发烧了该吃什么药?"
}