Open winner484 opened 6 years ago
主要差異在
新版把訓練資料、模型放的位置從設定檔獨立出來
舊版
@DoubleAix @crownpku 我按新版的来也是不行,我把配置文件里面的data和path删了,然后按照新版的教材手动添加,但是依然报错,请看:
$ python3 -m rasa_nlu.train \
--config sample_configs/config_jieba_mitie_sklearn.json \ --data data/examples/rasa/demo-rasa_zh.json \ --path projectzh Traceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/fengyu/rasa_nlu_chi/rasa_nlu/train.py", line 174, in
num_threads=cmdline_args.num_threads) File "/home/fengyu/rasa_nlu_chi/rasa_nlu/train.py", line 143, in do_train trainer = Trainer(cfg, component_builder) File "/home/fengyu/rasa_nlu_chi/rasa_nlu/model.py", line 146, in init components.validate_requirements(cfg.component_names) File "/home/fengyu/rasa_nlu_chi/rasa_nlu/config.py", line 146, in component_names return [c.get("name") for c in self.pipeline] File "/home/fengyu/rasa_nlu_chi/rasa_nlu/config.py", line 146, in return [c.get("name") for c in self.pipeline] AttributeError: 'str' object has no attribute 'get'
把設定檔改成yml的版本就可以了,不行的話,再來看看。因爲感覺像是parse出錯,導致變數不是字典變成字串了
感谢上面大神指导,最终试了如下命令OK:
训练:
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
這是我的問題,因為我在pull request的時候,沒有順便去修正README.md,造成困擾,我有責任上來回覆一下 假如 @crownpku 沒有時間處理,我這個假日可以把 README.md 修改一下
刚刚碰到同种问题,.json改为.yml,再配置上data参数,就可以解决了。 还有个问题,请教!json\yml两者有什么区别呢?为甚么会有两种,什么时候可以用?
@YanaGuo json\yml两者有什么区别呢?为甚么会有两种,什么时候可以用? JSON是舊版的格式,把所有設定都放進去,但是比較沒有彈性,這也是這個PROJECT長期以來想要解決的問題(EX:JIEBA字典) YML是新版的格式,只剩下用來設定PIPELINE,其他設定抽出來(訓練資料和訓練完後的模型位置),但讓每一個PIPELINE的COMPONENT都可以定義自己的參數設定 YML格式也比JSON格式更直覺,上面是我個人的想法
Rasa NLU version: 直接git clone https://github.com/crownpku/rasa_nlu_chi.git
Operating system (windows, osx, ...):ubuntu
Issue: 按照教程做,根本没法作阿,先是说json文件找不到,然后我改了路径, 后又提示data必须填写,我又指定了demo的json路径, 再然后报错。
fengyu@Y570:~/rasa_nlu_chi$ python3 -m rasa_nlu.train -c ./sample_configs/config_jieba_mitie_sklearn.json -d ./data/examples/rasa/demo-rasa_zh.jsonTraceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/fengyu/rasa_nlu_chi/rasa_nlu/train.py", line 174, in
num_threads=cmdline_args.num_threads)
File "/home/fengyu/rasa_nlu_chi/rasa_nlu/train.py", line 143, in do_train
trainer = Trainer(cfg, component_builder)
File "/home/fengyu/rasa_nlu_chi/rasa_nlu/model.py", line 146, in init
components.validate_requirements(cfg.component_names)
File "/home/fengyu/rasa_nlu_chi/rasa_nlu/config.py", line 146, in component_names
return [c.get("name") for c in self.pipeline]
File "/home/fengyu/rasa_nlu_chi/rasa_nlu/config.py", line 146, in
return [c.get("name") for c in self.pipeline]
AttributeError: 'str' object has no attribute 'get'