Wissam42 commited on
Commit
96c483a
·
verified ·
1 Parent(s): dbae7ad

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -98
README.md CHANGED
@@ -1,18 +1,33 @@
1
  ---
2
  pipeline_tag: sentence-similarity
 
 
 
3
  tags:
4
  - sentence-transformers
5
  - feature-extraction
6
  - sentence-similarity
7
  - transformers
8
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
- # Wissam42/sentence-croissant-llm-base
12
-
13
- This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 2048 dimensional dense vector space and can be used for tasks like clustering or semantic search.
14
 
15
- <!--- Describe your model here -->
16
 
17
  ## Usage (Sentence-Transformers)
18
 
@@ -26,102 +41,24 @@ Then you can use the model like this:
26
 
27
  ```python
28
  from sentence_transformers import SentenceTransformer
29
- sentences = ["This is an example sentence", "Each sentence is converted"]
30
-
31
- model = SentenceTransformer('Wissam42/sentence-croissant-llm-base')
32
  embeddings = model.encode(sentences)
33
  print(embeddings)
34
  ```
35
 
36
-
37
-
38
- ## Usage (HuggingFace Transformers)
39
- Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
40
-
41
- ```python
42
- from transformers import AutoTokenizer, AutoModel
43
- import torch
44
-
45
-
46
- #Mean Pooling - Take attention mask into account for correct averaging
47
- def mean_pooling(model_output, attention_mask):
48
- token_embeddings = model_output[0] #First element of model_output contains all token embeddings
49
- input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
50
- return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
51
-
52
-
53
- # Sentences we want sentence embeddings for
54
- sentences = ['This is an example sentence', 'Each sentence is converted']
55
-
56
- # Load model from HuggingFace Hub
57
- tokenizer = AutoTokenizer.from_pretrained('Wissam42/sentence-croissant-llm-base')
58
- model = AutoModel.from_pretrained('Wissam42/sentence-croissant-llm-base')
59
-
60
- # Tokenize sentences
61
- encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
62
-
63
- # Compute token embeddings
64
- with torch.no_grad():
65
- model_output = model(**encoded_input)
66
-
67
- # Perform pooling. In this case, mean pooling.
68
- sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
69
-
70
- print("Sentence embeddings:")
71
- print(sentence_embeddings)
72
- ```
73
-
74
-
75
-
76
- ## Evaluation Results
77
-
78
- <!--- Describe how your model was evaluated -->
79
-
80
- For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=Wissam42/sentence-croissant-llm-base)
81
-
82
-
83
- ## Training
84
- The model was trained with the parameters:
85
-
86
- **DataLoader**:
87
-
88
- `torch.utils.data.dataloader.DataLoader` of length 360 with parameters:
89
- ```
90
- {'batch_size': 16, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
91
- ```
92
-
93
- **Loss**:
94
-
95
- `__main__.CosineSimilarityLoss`
96
-
97
- Parameters of the fit()-Method:
98
- ```
99
- {
100
- "epochs": 10,
101
- "evaluation_steps": 500,
102
- "evaluator": "__main__.CustomEmbeddingSimilarityEvaluator",
103
- "max_grad_norm": 1,
104
- "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
105
- "optimizer_params": {
106
- "eps": 1e-06,
107
- "lr": 1e-05
108
- },
109
- "scheduler": "WarmupLinear",
110
- "steps_per_epoch": null,
111
- "warmup_steps": 360,
112
- "weight_decay": 0.01
113
- }
114
- ```
115
-
116
-
117
- ## Full Model Architecture
118
- ```
119
- SentenceTransformer(
120
- (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: LlamaModel
121
- (1): Pooling({'word_embedding_dimension': 2048, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
122
- )
123
- ```
124
-
125
  ## Citing & Authors
126
 
127
- <!--- Describe where people can find more information -->
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  pipeline_tag: sentence-similarity
3
+ language: fr
4
+ datasets:
5
+ - stsb_multi_mt
6
  tags:
7
  - sentence-transformers
8
  - feature-extraction
9
  - sentence-similarity
10
  - transformers
11
+ license: mit
12
+ model-index:
13
+ - name: sentence-croissant-llm-base by Wissam Siblini
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
+ # sentence-croissant-llm-base
 
 
29
 
30
+ The model [sentence-croissant-llm-base](https://huggingface.co/Wissam42/sentence-croissant-llm-base) is designed to generate French text embeddings. It has been fine-tuned using the very recent pre-trained LLM [croissantllm/CroissantLLMBase](https://huggingface.co/croissantllm/CroissantLLMBase) with the strategy of Siamese-BERT implemented in the library ['sentences-transformers'](https://www.sbert.net/). The fine tuning dataset used is the French training split of [stsb](https://huggingface.co/datasets/stsb_multi_mt/viewer/fr/train).
31
 
32
  ## Usage (Sentence-Transformers)
33
 
 
41
 
42
  ```python
43
  from sentence_transformers import SentenceTransformer
44
+ model = SentenceTransformer("Wissam42/sentence-croissant-llm-base")
45
+ sentences = ["Le chat mange la souris", "Un felin devore un rongeur", "Je travaille sur un ordinateur", "Je developpe sur mon pc"]
 
46
  embeddings = model.encode(sentences)
47
  print(embeddings)
48
  ```
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  ## Citing & Authors
51
 
52
+ @article{faysse2024croissantllm,
53
+ title={CroissantLLM: A Truly Bilingual French-English Language Model},
54
+ author={Faysse, Manuel and Fernandes, Patrick and Guerreiro, Nuno and Loison, Ant{\'o}nio and Alves, Duarte and Corro, Caio and Boizard, Nicolas and Alves, Jo{\~a}o and Rei, Ricardo and Martins, Pedro and others},
55
+ journal={arXiv preprint arXiv:2402.00786},
56
+ year={2024}
57
+ }
58
+
59
+ @article{reimers2019sentence,
60
+ title={Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks},
61
+ author={Nils Reimers, Iryna Gurevych},
62
+ journal={https://arxiv.org/abs/1908.10084},
63
+ year={2019}
64
+ }