-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextClassifier : reported metrics after training always report precision=1.0 #1748
Comments
Thanks for reporting this! This seems to be an error in the evaluation routine that occurs if no # 4. create the text classifier
classifier = TextClassifier(document_embeddings, label_dictionary=label_dict, label_type='question_type') I will put in a PR shortly that fixes this if no label type is passed. (Edit: |
This does not seem to solve the problem. Here is what I have tested following the suggested code: from torch.optim.adam import Adam
from flair.data import Corpus
from flair.datasets import TREC_6
from flair.embeddings import TransformerDocumentEmbeddings
from flair.models import TextClassifier
from flair.trainers import ModelTrainer
# 1. get the corpus
corpus: Corpus = TREC_6()
# 2. create the label dictionary
label_dict = corpus.make_label_dictionary()
# 3. initialize transformer document embeddings (many models are available)
document_embeddings = TransformerDocumentEmbeddings('distilbert-base-uncased', fine_tune=True)
# 4. create the text classifier
classifier = TextClassifier(document_embeddings, label_dictionary=label_dict, label_type='question_type')
# 5. initialize the text classifier trainer with Adam optimizer
trainer = ModelTrainer(classifier, corpus, optimizer=Adam)
# 6. start the training
trainer.train('/tmp/taggers/trec',
learning_rate=3e-5, # use very small learning rate
mini_batch_size=16,
mini_batch_chunk_size=4, # optionally set this if transformer is too much for your machine
max_epochs=5, # terminate after 5 epochs
) Results:
|
GH-1748: fix TextClassifier evaluation if no label_type is passed
Argh, you're right. I just pushed a PR that I believe fixes this. Could you try installing from master? pip install --upgrade git+https://github.com/flairNLP/flair.git |
From the master it looks like better:
|
I have also encountered this problem
micro avg 1.0000 0.6427 0.7825 15562 and I have tried to input: but here the error comes out: can you help me @alanakbik |
Try doing a fresh pip install flair. We just released a new flair version so you don't have to install from master. |
Okay, that works, thank you |
Describe the bug
The reported metrics after training always report precision=1.0.
To Reproduce
Training code:
Example of produced report:
Expected behavior
Reports correct metrics.
Screenshots
N/A
Environment (please complete the following information):
Additional context
Same problem with other datasets.
The text was updated successfully, but these errors were encountered: