Megatron gpt p-tuning


I am trying out p-tuning for megatron model. For my task, I finetuned a model on two classes.

However, if a text is passed to the model which doesn’t relate to the two categories, the prediction is still generated, classifying the text to either of them. I was wondering if there is a way to know the confidence or some score to discard the result in that case?

Any help on this please??

I would recommend tuning the models on 3 classes instead: class A, class B and third one - “neither A nor B”. Since you already have examples for A and B, gathering examples for “neither A nor B” should be easy

Yes, it is possible to get a confidence score or probability for the predictions made by your fine-tuned Megatron model. Many machine learning models, including transformer models like Megatron, include a predict_proba() method which can be used to get the probability or confidence score for each of the classes the model is able to predict.

For example, if you are using a fine-tuned Megatron model to classify texts into two categories, you could use the predict_proba() method to get a probability score for each of the two categories. If the probability score for one of the categories is very low, it may indicate that the model is not confident in its prediction for that text and you may want to discard the prediction.

Keep in mind that the confidence scores or probabilities generated by the predict_proba() method should be used with caution and may not always be reliable. The accuracy and reliability of the probabilities generated by the method will depend on the quality and diversity of the training data used to fine-tune the model, as well as the complexity of the task and the limitations of the model itself.

When using a fine-tuned model, it’s possible for the model to generate predictions even for inputs that are unrelated to the trained categories. To access the confidence or score associated with these predictions, you can utilize the probability values assigned to each class by the model. By examining these probabilities, you can set a threshold value to determine when to discard the results. For instance, if the highest probability for a prediction is below a certain threshold, you can consider it as an indication of low confidence and choose to discard the result.