🚀 二郎神SimCSE-110M中文模型
二郎神SimCSE-110M中文模型基於simcse無監督版本,使用搜集整理的中文NLI數據進行有監督任務訓練,在中文句子對任務上表現出色,能有效提取句子向量進行相似度判斷。
🚀 快速開始
模型主頁與代碼倉庫
✨ 主要特性
本模型基於bert-base模型,利用大量無監督數據和有監督數據進行對比學習,無需微調即可利用模型輸出的[CLS]進行相似度判斷,直接具備提取句子向量的能力。
📦 安裝指南
本模型可使用transformers
庫進行加載,以下是加載模型和分詞器的代碼:
from transformers import AutoTokenizer,AutoModelForMaskedLM
model =AutoModelForMaskedLM.from_pretrained('IDEA-CCNL/Erlangshen-SimCSE-110M-Chinese')
tokenizer = AutoTokenizer.from_pretrained('IDEA-CCNL/Erlangshen-SimCSE-110M-Chinese')
💻 使用示例
基礎用法
以下是一個使用本模型計算兩個句子相似度的示例代碼:
import torch
from sklearn.metrics.pairwise import cosine_similarity
texta = '今天天氣真不錯,我們去散步吧!'
textb = '今天天氣真糟糕,還是在宅家裡寫bug吧!'
inputs_a = tokenizer(texta,return_tensors="pt")
inputs_b = tokenizer(textb,return_tensors="pt")
outputs_a = model(**inputs_a ,output_hidden_states=True)
texta_embedding = outputs_a.hidden_states[-1][:,0,:].squeeze()
outputs_b = model(**inputs_b ,output_hidden_states=True)
textb_embedding = outputs_b.hidden_states[-1][:,0,:].squeeze()
with torch.no_grad():
silimarity_soce = cosine_similarity(texta_embedding.reshape(1,-1),textb_embedding .reshape(1,-1))[0][0]
print(silimarity_soce)
📚 詳細文檔
模型分類
屬性 |
詳情 |
需求 |
通用 |
任務 |
自然語言理解 |
系列 |
二郎神 |
模型 |
Bert |
參數 |
110M |
額外 |
中文 |
模型信息
本模型在一些任務上的測評效果如下:
模型 |
LCQMC |
BQ |
PAWSX |
ATEC |
STS-B |
Bert |
62 |
38.62 |
17.38 |
28.98 |
68.27 |
Bert-large |
63.78 |
37.51 |
18.63 |
30.24 |
68.87 |
RoBerta |
67.3 |
39.89 |
16.79 |
30.57 |
69.36 |
RoBerta large |
67.25 |
38.39 |
19.09 |
30.85 |
69.36 |
RoFormer |
63.58 |
39.9 |
17.52 |
29.37 |
67.32 |
SimBERT |
73.43 |
40.98 |
15.87 |
31.24 |
72 |
二郎神SimCSE-110M中文 |
74.94 |
56.97 |
21.84 |
34.12 |
70.5 |
備註:我們的模型是直接用[cls],無whitening;其餘模型是last avg + whitening
📄 許可證
本模型採用Apache-2.0許可證。
🔗 引用
如果您在您的工作中使用了我們的模型,可以引用我們的論文:
@article{fengshenbang,
author = {Jiaxing Zhang and Ruyi Gan and Junjie Wang and Yuxiang Zhang and Lin Zhang and Ping Yang and Xinyu Gao and Ziwei Wu and Xiaoqun Dong and Junqing He and Jianheng Zhuo and Qi Yang and Yongfeng Huang and Xiayu Li and Yanghan Wu and Junyu Lu and Xinyu Zhu and Weifeng Chen and Ting Han and Kunhao Pan and Rui Wang and Hao Wang and Xiaojun Wu and Zhongshen Zeng and Chongpei Chen},
title = {Fengshenbang 1.0: Being the Foundation of Chinese Cognitive Intelligence},
journal = {CoRR},
volume = {abs/2209.02970},
year = {2022}
}
也可以引用我們的網站:
@misc{Fengshenbang-LM,
title={Fengshenbang-LM},
author={IDEA-CCNL},
year={2021},
howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
}