Comments (10)
您好,这个工作是2年前做的,可能之前整理的代码遗漏了一些bug,马上会有同学回复您的问题。
from relphormer.
您好!请问:
- 在运行fb15k.sh时,现有的项目中导入没有找到Relphormer,请问怎么解决呢?
具体显示如下:
Traceback (most recent call last):
File "main.py", line 149, in
main()
File "main.py", line 77, in main
parser = _setup_parser()
File "main.py", line 54, in _setup_parser
model_class = _import_class(f"models.{temp_args.model_class}") # 通过 _import_class 函数,从 'models' 模块导入指定类,类名由 temp_args.model_class 提供
File "main.py", line 24, in import_class
class = getattr(module, class_name)
AttributeError: module 'models' has no attribute 'Relphormer'- 文章中提到了Structure-enhanced self-attention,在代码运行过程中,只发现了使用algos.floyd_warshall获取到了最短路径,但后续代码处理尤其是在huggingface_relformer模型文件中并没有找到相关的使用步骤,请问具体在什么地方实现的呢?
- 同样的提到的使用了contextual_loss,也没有找到相关实现,请问具体在什么地方实现的呢?
谢谢!!!
您好,我粗略看了一下,因为不是我开发的不知道回答是否准确仅供您参考。开发同学因有急事近期可能无法直接回答您的问题,非常抱歉。
问题2:
https://github.com/zjunlp/Relphormer/blob/main/data/processor.py#L920
from relphormer.
您好呀,非常抱歉给您带来困扰呀
- 关于attributeError: module 'models' has no attribute 'Relphormer'的问题,应该是文件或者模块命名的问题,我们这边会尽快修改更新;
- 关于algos.floyd_warshall处理结果,如上个回复所示,是作为参数传到了transformer的模块里面;
- 关于contextual_loss,复现实验中我们发现加上对比学习loss之后模型在一些比较大的图谱上迭代收敛速度会很慢;为了快速得到论文中接近的实验结果,当前版本并没有包含,后续我们会整合成可选择的模块;
from relphormer.
您好,如果您还有其他问题欢迎随时提问,这个项目有点历史悠久了,非常抱歉给您带来了不便。
from relphormer.
非常感谢您的解答!关于问题2我注意到在生成最短路径之后是作为distance_attention作为feature,经过处理后传入到了transformer模块中(https://github.com/zjunlp/Relphormer/blob/7ad8823d521b37f23f1fa142c7699460a7e3de75/lit_models/transformer.py#L125),但是在huggingface_relphomor.py文件中并没有找到关于distance_attention的特殊运用(https://github.com/zjunlp/Relphormer/blob/7ad8823d521b37f23f1fa142c7699460a7e3de75/models/huggingface_relformer.py#L927),请问这个与文章中提到的Structure-enhanced self-attention有关呢?同时请问Structure-enhanced self-attention具体是在哪部分代码中实现的呢?再次感谢您的解答!
from relphormer.
非常感谢您的解答!关于问题2我注意到在生成最短路径之后是作为distance_attention作为feature,经过处理后传入到了transformer模块中并且是作为attention_mask参数传入的(https://github.com/zjunlp/Relphormer/blob/7ad8823d521b37f23f1fa142c7699460a7e3de75/lit_models/transformer.py#L125),但是在huggingface_relphomor.py文件中并没有找到关于attention_mask的特殊运用,请问这个特殊的attention_mask是否与文章中提到的Structure-enhanced self-attention有关呢?同时请问Structure-enhanced self-attention具体是在哪部分代码中实现的呢?再次感谢您的解答!
您好,self-attention中有一个attention mask,这个是transformers的标准模块,可以控制token和token之间是否可见,structure信息已经通过attention mask传进去了。
from relphormer.
非常感谢您的解答!关于问题2我注意到在生成最短路径之后是作为distance_attention作为feature,经过处理后传入到了transformer模块中并且是作为attention_mask参数传入的(https://github.com/zjunlp/Relphormer/blob/7ad8823d521b37f23f1fa142c7699460a7e3de75/lit_models/transformer.py#L125),但是在huggingface_relphomor.py文件中并没有找到关于attention_mask的特殊运用,请问这个特殊的attention_mask是否与文章中提到的Structure-enhanced self-attention有关呢?同时请问Structure-enhanced self-attention具体是在哪部分代码中实现的呢?再次感谢您的解答!
您好,self-attention中有一个attention mask,这个是transformers的标准模块,可以控制token和token之间是否可见,structure信息已经通过attention mask传进去了。
感谢您的解答!由于现在无法复现kgc finetune部分的训练,所以没能看到完整的distance_attention的计算流。目前我看到的distance_attention是通过algos.floyd_warshall计算之后得到的其中中矩阵参数代表节点之间最短路径长度,随后作为feature并进行padding,padding中似乎是以-inf作为value的。数据进入模型之后,在BertModel中赋值给了extended_attention_mask并作为attention_mask直接传入encoder中,encoder中直接使用softmax进行计算,感觉这个计算方式与论文中提到的Structure-enhanced self-attention计算方式不太一样呢TAT。我的理解或许太浅显了,还希望能够解答一下!非常感谢!!!
from relphormer.
目前在传入bert module里面的structure bias,我们这边对结构特征做了归一化之后作为参数传入进去;
这边其实是一个超参数设置,您可以额外设置一个线性层对structure bias做一层网络的映射,或者作为参数覆盖直接传进去;
当前开源的实现方式是直接归一化特征传入进去的,也可以根据实际情况做更复杂的特征处理(比如添加线性层,或者取邻接矩阵的多次方);
最后padding都是-inf作为value的,因为不参与具体的attention计算;
抱歉目前这个代码可能框架太老了,所以比较难读;如果您这边后续要进一步的验证,最好使用最新的huggingface的transformer做更改。
具体可以加微信(bizhen_zju)交流呀
from relphormer.
您好,这部分主要对应论文的公式3,structure信息就是那个phi偏置项,通过attention mask是最简单的实现,这个技术在多个相关论文里都有介绍的,例如您可以参阅Do Transformers Really Perform Bad for Graph Representation?
from relphormer.
非常感谢您的解答!!!应该是我的理解还不够深!!!谢谢!!!
from relphormer.
Related Issues (20)
- What are the main differences between Relphormer and Kgtrransformer HOT 3
- Issue while saving model for Entity Embedding Initialization HOT 4
- BrokenPipe HOT 3
- 链路预测中 HittER 模型在wn18rr数据集上的指标与原文不一致 HOT 6
- conda environment file HOT 2
- triple2seq process HOT 2
- Question about examples. HOT 1
- About entity one-hop generate and fair comparision HOT 5
- 链接预测在FB15k-237数据集上跑出来的MRR比论文中低很多 HOT 8
- 似乎现有的pipeline不能跑通 HOT 3
- 第一步处理完的masked数据中出现了relation中没有的tmethod_of字段 HOT 5
- 请问是不是没有download.sh文件 HOT 4
- requirements.txt文件是空的? HOT 3
- some questions HOT 5
- 1
- Error: masked_head_neighbor.txt not found - How to reproduce recommendation task HOT 7
- Dependency issues between pytorch-lightning and pyyaml
- 关于数据集 HOT 2
- sonme questions HOT 3
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 relphormer.