How to trans a model with Parallel encoder
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 536
- Avg merge
- 12h 12m
- Merged PRs (30d)
- 4
Description
framework: OpenNMT-tf
model:
class TinyDualSourceTransformer(onmt.models.Transformer):
def __init__(self):
super(TinyDualSourceTransformer, self).__init__(
source_inputter=onmt.inputters.ParallelInputter([
onmt.inputters.WordEmbedder(embedding_size=256),
onmt.inputters.WordEmbedder(embedding_size=256)]),
target_inputter=onmt.inputters.WordEmbedder(embedding_size=256),
num_layers=4,
num_units=128,
num_heads=4,
ffn_inner_dim=512,
dropout=0.1,
attention_dropout=0.1,
ffn_dropout=0.1,
share_encoders=True)
def auto_config(self, num_replicas=1):
config = super(TinyDualSourceTransformer, self).auto_config(num_replicas=num_replicas)
max_length = config["train"]["maximum_features_length"]
return misc.merge_dict(config, {
"train": {
"maximum_features_length": [max_length, max_length]
}
})
model = TinyDualSourceTransformer
command:
onmt-main --config data_tiny_0504.yml --auto_config export --output_dir models/model_v2_ctrans --format ctranslate2
error:
2023-05-06 15:26:36.878000: I inputter.py:316] Initialized source_1 input layer:
2023-05-06 15:26:36.878000: I inputter.py:316] - vocabulary size: 50001
2023-05-06 15:26:36.878000: I inputter.py:316] - special tokens: BOS=no, EOS=no
2023-05-06 15:26:36.904000: I inputter.py:316] Initialized source_2 input layer:
2023-05-06 15:26:36.904000: I inputter.py:316] - vocabulary size: 4121
2023-05-06 15:26:36.904000: I inputter.py:316] - special tokens: BOS=no, EOS=no
2023-05-06 15:26:37.075000: I inputter.py:316] Initialized target input layer:
2023-05-06 15:26:37.075000: I inputter.py:316] - vocabulary size: 50001
2023-05-06 15:26:37.075000: I inputter.py:316] - special tokens: BOS=yes, EOS=yes
2023-05-06 15:26:37.139000: I runner.py:490] Restored checkpoint run_0504/ckpt-25000
2023-05-06 15:26:38.775468: I tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:428] Loaded cuDNN version 8201
Traceback (most recent call last):
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/bin/onmt-main", line 8, in <module>
sys.exit(main())
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/opennmt/bin/main.py", line 347, in main
runner.export(
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/opennmt/runner.py", line 496, in export
model.export(export_dir, exporter=exporter)
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/opennmt/models/model.py", line 439, in export
exporter.export(self, export_dir)
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/opennmt/utils/exporters.py", line 22, in export
self._export_model(model, export_dir)
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/opennmt/utils/exporters.py", line 169, in _export_model
converter.convert(export_dir, quantization=self._quantization, force=True)
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/ctranslate2/converters/converter.py", line 89, in convert
model_spec = self._load()
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/ctranslate2/converters/opennmt_tf.py", line 88, in _load
return spec_builder(self._model)
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/ctranslate2/converters/opennmt_tf.py", line 113, in __call__
check.validate()
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/ctranslate2/converters/utils.py", line 87, in validate
raise_unsupported(self._unsupported_reasons)
File "/ldap_home/kyro.wang/miniconda3/envs/nmt-tf/lib/python3.9/site-packages/ctranslate2/converters/utils.py", line 74, in raise_unsupported
raise ValueError(message)
ValueError: The model you are trying to convert is not supported by CTranslate2. We identified the following reasons:
- Parallel encoders are not supported
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 with ctranslate2/converters/opennmt_tf.py and the validation path shown in the traceback. Determine how the converter represents OpenNMT-tf parallel encoders and what conversion coverage is needed. Done means the reported model converts successfully and the resulting CTranslate2 model can be used for translation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100