当前位置:网站首页>SimCLR:NLP中的对比学习
SimCLR:NLP中的对比学习
2022-07-06 08:53:00 【InfoQ】
论文简介
- 诸神黄昏时代的对比学习
- “军备竞赛”时期的对比学习
- 使用预训练好的 Bert 直接获得句子向量,可以是 CLS 位的向量,也可以是不同 token 向量的平均值。
- Bert-flow^[On the Sentence Embeddings from Pre-trained Language Models],主要是利用流模型校正 Bert 的向量。
- Bert-whitening^[Whitening Sentence Representations for Better Semantics and Faster Retrieval],用预训练 Bert 获得所有句子的向量,得到句子向量矩阵,然后通过一个线性变换把句子向量矩阵变为一个均值 0,协方差矩阵为单位阵的矩阵。
- Sentence-Bert (SBERT)^[Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks],通过 Bert 的孪生网络获得两个句子的向量,进行有监督学习,SBERT 的结构如下图所示。
什么是dropout
dropout和其他数据增强方法进行比较
不同的dropout rate
对比学习评价指标
- alignment 计算所有正样本对之间的距离,如果 alignment 越小,则正样本的向量越接近,对比学习效果越好,计算公式如下:$$
- uniformity 表示所有句子向量分布的均匀程度,越小表示向量分布越均匀,对比学习效果越好,计算公式如下:$$\ell_{\text {uniform }} \triangleq \log \quad \mathbb{E}{x, y \stackrel{i . i . d .}{\sim} p{\text {data }}} e^{-2|f(x)-f(y)|^{2}}$$
无监督
有监督
结果
代码实践
pip install simcse
SimCSE("在这里填写不同版本")
from simcse import SimCSE
model = SimCSE("princeton-nlp/sup-simcse-bert-base-uncased")
embeddings = model.encode("A woman is reading.")
sentences_a = ['A woman is reading.', 'A man is playing a guitar.']
sentences_b = ['He plays guitar.', 'A woman is making a photo.']
similarities = model.similarity(sentences_a, sentences_b)
similarities1 = model.similarity('A woman is reading.', 'A man is playing a guitar.')
similarities2 = model.similarity('He plays guitar.', 'A man is playing a guitar.')
sentences = ['A woman is reading.', 'A man is playing a guitar.']
model.build_index(sentences)
results = model.search("He plays guitar.")
similarities2 = model.similarity('He plays guitar.', 'A man is playing a guitar.')
He plays guitar.
A man is playing a guitar.
边栏推荐
- [embedded] cortex m4f DSP Library
- JVM quick start
- Warning in install. packages : package ‘RGtk2’ is not available for this version of R
- Delay initialization and sealing classes
- Detailed explanation of heap sorting
- swagger设置字段required必填
- Charging interface docking tutorial of enterprise and micro service provider platform
- vb.net 随窗口改变,缩放控件大小以及保持相对位置
- Compétences en mémoire des graphiques UML
- 【ROS】usb_ Cam camera calibration
猜你喜欢
Excellent software testers have these abilities
Guangzhou will promote the construction of a child friendly city, and will explore the establishment of a safe area 200 meters around the school
View computer devices in LAN
MYSQL卸载方法与安装方法
注意力机制的一种卷积替代方式
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
Export IEEE document format using latex
JVM quick start
Trying to use is on a network resource that is unavailable
Variable length parameter
随机推荐
Sublime text using ctrl+b to run another program without closing other runs
Leetcode刷题题解2.1.1
swagger设置字段required必填
Export IEEE document format using latex
Image, CV2 read the conversion and size resize change of numpy array of pictures
Chapter 1 :Application of Artificial intelligence in Drug Design:Opportunity and Challenges
LeetCode:41. 缺失的第一个正数
LeetCode:673. Number of longest increasing subsequences
LeetCode:214. 最短回文串
LeetCode:124. 二叉树中的最大路径和
What is the role of automated testing frameworks? Shanghai professional third-party software testing company Amway
Esp8266-rtos IOT development
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
【嵌入式】使用JLINK RTT打印log
LeetCode:498. Diagonal traversal
C language double pointer -- classic question type
可变长参数
LeetCode:124. Maximum path sum in binary tree
Light of domestic games destroyed by cracking
R language ggplot2 visualization, custom ggplot2 visualization image legend background color of legend