Giter VIP home page Giter VIP logo

bert-bilstm-crf-pytorch's Introduction

Bert-BiLSTM-CRF-pytorch

bert-bilstm-crf implemented in pytorch for named entity recognition.

python == 3.6
pytorch == 0.4.1
pytorch_pretrained_bert == 0.6.1

Data

  • 首先将数据处理成BIO格式,processed文件夹下存放的是医疗命名实体识别的数据,代码可参考data_process.ipynb
  • 下载中文BERT预训练模型,来自pytorch-pretrained-bert

模型训练

python main.py -- n_epochs 100 --finetuning --top_rnns

模型预测

python crf_predict.py

bert-bilstm-crf-pytorch's People

Contributors

cooscao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bert-bilstm-crf-pytorch's Issues

CUDA error

Hi

First, thank u for having shared ur code with us
I tried to execute ur code on google colab but it gave me this error even if CUDA is activated

Screen Shot 2020-11-23 at 9 28 31 AM

do u have any ideas plz?
thank u

crf.py

您好,感谢您的代码,在crf.py中的_forward_alg函数里面有一行代码不太明白:
log_alpha = (log_sum_exp_batch(self.transitions + log_alpha, axis=-1) + feats[:, t]).unsqueeze(1)
在_forward_alg函数中的log_alpha处,为什么在函数log_sum_exp_batch的外面加feats[:, t],感觉在pytorch官方非batch版本中,是先加feats再进行log_sum_exp的啊,batch版本有什么不同吗?谢谢您的回复~

预训练模型载入失败

请问一下作者,我已经下载了chinese_L-12_H-768_A-12的压缩包,但是解压之后里面模型名为bert_model.ckpt.data-00000-of-00001,我是应该用链接使用这个文件么?之前我指向整个chinese_L-12_H-768_A-12文件夹的时候,终端报错提示找不到model,还是说我需要重命名模型文件么

more elaborations on the whole pipeline?

Hi! :)

Your work attracted my attention, and I want to follow your approach for my use case

If you do not mind, I have questions:

  • Do you have any paper/article/repo/blog you depended on to create this work?
  • Can you breifly elaborate on your work flow, what is your pipeline, how did you order the layers and models?

Thanks

model.py文件问题

好像在整个训练过程中并没有用到model.py文件,然而finetuning的逻辑是写在model.py文件中的,所以整个训练过程并没有实现finetuning功能。不知这样理解对不对?

bert一直报错

Model name 'model/bert-base-chinese' was not found in model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese). We assumed 'model/bert-base-chinese\vocab.txt' was a path or url but couldn't find any file associated to this path or url.

感觉_score_sentence方法错了

score = score +
batch_transitions.gather(-1, (label_ids[:, t] * self.tagset_size + label_ids[:, t - 1]).view(-1, 1))
+ feats[:, t].gather(-1, label_ids[:, t].view(-1, 1)).view(-1, 1)
是否应该变为
score = score +
batch_transitions.gather(-1, (label_ids[:, t-1] * self.tagset_size + label_ids[:, t ]).view(-1, 1))
+ feats[:, t].gather(-1, label_ids[:, t].view(-1, 1)).view(-1, 1)
真实分数不应该是前一个到后一个的lable的分数吗 是不是做反了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.