can't convert opennmt.py model with alibi or rotary embeddings to ctranslate2
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 536
- Avg merge
- 12h 12m
- Merged PRs (30d)
- 4
Description
I get this error when max_relative_positions: -1 or max_relative_positions: -2
Traceback (most recent call last):
File "/opt/conda/bin/onmt_release_model", line 33, in <module>
sys.exit(load_entry_point('OpenNMT-py==3.2.0', 'console_scripts', 'onmt_release_model')())
File "/opt/conda/lib/python3.10/site-packages/OpenNMT_py-3.2.0-py3.10.egg/onmt/bin/release_model.py", line 35, in main
converter.convert(opt.output, force=True, quantization=opt.quantization)
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/converter.py", line 89, in convert
model_spec = self._load()
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 189, in _load
return _get_model_spec_seq2seq(
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 89, in _get_model_spec_seq2seq
set_transformer_spec(model_spec, variables)
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 199, in set_transformer_spec
set_transformer_encoder(spec.encoder, variables)
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 204, in set_transformer_encoder
set_input_layers(spec, variables, "encoder")
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 230, in set_input_layers
set_position_encodings(
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 330, in set_position_encodings
spec.encodings = _get_variable(variables, "%s.pe" % scope).squeeze()
File "/opt/conda/lib/python3.10/site-packages/ctranslate2/converters/opennmt_py.py", line 334, in _get_variable
return variables[name].numpy()
KeyError: 'encoder.embeddings.make_embedding.pe.pe'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the conversion with OpenNMT-py models using max_relative_positions -1 and -2. Trace the path through ctranslate2/converters/opennmt_py.py, especially set_position_encodings and _get_variable, and compare the variables available for these models. Done means both model types convert without the reported KeyError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100