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": "我发烧了该吃什么药?"
}