Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
PyTorch solution of named entity recognition task Using Google AI's pre-trained BERT model.
| Date | Stars |
|---|---|
| 2026-07-24 | 446 |
| 2026-07-25 | 446 |
| 2026-07-28 | 446 |
| 2026-07-30 | 446 |
| 2026-08-06 | 446 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# NER-BERT-pytorch
**PyTorch solution of [Named Entity Recognition](https://en.wikipedia.org/wiki/Named-entity_recognition) task with Google AI's BERT model.**
利用Google AI的BERT模型进行中文命名实体识别任务的PyTorch实现。
Welcome to watch, star or fork.
<div align=center><img src="./img/model.png" width="500px"></div>
## MSRA dataset
Here, we take the Chinese NER data MSRA as an example. Of course, the English NER data is also fully applicable.
Named entity recognition task is one of the tasks of the [Third SIGHAN Chinese Language Processing Bakeoff](http://sighan.cs.uchicago.edu/bakeoff2006/), we take the simplified Chinese version of the Microsoft NER dataset as the research object.
### Data Formats
The NER dataset of MSRA consists of training set `data/msra_train_bio` and test set `data/msra_test_bio`, and no validation set is provided. There are 45000 training samples and 3442 test samples, and we will divide them appropriately later.
The dataset contains three types of entities: **Person**, **Organization**, **Location** and **Other**, the corresponding abbreviated tags are `PER`, `ORG` and `LOC` and `O`.
The format is similar to that of the Co-NLL NER task 2002, adapted for Chinese. The data is presented in two-column format, where the first column consists of the **character** and the second is a **tag**. The tag is specified as follows:
| Tag | Meaning |
| :---: | ------------------------------------------------ |
| O | Not part of a named entity |
| B-PER | Beginning character of a person name |
| I-PER | Non-beginning character of a person name |
| B-ORG | Beginning character of an organization name |
| I-ORG | Non-beginning character of an organization name |
| B-LOC | Beginning character of a location name |
| I-LOC | Non-beginning character of a location name |
| B-GPE | Beginning character of a geopolitical entity |
| I-GPE | Non-beginning character of a geopolitical entity |
### Dataset patition
We randomly select 3000 samples from the training set as the validation set, and the test set is unchanged. Thus, the dataset distribution is as follows.
| Dataset | Number |
| :------------: | :----: |
| training set | 42000 |
| validation set | 3000 |
| test set | 3442 |
## Requirements
This repo was tested on Python 3.5+ and PyTorch 0.4.1/1.0.0. The requirements are:
- tensorflow >= 1.11.0
- torch >= 0.4.1
- pytorch-pretrained-bert == 0.4.0
- tqdm
- apex
**Note**: The tensorflow library is only used for the conversion of pre-trained models from TensorFlow to PyTorch. apex is a tool for easy mixed precision and distributed training in Pytorch, please see https://github.com/NVIDIA/apex.
## Results
We didn't search best parameters and obtained the following results.
### Overall results
Based on the best performance of the model on the validation set, the overall effect of the model is as follows:
| Dataset | F1_score |
| :------------: | :-------: |
| training set | 99.88 |
| validation set | **95.90** |
| test set | **94.62** |
### Detail results on test set
Based on the best model on the validation set, we can get the recognition effect of each entity type on the test set.
| NE Types | Precison | Recall | F1_score |
| :------: | :------: | :----: | :------: |
| PER | 96.36 | 96.43 | 96.39 |
| ORG | 89.64 | 92.07 | 90.84 |
| LOC | 95.92 | 95.13 | 95.52 |
## Usage
1. **Get BERT model for PyTorch**
There are two ways to get the pre-trained BERT model in a PyTorch dump for your experiments :
- **Direct download of the converted pytorch version of the BERT model**
You can download the pytorch dump I converted from the tensorflow checkpont from my Google Cloud Drive folder [`bert-base-chinese-pytorch`](https://drive.google.com/drive/folders/1K_xCYMCEfjpPjedSnMyL9zMVzqbanQX9), including the BERT parameters file `beExcerpt of 7,569 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:3fc0e09d6839020d, topic:named-entity-recognition, topic:information-extraction, desc:named entity recognition
matched fp:3fc0e09d6839020d, topic:pytorch, readme:distributed training