Dear transformers team, how could I use bert to NER task?
Author: jasonsu123
Pull request: no
Labels: name: wontfix


# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->

<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Dear  transformers team,
I have train and test corpus with BIO tags, like below:
The	O
patient	O
was	O
noted	O
with	O
first	O
depressive	O
episode	O
at	O
aged	O
36	O
.	O

How could I use bert to train my data to produce models and to predict the BIO tags of test data?
The resource have many programs, but I have no ideas that which program is what I need.

I would like to use google colab to run the program that could save python environmental problems.

Could you offer the tutorial of Bert NER task? 

Thank you
   Best regards;

Comments:
Hi,

Have a look at the following script from Huggingface:

https://github.com/huggingface/transformers/blob/master/examples/token-classification/run_ner.py

It shows how you can finetune a pretrained BERT-model for NER.
Remember to take a look at the utility code as well, since this is the code preparing and  creating your features (and tensors in general).

https://github.com/huggingface/transformers/blob/master/examples/token-classification/utils_ner.py

Regards


> Hi,
> 
> Have a look at the following script from Huggingface:
> 
> https://github.com/huggingface/transformers/blob/master/examples/token-classification/run_ner.py
> 
> It shows how you can finetune a pretrained BERT-model for NER.
> Remember to take a look at the utility code as well, since this is the code preparing and creating your features (and tensors in general).
> 
> https://github.com/huggingface/transformers/blob/master/examples/token-classification/utils_ner.py
> 
> Regards

Thanks for your response very much.

Actually I am not good at python programming.

run_ner.py could create a new pretrained model or I could us it to fine tune a existed model to my target NER task?

What are the functions of these two programs? And what parameters should I set?
What are the formats of train and test data?

I also could not find these two programs in the download folder. 
![image](https://user-images.githubusercontent.com/16911126/93067378-ba15fe00-f6ad-11ea-99ab-e4fd87742e0b.png)

By the way, could you offer the tutorial of colab format of NER task just like below link?
https://www.depends-on-the-definition.com/named-entity-recognition-with-bert/

It is complicated and consuming to set virtual environment in PC.

Thank you
       Best regards; 




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.