I am trying to store a hugging face transformer ai model for each individual user locally instead of storing it in a database.
model = BertForSequenceClassification.from_pretrained('bert-base-uncased',num_labels=2)
model.save_pretrained("locallystored")
I then would like to train that users model that I stored locally. I send a websocket to backend to train the model stored in the users local machine.
socketio.on("willtraintheusersmodel")
model = BertForSequenceClassification.from_pretrained('locallystored')
*training*
model.train()
model.save_pretrained("locallystored")
#then I update the changes made
How can I save a model in the users computer locally and retrieve it anytime i need to train or make predictions? I am trying to make this work in production with multiple users.
I have a python-socketio backend with react frontend
Any help would be extremely appreciated thanks.