Pytorch based Bert NER for transfer learning/retraining - pytorch

I trained an Bert-based NER model using Pytorch framework by referring the below article.
https://www.depends-on-the-definition.com/named-entity-recognition-with-bert/.
After training the model using this approach, I saved that model using torch.save() method. Now, I want to retrain the model with new dataset.
Can someone please help me on how to perform retraining/transfer learning as I'm new to NLP and transformers.
Thanks in advance.

First, you can read the doc on pytorch loading, the model that can be very helpful to retrain the save model in a new dataset. I will provide the example of loading a save model. That can be very helpful to you
Original Doc :- https://pytorch.org/tutorials/beginner/saving_loading_models.html
Example code :- https://pythonguides.com/pytorch-load-model/
This two link are very helpful to train the new dataset on save model

Related

how can I train a OpenAI fine tuned model with more prompts

I fine-tuned OpenAI model with some prompts following this documentation it succeeded and created a new model in the playground. How I can retrain (fine-tune) that same model with new prompts?
This is what I found out on Open AI Documentation
If you have already fine-tuned a model for your task and now have additional training data that you would like to incorporate, you can continue fine-tuning from the model. This creates a model that has learned from all of the training data without having to re-train from scratch.
i.e you can't train the already existing trained model again.

alternative for maximum entropy for NLP model

I am working on a NLP model where the model identifies the ARGs given the PREDICATE.
I am using MaxEnt for the model.
My model works fine. I trained the model with a Train dataset, created all the features, and then tested it with a Test dataset.
I wanted to try this with some other package and not with MaxEnt.
Can someone suggest what else can I use?

Does training a tflite model require images annotated?

I am trying to implement TFLite model for food detection and segmentation. This is the model i chose suitable for my food images dataset: [https://tfhub.dev/s?deployment-format=lite&q=inception%20resnet%20v2].
I searched over google to understand how the images are required to be annotated, but only end up in confusion. I understand the dataset is converted to TFRecords and then fed to the pretrained model. But for training the model with custom dataset, does not it require an annotation file? I dont see any info about this on TF hub either.
Please can anyone help me on this!
The answer to your question is depends on what model do you plan to train.
In the case of a model for food detection and segmentation you do need annotations when training. If you do not provide the model with labeled training data as it is a supervised learning model it cannot learn from them.
If you were to train an autoencoder the data does not need to be annotated. Hope the keywords used in this answer help you out search for more information about the topic.

Object detection using turicreate

I was exploring turicreate ObjectDetector API. The documentation mentions it is a trained model. I wanted to know if I can use this trained model & detect the 1000 labels which was used to originally train this turi model. All the examples mention to train with our dataset, I do not want to train but wanted to use pre-trained model which can classify. Any help is appreciated.
Is your question about how to load and use a pre-trained model? Turi create API docs mentions a load_model method:
model.save('my_model_file')
loaded_model = tc.load_model('my_model_file')
EDIT: Yep, ObjectDetector exposes a save method that works well with load_model.

Train, Save and Load a Tensorflow Model

Refer to this to train a GAN model for MNIST dataset, I want to save a model and restore it for further prediction. After having some understanding of Saving and Importing a Tensorflow Model I am able to save and restore some variables of inputs and outputs but for this network I am able to save the model only after some specific iterations and not able to predict some output.
Did you refer to this guide? It explains very clearly how to load and save tensorflow models in all possible formats.
If you are new to ML, I'd recommend you give Keras a try first, which is much easier to use. See https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model, pretty much you can use:
model.save('my_model.h5')
to save your model to disk.
model = load_model('my_model.h5')
to load your model and make prediction

Resources