CoolFace
Modelpublic

Weike1000/Snack_Embed

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes69downloads
Model Card

SentenceTransformer based on sentence-transformers/all-mpnet-base-v2

This is a sentence-transformers model finetuned from sentence-transformers/all-mpnet-base-v2. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more. The purpose is to create closer semantic relations with certain snack/food names (ie chips -> potato chips).

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: sentence-transformers/all-mpnet-base-v2 <!-- at revision 12e86a3c702fc3c50205a8db88f0ec7c0b6b94a0 -->
  • Maximum Sequence Length: 384 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 384, 'do_lower_case': False, 'architecture': 'MPNetModel'})
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
  (2): Normalize()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("Weike1000/Snack_Embed")
# Run inference
sentences = [
    'cheddar cheese',
    'Cheddar Cheese Block',
    'Cucumber',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9452, 0.1340],
#         [0.9452, 1.0000, 0.1356],
#         [0.1340, 0.1356, 1.0000]])

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • Size: 1,275 training samples
  • Columns: <code>sentence0</code> and <code>sentence1</code>
  • Approximate statistics based on the first 1000 samples: | | sentence0 | sentence1 | |:--------|:---------------------------------------------------------------------------------|:--------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 3 tokens</li><li>mean: 5.33 tokens</li><li>max: 11 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 6.4 tokens</li><li>max: 15 tokens</li></ul> |
  • Samples: | sentence0 | sentence1 | |:------------------------------|:------------------------------------------------| | <code>fudge stripes</code> | <code>Keebler Fudge Stripes Cookies</code> | | <code>gummy bears bag</code> | <code>Gummy Bears</code> | | <code>kind bar caramel</code> | <code>Kind Bar Caramel Almond & Sea Salt</code> |
  • Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • num_train_epochs: 1000
  • multi_dataset_batch_sampler: round_robin
All Hyperparameters

<details><summary>Click to expand</summary>

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 1000
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • fp16: False
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • tp_size: 0
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin
  • router_mapping: {}
  • learning_rate_mapping: {}

</details>

Training Logs

<details><summary>Click to expand</summary>

EpochStepTraining Loss
6.255000.0756
12.510000.0396
18.7515000.033
25.020000.0283
31.2525000.0257
37.530000.0249
43.7535000.0248
50.040000.019
56.2545000.0242
62.550000.0203
68.7555000.0205
75.060000.0225
81.2565000.0183
87.570000.0227
93.7575000.0224
100.080000.022
106.2585000.0244
112.590000.0231
118.7595000.021
125.0100000.0215
131.25105000.0166
137.5110000.0186
143.75115000.0211
150.0120000.0208
156.25125000.0214
162.5130000.0207
168.75135000.0216
175.0140000.0214
181.25145000.0209
187.5150000.0197
193.75155000.022
200.0160000.0183
206.25165000.0189
212.5170000.0188
218.75175000.0163
225.0180000.0209
231.25185000.0185
237.5190000.0211
243.75195000.02
250.0200000.0206
256.25205000.0222
262.5210000.0185
268.75215000.0205
275.0220000.0165
281.25225000.0185
287.5230000.0164
293.75235000.0191
300.0240000.0197
306.25245000.0195
312.5250000.0185
318.75255000.017
325.0260000.0184
331.25265000.0184
337.5270000.0211
343.75275000.0182
350.0280000.0189
356.25285000.0172
362.5290000.0195
368.75295000.0221
375.0300000.0197
381.25305000.0228
387.5310000.0173
393.75315000.0191
400.0320000.0203
406.25325000.0202
412.5330000.0186
418.75335000.0178
425.0340000.018
431.25345000.0192
437.5350000.0186
443.75355000.0211
450.0360000.0209
456.25365000.0216
462.5370000.0201
468.75375000.0227
475.0380000.02
481.25385000.018
487.5390000.0218
493.75395000.0237
500.0400000.0208
506.25405000.0185
512.5410000.0188
518.75415000.0188
525.0420000.0168
531.25425000.017
537.5430000.0165
543.75435000.0197
550.0440000.0159
556.25445000.0224
562.5450000.0179
568.75455000.0188
575.0460000.0203
581.25465000.018
587.5470000.0195
593.75475000.0194
600.0480000.0205
606.25485000.0185
612.5490000.0208
618.75495000.0205
625.0500000.0201
631.25505000.0175
637.5510000.0171
643.75515000.0184
650.0520000.0228
656.25525000.0203
662.5530000.0222
668.75535000.0188
675.0540000.0235
681.25545000.0182
687.5550000.0215
693.75555000.018
700.0560000.0227
706.25565000.0185
712.5570000.0179
718.75575000.0176
725.0580000.0233
731.25585000.0213
737.5590000.0208
743.75595000.015
750.0600000.0199
756.25605000.0197
762.5610000.0199
768.75615000.0209
775.0620000.0185
781.25625000.0183
787.5630000.0169
793.75635000.0176
800.0640000.0206
806.25645000.0186
812.5650000.0181
818.75655000.0179
825.0660000.0184
831.25665000.0157
837.5670000.0181
843.75675000.0174
850.0680000.0185
856.25685000.0213
862.5690000.0181
868.75695000.02
875.0700000.0141
881.25705000.0168
887.5710000.0218
893.75715000.0188
900.0720000.0139
906.25725000.0188
912.5730000.022
918.75735000.0154
925.0740000.0165
931.25745000.0186
937.5750000.0191
943.75755000.0188
950.0760000.0176
956.25765000.0218
962.5770000.0185
968.75775000.0193
975.0780000.0218
981.25785000.0161
987.5790000.0216
993.75795000.0225
1000.0800000.0194

</details>

Framework Versions

  • Python: 3.9.6
  • Sentence Transformers: 5.0.0
  • Transformers: 4.51.3
  • PyTorch: 2.7.0
  • Accelerate: 1.7.0
  • Datasets: 4.0.0
  • Tokenizers: 0.21.1

Citation

BibTeX

Sentence Transformers
bibtex
@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/1908.10084",
}
MultipleNegativesRankingLoss
bibtex
@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->