Hi,
I was trying to convert a bert pretrained model to tflite model,
modelQA = TFAutoModelForQuestionAnswering.from_pretrained(“vumichien/mobilebert-uncased-squad-v2”)
modelQA.save_pretrained(“project_dir”)
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:
f.write(tflite_model)
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’: {}}