Team Ai
Modelpublic

Nutanix/jina-embeddings-v2-base-code-mbpp

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes91downloads
Model Card

SentenceTransformer based on jinaai/jina-embeddings-v2-base-code

This is a sentence-transformers model finetuned from jinaai/jina-embeddings-v2-base-code. 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: jinaai/jina-embeddings-v2-base-code <!-- at revision fa8baa2e34f0fe28aae07f9bd7bcd1215de41dce -->
  • —Maximum Sequence Length: 8192 tokens
  • —Output Dimensionality: 768 tokens
  • —Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: BertModel 
  (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:

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("Nutanix/jina-embeddings-v2-base-code-mbpp")
# Run inference
sentences = [
    'Write a function to find sum and average of first n natural numbers.',
    'def sum_average(number):\r\n total = 0\r\n for value in range(1, number + 1):\r\n    total = total + value\r\n average = total / number\r\n return (total,average)',
    'def long_words(n, str):\r\n    word_len = []\r\n    txt = str.split(" ")\r\n    for x in txt:\r\n        if len(x) > n:\r\n            word_len.append(x)\r\n    return word_len\t',
]
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]

<!--

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. -->

Evaluation

Metrics

Triplet
MetricValue
cosine_accuracy0.4795
dot_accuracy0.3189
manhattan_accuracy0.4905
euclidean_accuracy0.4795
max_accuracy0.4905

<!--

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 Hyperparameters

Non-Default Hyperparameters
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —num_train_epochs: 1
  • —warmup_ratio: 0.1
  • —fp16: True
  • —batch_sampler: no_duplicates
All Hyperparameters

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

  • —overwrite_output_dir: False
  • —do_predict: False
  • —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
  • —learning_rate: 5e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 1
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —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
  • —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: True
  • —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}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'gradientaccumulation_kwargs': 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: False
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —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
  • —dispatch_batches: None
  • —split_batches: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

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

EpochStepTraining Losssts-dev_max_accuracy
00-0.5027
0.00501005.0-
0.01012005.0-
0.01513004.9999-
0.02024005.0001-
0.02525005.0-
0.03026005.0-
0.03537004.9999-
0.04038005.0001-
0.04539005.0-
0.050410005.0001-
0.055411004.9999-
0.060512005.0-
0.065513005.0-
0.070514004.9999-
0.075615005.0-
0.080616004.9999-
0.085717005.0001-
0.090718005.0001-
0.095719005.0-
0.100820005.0001-
0.105821005.0-
0.110922004.9999-
0.115923004.9999-
0.120924005.0-
0.126025005.0-
0.131026005.0001-
0.136027004.9999-
0.141128005.0001-
0.146129005.0001-
0.151230005.0-
0.156231005.0001-
0.161232004.9999-
0.166333005.0001-
0.171334004.9999-
0.176435004.9999-
0.181436004.9999-
0.186437005.0-
0.191538004.9999-
0.196539005.0-
0.201640005.0-
0.206641005.0-
0.211642005.0002-
0.216743005.0002-
0.221744005.0-
0.226745005.0001-
0.231846005.0001-
0.236847005.0001-
0.241948004.9998-
0.246949005.0-
0.251950004.9999-
0.257051004.9999-
0.262052005.0001-
0.267153005.0001-
0.272154004.9999-
0.277155005.0-
0.282256005.0002-
0.287257005.0002-
0.292358004.9999-
0.297359005.0-
0.302360005.0001-
0.307461004.9999-
0.312462004.9997-
0.317463004.9999-
0.322564005.0-
0.327565004.9998-
0.332666005.0-
0.337667004.9998-
0.342668005.0001-
0.347769005.0002-
0.352770005.0-
0.357871004.9998-
0.362872005.0003-
0.367873005.0-
0.372974005.0002-
0.377975005.0-
0.382976005.0001-
0.388077005.0002-
0.393078005.0001-
0.398179005.0001-
0.403180005.0-
0.408181004.9998-
0.413282004.9999-
0.418283005.0001-
0.423384005.0001-
0.428385005.0-
0.433386005.0002-
0.438487005.0001-
0.443488005.0-
0.448589004.9996-
0.453590004.9999-
0.458591005.0-
0.463692004.9999-
0.468693004.9999-
0.473694004.9998-
0.478795005.0001-
0.483796004.9998-
0.488897004.9999-
0.493898005.0-
0.498899004.9998-
0.5039100005.0-
0.5089101005.0002-
0.5140102005.0003-
0.5190103004.9998-
0.5240104004.9999-
0.5291105005.0-
0.5341106004.9999-
0.5392107005.0-
0.5442108005.0001-
0.5492109004.9999-
0.5543110005.0-
0.5593111004.9999-
0.5643112005.0-
0.5694113004.9999-
0.5744114004.9997-
0.5795115005.0002-
0.5845116004.9999-
0.5895117005.0001-
0.5946118005.0001-
0.5996119005.0004-
0.6047120004.9998-
0.6097121005.0002-
0.6147122004.9998-
0.6198123005.0001-
0.6248124005.0001-
0.6298125005.0001-
0.6349126004.9999-
0.6399127005.0001-
0.6450128004.9999-
0.6500129005.0001-
0.6550130004.9999-
0.6601131005.0002-
0.6651132005.0001-
0.6702133005.0002-
0.6752134004.9997-
0.6802135005.0001-
0.6853136004.9996-
0.6903137004.9999-
0.6954138005.0002-
0.7004139004.9997-
0.7054140005.0-
0.7105141005.0001-
0.7155142005.0001-
0.7205143004.9999-
0.7256144004.9999-
0.7306145004.9998-
0.7357146005.0-
0.7407147005.0002-
0.7457148005.0001-
0.7508149004.9998-
0.7558150005.0002-
0.7609151005.0002-
0.7659152005.0-
0.7709153005.0002-
0.7760154005.0-
0.7810155005.0001-
0.7861156005.0-
0.7911157005.0004-
0.7961158005.0-
0.8012159005.0001-
0.8062160005.0003-
0.8112161004.9999-
0.8163162005.0-
0.8213163004.9999-
0.8264164005.0-
0.8314165004.9999-
0.8364166004.9998-
0.8415167004.9998-
0.8465168005.0002-
0.8516169004.9999-
0.8566170004.9999-
0.8616171004.9997-
0.8667172005.0001-
0.8717173004.9999-
0.8768174005.0001-
0.8818175004.9999-
0.8868176005.0001-
0.8919177005.0001-
0.8969178005.0001-
0.9019179004.9996-
0.9070180005.0001-
0.9120181004.9997-
0.9171182005.0001-
0.9221183004.9998-
0.9271184004.9997-
0.9322185004.9999-
0.9372186005.0001-
0.9423187005.0004-
0.9473188004.9997-
0.9523189004.9999-
0.9574190005.0001-
0.9624191004.9999-
0.9674192005.0-
0.9725193004.9999-
0.9775194004.9999-
0.9826195004.9999-
0.9876196004.9998-
0.9926197005.0-
0.9977198004.9999-
1.019846-0.4905

</details>

Framework Versions

  • —Python: 3.10.14
  • —Sentence Transformers: 3.0.1
  • —Transformers: 4.40.0
  • —PyTorch: 2.3.0+cu121
  • —Accelerate: 0.33.0
  • —Datasets: 2.20.0
  • —Tokenizers: 0.19.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",
}
TripletLoss
bibtex
@misc{hermans2017defense,
    title={In Defense of the Triplet Loss for Person Re-Identification}, 
    author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
    year={2017},
    eprint={1703.07737},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

<!--

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. -->