Like you mention the models need to be converted to TFLIte, The usual steps to convert a model ,would be :
1. Export the Model to ONNX (using PyTorch)
import torch
import onnx
from transformers import AutoModel
model = AutoModel.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B")
dummy_input = torch.randn(1, 128) # Adjust input shape as needed
torch.onnx.export(model, dummy_input, "deepseek_r1.onnx")
2. Convert ONNX to TensorFlow
from onnx_tf.backend import prepare
import onnx
onnx_model = onnx.load("deepseek_r1.onnx")
tf_model = prepare(onnx_model)
tf_model.export_graph("deepseek_r1_tf")
3./Convert TensorFlow Model to TFLite
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model("deepseek_r1_tf")
tflite_model = converter.convert()
with open("deepseek_r1.tflite", "wb") as f:
f.write(tflite_model)