Closed LoicDagnas closed 3 years ago
bert2bert needs input_ids, input_mask, segment_ids and target_ids to train. You should save the model with all features provided.
If you care about inference and there is no target_ids, you should not use Keras model.save(). Keras does not support None as inputs. Instead, we directly define a tf.Module including the bert2bert core model and save the tf.function using tf.saved_model.save() API. Usually, the seq2seq model is not friendly to Keras assumptions.
@saberkun in fact I get the exact same error using
tf.saved_model.save(model, "any/path")
at the end of my example above.
1. The entire URL of the file you are using
https://github.com/tensorflow/models/blob/master/official/nlp/nhnet/models.py
2. Describe the bug
When saving a Bert2Bert model instance, I am forced to pass the target_ids input which should be used only at training time.
Passing the target ids calling the model and using a custom serving function without these target ids as input make the saving works but IMO it is weird to do it that way.
3. Steps to reproduce
You can simply run the following piece of code:
you'll get the following stack:
4. Expected behavior
Saving should work using only the input needed at serving time.
5. Additional context
Adding:
to the list of inputs make the saving works.
6. System information