Git Product home page Git Product logo

ccks2019-ckbqa-4th-codes's People

Contributors

duterscmy 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  avatar  avatar  avatar  avatar  avatar  avatar

ccks2019-ckbqa-4th-codes's Issues

有关tuple_filter.py产生的结果指标,一项略低其余正常

作者及各位同行好,复现目前最新版本的代码,几个指标中其余指标都正常,就是在验证集上逻辑回归筛选后top10召回率为比较低只有0.34。tuple_filter.py仅做了如下修改:1.feature[-1],取最后一列。2.pro0.5改为0.05

其余指标如下:
训练集:
单实体问题中,候选答案可召回的的比例为:0.853
候选答案能覆盖标准查询路径的比例为:0.654
验证集:
单实体问题中,候选答案可召回的的比例为:0.876
候选答案能覆盖标准查询路径的比例为:0.672

请教各位,不知哪里出了问题?

kb.py

在运行entity_eextractor.py中,from kb import GetRelations_2hop,GetRelationNum

其中kb.py程序缺少GetRelationNum计算流行度的函数

tuple_extractor.py

tuple_extractor.py这个函数抽取出来的candidates_tuple如下:{('<猎国莫妮卡>', '<性别>', '<词性>'): ['<猎国莫妮卡>', '莫妮卡', 0.00027995862]},
导致tuple_filter.py里面的X.append([features[9][0][1]])索引出错。这里 score = [entity]+[s for s in candidate_entitys[entity][0:1]]是不是写错了?

def extract_tuples(self,candidate_entitys,question):
    ''''''
    candidate_tuples = {}
    
    for entity in candidate_entitys:
        #得到该实体的所有关系路径
        starttime=time.time()
        
        relations = GetRelationPaths(entity)
        
        mention = candidate_entitys[entity][0]
        for r in relations:
            
            this_tuple = tuple([entity]+r)#生成候选tuple
            predicates = [relation[1:-1] for relation in r]#python-list 关系名列表

            human_question = '的'.join([mention]+predicates)
                
            score = [entity]+[s for s in candidate_entitys[entity][0:1]]#初始化特征
            
            try:
                sim2 = self.sentencepair2sim[question+human_question]
            except:
                sim2 = self.simmer.predict(question,human_question)[0][1]
                self.sentencepair2sim[question+human_question] = sim2
            self.sentencepair2sim[question+human_question] =sim2
            score.append(sim2)
            
            candidate_tuples[this_tuple] = score
        print ('====查询候选关系并计算特征耗费%.2f秒===='%(time.time()-starttime))

    return candidate_tuples

关于在entity_extractor等代码中因为调用kb.py访问neo4j数据库过慢的解决方法

修改kb.py代码,使其能通过http api直接访问PKUBASE的数据库。还省去了搭建本地neo4j的步骤。在我自己的机器上,效率从300秒处理完一个数据变成了3秒一个数据。

可能存在的问题:因为将Cypher语句转化成了 sparql语句,可能存在查询不全的问题(原代码中cypher语句基本上是无向查询,而sparql本身就是有向的查询)。如果后期发现有问题再进行修改。

6月9号更新
try要在json.loads之后,不然会报错。现在只有在断网的时候才会报错。
kb_http主要在entity_extractor和tuple_extractor里面使用,这里附上我的修改后的版本。
仅供参考,因为还没有完全调试好,结构写的也不够清晰!!
在修改里参考了原作者的思路,加上了几个本地缓存来避免断网之后要重新查找的问题,毕竟对整个数据集完整查询一次还挺慢的。这样查询完之后再训练,如果以后报错了可以省几个小时。

kb_http.zip

tuple_filter.py中的疑问

tuple_filter.py 中的GetData_train函数有如下代码:

        for t in candidate_tuples:
            features = candidate_tuples[t]
            if len(gold_tuple) == len(set(gold_tuple).intersection(set(t))):
                X.append([features[9][0][1]])
                Y.append([1])
            else:
                prop = random.random()
                if prop<0.5:
                    X.append([features[9][0][1]])
                    Y.append([0])

为啥是取[features[9][0][1]] ? 请问下其背后的思考逻辑。谢谢!

entity_extractor.py

提示缺少entity_extractor_ans.txt文件,想请问entity_extractor_ans.txt来自哪里

建立分词词典为什么只统计三元组的subject

作者,您好,在GetSegmentDic.py中建立segment_dic.txt文件的时候,只选择了知识库中所有三元组的subject,为什么不用object呢?2018年第二名也是采用这种方式,但是一直没完全想明白,比如下面这个Just do it在知识库中没有subject不就不能识别出该实体或属性呢?:

q982:公司口号为"just do it "的运动品牌的著名签约明星都有谁?
select ?y where { ?x <公司口号> "Just do it". ?x <签约明星> ?y. }
"詹姆斯" "C罗" "乔丹" "科比"

neo4j的关系种类数限制是6.5w 请问你是怎么解决的

Import error: Maximum id limit for RELATIONSHIP_TYPE_TOKEN has been reached. Generated id 65536 is out of permitted range [0, 65535].
Caused by:Maximum id limit for RELATIONSHIP_TYPE_TOKEN has been reached. Generated id 65536 is out of permitted range [0, 65535].
org.neo4j.internal.id.IdCapacityExceededException: Maximum id limit for RELATIONSHIP_TYPE_TOKEN has been reached. Generated id 65536 is out of permitted range [0, 65535].

搜索关系时当实体是object怎么搜索出来?

作者,您好,在kb.py代码中GetRelations_2hop函数在搜索2跳内的所有关系的时候,也包括其它都是把实体当作subject来进行搜索("match (a:Entity)-[r1:Relation]-()-[r2:Relation]->() where a.name=$name return DISTINCT r1.name,r2.name"),如果question中的gold_entity是object,这样不是就不能搜索出来呢?比如下面这个例子:
q43:谁废除了分封制?
select ?x where { ?x <主要成就> "废除 分封制". }
<秦始皇_(**首位皇帝)>

neo4j建立索引

作者,您好,我在用neo4j-admin导入所有数据后发现查询很慢,因此考虑建立索引。但是建立索引试了很多次都无法成功(我试了少量数据的时候是可以成功的,采用create constraint on (s:Teacher) assert s.name is unique方式建立),请问作者当时是怎么处理这个问题的?还是对于大量数据直接就建立索引成功了?

询问不使用词向量相似性构建特征的原因

作者,您好,计算实体特征只采用了报告中提到的5个特征,而没有使用词向量相似性比较构建特征(我看utils.py文件中有比较相似性特征的函数),这个是出于什么原因考虑呢?

tuple_filter.py中疑问

作者,您好!我想问下这个文件中既然只取Bert相似度的特征,为什么不直接按照这个特征进行排序,还要训练逻辑回归模型?answer_bot.py也加载了逻辑回归模型进行预测

关于tuple_filter.py中验证集的召回率

作者您好,我在运行您程序的时候遇到一个问题,在运行tuple_filter时,在验证集机上逻辑回归筛选后的top10召回率非常低,为0.04,其他指标看起来还算正常,我因为最近也学习问答系统所以才下载运行您的代码,代码应该是您最新上传的代码,前面的步骤都运行正常,但是在这里遇到这个问题,请问您在这一步验证集召回率也是这么低吗?我不知道我应该做什么,因为我也没改过您的任何代码,就照着步骤做了,还希望您能够解答我这个困惑,或者告诉我应该怎么做,非常感谢!
32e2079a304271608cb939ad6a19a5d

train_ner.py命名实体识别f值低

您好,我跑您提供的训练命名实体识别的的代码,f值一直都是0.65左右。识别率好低,请问您当时命名实体识别部分的f值是多少?

文本匹配模型中dev.csv的构造方式

您好,请问在文本匹配模型similarity中使用到的train.csv的构造,我看到您是对于每个问题选择了一个正例和三个负例,生成方式是在实体和候选关系中加了的进行连接,但是在验证集valid.csv上好像并不是这样构造的,请问验证集的正负例是怎么生成的呢?比例应该是什么样的呢?

缺少helper文件

你好,我看到您上传的程序中好像没有helper文件,请问能不能提供用于生成一些字典/语料集预处理的程序文件,十分感谢!

文本匹配模型中dev.csv的构造方式

您好,请问在文本匹配模型similarity中使用到的train.csv的构造,我看到您是对于每个问题选择了一个正例和三个负例,生成方式是在实体和候选关系中加了的进行连接,但是在验证集train.csv上好像并不是这样构造的,请问验证集的正负例是怎么生成的呢?比例应该是什么样的呢?

tuple_extractor.py中的疑问

首先感谢作者的分享,收益颇多。但是在学习过程存在以下疑问,希望作者能够帮忙解答。
tuple_extractor.pyentity2relations_dic 存储为entity2relation_dic.pklsentencepair2sim存储为sentencepair2sim_dic.pkl
(1)但是代码中没有对于``entity2relations_dic 这个变量处理的逻辑。 (2)代码中from kb import GetRelationPaths` 但是项目中似乎缺乏这个可以被引入的依赖。希望您能够补充下。
谢谢!

文本匹配数据集创建代码

作者,您好,请问可以提供文本匹配模型数据集创建的代码和实验吗?src/data目录下只有训练集是对的。在去年第二名的文章中好像还对正例进行了过采样等,这些作者有尝试过吗?

文件问题?

在entity_extractor.py中,
self.word_2_frequency = self.LoadWord2Index('../../token2vec/SouGou_word_frequece/SogouLabDic.dic')
其中的SogouLabDic.dic这个文件怎样才可以得到呢?

prop_extractor.py

很感谢作者能公开代码,在查看代码的时候遇到几个问题想请教下:

  1. prop_extractor.py里面的self.question2mention要读取的文件是从哪里来的?还需要这个文件吗?
  2. 抽取属性的时候模糊匹配被注释掉是因为这部分效果不怎么好吗或者是用了其它替代方法?即props['fuzzy_props'],且这个依赖char_2_prop.pkl文件

PKUBASE知识库处理成neo4j-admin import可以导入的数据

已经安装了neo4j数据库。PKUBASE知识库源文件需要处理成可以 让 neo4j-admin import的格式。为了能够保持这部分数据格式与您数据格式的一致性,从而确保后续查询语句可以套用,希望您能够提供下这部分预处理的脚本或者neo4j-admin import 导入的样例数据。最好是有完整的处理脚本,谢谢!

prop_extractor.py

@duterscmy 在prop_extractor.py 48行这一部分提取属性值,这里为什么要用question2mention来提取实体?
try:
max_props = self.question2mention[QUES][1]
for p in max_props:
mark_props[p] = p
except:
print('this question dont have long props')
pass

noe4j相关

请问在tuple_extractor中,需要和neo4j交互,但是neo4j中属性值不能作为一个节点,所以如果问句中包含属性值,sql中有属性值限制,那怎么在neo4j中得到可能的关系路径?是不仅考虑两步内的关系、还要考虑头实体的属性及其中间实体尾实体的属性吗?

文本匹配数据集疑问

作者,您好!我看了你提供的文本匹配模型的训练集train.csv生成的human语句采用了知识库实体,我在想使用mention会不会好点?
比如question:奥巴马出生在哪?知识库实体侯赛因_(美国总统)和question从字面上来说没有太大相关性,而且很多知识库实体_(?)部分也和question字面含义关系不大,这感觉会造成一定的干扰。
如果使用mention来生成human语句,好像就能避免上面的问题,而且这样生成句子感觉和question语义及语法结构上更匹配,想请问作者有什么高见吗?

question_2_mention.pkl怎么生成

您好,感谢作者提供的代码,我运行helper文件程序后,再运行mention_extractor.py,发现缺少question_2_mention.pkl
helper文件没找到生成该字典的程序。

about killed

作者您好,我在使用entity_extractor.py去neo4j搜索相应的特征时,在搜索几个实体以后程序就被莫名的killed掉了,但我排查了内存应该不是内存泄露,请问您遇到过类似的情况吗

mention_extractor.py结果

执行mention_extractor.py得到的mention如下,应该得到的是实体,但我得到的结果和分词结果一样。是我的segment.txt的原因吗?结果如下:

维力医疗有哪些高管硕士学历?
{'维力医疗': '维力医疗', '有': '有', '硕士': '硕士', '学历': '学历', '?': '?'}
维力医疗有哪些高管本科学历?
{'维力医疗': '维力医疗', '有': '有', '?': '?'}
维力医疗有哪些高管大专学历?
{'维力医疗': '维力医疗', '有': '有', '大专学历': '大专学历', '?': '?'}
维力医疗的董事长?
{'维力医疗': '维力医疗', '的': '的', '董事长': '董事长', '?': '?'}
维力医疗的第一任董事长?
{'维力医疗': '维力医疗', '的': '的', '董事长': '董事长', '?': '?'}

SogouLabDic.dic

请问有没有SogouLabDic.dic的下载地址?在entity_extractor.py中用到了SogouLabDic.dic

F1:40%左右

这是运行tuple_filter.py 的结果
在验证集上逻辑回归筛选后top10 召回率为0.87
单实体问题中,候选答案可召回的的比例为:0.893
候选答案能覆盖标准查询路径的比例为:0.685

为啥子测试的时候F1那么低~ 有大佬复现了代码的结果吗?

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.