zhiguowang / BiMPM

BiMPM: Bilateral Multi-Perspective Matching for Natural Language Sentences
Apache License 2.0
439 stars 150 forks source link

Error while testing with the default config file #60

Open OXPHOS opened 4 years ago

OXPHOS commented 4 years ago

I ran into several errors when I tried to run the testing script with the provided instructions:

python ${workspace}/BiMPM/src/SentenceMatchDecoder.py --in_path ${your_path_to}/dev.tsv --word_vec_path ${your_path_to}/wordvec.txt --out_path ${your_path_to}/result.json --model_prefix ${model_dir}/SentenceMatch.${suffix}

And most of them were caused by missing values of the params in the automactiaclly-generated ${model_prefix}.config.json file.

For example: AttributeError: 'Bunch' object has no attribute 'isLower'

NameError: name 'char_vocab' is not defined

AttributeError: 'Bunch' object has no attribute 'use_cudnn'

And so on. The solution I found was to replace the Line 25 in SentenceMatchDecoder.pyfrom options = namespace_utils.load_namespace(args.model_prefix + ".config.json") to options = namespace_utils.load_namespace('/Users/zora/Github/BiMPM/configs/quora.sample.config') , thus the script could use the config file supplied for training. I am not sure whether this is the correct move, but it worked.

P.S. My config.json generated automatically by SentenceMatchTrainer.py:

{
    "aggregation_layer_num": 1,
    "aggregation_lstm_dim": 100,
    "batch_size": 60,
    "char_emb_dim": 20,
    "char_lstm_dim": 100,
    "config_path": null,
    "context_layer_num": 1,
    "context_lstm_dim": 100,
    "dev_path": null,
    "dropout_rate": 0.1,
    "fix_word_vec": false,
    "highway_layer_num": 1,
    "in_format": "tsv",
    "lambda_l2": 0.0,
    "learning_rate": 0.001,
    "max_char_per_word": 10,
    "max_epochs": 10,
    "max_sent_length": 100,
    "model_dir": "/***/BiMPM/quora/logs/",
    "optimize_type": "adam",
    "suffix": "normal",
    "test_path": null,
    "train_path": null,
    "with_aggregation_highway": false,
    "with_attentive_match": false,
    "with_char": false,
    "with_full_match": false,
    "with_highway": false,
    "with_match_highway": false,
    "with_max_attentive_match": false,
    "with_maxpool_match": false,
    "word_vec_path": "/***/BiMPM/quora/data/wordvec.txt"
}
pellfun commented 4 years ago

I tried what you said but I still can't find the ".label_vocab" file