buppt / chinesenre Goto Github PK
View Code? Open in Web Editor NEW中文实体关系抽取,pytorch,bilstm+attention
中文实体关系抽取,pytorch,bilstm+attention
博主你好,window系统pytorch 0.4现在都只基于python3.6/3.7 ,请问怎样在python2 中安装0.4的版本呢?
The model has been trained. I now want to budget for the data and I don’t know how to use the model. I try to put my statement"朱时茂 陈佩斯 ??? 《水与火的缠绵》《低头不见抬头见》《天剑群侠》小品陈佩斯与朱时茂1984年《吃面条》合作者:陈佩斯聽1985年《拍电影》合" generates a pkl file, and then uses the trained model to report an error RuntimeError: Expected hidden[0] size (2, 1, 100), got (2, 128, 100)
楼主您好,增大训练集是不是就把count[relation2id[line[2]]] < 1500中的1500增大就行?增大后f1和recall停止在20%怎么解决?求指教
您好,您就是直接用这个代码跑的结果么,我怎么只能达到50,您应该时达到了60吧。而且您了解,如果训练集有16万,特别大,几乎收敛不了的原因么,不是应该数据越多越好么
File "D:\ruanjian\ana\lib\site-packages\torch\utils\data\dataloader.py", line 1024, in _try_get_data
raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
RuntimeError: DataLoader worker (pid(s) 12048, 7612) exited unexpectedly
完整提示如上,请问如何修改,谢谢
是不是就是用了两个实体第一个字位置信息的文本分类啊。工业上的NRE是这样做的吗
您好,感谢您分享代码供新手学习,有一处问题想请教一下:
data_util.py Line38处为什么需要i+=1呢? enumerate过程中i不是已经自动递增了吗?
感谢您的分享,希望得到您的回复,谢谢啦!
祝好~~
请问更换数据集后应该再修改代码哪个部分可以稍微提高一些,目前f1只有0.1左右
https://www.biendata.com/competition/ccks_2019_ipre/
CCKS2019的一项比赛,人物关系抽取,给了数据集
运行时出现这个问题
raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str))
RuntimeError: DataLoader worker (pid(s) 16184, 7428) exited unexpectedly
应该怎么办?小白求解答,谢谢
SemEval-2010 Task 8 dataset数据集有关于实体顺序的标签,好像代码里面只考虑了关系的抽取,没有考虑实体的抽取,请解答一下,谢谢!
RT
请问在ChineseNRE/data/people-relation/data_util.py的54行
set_ids = range(1, len(set_words)+1)
那么“所有单词”列表的id索引是从1开始的,而在使用nn.Embedding时,取某个单词的vec索引是从索引0开始的,不就混乱了吗?
为什么不直接这样set_ids = range(len(set_words))写呢?
谢谢
请问:self.attention不是应该传入lstm的hidden state吗?你传入的是output ;
att_out = F.tanh(self.attention(lstm_out))
代码行在这里:L73
if len(sys.argv)==2 and sys.argv[1]=="pretrained":
print( "use pretrained embedding")
config["pretrained"]=True
word2vec = {}
with codecs.open('vec.txt','r','utf-8') as input_data:
for line in input_data.readlines():
word2vec[line.split()[0]] = map(eval,line.split()[1:])
unknow_pre = []
unknow_pre.extend([1]*100)
embedding_pre.append(unknow_pre) #wordvec id 0
for word in word2id: # <----这里对word2id循环,应该不对的吧,循环出来是id,下面word2vec里面是word,应该是对id2word循环的
if word2vec.has_key(word):
embedding_pre.append(word2vec[word])
else:
embedding_pre.append(unknow_pre)
embedding_pre = np.asarray(embedding_pre)
print(embedding_pre.shape)
您好,我现在想复现一下程序功能,看到程序是python2.7+pytorch 只能在linux系统中运行,想问问有没有什么办法可以在Windows操作系统中实现,或者python3.0以上的代码,谢谢了!
您好,模型可以用在别的语言上吗
您好!
我下载您的项目一直网络错误,可以麻烦您把项目发我qq邮箱吗 [email protected], 谢谢
中文数据集成功跑通了,不过英文数据集并没有成功,报错如下:
Traceback (most recent call last):
File "train.py", line 119, in
y = model(sentence,pos1,pos2)
File "/home/jfy/anaconda3/envs/py27/lib/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/jfy/下载/NER/BiLSTM_ATT.py", line 63, in forward
embeds = torch.cat((self.word_embeds(sentence),self.pos1_embeds(pos1),self.pos2_embeds(pos2)),2)
File "/home/jfy/anaconda3/envs/py27/lib/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/jfy/anaconda3/envs/py27/lib/python2.7/site-packages/torch/nn/modules/sparse.py", line 110, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "/home/jfy/anaconda3/envs/py27/lib/python2.7/site-packages/torch/nn/functional.py", line 1110, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: index out of range at /opt/conda/conda-bld/pytorch_1535488076166/work/aten/src/TH/generic/THTensorMath.cpp:352
必须确定了两个实体才能得出位置向量,但通常一句话里不止有2个实体,也不只有一个关系,这种情况下位置向量该怎么得出呢,怎么确定哪两个实体有关系,多关系怎么预测呢。
麻烦您为我解答一下,谢谢
老哥请问在程序里面更新了加载字向量的代码吗,小白想了解距离向量具体起了哪些作用
我按照提示在train.py文件运行完成以后,再运行BiLSTM_ATT.py,BiLSTM_ATT.py这个文件应该就是输入输出的文件吧。然后提示in 让我输入 这个输入是在哪个地方被调用的呢,我输入了中文之后,out出Out[4]: '\xe6\x88\x91\xe8\xbe\x93\xe5\x85\xa5\xe4\xb 这是什么意思
你好,我想请问一下train.py的43,44行中的两个参数POS_SIZE = 82,POS_DIM = 25分别代表什么意思呢?具体是怎么得到的呢?
我使用python2.7的时候需要导入torch包,但是在下载pytorch0.40这个版本的时候没有找到对应的python2.7的版本,我用的windows系统。windos系统下有没有对应的版本呢
跑了下这个代码,请问预测时如何设置batch大小,我用训练的数据测试预测,当我要预测的数据不是按照batch大小输入时,会报下面的错误:
RuntimeError(msg.format(expected_hidden_size, tuple(hx.size())))
RuntimeError: Expected hidden[0] size (2, 12, 100), got (2, 128, 100)
我用的训练的数据,只不过把batch修改成了12。
请问一下如果用那个英文数据集的话POS_SIZE应该设置成多少才不会报错啊
我看问题有人问过,好像是没有提供预测的代码。
请问有没有大佬能分享一下预测代码,感谢了!
你好大神,我是一个纯新手,看到position1.append(i-3-index1),position2.append(i-3-index2)有些疑惑,这个position1和2是不是表示当前字分别到两个实体的距离?为什么是i-3?而不是直接i-index1?麻烦方便的时候能回复一下,不胜感激。
这里的小于1500是在判断什么呀 为什么要这一步操作?
你好,我看了人物关系那个数据集,感觉里面很多数据即使是人都无法直接判断,不知道你的实验结果p,r,f咋样?
大佬我跑完以后有model的文件了 怎么预测啊
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.