Van Tuan DANG commited on
Commit
fbe11a5
1 Parent(s): 5b379ad

Add README

Browse files
Files changed (1) hide show
  1. README.md +118 -0
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ language: fr
4
+ datasets:
5
+ - stsb_multi_mt
6
+ tags:
7
+ - Text
8
+ - Sentence Similarity
9
+ - Sentence-Embedding
10
+ - camembert-base
11
+ license: apache-2.0
12
+ model-index:
13
+ - name: sentence-camembert-base by Van Tuan DANG
14
+ results:
15
+ - task:
16
+ name: Sentence-Embedding
17
+ type: Text Similarity
18
+ dataset:
19
+ name: Text Similarity fr
20
+ type: stsb_multi_mt
21
+ args: fr
22
+ metrics:
23
+ - name: Test Pearson correlation coefficient
24
+ type: Pearson_correlation_coefficient
25
+ value: xx.xx
26
+ ---
27
+
28
+ ## Pre-trained sentence embedding models are the state-of-the-art of Sentence Embeddings for French.
29
+ Model is Fine-tuned using pre-trained [facebook/camembert-base](https://huggingface.co/camembert/camembert-base) and
30
+ [Siamese BERT-Networks with 'sentences-transformers'](https://www.sbert.net/) on dataset [stsb](https://huggingface.co/datasets/stsb_multi_mt/viewer/fr/train)
31
+
32
+
33
+ ## Usage
34
+ The model can be used directly (without a language model) as follows:
35
+
36
+ ```python
37
+ from sentence_transformers import SentenceTransformer
38
+ model = SentenceTransformer("dangvantuan/sentence-camembert-base")
39
+
40
+ sentences = ["Un avion est en train de décoller.",
41
+ "Un homme joue d'une grande flûte.",
42
+ "Un homme étale du fromage râpé sur une pizza.",
43
+ "Une personne jette un chat au plafond.",
44
+ "Une personne est en train de plier un morceau de papier.",
45
+ ]
46
+
47
+ embeddings = model.encode(sentences)
48
+ ```
49
+
50
+ ## Evaluation
51
+ The model can be evaluated as follows on the French test data of stsb.
52
+
53
+ ```python
54
+ from sentence_transformers import SentenceTransformer
55
+ from sentence_transformers.readers import InputExample
56
+ from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
57
+ from datasets import load_dataset
58
+ def convert_dataset(dataset):
59
+ dataset_samples=[]
60
+ for df in dataset:
61
+ score = float(df['similarity_score'])/5.0 # Normalize score to range 0 ... 1
62
+ inp_example = InputExample(texts=[df['sentence1'],
63
+ df['sentence2']], label=score)
64
+ dataset_samples.append(inp_example)
65
+ return dataset_samples
66
+
67
+ # Loading the dataset for evaluation
68
+ df_dev = load_dataset("stsb_multi_mt", name="fr", split="dev")
69
+ df_test = load_dataset("stsb_multi_mt", name="fr", split="test")
70
+
71
+ # Convert the dataset for evaluation
72
+
73
+ # For Dev set:
74
+ dev_samples = convert_dataset(df_dev)
75
+ val_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
76
+ val_evaluator(model, output_path="./")
77
+
78
+ # For Test set:
79
+ test_samples = convert_dataset(df_test)
80
+ test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
81
+ test_evaluator(model, output_path="./")
82
+ ```
83
+
84
+ **Test Result**:
85
+ The performance is measured using Pearson and Spearman correlation:
86
+ - On dev
87
+
88
+
89
+ | Model | Pearson correlation | Spearman correlation |
90
+ | ------------- | ------------- | ------------- |
91
+ | [dangvantuan/sentence-camembert-base](https://huggingface.co/dangvantuan/sentence-camembert-base)| 86.73 |86.54 |
92
+ | [distiluse-base-multilingual-cased](https://huggingface.co/sentence-transformers/distiluse-base-multilingual-cased) | 81.15 | 81.15|
93
+ - On test
94
+
95
+
96
+ | Model | Pearson correlation | Spearman correlation |
97
+ | ------------- | ------------- | ------------- |
98
+ | [dangvantuan/sentence-camembert-base](https://huggingface.co/dangvantuan/sentence-camembert-base)| 82.36 | 81.64|
99
+ | [distiluse-base-multilingual-cased](https://huggingface.co/sentence-transformers/distiluse-base-multilingual-cased) | 79.16 | 77.73|
100
+
101
+
102
+ ## Citation
103
+
104
+
105
+ @article{reimers2019sentence,
106
+ title={Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks},
107
+ author={Nils Reimers, Iryna Gurevych},
108
+ journal={https://arxiv.org/abs/1908.10084},
109
+ year={2019}
110
+ }
111
+
112
+
113
+ @article{martin2020camembert,
114
+ title={CamemBERT: a Tasty French Language Mode},
115
+ author={Martin, Louis and Muller, Benjamin and Su{\'a}rez, Pedro Javier Ortiz and Dupont, Yoann and Romary, Laurent and de la Clergerie, {\'E}ric Villemonte and Seddah, Djam{\'e} and Sagot, Beno{\^\i}t},
116
+ journal={Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
117
+ year={2020}
118
+ }