Comments (11)
谢谢您的项目,真的很棒。我这几天简单看了一下BertForTokenClassification源码。发现一个可能的原因。
在0.4.0中,bertForTokenClassification的前向传播是这样的
在0.6.0中,其是这样的
可以看到,在0.6.0中,求loss时进行了mask,但是0.4.0中没有。我试了一下,在0.4.0版本下,显示调用bertForTokenClassificaiton的前向传播。若求loss进行mask。则效果会变得很差。
具体原因还在分析。
from ner-bert-pytorch.
建议使用版本pytorch-pretrained-bert==0.4.0
,后面有时间,我会再查找具体原因及更新。
from ner-bert-pytorch.
希望能够给到您帮助
from ner-bert-pytorch.
谢谢反馈,后面我再仔细分析下。
from ner-bert-pytorch.
@lemonhu 您好,在版本0.6.1中您是否已经修复了这个问题?新版我还是会出现f1值低的原因
祝您生活愉快
super.single430
from ner-bert-pytorch.
大佬代码写的真好,学习了。
有个小建议,您的dataiterator,在不能被batch size整除的情况下,直接pass了最后一个batch,在inference的时候可能不大方便。
from ner-bert-pytorch.
@lemonhu 您好,在版本0.6.1中您是否已经修复了这个问题?新版我还是会出现f1值低的原因
祝您生活愉快
super.single430
问题如@Wangpeiyi9979所指,稍作修改即可适应新版本。
from ner-bert-pytorch.
大佬代码写的真好,学习了。
有个小建议,您的dataiterator,在不能被batch size整除的情况下,直接pass了最后一个batch,在inference的时候可能不大方便。
谢谢您的建议。
from ner-bert-pytorch.
谢谢您的项目,真的很棒。我这几天简单看了一下BertForTokenClassification源码。发现一个可能的原因。
在0.4.0中,bertForTokenClassification的前向传播是这样的
在0.6.0中,其是这样的
可以看到,在0.6.0中,求loss时进行了mask,但是0.4.0中没有。我试了一下,在0.4.0版本下,显示调用bertForTokenClassificaiton的前向传播。若求loss进行mask。则效果会变得很差。
具体原因还在分析。
请问您分析出来是什么原因导致mask 之后的loss变得很差?
from ner-bert-pytorch.
谢谢您的项目,真的很棒。我这几天简单看了一下BertForTokenClassification源码。发现一个可能的原因。
在0.4.0中,bertForTokenClassification的前向传播是这样的
在0.6.0中,其是这样的
可以看到,在0.6.0中,求loss时进行了mask,但是0.4.0中没有。我试了一下,在0.4.0版本下,显示调用bertForTokenClassificaiton的前向传播。若求loss进行mask。则效果会变得很差。
具体原因还在分析。
按理说pad的输入预测的logits和pad的标签不应该需要做损失计算啊,为什么会这样真的是很神奇的问题,0.6和0.4的区别也就是这个了,新版pytorch-transformer 也是mask了loss。
from ner-bert-pytorch.
@sakuranew 谢谢关注与反馈。
我最近的实验,也表明在计算损失时引入mask会严重降低NER的效果,有些神奇(新版的pytorch-transformer引入了mask了loss)。
这个也作为该问题的一个实验性解答吧。
from ner-bert-pytorch.
Related Issues (20)
- AttributeError: 'tuple' object has no attribute 'backward' HOT 2
- Something wrong with the total number of entities being evaluated ? HOT 2
- 我显卡不太行,把batch_size改成了5,其余参数没变,6个epoch后测试集上的F1只有67.51,然后模型自动停止训练,没有训练到20epoch,请问是我卡的原因吗?
- 大佬我想学习你的代码,这段代码是什么意思呀 HOT 2
- 请问如何用该模型预测我的数据? HOT 5
- 训练中在train和val数据上f1正常,但是在test数据上f1得分特低 HOT 2
- an epoch cannot finish HOT 1
- 能否在训练好的模型上继续 finetune
- 这两个f1值为什么:不一样? HOT 1
- 预训练的bin、config和txt文件地址打不开
- how to make ner prediction after fine-tuning the bert model?
- AttributeError: 'NoneType' object has no attribute 'tokenize' HOT 6
- bert-base-chinese-pytorch 无法下载 HOT 1
- About Pre-processing of MSRA
- 无法复现结果 HOT 2
- 调用txt文件中的句子(大概有十几万条),预测结果有问题...
- bert-lstm-crf_run.py
- f1值不能重现 HOT 4
- 没有使用高版本f1值也并不理想
- Project dependencies may have API risk issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ner-bert-pytorch.