SimCSE-Chinese-Pytorch icon indicating copy to clipboard operation
SimCSE-Chinese-Pytorch copied to clipboard

SimCSE在中文上的复现,有监督+无监督

Results 13 SimCSE-Chinese-Pytorch issues
Sort by recently updated
recently updated
newest added

楼主好,我看了您的有监督simcse的loss实现,发现对于三元组{x_1, x_2, x_3},只考虑了利用{x_1}和{x_2}的相互关系,及两者作为正样本,而负样本的选择是整个batch的其他样本作为负样本。 但考虑一个情况,如果{x_1, x_2}是真实正样本关系,{x_1}和{x_3}是真实负样本关系,那如果想利用真实负样本参与训练,请问在loss里面怎么区分真实负样本和batch内的负样本呢?谢谢您 [https://github.com/vdogmcgee/SimCSE-Chinese-Pytorch/blob/e04263b1846fceef8dff60ead29d35e02947918b/simcse_sup.py#L130](https://github.com/vdogmcgee/SimCSE-Chinese-Pytorch/blob/e04263b1846fceef8dff60ead29d35e02947918b/simcse_sup.py#L130)

https://github.com/vdogmcgee/SimCSE-Chinese-Pytorch/blob/main/simcse_unsup.py#L142-L145 ![image](https://user-images.githubusercontent.com/5136418/145787542-55ee890b-652b-437e-b278-6ce5f1e8d694.png) 这里求对比损失的时候又在loss外面包了一层`torch.mean(loss)`,ce默认已经是`mean`均值形式了,为什么返回的时候又执行mean操作呢