Tflite conversion

I was trying to convert a bert pretrained model to tflite model,

modelQA = TFAutoModelForQuestionAnswering.from_pretrained(“vumichien/mobilebert-uncased-squad-v2”)
loaded_model = TFAutoModelForQuestionAnswering.from_pretrained(“project_dir”)
converter = tf.lite.TFLiteConverter.from_keras_model(loaded_model) # path to the SavedModel directory
tflite_model = converter.convert()

Save the model.

with open(“.\model.tflite”, ‘wb’) as f:

After conversion the the input/attention_mask/segement_id shape becomes [1,1].
Did i miss something here?

{‘name’: ‘serving_default_attention_mask:0’, ‘index’: 0, ‘shape’: array([1, 1]), ‘shape_signature’: array([-1, -1]), ‘dtype’: <class ‘numpy.int32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}

Hi @Krishnaraj_k

Loading and converting directly the BERT model will not give you the inputs/outputs to a file that you desire so you can use it inside a mobile for example. Can you check this example? Maybe it will solve your issue. Come back if you have any more questions.