ousaxkos commited on
Commit
f55a45b
·
verified ·
1 Parent(s): 11459bf

<enter_your_space_name>/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,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 woman wearing all white and eating, walks next to a man holding
12
+ a briefcase.
13
+ sentences:
14
+ - A married couple is sleeping.
15
+ - The people are eating omelettes.
16
+ - Two adults walk across a street.
17
+ - source_sentence: Woman in white in foreground and a man slightly behind walking
18
+ with a sign for John's Pizza and Gyro in the background.
19
+ sentences:
20
+ - There are people waiting on a train.
21
+ - The family is outside.
22
+ - The man with the sign is caucasian.
23
+ - source_sentence: Two blond women are hugging one another.
24
+ sentences:
25
+ - The women are sleeping.
26
+ - Olympic swimming.
27
+ - A couple are playing frisbee with a young child at the beach.
28
+ - source_sentence: Woman in white in foreground and a man slightly behind walking
29
+ with a sign for John's Pizza and Gyro in the background.
30
+ sentences:
31
+ - The woman is wearing black.
32
+ - They are smiling at their parents
33
+ - The woman and man are playing baseball together.
34
+ - source_sentence: A woman is walking across the street eating a banana, while a man
35
+ is following with his briefcase.
36
+ sentences:
37
+ - A school is hosting an event.
38
+ - There are people just getting on a train
39
+ - An actress and her favorite assistant talk a walk in the city.
40
+ pipeline_tag: sentence-similarity
41
+ library_name: sentence-transformers
42
+ ---
43
+
44
+ # SentenceTransformer based on abdeljalilELmajjodi/model
45
+
46
+ 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.
47
+
48
+ ## Model Details
49
+
50
+ ### Model Description
51
+ - **Model Type:** Sentence Transformer
52
+ - **Base model:** [abdeljalilELmajjodi/model](https://huggingface.co/abdeljalilELmajjodi/model) <!-- at revision 284169e2c18b482372374a251b8dc1e1756416de -->
53
+ - **Maximum Sequence Length:** 512 tokens
54
+ - **Output Dimensionality:** 1024 dimensions
55
+ - **Similarity Function:** Cosine Similarity
56
+ - **Supported Modality:** Text
57
+ - **Training Dataset:**
58
+ - all-nli
59
+ <!-- - **Language:** Unknown -->
60
+ <!-- - **License:** Unknown -->
61
+
62
+ ### Model Sources
63
+
64
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
65
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
66
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
67
+
68
+ ### Full Model Architecture
69
+
70
+ ```
71
+ SentenceTransformer(
72
+ (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
73
+ (1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'mean', 'include_prompt': True})
74
+ )
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ### Direct Usage (Sentence Transformers)
80
+
81
+ First install the Sentence Transformers library:
82
+
83
+ ```bash
84
+ pip install -U sentence-transformers
85
+ ```
86
+ Then you can load this model and run inference.
87
+ ```python
88
+ from sentence_transformers import SentenceTransformer
89
+
90
+ # Download from the 🤗 Hub
91
+ model = SentenceTransformer("sentence_transformers_model_id")
92
+ # Run inference
93
+ sentences = [
94
+ 'A woman is walking across the street eating a banana, while a man is following with his briefcase.',
95
+ 'An actress and her favorite assistant talk a walk in the city.',
96
+ 'A school is hosting an event.',
97
+ ]
98
+ embeddings = model.encode(sentences)
99
+ print(embeddings.shape)
100
+ # [3, 1024]
101
+
102
+ # Get the similarity scores for the embeddings
103
+ similarities = model.similarity(embeddings, embeddings)
104
+ print(similarities)
105
+ # tensor([[1.0000, 0.9934, 0.9887],
106
+ # [0.9934, 1.0000, 0.9916],
107
+ # [0.9887, 0.9916, 1.0000]])
108
+ ```
109
+ <!--
110
+ ### Direct Usage (Transformers)
111
+
112
+ <details><summary>Click to see the direct usage in Transformers</summary>
113
+
114
+ </details>
115
+ -->
116
+
117
+ <!--
118
+ ### Downstream Usage (Sentence Transformers)
119
+
120
+ You can finetune this model on your own dataset.
121
+
122
+ <details><summary>Click to expand</summary>
123
+
124
+ </details>
125
+ -->
126
+
127
+ <!--
128
+ ### Out-of-Scope Use
129
+
130
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
131
+ -->
132
+
133
+ <!--
134
+ ## Bias, Risks and Limitations
135
+
136
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
137
+ -->
138
+
139
+ <!--
140
+ ### Recommendations
141
+
142
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
143
+ -->
144
+
145
+ ## Training Details
146
+
147
+ ### Training Dataset
148
+
149
+ #### all-nli
150
+
151
+ * Dataset: all-nli
152
+ * Size: 80 training samples
153
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
154
+ * Approximate statistics based on the first 80 samples:
155
+ | | sentence1 | sentence2 | score |
156
+ |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
157
+ | type | string | string | float |
158
+ | details | <ul><li>min: 10 tokens</li><li>mean: 25.77 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 12.45 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.51</li><li>max: 1.0</li></ul> |
159
+ * Samples:
160
+ | sentence1 | sentence2 | score |
161
+ |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:-----------------|
162
+ | <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 walk across the street.</code> | <code>1.0</code> |
163
+ | <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 is sitting down while he has a sign for John's Pizza and Gyro in his arms.</code> | <code>0.0</code> |
164
+ | <code>High fashion ladies wait outside a tram beside a crowd of people in the city.</code> | <code>The women do not care what clothes they wear.</code> | <code>0.0</code> |
165
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
166
+ ```json
167
+ {
168
+ "scale": 20.0,
169
+ "similarity_fct": "pairwise_cos_sim"
170
+ }
171
+ ```
172
+
173
+ ### Evaluation Dataset
174
+
175
+ #### all-nli
176
+
177
+ * Dataset: all-nli
178
+ * Size: 20 evaluation samples
179
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
180
+ * Approximate statistics based on the first 20 samples:
181
+ | | sentence1 | sentence2 | score |
182
+ |:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
183
+ | type | string | string | float |
184
+ | details | <ul><li>min: 10 tokens</li><li>mean: 25.55 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 10.1 tokens</li><li>max: 17 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.47</li><li>max: 1.0</li></ul> |
185
+ * Samples:
186
+ | sentence1 | sentence2 | score |
187
+ |:-------------------------------------------------------------|:-----------------------------------------------|:-----------------|
188
+ | <code>A couple play in the tide with their young son.</code> | <code>The family is outside.</code> | <code>1.0</code> |
189
+ | <code>Two blond women are hugging one another.</code> | <code>The women are sleeping.</code> | <code>0.0</code> |
190
+ | <code>Children smiling and waving at camera</code> | <code>They are smiling at their parents</code> | <code>0.5</code> |
191
+ * Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
192
+ ```json
193
+ {
194
+ "scale": 20.0,
195
+ "similarity_fct": "pairwise_cos_sim"
196
+ }
197
+ ```
198
+
199
+ ### Framework Versions
200
+ - Python: 3.12.13
201
+ - Sentence Transformers: 5.4.1
202
+ - Transformers: 5.0.0
203
+ - PyTorch: 2.10.0+cu128
204
+ - Accelerate: 1.13.0
205
+ - Datasets: 4.8.5
206
+ - Tokenizers: 0.22.2
207
+
208
+ ## Citation
209
+
210
+ ### BibTeX
211
+
212
+ #### Sentence Transformers
213
+ ```bibtex
214
+ @inproceedings{reimers-2019-sentence-bert,
215
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
216
+ author = "Reimers, Nils and Gurevych, Iryna",
217
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
218
+ month = "11",
219
+ year = "2019",
220
+ publisher = "Association for Computational Linguistics",
221
+ url = "https://arxiv.org/abs/1908.10084",
222
+ }
223
+ ```
224
+
225
+ #### CoSENTLoss
226
+ ```bibtex
227
+ @article{10531646,
228
+ 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.},
229
+ journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
230
+ title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
231
+ year={2024},
232
+ doi={10.1109/TASLP.2024.3402087}
233
+ }
234
+ ```
235
+
236
+ <!--
237
+ ## Glossary
238
+
239
+ *Clearly define terms in order to be accessible across audiences.*
240
+ -->
241
+
242
+ <!--
243
+ ## Model Card Authors
244
+
245
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
246
+ -->
247
+
248
+ <!--
249
+ ## Model Card Contact
250
+
251
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
252
+ -->
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:37267ff08ffc58b9dcaffc31ee490c27fb204ed0c1c327f7470e97347bf4f8f2
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