Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_weight的功能 #24

Closed
FujiwaraKeine opened this issue Mar 27, 2023 · 2 comments
Closed

use_weight的功能 #24

FujiwaraKeine opened this issue Mar 27, 2023 · 2 comments

Comments

@FujiwaraKeine
Copy link

在查阅代码的过程中,我反复地看到一些与args.use_weight参数相关的代码。看起来这个use_weight是在loss计算时实现一种加权的loss值。请问关于use_weight使用的这种算法,具体是如何实现的,有没有相关的论文介绍?

@hzwy3c
Copy link
Collaborator

hzwy3c commented Mar 28, 2023

您好!

  1. 具体是如何实现的:args.use_wight主要是控制subsampling_weight的计算,subsampling_weight的计算方式是对一个triple累计它的实体和关系对出现的次数,然后对这个次数做倒数并开根号得到对应triple的subsampling_weight,最后在loss中作为权重。
  2. 目的是什么:可以看到,与这个triple有关的数据出现的频率越高,subsampling_weight越小,乘上subsampling_weight后针对这个triple的loss所占的比例就越小。它的目的是为了减弱低频triple与高频triple数据间存在的不平衡现象,因为某些triple的实体和关系对可能出现的频率很高,而另一些triple的实体和关系对出现的频率很低,计算score时高频的影响会很大,存在不平衡的现象,但是低频的信息也应该被模型很好地学习。use_weight是一个常用的trick,经过测试在一些模型上可以显著提高效果。
  3. 有没有相关的论文介绍:它的方法来源于Word2vec中的Subsampling,对Subsampling方法的直观理解可以参考这篇博客

@FujiwaraKeine
Copy link
Author

您提供的信息对我很有帮助,谢谢您的回复!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants