rloganiv / kglm-model

Code for KGLM paper
121 stars 26 forks source link

Training and Evaluating #54

Closed anandhperumal closed 4 years ago

anandhperumal commented 5 years ago

@rloganiv Nice work.

  1. Is there any pre-trained model available? How can I use it for sentence completion task.

I tried using the model in test folder but then I get this error :

E:\GitHub\kglm-model>python -m kglm.run predict --predictor cloze kglm\tests\fixtures\kglm.model.tar.gz input.txt
Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex.
D:\Programs\Python\Python37\lib\site-packages\sklearn\utils\linear_assignment_.py:21: DeprecationWarning: The linear_assignment_ module is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.
  DeprecationWarning)
2019-10-23 18:10:59,191 - INFO - allennlp.models.archival - loading archive file kglm\tests\fixtures\kglm.model.tar.gz
2019-10-23 18:10:59,194 - INFO - allennlp.models.archival - extracting archive file kglm\tests\fixtures\kglm.model.tar.gz to temp dir C:\Users\anand\AppData\Local\Temp\tmphjgljrs7
2019-10-23 18:10:59,216 - WARNING - allennlp.common.params - _jsonnet not loaded, treating C:\Users\anand\AppData\Local\Temp\tmphjgljrs7\config.json as json
Traceback (most recent call last):
  File "D:\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "E:\GitHub\kglm-model\kglm\run.py", line 24, in <module>
    'complete-the-sentence': CompleteTheSentence(),
  File "D:\Programs\Python\Python37\lib\site-packages\allennlp\commands\__init__.py", line 101, in main
    args.func(args)
  File "D:\Programs\Python\Python37\lib\site-packages\allennlp\commands\predict.py", line 187, in _predict
    predictor = _get_predictor(args)
  File "D:\Programs\Python\Python37\lib\site-packages\allennlp\commands\predict.py", line 99, in _get_predictor
    overrides=args.overrides)
  File "D:\Programs\Python\Python37\lib\site-packages\allennlp\models\archival.py", line 156, in load_archive
    cuda_device=cuda_device)
  File "D:\Programs\Python\Python37\lib\site-packages\allennlp\models\model.py", line 322, in load
    return cls.by_name(model_type)._load(config, serialization_dir, weights_file, cuda_device)
  File "D:\Programs\Python\Python37\lib\site-packages\allennlp\common\registrable.py", line 58, in by_name
    raise ConfigurationError("%s is not a registered name for %s" % (name, cls.__name__))
allennlp.common.checks.ConfigurationError: 'kglm is not a registered name for Model'
2019-10-23 18:10:59,257 - INFO - allennlp.models.archival - removing temporary unarchived model dir at C:\Users\anand\AppData\Local\Temp\tmphjgljrs7
  1. Error in training:
    
    (env) λ allennlp train E:\GitHub\kglm-model\experiments\kglm.jsonnet -s E:\GitHub\kglm-model\experiments\checkpoint --include-package kglm
    Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex.
    e:\github\kglm-model\env\lib\site-packages\sklearn\utils\linear_assignment_.py:21: DeprecationWarning: The linear_assignment_ module is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.
    DeprecationWarning)
    2019-10-23 18:46:47,867 - WARNING - allennlp.common.params - _jsonnet not loaded, treating E:\GitHub\kglm-model\experiments\kglm.jsonnet as json
    Traceback (most recent call last):
    File "E:\GitHub\kglm-model\env\Scripts\allennlp-script.py", line 11, in <module>
    load_entry_point('allennlp===0.8.2-unreleased', 'console_scripts', 'allennlp')()
    File "e:\github\kglm-model\env\lib\site-packages\allennlp\run.py", line 18, in run
    main(prog="allennlp")
    File "e:\github\kglm-model\env\lib\site-packages\allennlp\commands\__init__.py", line 101, in main
    args.func(args)
    File "e:\github\kglm-model\env\lib\site-packages\allennlp\commands\train.py", line 103, in train_model_from_args
    args.force)
    File "e:\github\kglm-model\env\lib\site-packages\allennlp\commands\train.py", line 135, in train_model_from_file
    params = Params.from_file(parameter_filename, overrides)
    File "e:\github\kglm-model\env\lib\site-packages\allennlp\common\params.py", line 442, in from_file
    file_dict = json.loads(evaluate_file(params_file, ext_vars=ext_vars))
    File "D:\Programs\Python\Python37\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
    File "D:\Programs\Python\Python37\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "D:\Programs\Python\Python37\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 99 column 9 (char 2996)
rloganiv commented 5 years ago
  1. No pretrained model is currently available (the one in the test folder is purely for testing purposes, I would recommend training your own). To avoid the ConfigurationError you need to add --include-package kglm to the command.

  2. To avoid this error jsonnet needs to be loaded - can you double check that jsonnet is installed on your system?