2
$\begingroup$

I am working on a text classification task that contains 216 labeled paragraphs. The distribution of tags is as follows:

{0: 17, 1: 15, 2: 16, 3: 9, 4: 10, 5: 18, 6: 24, 7: 9, 8: 33, 9: 38, 10: 27}.

The keys are representing the classes, and the value is the number of samples.

Here's my questions:
Q1. Is there any way to train a classifier?
Q2. If we want an 11-class text classifier how many samples do we need?

$\endgroup$

2 Answers 2

1
$\begingroup$

Yes, you can employ different methods. You can employ deep learning models, but you should not train them from scratch. You should employ transfer learning. Due to the fact that your dataset is small, you should utilize a deep learning model that is already trained. Next, you should replace the last layer with another layer that has the same number of neurons as your classes. The connections of this newly added layer should have random weight at first. Finally, you will freeze all the weights except for the newly added layer. In this case, your model will have a nice capacity to learn your data, and it will not overfit it. You may want to see the following links:

You can also utilize SVM with soft-margin to have good generalization.

About the number of samples, it cannot be said in advance. Moreover, for different tasks, it may be different. By the way, someone who looks at your data can easily figure out you have small dataset.

$\endgroup$
1
$\begingroup$

@Media has given a great answer. I would only like to elaborate a few points here on the same.

  1. In order to use transfer learning on text, there are few amazing models that you can be using such as RoBERTa, BERT etc, which are easily available at huggingface's transformers library. You can train them as follows:

    • Just initialize the models with pre-trained weights and freeze their weights.
    • Change the last classification layer as per your classes and then train the classification layer with your dataset. (Just make sure you are using the right learning rate in order to train the classifier.)
  2. Well there is no clearly defined rule for how much data is required for training the neural network. But as a good rule of thumb, it is clearly a good practice to have at least 10 times data of the number of the classes. So in your case, it should be at least around 100 datapoints each class.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.