Pascalymb commited on
Commit
90e6121
·
verified ·
1 Parent(s): 458e046

pascalymb/hack_ai_embbedding_model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 1024,
3
+ "pooling_mode": "mean",
4
+ "include_prompt": true
5
+ }
README.md ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:80
8
+ - loss:CoSENTLoss
9
+ base_model: abdeljalilELmajjodi/model
10
+ widget:
11
+ - source_sentence: A person on a horse jumps over a broken down airplane.
12
+ sentences:
13
+ - A person is at a diner, ordering an omelette.
14
+ - The man with the sign is caucasian.
15
+ - A man in a restaurant is waiting for his meal to arrive.
16
+ - source_sentence: Woman in white in foreground and a man slightly behind walking
17
+ with a sign for John's Pizza and Gyro in the background.
18
+ sentences:
19
+ - The women enjoy having a good fashion sense.
20
+ - The man is sitting down while he has a sign for John's Pizza and Gyro in his arms.
21
+ - Olympic swimming.
22
+ - source_sentence: A man and a woman cross the street in front of a pizza and gyro
23
+ restaurant.
24
+ sentences:
25
+ - The people are standing still on the curb.
26
+ - two coworkers cross pathes on a street
27
+ - Two adults swimming in water
28
+ - source_sentence: A few people in a restaurant setting, one of them is drinking orange
29
+ juice.
30
+ sentences:
31
+ - The diners are at a restaurant.
32
+ - A family of three is at the mall shopping.
33
+ - The mans briefcase is for work.
34
+ - source_sentence: Two adults, one female in white, with shades and one male, gray
35
+ clothes, walking across a street, away from a eatery with a blurred image of a
36
+ dark colored red shirted person in the foreground.
37
+ sentences:
38
+ - Two women are at a restaurant drinking wine.
39
+ - A man and a woman walk down a crowded city street.
40
+ - Two adults walk across the street.
41
+ pipeline_tag: sentence-similarity
42
+ library_name: sentence-transformers
43
+ ---
44
+
45
+ # SentenceTransformer based on abdeljalilELmajjodi/model
46
+
47
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) on the all-nli dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for retrieval.
48
+
49
+ ## Model Details
50
+
51
+ ### Model Description
52
+ - **Model Type:** Sentence Transformer
53
+ - **Base model:** [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) <!-- at revision 284169e2c18b482372374a251b8dc1e1756416de -->
54
+ - **Maximum Sequence Length:** 512 tokens
55
+ - **Output Dimensionality:** 1024 dimensions
56
+ - **Similarity Function:** Cosine Similarity
57
+ - **Supported Modality:** Text
58
+ - **Training Dataset:**
59
+ - all-nli
60
+ <!-- - **Language:** Unknown -->
61
+ <!-- - **License:** Unknown -->
62
+
63
+ ### Model Sources
64
+
65
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
66
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
67
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
68
+
69
+ ### Full Model Architecture
70
+
71
+ ```
72
+ SentenceTransformer(
73
+ (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
74
+ (1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'mean', 'include_prompt': True})
75
+ )
76
+ ```
77
+
78
+ ## Usage
79
+
80
+ ### Direct Usage (Sentence Transformers)
81
+
82
+ First install the Sentence Transformers library:
83
+
84
+ ```bash
85
+ pip install -U sentence-transformers
86
+ ```
87
+ Then you can load this model and run inference.
88
+ ```python
89
+ from sentence_transformers import SentenceTransformer
90
+
91
+ # Download from the 🤗 Hub
92
+ model = SentenceTransformer("sentence_transformers_model_id")
93
+ # Run inference
94
+ sentences = [
95
+ 'Two adults, one female in white, with shades and one male, gray clothes, walking across a street, away from a eatery with a blurred image of a dark colored red shirted person in the foreground.',
96
+ 'Two adults walk across the street.',
97
+ 'Two women are at a restaurant drinking wine.',
98
+ ]
99
+ embeddings = model.encode(sentences)
100
+ print(embeddings.shape)
101
+ # [3, 1024]
102
+
103
+ # Get the similarity scores for the embeddings
104
+ similarities = model.similarity(embeddings, embeddings)
105
+ print(similarities)
106
+ # tensor([[1.0000, 0.9900, 0.9921],
107
+ # [0.9900, 1.0000, 0.9920],
108
+ # [0.9921, 0.9920, 1.0000]])
109
+ ```
110
+ <!--
111
+ ### Direct Usage (Transformers)
112
+
113
+ <details><summary>Click to see the direct usage in Transformers</summary>
114
+
115
+ </details>
116
+ -->
117
+
118
+ <!--
119
+ ### Downstream Usage (Sentence Transformers)
120
+
121
+ You can finetune this model on your own dataset.
122
+
123
+ <details><summary>Click to expand</summary>
124
+
125
+ </details>
126
+ -->
127
+
128
+ <!--
129
+ ### Out-of-Scope Use
130
+
131
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
132
+ -->
133
+
134
+ <!--
135
+ ## Bias, Risks and Limitations
136
+
137
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
138
+ -->
139
+
140
+ <!--
141
+ ### Recommendations
142
+
143
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
144
+ -->
145
+
146
+ ## Training Details
147
+
148
+ ### Training Dataset
149
+
150
+ #### all-nli
151
+
152
+ * Dataset: all-nli
153
+ * Size: 80 training samples
154
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
155
+ * Approximate statistics based on the first 80 samples:
156
+ | | sentence1 | sentence2 | score |
157
+ |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
158
+ | type | string | string | float |
159
+ | details | <ul><li>min: 10 tokens</li><li>mean: 24.73 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 11.85 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.53</li><li>max: 1.0</li></ul> |
160
+ * Samples:
161
+ | sentence1 | sentence2 | score |
162
+ |:-------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------|:-----------------|
163
+ | <code>A man and a woman cross the street in front of a pizza and gyro restaurant.</code> | <code>The couple are walking across the street together.</code> | <code>0.5</code> |
164
+ | <code>A couple playing with a little boy on the beach.</code> | <code>A couple watch a little girl play by herself on the beach.</code> | <code>0.0</code> |
165
+ | <code>Woman in white in foreground and a man slightly behind walking with a sign for John's Pizza and Gyro in the background.</code> | <code>The woman is wearing white.</code> | <code>1.0</code> |
166
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
167
+ ```json
168
+ {
169
+ "scale": 20.0,
170
+ "similarity_fct": "pairwise_cos_sim"
171
+ }
172
+ ```
173
+
174
+ ### Evaluation Dataset
175
+
176
+ #### all-nli
177
+
178
+ * Dataset: all-nli
179
+ * Size: 20 evaluation samples
180
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
181
+ * Approximate statistics based on the first 20 samples:
182
+ | | sentence1 | sentence2 | score |
183
+ |:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
184
+ | type | string | string | float |
185
+ | details | <ul><li>min: 15 tokens</li><li>mean: 29.75 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 12.5 tokens</li><li>max: 24 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.42</li><li>max: 1.0</li></ul> |
186
+ * Samples:
187
+ | sentence1 | sentence2 | score |
188
+ |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------|:-----------------|
189
+ | <code>Two adults, one female in white, with shades and one male, gray clothes, walking across a street, away from a eatery with a blurred image of a dark colored red shirted person in the foreground.</code> | <code>Two adults walking across a road</code> | <code>1.0</code> |
190
+ | <code>A woman is walking across the street eating a banana, while a man is following with his briefcase.</code> | <code>The mans briefcase is for work.</code> | <code>0.5</code> |
191
+ | <code>Woman in white in foreground and a man slightly behind walking with a sign for John's Pizza and Gyro in the background.</code> | <code>The man with the sign is caucasian.</code> | <code>0.5</code> |
192
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
193
+ ```json
194
+ {
195
+ "scale": 20.0,
196
+ "similarity_fct": "pairwise_cos_sim"
197
+ }
198
+ ```
199
+
200
+ ### Framework Versions
201
+ - Python: 3.12.13
202
+ - Sentence Transformers: 5.4.1
203
+ - Transformers: 5.0.0
204
+ - PyTorch: 2.10.0+cu128
205
+ - Accelerate: 1.13.0
206
+ - Datasets: 4.8.5
207
+ - Tokenizers: 0.22.2
208
+
209
+ ## Citation
210
+
211
+ ### BibTeX
212
+
213
+ #### Sentence Transformers
214
+ ```bibtex
215
+ @inproceedings{reimers-2019-sentence-bert,
216
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
217
+ author = "Reimers, Nils and Gurevych, Iryna",
218
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
219
+ month = "11",
220
+ year = "2019",
221
+ publisher = "Association for Computational Linguistics",
222
+ url = "https://arxiv.org/abs/1908.10084",
223
+ }
224
+ ```
225
+
226
+ #### CoSENTLoss
227
+ ```bibtex
228
+ @article{10531646,
229
+ author={Huang, Xiang and Peng, Hao and Zou, Dongcheng and Liu, Zhiwei and Li, Jianxin and Liu, Kay and Wu, Jia and Su, Jianlin and Yu, Philip S.},
230
+ journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
231
+ title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
232
+ year={2024},
233
+ doi={10.1109/TASLP.2024.3402087}
234
+ }
235
+ ```
236
+
237
+ <!--
238
+ ## Glossary
239
+
240
+ *Clearly define terms in order to be accessible across audiences.*
241
+ -->
242
+
243
+ <!--
244
+ ## Model Card Authors
245
+
246
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
247
+ -->
248
+
249
+ <!--
250
+ ## Model Card Contact
251
+
252
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
253
+ -->
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_cross_attention": false,
3
+ "architectures": [
4
+ "XLMRobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "dtype": "float32",
10
+ "eos_token_id": 2,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 1024,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 4096,
16
+ "is_decoder": false,
17
+ "layer_norm_eps": 1e-05,
18
+ "max_position_embeddings": 514,
19
+ "model_type": "xlm-roberta",
20
+ "num_attention_heads": 16,
21
+ "num_hidden_layers": 24,
22
+ "output_past": true,
23
+ "pad_token_id": 1,
24
+ "position_embedding_type": "absolute",
25
+ "tie_word_embeddings": true,
26
+ "transformers_version": "5.0.0",
27
+ "type_vocab_size": 1,
28
+ "use_cache": true,
29
+ "use_flash_attention_2": true,
30
+ "vocab_size": 250002
31
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "pytorch": "2.10.0+cu128",
4
+ "sentence_transformers": "5.4.1",
5
+ "transformers": "5.0.0"
6
+ },
7
+ "default_prompt_name": null,
8
+ "model_type": "SentenceTransformer",
9
+ "prompts": {
10
+ "document": "",
11
+ "query": ""
12
+ },
13
+ "similarity_fn_name": "cosine"
14
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:292dde1fd9e5a4af90dec369b386f481ea7bd756c53976e0607a29968dcb07d1
3
+ size 2239607120
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ }
8
+ },
9
+ "module_output_name": "token_embeddings"
10
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fe715a86a37cd2b20e5eaeee8b22815bce65de676d1e0cd856114b59dab67fc
3
+ size 16766387
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<s>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "cls_token": "<s>",
7
+ "eos_token": "</s>",
8
+ "is_local": false,
9
+ "mask_token": "<mask>",
10
+ "model_max_length": 512,
11
+ "model_specific_special_tokens": {},
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "tokenizer_class": "XLMRobertaTokenizer",
15
+ "unk_token": "<unk>"
16
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6ea488ee6e9089a524722aa1c00b55b8ba2c4f57cb4cc27c18463a3d0bcca89
3
+ size 5521