SentenceTransformer based on google/bert_uncased_L-2_H-128_A-2

This is a sentence-transformers model finetuned from google/bert_uncased_L-2_H-128_A-2. It maps sentences & paragraphs to a 128-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: google/bert_uncased_L-2_H-128_A-2
  • Maximum Sequence Length: 128 tokens
  • Output Dimensionality: 128 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modality: Text

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
  (1): Pooling({'embedding_dimension': 128, 'pooling_mode': 'mean', 'include_prompt': True})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

pip install -U sentence-transformers

Then you can load this model and run inference.

from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("swardiantara/bert-tiny-amazon_reviews-k10-fixed-cosine")
# Run inference
sentences = [
    "Arrived broken. Manufacturer defect. Two of the legs of the base were not completely formed, so there was no way to insert the casters. I unpackaged the entire chair and hardware before noticing this. So, I'll spend twice the amount of time boxing up the whole useless thing and send it back with a 1-star review of part of a chair I never got to sit in. I will go so far as to include a picture of what their injection molding and quality assurance process missed though. I will be hesitant to buy again. It makes me wonder if there aren't missing structures and supports that don't impede the assembly process.",
    'I like the design of the bag, though it came a little crumpled up. Hoping everything smoothes out with use. Also very upset that I paid more for this bag and my key chain was never sent.',
    'I bought these plates because I liked the way they looked. They are good enough for a single use but do not hold up too well with multiple uses. Once they are put in the microwave they start to crack quite easily.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 128]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.2434, 0.1683],
#         [0.2434, 1.0000, 0.4315],
#         [0.1683, 0.4315, 1.0000]])

Training Details

Training Dataset

Unnamed Dataset

  • Size: 8,201,450 training samples
  • Columns: text_a, text_b, and label
  • Approximate statistics based on the first 100 samples:
    text_a text_b label
    type string string list
    modality text text
    details
    • min: 15 tokens
    • mean: 66.74 tokens
    • max: 128 tokens
    • min: 8 tokens
    • mean: 46.15 tokens
    • max: 128 tokens
    • size: 2 elements
  • Samples:
    text_a text_b label
    Arrived broken. Manufacturer defect. Two of the legs of the base were not completely formed, so there was no way to insert the casters. I unpackaged the entire chair and hardware before noticing this. So, I'll spend twice the amount of time boxing up the whole useless thing and send it back with a 1-star review of part of a chair I never got to sit in. I will go so far as to include a picture of what their injection molding and quality assurance process missed though. I will be hesitant to buy again. It makes me wonder if there aren't missing structures and supports that don't impede the assembly process. I ordered this a while ago, even using prime it took over a month to get here, now that I finally got it, I only receved 6 of the 12! Im a little upset. It's still funny, but would not recomend for someone who needs foam quick and in bulk like i do. [1.0, 0.0]
    Arrived broken. Manufacturer defect. Two of the legs of the base were not completely formed, so there was no way to insert the casters. I unpackaged the entire chair and hardware before noticing this. So, I'll spend twice the amount of time boxing up the whole useless thing and send it back with a 1-star review of part of a chair I never got to sit in. I will go so far as to include a picture of what their injection molding and quality assurance process missed though. I will be hesitant to buy again. It makes me wonder if there aren't missing structures and supports that don't impede the assembly process. I was happy to find this piece to replace on my broken Shark. Price was good and had it in a few days. When I installed it however, I was no longer satisfied. It wouldn't stay attached and kept popping of with any pull on the handle. Returned the same day it areived. [0.0, 0.25]
    Arrived broken. Manufacturer defect. Two of the legs of the base were not completely formed, so there was no way to insert the casters. I unpackaged the entire chair and hardware before noticing this. So, I'll spend twice the amount of time boxing up the whole useless thing and send it back with a 1-star review of part of a chair I never got to sit in. I will go so far as to include a picture of what their injection molding and quality assurance process missed though. I will be hesitant to buy again. It makes me wonder if there aren't missing structures and supports that don't impede the assembly process. Had to return. This unit is tiny and very cheap quality. [0.0, 0.25]
  • Loss: main.OrdinalProxyContrastiveLoss

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 1024
  • num_train_epochs: 10
  • learning_rate: 2e-05
  • load_best_model_at_end: True

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 1024
  • num_train_epochs: 10
  • max_steps: -1
  • learning_rate: 2e-05
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_steps: 0
  • optim: adamw_torch
  • optim_args: None
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • optim_target_modules: None
  • gradient_accumulation_steps: 1
  • average_tokens_across_devices: True
  • max_grad_norm: 1.0
  • label_smoothing_factor: 0.0
  • bf16: False
  • fp16: False
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • use_liger_kernel: False
  • liger_kernel_config: None
  • use_cache: False
  • neftune_noise_alpha: None
  • torch_empty_cache_steps: None
  • auto_find_batch_size: False
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • include_num_input_tokens_seen: no
  • log_level: passive
  • log_level_replica: warning
  • disable_tqdm: False
  • project: huggingface
  • trackio_space_id: None
  • trackio_bucket_id: None
  • trackio_static_space_id: None
  • per_device_eval_batch_size: 8
  • prediction_loss_only: True
  • eval_on_start: False
  • eval_do_concat_batches: True
  • eval_use_gather_object: False
  • eval_accumulation_steps: None
  • include_for_metrics: []
  • batch_eval_metrics: False
  • save_only_model: False
  • save_on_each_node: False
  • enable_jit_checkpoint: False
  • push_to_hub: False
  • hub_private_repo: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_always_push: False
  • hub_revision: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • restore_callback_states_from_checkpoint: False
  • full_determinism: False
  • seed: 42
  • data_seed: None
  • use_cpu: False
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • dataloader_prefetch_factor: None
  • remove_unused_columns: True
  • label_names: None
  • train_sampling_strategy: random
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • ddp_static_graph: None
  • ddp_backend: None
  • ddp_timeout: 1800
  • fsdp: None
  • fsdp_config: None
  • deepspeed: None
  • debug: []
  • skip_memory_metrics: True
  • do_predict: False
  • resume_from_checkpoint: None
  • warmup_ratio: None
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Click to expand
Epoch Step Training Loss
0.0624 500 0.0096
0.1248 1000 0.0055
0.1873 1500 0.0053
0.2497 2000 0.0052
0.3121 2500 0.0051
0.3745 3000 0.0051
0.4370 3500 0.0050
0.4994 4000 0.0050
0.5618 4500 0.0050
0.6242 5000 0.0049
0.6866 5500 0.0049
0.7491 6000 0.0049
0.8115 6500 0.0048
0.8739 7000 0.0049
0.9363 7500 0.0048
0.9988 8000 0.0048
1.0 8010 -
1.0612 8500 0.0047
1.1236 9000 0.0047
1.1860 9500 0.0047
1.2484 10000 0.0047
1.3109 10500 0.0046
1.3733 11000 0.0047
1.4357 11500 0.0047
1.4981 12000 0.0047
1.5605 12500 0.0046
1.6230 13000 0.0046
1.6854 13500 0.0047
1.7478 14000 0.0046
1.8102 14500 0.0046
1.8727 15000 0.0046
1.9351 15500 0.0046
1.9975 16000 0.0046
2.0 16020 -
2.0599 16500 0.0045
2.1223 17000 0.0045
2.1848 17500 0.0045
2.2472 18000 0.0045
2.3096 18500 0.0045
2.3720 19000 0.0044
2.4345 19500 0.0045
2.4969 20000 0.0045
2.5593 20500 0.0045
2.6217 21000 0.0045
2.6841 21500 0.0045
2.7466 22000 0.0045
2.8090 22500 0.0045
2.8714 23000 0.0044
2.9338 23500 0.0045
2.9963 24000 0.0044
3.0 24030 -
3.0587 24500 0.0044
3.1211 25000 0.0044
3.1835 25500 0.0044
3.2459 26000 0.0044
3.3084 26500 0.0044
3.3708 27000 0.0043
3.4332 27500 0.0043
3.4956 28000 0.0044
3.5581 28500 0.0044
3.6205 29000 0.0044
3.6829 29500 0.0043
3.7453 30000 0.0044
3.8077 30500 0.0044
3.8702 31000 0.0044
3.9326 31500 0.0043
3.9950 32000 0.0043
4.0 32040 -
4.0574 32500 0.0043
4.1199 33000 0.0043
4.1823 33500 0.0043
4.2447 34000 0.0043
4.3071 34500 0.0043
4.3695 35000 0.0043
4.4320 35500 0.0043
4.4944 36000 0.0043
4.5568 36500 0.0042
4.6192 37000 0.0042
4.6816 37500 0.0043
4.7441 38000 0.0043
4.8065 38500 0.0043
4.8689 39000 0.0042
4.9313 39500 0.0043
4.9938 40000 0.0043
5.0 40050 -
5.0562 40500 0.0042
5.1186 41000 0.0042
5.1810 41500 0.0042
5.2434 42000 0.0042
5.3059 42500 0.0043
5.3683 43000 0.0042
5.4307 43500 0.0043
5.4931 44000 0.0042
5.5556 44500 0.0042
5.6180 45000 0.0042
5.6804 45500 0.0042
5.7428 46000 0.0042
5.8052 46500 0.0043
5.8677 47000 0.0042
5.9301 47500 0.0042
5.9925 48000 0.0042
6.0 48060 -
6.0549 48500 0.0042
6.1174 49000 0.0042
6.1798 49500 0.0042
6.2422 50000 0.0042
6.3046 50500 0.0042
6.3670 51000 0.0042
6.4295 51500 0.0042
6.4919 52000 0.0042
6.5543 52500 0.0042
6.6167 53000 0.0042
6.6792 53500 0.0041
6.7416 54000 0.0041
6.8040 54500 0.0041
6.8664 55000 0.0042
6.9288 55500 0.0042
6.9913 56000 0.0041
7.0 56070 -
7.0537 56500 0.0042
7.1161 57000 0.0042
7.1785 57500 0.0041
7.2409 58000 0.0041
7.3034 58500 0.0041
7.3658 59000 0.0041
7.4282 59500 0.0041
7.4906 60000 0.0042
7.5531 60500 0.0041
7.6155 61000 0.0042
7.6779 61500 0.0041
7.7403 62000 0.0041
7.8027 62500 0.0042
7.8652 63000 0.0041
7.9276 63500 0.0041
7.9900 64000 0.0041
8.0 64080 -
8.0524 64500 0.0041
8.1149 65000 0.0041
8.1773 65500 0.0041
8.2397 66000 0.0041
8.3021 66500 0.0041
8.3645 67000 0.0041
8.4270 67500 0.0041
8.4894 68000 0.0041
8.5518 68500 0.0041
8.6142 69000 0.0041
8.6767 69500 0.0040
8.7391 70000 0.0041
8.8015 70500 0.0042
8.8639 71000 0.0042
8.9263 71500 0.0040
8.9888 72000 0.0041
9.0 72090 -
9.0512 72500 0.0041
9.1136 73000 0.0042
9.1760 73500 0.0041
9.2385 74000 0.0040
9.3009 74500 0.0041
9.3633 75000 0.0041
9.4257 75500 0.0041
9.4881 76000 0.0041
9.5506 76500 0.0041
9.6130 77000 0.0041
9.6754 77500 0.0042
9.7378 78000 0.0041
9.8002 78500 0.0041
9.8627 79000 0.0041
9.9251 79500 0.0041
9.9875 80000 0.0041
10.0 80100 -
  • The bold row denotes the saved checkpoint.

Training Time

  • Training: 6.8 hours
  • Evaluation: 44.3 seconds
  • Total: 6.8 hours

Framework Versions

  • Python: 3.12.4
  • Sentence Transformers: 5.5.1
  • Transformers: 5.11.0
  • PyTorch: 2.5.1+cu121
  • Accelerate: 1.13.0
  • Datasets: 2.21.0
  • Tokenizers: 0.22.2

Citation

BibTeX

Sentence Transformers

@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",
}
Downloads last month
34
Safetensors
Model size
4.39M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for swardiantara/bert-tiny-amazon_reviews-k10-fixed-cosine

Finetuned
(120)
this model

Paper for swardiantara/bert-tiny-amazon_reviews-k10-fixed-cosine