Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while converting to Ctranslate2 from openNMTPy. #1767

Open
aryan1165 opened this issue Aug 28, 2024 · 1 comment
Open

Error while converting to Ctranslate2 from openNMTPy. #1767

aryan1165 opened this issue Aug 28, 2024 · 1 comment

Comments

@aryan1165
Copy link

I have a openNMTPy model translator.pt. While converting it using ct2-opennmt-py-converter --model_path himangy_triton_repo/himangy-hi-pa/1/2.pt --output_dir ct2_model --quantization "int8" command. I get following error :-

  File "/opt/anaconda3/envs/NMT/bin/ct2-opennmt-py-converter", line 8, in <module>
    sys.exit(main())
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 355, in main
    OpenNMTPyConverter(args.model_path).convert_from_args(args)
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/converter.py", line 50, in convert_from_args
    return self.convert(
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/converter.py", line 89, in convert
    model_spec = self._load()
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 181, in _load
    check_opt(checkpoint["opt"], num_source_embeddings=len(src_vocabs))
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 55, in check_opt
    check.validate()
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/utils.py", line 106, in validate
    raise_unsupported(self._unsupported_reasons)
  File "/opt/anaconda3/envs/NMT/lib/python3.10/site-packages/ctranslate2/converters/utils.py", line 93, in raise_unsupported
    raise ValueError(message)
ValueError: The model you are trying to convert is not supported by CTranslate2. We identified the following reasons:

- Options --encoder_type and --decoder_type must be 'transformer' or 'transformer_lm
- Options --position_encoding and --max_relative_positions cannot be both enabled or both disabled

Ctranslate2 - ctranslate2==4.3.1
OpenNMTPy - OpenNMT-py==1.2.0

@ymoslem
Copy link

ymoslem commented Aug 30, 2024

The OpenNMT version is too old. You might try an older version of CTranslate2 (two years old, if still available).

However, let's first check the errors:

Options --encoder_type and --decoder_type must be 'transformer' or 'transformer_lm

Is this model based on the Transformer architecture? If not, it is not supported by CTranslate2.

Options --position_encoding and --max_relative_positions cannot be both enabled or both disabled

If you use max_relative_positions you must set position_encoding to False during training with OpenNMT. The error started to show in 2021, and I am not sure if there was an earlier version of CTranslate2 that didn't complain about it.

With all of this in mind, there is a chance you will not be able to convert this model to CTranslate2. Currently, there are several pre-trained OPUS models, NLLB-200, and MADLAD-400, all of which are supported by CTranslate2.

All the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants