metadata
language:
- en
license: apache-2.0
library_name: sentence-transformers
datasets:
- davanstrien/similarity-dataset-sc2-8b
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dataset_size:n<1K
- loss:MultipleNegativesRankingLoss
base_model: microsoft/mpnet-base
metrics:
- cosine_accuracy
- dot_accuracy
- manhattan_accuracy
- euclidean_accuracy
- max_accuracy
widget:
- source_sentence: >-
Write a Python function that counts the number of even numbers in a given
list of integers or floats
sentences:
- >-
Write a Python function that returns the number of even numbers in a
list.
- >-
Create a Python function that adds up all the numbers in a given list.
The function should support lists containing only positive integers.
- >-
Write a Python function that converts a JSON string into a Python
dictionary using the json module and returns it.
- source_sentence: >-
Develop a Python function to validate whether a given string represents a
valid IPv4 address or not.
sentences:
- >-
Create a Python function to validate a string `s` as an IPv4 address.
The function should return `True` if `s` is a valid IPv4 address, and
`False` otherwise.
- >-
Write a Python function to find the key with the highest value in a
dictionary. The function should return the value of the key if it exists
- >-
Write a Python function that, given a dictionary `d` and an integer `k`,
returns the sum of the values of the first `k` keys in `d`.
- source_sentence: >-
Write a Python function to create a list of numbers with exactly one even
number and n-1 odd numbers
sentences:
- >-
Write a Python function that returns the number of even numbers in a
list.
- >-
Write a Python function that recursively traverses a given folder
structure and returns the absolute path of all files that end with
".txt".
- >-
Write a Python decorator function that overrides the docstring of the
decorated function, and stores the old docstring and other metadata in a
`_doc_metadata` attribute of the function.
- source_sentence: >-
Implement a Python function that prints the first character of a string
using its indexing feature.
sentences:
- >-
Write a Python function that takes a string as a parameter and returns
the first character of the string.
- >-
Write a Python function that checks if the bit at position `bit` is set
in the given `integer`. This function should return a boolean value.
- >-
Write a Python function `floor_division(x: int, y: int) -> int` that
divides two integers `x` and `y` and returns the largest whole number
less than or equal to the result.
- source_sentence: >-
Write a Python function that takes a MIDI note number and returns the
corresponding piano key number.
sentences:
- >-
Create a Python function that translates MIDI note numbers into piano
key numbers, facilitating music generation.
- >-
Write a Python function that accepts a dictionary and returns a set of
distinct values. If a key maps to an empty list, return an empty set.
- >-
Write a Python function `join_strings_with_comma(lst)` that takes a list
of strings and returns a single string with all the strings from the
list, separated by commas.
pipeline_tag: sentence-similarity
co2_eq_emissions:
emissions: 2.213004168952992
energy_consumed: 0.006336878829164133
source: codecarbon
training_type: fine-tuning
on_cloud: false
cpu_model: Intel(R) Xeon(R) CPU @ 2.20GHz
ram_total_size: 62.804237365722656
hours_used: 0.049
hardware_used: 1 x NVIDIA L4
model-index:
- name: MPNet base trained on AllNLI triplets
results:
- task:
type: triplet
name: Triplet
dataset:
name: code similarity dev
type: code-similarity-dev
metrics:
- type: cosine_accuracy
value: 0.934010152284264
name: Cosine Accuracy
- type: dot_accuracy
value: 0.07106598984771574
name: Dot Accuracy
- type: manhattan_accuracy
value: 0.934010152284264
name: Manhattan Accuracy
- type: euclidean_accuracy
value: 0.9390862944162437
name: Euclidean Accuracy
- type: max_accuracy
value: 0.9390862944162437
name: Max Accuracy
- task:
type: triplet
name: Triplet
dataset:
name: Unknown
type: unknown
metrics:
- type: cosine_accuracy
value: 0.934010152284264
name: Cosine Accuracy
- type: dot_accuracy
value: 0.07106598984771574
name: Dot Accuracy
- type: manhattan_accuracy
value: 0.934010152284264
name: Manhattan Accuracy
- type: euclidean_accuracy
value: 0.9390862944162437
name: Euclidean Accuracy
- type: max_accuracy
value: 0.9390862944162437
name: Max Accuracy
MPNet base trained on AllNLI triplets
This is a sentence-transformers model finetuned from microsoft/mpnet-base. 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.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: microsoft/mpnet-base
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 tokens
- Similarity Function: Cosine Similarity
- Language: en
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: 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})
)
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("davanstrien/code-prompt-similarity-model")
# Run inference
sentences = [
'Write a Python function that takes a MIDI note number and returns the corresponding piano key number.',
'Create a Python function that translates MIDI note numbers into piano key numbers, facilitating music generation.',
'Write a Python function that accepts a dictionary and returns a set of distinct values. If a key maps to an empty list, return an empty set.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Triplet
- Dataset:
code-similarity-dev
- Evaluated with
TripletEvaluator
Metric | Value |
---|---|
cosine_accuracy | 0.934 |
dot_accuracy | 0.0711 |
manhattan_accuracy | 0.934 |
euclidean_accuracy | 0.9391 |
max_accuracy | 0.9391 |
Triplet
- Evaluated with
TripletEvaluator
Metric | Value |
---|---|
cosine_accuracy | 0.934 |
dot_accuracy | 0.0711 |
manhattan_accuracy | 0.934 |
euclidean_accuracy | 0.9391 |
max_accuracy | 0.9391 |
Training Details
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 16per_device_eval_batch_size
: 16num_train_epochs
: 10warmup_ratio
: 0.1bf16
: Truebatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 16per_device_eval_batch_size
: 16per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 1eval_accumulation_steps
: Nonelearning_rate
: 5e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 10max_steps
: -1lr_scheduler_type
: linearlr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_steps
: 0log_level
: passivelog_level_replica
: warninglog_on_each_node
: Truelogging_nan_inf_filter
: Truesave_safetensors
: Truesave_on_each_node
: Falsesave_only_model
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 42data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Truefp16
: Falsefp16_opt_level
: O1half_precision_backend
: autobf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 0dataloader_prefetch_factor
: Nonepast_index
: -1disable_tqdm
: Falseremove_unused_columns
: Truelabel_names
: Noneload_best_model_at_end
: Falseignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap
: Noneaccelerator_config
: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torchoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_find_unused_parameters
: Noneddp_bucket_cap_mb
: Noneddp_broadcast_buffers
: Falsedataloader_pin_memory
: Truedataloader_persistent_workers
: Falseskip_memory_metrics
: Trueuse_legacy_prediction_loop
: Falsepush_to_hub
: Falseresume_from_checkpoint
: Nonehub_model_id
: Nonehub_strategy
: every_savehub_private_repo
: Falsehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseeval_do_concat_batches
: Truefp16_backend
: autopush_to_hub_model_id
: Nonepush_to_hub_organization
: Nonemp_parameters
:auto_find_batch_size
: Falsefull_determinism
: Falsetorchdynamo
: Noneray_scope
: lastddp_timeout
: 1800torch_compile
: Falsetorch_compile_backend
: Nonetorch_compile_mode
: Nonedispatch_batches
: Nonesplit_batches
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falsebatch_sampler
: no_duplicatesmulti_dataset_batch_sampler
: proportional
Training Logs
Epoch | Step | Training Loss | loss | code-similarity-dev_max_accuracy | max_accuracy |
---|---|---|---|---|---|
0 | 0 | - | - | 0.8680 | - |
2.0 | 100 | 0.6379 | 0.1845 | 0.9340 | - |
4.0 | 200 | 0.0399 | 0.1577 | 0.9543 | - |
6.0 | 300 | 0.0059 | 0.1577 | 0.9543 | - |
8.0 | 400 | 0.0018 | 0.1662 | 0.9492 | - |
10.0 | 500 | 0.0009 | 0.1643 | 0.9391 | 0.9391 |
Environmental Impact
Carbon emissions were measured using CodeCarbon.
- Energy Consumed: 0.006 kWh
- Carbon Emitted: 0.002 kg of CO2
- Hours Used: 0.049 hours
Training Hardware
- On Cloud: No
- GPU Model: 1 x NVIDIA L4
- CPU Model: Intel(R) Xeon(R) CPU @ 2.20GHz
- RAM Size: 62.80 GB
Framework Versions
- Python: 3.10.12
- Sentence Transformers: 3.0.0
- Transformers: 4.41.1
- PyTorch: 2.3.0+cu121
- Accelerate: 0.30.1
- Datasets: 2.19.1
- Tokenizers: 0.19.1
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",
}
MultipleNegativesRankingLoss
@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}
}