question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Finetuned BERT model does not seem to predict right labels/work properly?

See original GitHub issue

❓ Questions & Help

I am trying out a finetuned BERT model for token classification (–> https://huggingface.co/bert-base-cased-finetuned-conll03-english), but when I observe the model output (i.e. the logits after applying the softmax) and compare it with the true label_ids, they are totally uncorrelated (see pictures).

https://i.stack.imgur.com/gVyMn.png https://i.stack.imgur.com/qS62L.png

Details

I assume that the finetuned model (bert-base-cased-finetuned-conll03-english) is correctly pretrained, but I don’t seem to understand why its predictions are off. I think one issue is that the pretrained model has another labelling scheme than I made myself during data prep (so that the tag2name dict is different), but I don’t know how I can find out what label-index map the model uses for its predictions. Even then it is not the case that the model consistently makes the same mistakes, it is outputting things quite randomly.

Any idea what the issue could be?

``

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LysandreJikcommented, Mar 2, 2020

Hi! From my experience using the community-contributed dbmdz/bert-large-cased-finetuned-conll03-english (which is the same checkpoint as) bert-large-cased-finetuned-conll03-english, using the bert-base-cased tokenizer instead of the tokenizer loaded from that checkpoint works better.

You can see an example of this in the usage, let me know if it helps.

I suspect the difference between the tokenizers is due to a lowercasing of all inputs. I’m looking into it now.

PS: the file bert-large-cased-finetuned-conll03-english is deprecated in favor of the aforementionned dbmdz/bert-large-cased-finetuned-conll03-english as they are duplicates. @julien-c is currently deleting it from the S3, please use the dbmdz file/folder.

0reactions
stale[bot]commented, May 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the fine-tuned model for actual prediction after re ...
I'm trying to reload a DistilBertForSequenceClassification model I've fine-tuned to predict some sentences into their appropriate labels (text ...
Read more >
Huggingface TFBertForSequenceClassification always ...
I am using Huggingface's TFBertForSequenceClassification for sequence classification task to predict 4 labels of sentences in German text. I use ...
Read more >
Tutorial: Fine-tuning BERT for Sentiment Analysis - by Skim AI
This value is the baseline performance and will be used to evaluate the performance of our fine-tune BERT model. In [0]:. # Compute...
Read more >
BERT Fine-Tuning Tutorial with PyTorch - Chris McCormick
In this tutorial I'll show you how to use BERT with the huggingface PyTorch library to quickly and efficiently fine-tune a model to...
Read more >
Tips and Tricks for your BERT based applications
(2) Will fine-tuning the model beforehand increase the accuracy? ... Exp 1: No finetuning + BERT model with Pooler output; Exp 2: No...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found