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

negative_samples 实际运行有问题 #8

Open
chenzelong opened this issue Jun 7, 2022 · 3 comments
Open

negative_samples 实际运行有问题 #8

chenzelong opened this issue Jun 7, 2022 · 3 comments

Comments

@chenzelong
Copy link

你好博主,感谢你的分享,我在运行过程中发现单独运行ESimCSE_train.py和单独运行ESimCSE_dataloader.py过程中negative_samples实际表现不一致,代码编辑如下:
def negative_samples(self, batch_src_text):
batch_size = len(batch_src_text)
print('*' * 10)
print('len(self.q):', len(self.q))
print('batch_size:', batch_size)
negative_samples = None
if len(self.q) > 0:
negative_samples = self.q[:self.q_size]
# print("size of negative_samples", len(negative_samples))
if len(self.q) + batch_size >= self.q_size:
del self.q[:batch_size]
self.q.extend(batch_src_text)
print('len(self.q)2:', len(self.q))
if negative_samples:
print('len(negative_samples):', len(negative_samples))
return negative_samples

ESimCSE_train.py打印日志如下:


len(self.q): 0
batch_size: 16
len(self.q)2: 16
##########


len(self.q): 0
batch_size: 16
len(self.q)2: 16
##########



len(self.q): 0
batch_size: 16
len(self.q): 0
len(self.q)2: 16
batch_size: 16
##########
len(self.q)2: 16
##########


len(self.q): 0
batch_size: 16
len(self.q)2: 16
##########

可以发现self.q赋值有问题,一直没找到问题根源在哪,希望可以一起讨论一下

@chenzelong
Copy link
Author

哎呀我懂了,一个是num_workers=1,num_workers=12

@chenzelong
Copy link
Author

博主,那就有另外一个问题了。在实际训练过程中如果num_workers>1,就会有很多数据实际上负样本不足设定的q_size,这对训练效果是否有影响呢?

@shuxinyin
Copy link
Owner

博主,那就有另外一个问题了。在实际训练过程中如果num_workers>1,就会有很多数据实际上负样本不足设定的q_size,这对训练效果是否有影响呢?

这个会有影响的,我这里提供的是一个实现案例参考喔,实际应用中,当然你应该按照你的数据情况做适应的调整了。

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