论文复现-1:ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer

论文题目: ConSERT: A Contrastive Framework for Self-Supervised Sentence
Representation Transfer

论文内容回顾

论文做了什么?

为了解决bert得到的语言表示的崩塌问题 collapse 问题,这个问题也导致模型在语义相似度判断任务中表现不良。
论文采用对比学习框架解决自监督语言模型的学习问题,是在unsupervised方式下实现对PLM的改进的。
论文在小样本情景下,也具有不错的表现,提到在1000个samples上,也可以得到comparable results。

一、问题发现

1、当直接使用bert-based sentence的representation进行语义文本相似性(STS)任务时,几乎所有的句子对都达到了0.6到1.0的相似性分数,即使有些句子对被人类注释者认为是完全不相关的,也认为相似度是较大的。
almost all sentences are mapped into a small area and therefore produce high similarity
在这里插入图片描述
2、BERT的词表示空间是
各向异性
的,高频词聚集在一起并靠近原点,而低频词则稀疏地分散开来。
BERT is anisotropic

二、related work

supervised approach 方法上,多数是使用NLI 任务来训练以得到更加的semantic representation。
self-supervise的 approach 方法上,以Bert最为经典,是采用的MLM objective 和 NSP 同时做了training objective。
constractive learning 上,起源是来自于CV领域,也有比较经典的双塔模型,比如SimCLR

三、论文工作

这篇论文做了sentence-level training objective based on constractive learning+multiple data argumentation strategy,在multiple data argumentation stategy策略上,作者尝试了adversarial attacktoken shufflingcutoffdropout

3.1 模型架构

在这里插入图片描述

3.2 模型详解

整个模型的结构包括三个部分:data argumentationbert encoderconstractive loss module
在encoder选择中,使用的类似于bert的这种PLM模型。数据集采用的unsupervised dataset。
训练过程是在unsupervised dataset上,finetune M.
1.在数据增强模块,是采用transformation,进而能够生成同一个sample的positive pair。如果在一个batch中有N个sample,经过数据增强后,可以得到2N个samples。
2、在bert编码模块,是采用bert模型的最后一层的average pooling 作为了参与loss计算的semantic representation
3、在constractive loss layer,是要保持similarity 的samples的距离尽可能的近,而dissimilar的samples的距离尽可能的远。在这篇论文中:正例是通过data transformation得到的samples,负例是在一个batch中的其他的samples
4、在损失函数设置,采用的是temperature-scaled cross-entropy loss .其中,temperature是为了控制控制logits的分布形状。对于既定的logits分布的形状,当温度系数变大,则 1/温度系数就变小, q·k/温度系数则会使得原来logits分布里的数值更加平滑,从而使得模型更加鲁棒。模型最终的损失函数时将一个batch中loss的average作为了final constractive loss。

在这里插入图片描述

3.3 数据增强手段

1)adversarial attack :在input samples 的embedding matricx空间内加入扰动,这种策略一般使用在监督条件下。
2)token shuffling: pass the shuffled position ids to the emdding layer while keep the order of the token ids unchanged
3) cutoff :有三种不同的情况,第一种是token cutoff ,random erase some tokens,第二种是feature dimensions (feature cutoff),第三种是token spans(span cutoff)。这个策略是直接在n*d的embedding space中使用的。
4)dropout:random drop elements in the token embedding layer by a specific probabiility and set their value to zero.
在这里插入图片描述

3.4 融入supervision信号

上述过程是在介绍模型如何在UNsupervision 情况下工作的,下面这部分是介绍模型在supervision机制下,怎么得到更加的semantic representation,进而更好用于下游任务。
NLI 任务为例:
1.joint training:

Ljoint = Lce + αLcon

2.supervised training then unsupervised transfer

first train the model with Lce on NLI dataset, then use Lcon to fine tune it on the target dataset.

3.Joint training then unsupervised transfer

first train the model with the Ljoint on NLI dataset, then use Lcon to fine-tune it on the target dataset

3.5 模型实验

first obtain the representation of sentences by averaging the token embeddings at the last two layers, then we report the spearman correlation
实验模型:bert-base / bert-large
实验设置:max_seq_length_64
remove the dropout layer of bert but considering the cutoff 和dropout . ratio of token cutoff and feature cutoff is set to 0.15 and 0.2
The temperature τ of NT-Xent loss is set to 0.1, and the α is set to 0.15
optimizer :Adam
learning rate: 5e-7
batch size: 96

四、Ablation study

1、frequency的影响
2、data argumention strategy 的影响
3、few-shot setting下的结果
4、模型中参数的影响

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
【资源介绍】 Python基于BERT的中文文本相似度识别模型源码+项目说明.zipPython基于BERT的中文文本相似度识别模型源码+项目说明.zip 无监督学习:向量白化、对比学习 bertwhitening:bert输出向量白化 论文:Whitening Sentence Representations for Better Semantics and Faster Retrieval 训练数据:lcqmc随机选取10000语句,抛弃标签。 SimCSE_unsupervised:采用与论文相同的损失函数 论文:SimCSE: Simple Contrastive Learning of Sentence Embeddings 训练数据:lcqmc随机选取10000语句,抛弃标签。 SimCSE_unsupervised_sp:采用与苏剑林相同的损失函数 训练数据:同上 SimCSE_unsupervised_sp_simplified:采用与苏剑林相同的损失函数,从transformers加载bert 训练数据:同上 SimCSE_unsupervised_simplified:采用与论文相同的损失函数,从transformers加载bert 训练数据:同上 ConSERT_unsupervised_shuffle:对posids进行shuffle 论文ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer 训练数据:同上 ESimCSE_unsupervised_endpoints: 采用与论文相同的损失函数 论文:ESimCSE: Enhanced Sample Building Method for Contrastive Learning of Unsupervised Sentence Embedding 训练数据:同上 ## 监督学习:双塔模型、对比学习 SBERT:SentenceBERT 论文Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks 训练数据:lcqmc训练集 SBERT:SentenceBERT_simplified, 从transformers加载bert 论文:同上 训练数据:同上 SimCSE_supervised:采用与论文相同的损失函数 训练数据:snli随机选取10000条数据,数据格式[sentence,sentence_entailment,sentence_contradiction] 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,也适用于小白学习入门进阶。当然也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或者热爱钻研,亦可在此项目代码基础上进行修改添加,实其他不同功能。 欢迎下载,沟通交流,互相学习,共同进步!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YingJingh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值