Sentence Similarity
sentence-transformers
PyTorch
ONNX
Safetensors
OpenVINO
Chinese
bert
Sentence Transformers
Instructions to use shibing624/text2vec-base-chinese with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use shibing624/text2vec-base-chinese with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("shibing624/text2vec-base-chinese") sentences = [ "那是 個快樂的人", "那是 條快樂的狗", "那是 個非常幸福的人", "今天是晴天" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Inference
- Notebooks
- Google Colab
- Kaggle
Commit ·
b606b56
1
Parent(s): 630e10f
Update README.md
Browse files
README.md
CHANGED
|
@@ -11,7 +11,7 @@ datasets:
|
|
| 11 |
language:
|
| 12 |
- zh
|
| 13 |
metrics:
|
| 14 |
-
-
|
| 15 |
library_name: transformers
|
| 16 |
---
|
| 17 |
# shibing624/text2vec-base-chinese
|
|
@@ -26,12 +26,24 @@ For an automated evaluation of this model, see the *Evaluation Benchmark*: [text
|
|
| 26 |
|
| 27 |
- chinese text matching task:
|
| 28 |
|
| 29 |
-
|
|
| 30 |
-
|
|
| 31 |
-
| w2v-light-tencent-chinese
|
| 32 |
-
| paraphrase-multilingual-MiniLM-L12-v2 | 18.42 | 38.52 | 63.96 | 10.14 | 78.90 |
|
| 33 |
-
|
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Usage (text2vec)
|
| 37 |
Using this model becomes easy when you have [text2vec](https://github.com/shibing624/text2vec) installed:
|
|
@@ -117,6 +129,37 @@ CoSENT(
|
|
| 117 |
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_mean_tokens': True})
|
| 118 |
)
|
| 119 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
## Citing & Authors
|
| 121 |
This model was trained by [text2vec](https://github.com/shibing624/text2vec).
|
| 122 |
|
|
|
|
| 11 |
language:
|
| 12 |
- zh
|
| 13 |
metrics:
|
| 14 |
+
- spearmanr
|
| 15 |
library_name: transformers
|
| 16 |
---
|
| 17 |
# shibing624/text2vec-base-chinese
|
|
|
|
| 26 |
|
| 27 |
- chinese text matching task:
|
| 28 |
|
| 29 |
+
| Arch | BaseModel | Model | ATEC | BQ | LCQMC | PAWSX | STS-B | SOHU-dd | SOHU-dc | Avg | QPS |
|
| 30 |
+
|:-----------|:----------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------|:-----:|:-----:|:-----:|:-----:|:-----:|:-------:|:-------:|:---------:|:-----:|
|
| 31 |
+
| Word2Vec | word2vec | [w2v-light-tencent-chinese](https://ai.tencent.com/ailab/nlp/en/download.html) | 20.00 | 31.49 | 59.46 | 2.57 | 55.78 | 55.04 | 20.70 | 35.03 | 23769 |
|
| 32 |
+
| SBERT | xlm-roberta-base | [sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) | 18.42 | 38.52 | 63.96 | 10.14 | 78.90 | 63.01 | 52.28 | 46.46 | 3138 |
|
| 33 |
+
| Instructor | hfl/chinese-roberta-wwm-ext | [moka-ai/m3e-base](https://huggingface.co/moka-ai/m3e-base) | 41.27 | 63.81 | 74.87 | 12.20 | 76.96 | 75.83 | 60.55 | 57.93 | 2980 |
|
| 34 |
+
| CoSENT | hfl/chinese-macbert-base | [shibing624/text2vec-base-chinese](https://huggingface.co/shibing624/text2vec-base-chinese) | 31.93 | 42.67 | 70.16 | 17.21 | 79.30 | 70.27 | 50.42 | 51.61 | 3008 |
|
| 35 |
+
| CoSENT | hfl/chinese-lert-large | [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese) | 32.61 | 44.59 | 69.30 | 14.51 | 79.44 | 73.01 | 59.04 | 53.12 | 2092 |
|
| 36 |
+
| CoSENT | nghuyong/ernie-3.0-base-zh | [shibing624/text2vec-base-chinese-sentence](https://huggingface.co/shibing624/text2vec-base-chinese-sentence) | 43.37 | 61.43 | 73.48 | 38.90 | 78.25 | 70.60 | 53.08 | 59.87 | 3089 |
|
| 37 |
+
| CoSENT | nghuyong/ernie-3.0-base-zh | [shibing624/text2vec-base-chinese-paraphrase](https://huggingface.co/shibing624/text2vec-base-chinese-paraphrase) | 44.89 | 63.58 | 74.24 | 40.90 | 78.93 | 76.70 | 63.30 | 63.08 | 3066 |
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
说明:
|
| 41 |
+
- 结果评测指标:spearman系数
|
| 42 |
+
- `shibing624/text2vec-base-chinese`模型,是用CoSENT方法训练,基于`hfl/chinese-macbert-base`在中文STS-B数据训练得到,并在中文STS-B测试集评估达到较好效果,运行[examples/training_sup_text_matching_model.py](https://github.com/shibing624/text2vec/blob/master/examples/training_sup_text_matching_model.py)代码可训练模型,模型文件已经上传HF model hub,中文通用语义匹配任务推荐使用
|
| 43 |
+
- `shibing624/text2vec-base-chinese-sentence`模型,是用CoSENT方法训练,基于`nghuyong/ernie-3.0-base-zh`用人工挑选后的中文STS数据集[shibing624/nli-zh-all/text2vec-base-chinese-sentence-dataset](https://huggingface.co/datasets/shibing624/nli-zh-all/tree/main/text2vec-base-chinese-sentence-dataset)训练得到,并在中文各NLI测试集评估达到较好效果,运行[examples/training_sup_text_matching_model_jsonl_data.py](https://github.com/shibing624/text2vec/blob/master/examples/training_sup_text_matching_model_jsonl_data.py)代码可训练模型,模型文件已经上传HF model hub,中文s2s(句子vs句子)语义匹配任务推荐使用
|
| 44 |
+
- `shibing624/text2vec-base-chinese-paraphrase`模型,是用CoSENT方法训练,基于`nghuyong/ernie-3.0-base-zh`用人工挑选后的中文STS数据集[shibing624/nli-zh-all/text2vec-base-chinese-paraphrase-dataset](https://huggingface.co/datasets/shibing624/nli-zh-all/tree/main/text2vec-base-chinese-paraphrase-dataset),数据集相对于[shibing624/nli-zh-all/text2vec-base-chinese-sentence-dataset](https://huggingface.co/datasets/shibing624/nli-zh-all/tree/main/text2vec-base-chinese-sentence-dataset)加入了s2p(sentence to paraphrase)数据,强化了其长文本的表征能力,并在中文各NLI测试集评估达到SOTA,运行[examples/training_sup_text_matching_model_jsonl_data.py](https://github.com/shibing624/text2vec/blob/master/examples/training_sup_text_matching_model_jsonl_data.py)代码可训练模型,模型文件已经上传HF model hub,中文s2p(句子vs段落)语义匹配任务推荐使用
|
| 45 |
+
- `sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2`模型是用SBERT训练,是`paraphrase-MiniLM-L12-v2`模型的多语言版本,支持中文、英文等
|
| 46 |
+
- `w2v-light-tencent-chinese`是腾讯词向量的Word2Vec模型,CPU加载使用,适用于中文字面匹配任务和缺少数据的冷启动情况
|
| 47 |
|
| 48 |
## Usage (text2vec)
|
| 49 |
Using this model becomes easy when you have [text2vec](https://github.com/shibing624/text2vec) installed:
|
|
|
|
| 129 |
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_mean_tokens': True})
|
| 130 |
)
|
| 131 |
```
|
| 132 |
+
|
| 133 |
+
## Intended uses
|
| 134 |
+
|
| 135 |
+
Our model is intented to be used as a sentence and short paragraph encoder. Given an input text, it ouptuts a vector which captures
|
| 136 |
+
the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
|
| 137 |
+
|
| 138 |
+
By default, input text longer than 256 word pieces is truncated.
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
## Training procedure
|
| 142 |
+
|
| 143 |
+
### Pre-training
|
| 144 |
+
|
| 145 |
+
We use the pretrained [`hfl/chinese-macbert-base`](https://huggingface.co/hfl/chinese-macbert-base) model.
|
| 146 |
+
Please refer to the model card for more detailed information about the pre-training procedure.
|
| 147 |
+
|
| 148 |
+
### Fine-tuning
|
| 149 |
+
|
| 150 |
+
We fine-tune the model using a contrastive objective. Formally, we compute the cosine similarity from each
|
| 151 |
+
possible sentence pairs from the batch.
|
| 152 |
+
We then apply the rank loss by comparing with true pairs and false pairs.
|
| 153 |
+
|
| 154 |
+
#### Hyper parameters
|
| 155 |
+
|
| 156 |
+
- training dataset: https://huggingface.co/datasets/shibing624/nli_zh
|
| 157 |
+
- max_seq_length: 218
|
| 158 |
+
- best epoch: 5
|
| 159 |
+
- sentence embedding dim: 768
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
## Citing & Authors
|
| 164 |
This model was trained by [text2vec](https://github.com/shibing624/text2vec).
|
| 165 |
|