OpenNMT Forum

Ctranslate2 conversion error

Hello,
I tried to convert the opennmt-py example provided here https://pypi.org/project/ctranslate2/#installation, then I got this error, any help?

Traceback (most recent call last):
File “/usr/local/bin/ct2-opennmt-py-converter”, line 8, in
sys.exit(main())
File “/usr/local/lib/python3.6/dist-packages/ctranslate2/bin/opennmt_py_converter.py”, line 11, in main
converters.OpenNMTPyConverter(args.model_path).convert_from_args(args)
File “/usr/local/lib/python3.6/dist-packages/ctranslate2/converters/converter.py”, line 40, in convert_from_args
force=args.force)
File “/usr/local/lib/python3.6/dist-packages/ctranslate2/converters/converter.py”, line 52, in convert
src_vocab, tgt_vocab = self._load(model_spec)
File “/usr/local/lib/python3.6/dist-packages/ctranslate2/converters/opennmt_py.py”, line 22, in _load
checkpoint = torch.load(self._model_path, map_location=“cpu”)
File “/usr/local/lib/python3.6/dist-packages/torch/serialization.py”, line 593, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File “/usr/local/lib/python3.6/dist-packages/torch/serialization.py”, line 773, in _legacy_load
result = unpickler.load()
File “/usr/local/lib/python3.6/dist-packages/torchtext/vocab.py”, line 119, in setstate
if state[‘unk_index’] is None:
KeyError: ‘unk_index’

Hi,

See:

It’s a bug in torchtext 0.4.0. You need to update this package.

1 Like

Problem Solved!
Thank you.