Getting a keyword error when I try to train a model in OpenNMT-tf model

I’m getting a keyword error when I try to train a model using Open-NMTtf. I did some googling but I didn’t see much on this error.

$onmt-main --model_type Transformer --config data.yml --auto_config train --with_eval

Below is my data.yml file:

model_dir: run/

  train_features_file: src-train.txt
  train_labels_file: tgt-train.txt
  eval_features_file: src-val.txt
  eval_labels_file: tgt-val.txt
  source_vocabulary: src-vocab.txt
  target_vocabulary: tgt-vocab.txt

Below is the error I’m getting.

Traceback (most recent call last):
  File "/home/username/.local/bin/onmt-main", line 8, in <module>
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/bin/", line 231, in main
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/", line 199, in train
checkpoint_path=checkpoint_path, weights_only=checkpoint_path is not None)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/utils/", line 129, in restore
checkpoint_path, tmp_model, optimizer=tmp_optimizer)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/utils/", line 274, in _restore_v1_checkpoint
mapping = model.map_v1_weights(v1_structure)
  File "/home/username/.local/lib/python3.6/site-packages/opennmt/models/", line 158, in map_v1_weights
weights["seq2seq"] = weights.pop("transformer")
KeyError: 'transformer'

Can you delete the run/ directory before starting the training?