wzzzd / lm_ner Goto Github PK
View Code? Open in Web Editor NEW基于Pytorch的命名实体识别框架,支持LSTM+CRF、Bert+CRF、RoBerta+CRF等框架
基于Pytorch的命名实体识别框架,支持LSTM+CRF、Bert+CRF、RoBerta+CRF等框架
metrics: lab:DISEASE, precision:0.0 recall:0.0 f1:0.0
metrics: precision:0.0 recall:0.0 f1:0.0
训练的时候,每个epoch的验证结果都是这样的,我把预测结果打印了,确实全部预测错了
是哪里出问题了??
[CLS]当前第一位是要切实安排好受灾群众的生活,一定要让受灾群众有饭吃,有水喝,有衣穿,有病能得到医治。[SEP] [('ORG', '。[SEP]', [48, 95])] []
[CLS]因此,路易斯和赫苏斯两兄弟有[UNK]合成毒品大王[UNK]之称。[SEP] [('ORG', '。[SEP]', [25, 95]), ('PER', '路易斯', [4, 6]), ('PER', '赫苏斯', [8, 10])] [('PER', '路易斯', [4, 6]), ('PER', '赫苏斯', [8, 10])]
[CLS]其次,他不具高人一头的身材,腿与上身的比例也不尽如人意,作为男舞员很吃亏。[SEP] [('ORG', '。[SEP]', [37, 95])] []
[CLS]大部分人主张把钱分了,靠拿银行利息过日子比过去种地强。[SEP] [('ORG', '。[SEP]', [27, 95])] []
[CLS]所有这一切,又被作家凝缩和提升为哲理性的思索。[SEP] [('ORG', '。[SEP]', [23, 95])] []
[CLS]他们赶到出事现场,只见一个女青年正在水中拼命挣扎。[SEP] [('ORG', '。[SEP]', [25, 95])] []
这是部分output的数据,里面有很多的ORG。[SEP]这种 是因为什么会造成这样阿
请问unk是什么意思?字符不在vocab里面吗?输出的output.txt文件里面原文本有些地方没有显示原文,比如Murphy,显示的是【UNK】urphy,可以输出原文本Murphy吗?
自己看了很多遍代码,还是无法解决,期待你的回复
预测输入:[[101, 3851, 3736, 4689, 3343, 2336, 2356, 677, 1814, 3777, 1773, 6125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102]
预测label:[['O', 'B-prov', 'I-prov', 'E-prov', 'B-city', 'I-city', 'E-city', 'B-district', 'E-district', 'B-road', 'I-road', 'E-road', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
预测结果:[['O', 'B-prov', 'I-prov', 'E-prov', 'B-city', 'I-city', 'E-city', 'B-district', 'E-district', 'B-road', 'I-road', **'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov', 'B-prov']
你好,请问下如果想搭建deberta的NER的话,config里面的BertConfig.py还适配嘛,还是要自己重新写一个config文件呢
使用英文数据集训练出现如下错误,看了好久不知道怎么解决:
Traceback (most recent call last):
File "run.py", line 42, in
trainer.train()
File "F:\Files\lm_ner-main\process\Trainer.py", line 220, in train
loss = self.step(bs)
File "F:\Files\lm_ner-main\process\Trainer.py", line 248, in step
outputs = self.model(input_ids, labels=labels, attention_mask=attention_mask) #
File "F:\software_of_computer_learning\Anaconda\install_path\envs\Bert_BiLstm\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "F:\software_of_computer_learning\Anaconda\install_path\envs\Bert_BiLstm\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "F:\biyesheji\lm_ner-main\model\transformer_crf.py", line 52, in forward
loss = -1 * self.crf(emissions = logits, tags=labels, mask=attention_mask)
File "F:\software_of_computer_learning\Anaconda\install_path\envs\Bert_BiLstm\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "F:\software_of_computer_learning\Anaconda\install_path\envs\Bert_BiLstm\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "F:\Files\lm_ner-main\model\layers\crf.py", line 100, in forward
numerator = self._compute_score(emissions, tags, mask)
File "F:\Files\lm_ner-main\model\layers\crf.py", line 213, in _compute_score
last_tags = tags[seq_ends, torch.arange(batch_size)]
IndexError: index 1065 is out of bounds for dimension 0 with size 256
博主 就是我用了你的代码跟数据去跑的bert-crf 然后出现的情况就是padding全部变成了某一个label了,输出到了output,我看上面有人说遇到同样的情况,他说改成torchcrf就行,我想问问这部分代码怎么改呀 我看你改过这部分 是注释了的 我换成你写的那部分了 运行不了 能解决一下吗
apex==0.1安装起来比较困难,可以提供下方法吗
请问每个数据之间是用空格分割的吗?想用别的符号分割应该在哪里修改呢?
想问一下怎么开多卡呀 我把那个可见的gpu=【1,2,3,0】,但是跑起来的还是只有1 gpu 为什么阿
src predict label
[CLS]1979年9月参加工作,[SEP] [('TITLE', ',[SEP]', [12, 127])] []
[CLS]华泰集团有限公司总裁;[SEP] [('TITLE', '总裁;[SEP]', [9, 127]), ('ORG', '华泰集团有限公司', [1, 8])] [('TITLE', '总裁', [9, 10]), ('ORG', '华泰集团有限公司', [1, 8])]
[CLS]陈倩女士,女,[SEP] [('TITLE', ',[SEP]', [7, 127]), ('NAME', '陈倩', [1, 2])] [('NAME', '陈倩', [1, 2])]
[CLS]1959年出生,大专学历。[SEP] [('TITLE', '。[SEP]', [13, 127]), ('EDU', '大专学历', [9, 12])] [('EDU', '大专学历', [9, 12])]
[CLS]严文俊先生简历严文俊,男,[SEP] [('TITLE', ',[SEP]', [13, 127]), ('NAME', '严文俊', [1, 3]), ('NAME', '严文俊', [8, 10])] [('NAME', '严文俊', [1, 3]), ('NAME', '严文俊', [8, 10])]
[CLS]历任中航供销汉中公司财务科员、副科长、科长(经理)、副总会计师,汉航集团财务部副部长、人力资源部部长、财务审计部部长。[SEP] [('TITLE', '财务科员', [11, 14]), ('TITLE', '副科长', [16, 18]), ('TITLE', '科长', [20, 21]), ('TITLE', '经理', [23, 24]), ('TITLE', '副总会计师', [27, 31]), ('TITLE', '财务部副部长', [37, 42]), ('TITLE', '人力资源部部长', [44, 50]), ('TITLE', '财务审计部部长。[SEP]', [52, 127]), ('ORG', '中航供销汉中公司', [3, 10]), ('ORG', '汉航集团', [33, 36])] [('TITLE', '财务科员', [11, 14]), ('TITLE', '副科长', [16, 18]), ('TITLE', '科长', [20, 21]), ('TITLE', '经理', [23, 24]), ('TITLE', '副总会计师', [27, 31]), ('TITLE', '财务部副部长', [37, 42]), ('TITLE', '人力资源部部长', [44, 50]), ('TITLE', '财务审计部部长', [52, 58]), ('ORG', '中航供销汉中公司', [3, 10]), ('ORG', '汉航集团', [33, 36])]
[CLS]姜华方,[SEP] [('TITLE', ',[SEP]', [4, 127]), ('NAME', '姜华方', [1, 3])] [('NAME', '姜华方', [1, 3])]
老哥 你看这是我用的robert_Crf那个模型跑出来的结果 我训练了20个epoch,loss=0.5,f1=.95,这么看他的预测结果是准确的 但是为什么我发现这个里面有很多都是('TITLE', ',[SEP]', [句尾,规定的max_len]), 这是为什么啊 能帮忙改一下吗谢谢 急!!!
还有一个就是,英文的很多单词在经过BertTokenizer的时候被编码成了[UNK],导致很多单词学习不到,这有什么好的解决办法吗?
ImportError: cannot import name 'container_abcs'
3.预测
请问预测未知标签数据集是用哪部分代码呢?是用test数据集吗?我看CNER数据集里也有标签
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.