Erlangshen-SimCSE-110M-Chinese
is based on the unsupervised version of simcse, And training simcse supervised task with collected and sorted chinese NLI data for. It has good effect on the task in Chinese sentences pair.
In order to obtain a general sentence-embedding-model, we use a large number of unsupervised data and supervised data for comparative learning based on the Bert-base model, and finally obtained a model that can use the [CLS] output from the model to judge the similarity without fine-tuning. Different from the sentence similarity task after fine tuning the task with the bert model, our model has the ability to extract sentence vectors directly after pre training. In some tasks, the evaluation results are as follows:
ps:Our model use [cls] directly,and no whitening;Other model use last avg and do whitening
使用 Usage
加载模型 Loading Models
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')
使用示例 Usage Examples
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()
# if you use cuda, the text_embedding should be textb_embedding.cpu().numpy()# 或者用torch.no_grad():with torch.no_grad():
silimarity_soce = cosine_similarity(texta_embedding.reshape(1,-1),textb_embedding .reshape(1,-1))[0][0]
print(silimarity_soce)
If you are using the resource for your work, please cite the our
paper
:
@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}
}
Erlangshen-SimCSE-110M-Chinese huggingface.co is an AI model on huggingface.co that provides Erlangshen-SimCSE-110M-Chinese's model effect (), which can be used instantly with this IDEA-CCNL Erlangshen-SimCSE-110M-Chinese model. huggingface.co supports a free trial of the Erlangshen-SimCSE-110M-Chinese model, and also provides paid use of the Erlangshen-SimCSE-110M-Chinese. Support call Erlangshen-SimCSE-110M-Chinese model through api, including Node.js, Python, http.
Erlangshen-SimCSE-110M-Chinese huggingface.co is an online trial and call api platform, which integrates Erlangshen-SimCSE-110M-Chinese's modeling effects, including api services, and provides a free online trial of Erlangshen-SimCSE-110M-Chinese, you can try Erlangshen-SimCSE-110M-Chinese online for free by clicking the link below.
IDEA-CCNL Erlangshen-SimCSE-110M-Chinese online free url in huggingface.co:
Erlangshen-SimCSE-110M-Chinese is an open source model from GitHub that offers a free installation service, and any user can find Erlangshen-SimCSE-110M-Chinese on GitHub to install. At the same time, huggingface.co provides the effect of Erlangshen-SimCSE-110M-Chinese install, users can directly use Erlangshen-SimCSE-110M-Chinese installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Erlangshen-SimCSE-110M-Chinese install url in huggingface.co: