SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2

This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2 on the codesearchnet dataset. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: sentence-transformers/all-MiniLM-L6-v2
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 384 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modality: Text
  • Training Dataset:
    • codesearchnet

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': 384, 'pooling_mode': 'mean', 'include_prompt': True})
  (2): Normalize({})
)

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("Kodikalaiyarasan/all-MiniLM-L6-v2-tech-code-search")
# Run inference
sentences = [
    'Associations labels getter.\n\n@param \\Cake\\Datasource\\RepositoryInterface $table Table instance\n@return mixed[]',
    'public function getAssociationLabels(RepositoryInterface $table) : array\n    {\n        /** @var \\Cake\\ORM\\Table */\n        $table = $table;\n\n        $result = [];\n        foreach ($table->associations() as $association) {\n            if (!in_array($association->type(), $this->searchableAssociations)) {\n                continue;\n            }\n\n            $result[$association->getName()] = Inflector::humanize(current((array)$association->getForeignKey()));\n        }\n\n        return $result;\n    }',
    'public function setGender(\\Innova\\LexiconBundle\\Entity\\Gender $gender = null)\n    {\n        $this->gender = $gender;\n\n        return $this;\n    }',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.7968, 0.2078],
#         [0.7968, 1.0000, 0.2351],
#         [0.2078, 0.2351, 1.0000]])

Training Details

Training Dataset

codesearchnet

  • Dataset: codesearchnet
  • Size: 5,000 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 100 samples:
    anchor positive
    type string string
    modality text text
    details
    • min: 5 tokens
    • mean: 31.45 tokens
    • max: 94 tokens
    • min: 29 tokens
    • mean: 129.63 tokens
    • max: 256 tokens
  • Samples:
    anchor positive
    Computes the new parent id for the node being moved.

    @return int
    protected function parentId()
    {
    switch ( $this->position )
    {
    case 'root':
    return null;

    case 'child':
    return $this->target->getKey();

    default:
    return $this->target->getParentId();
    }
    }
    // SetWinSize overwrites the playlist's window size. func (p *MediaPlaylist) SetWinSize(winsize uint) error {
    if winsize > p.capacity {
    return errors.New("capacity must be greater than winsize or equal")
    }
    p.winsize = winsize
    return nil
    }
    Show the sidebar and squish the container to make room for the sidebar.
    If hideOthers is true, hide other open sidebars.
    function() {
    var options = this.options;

    if (options.hideOthers) {
    this.secondary.each(function() {
    var sidebar = $(this);

    if (sidebar.hasClass('is-expanded')) {
    sidebar.toolkit('offCanvas', 'hide');
    }
    });
    }

    this.fireEvent('showing');

    this.container.addClass('move-' + this.opposite);

    this.element
    .reveal()
    .addClass('is-expanded')
    .aria('expanded', true);

    if (options.stopScroll) {
    $('body').addClass('no-scroll');
    }

    this.fireEvent('shown');
    }
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "gather_across_devices": false,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 16
  • warmup_steps: 0.1
  • fp16: True

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 16
  • num_train_epochs: 3
  • max_steps: -1
  • learning_rate: 5e-05
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_steps: 0.1
  • optim: adamw_torch_fused
  • 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: True
  • 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: False
  • 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
  • dataloader_multiprocessing_context: None
  • dataloader_in_order: True
  • 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
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}
  • warmup_ratio: None

Training Logs

Epoch Step Training Loss
0.1597 50 0.2163
0.3195 100 0.1601
0.4792 150 0.1289
0.6390 200 0.1498
0.7987 250 0.1697
0.9585 300 0.1491
1.1182 350 0.0636
1.2780 400 0.0428
1.4377 450 0.0546
1.5974 500 0.0485
1.7572 550 0.0594
1.9169 600 0.0463
2.0767 650 0.0256
2.2364 700 0.0157
2.3962 750 0.0250
2.5559 800 0.0378
2.7157 850 0.0153
2.8754 900 0.0237

Training Time

  • Training: 3.9 minutes

Framework Versions

  • Python: 3.13.16
  • Sentence Transformers: 5.7.0
  • Transformers: 5.20.2
  • PyTorch: 2.11.0+cu130
  • Accelerate: 1.15.0
  • Datasets: 4.8.5
  • Tokenizers: 0.23.3

Additional Resources

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{oord2019representationlearningcontrastivepredictive,
      title={Representation Learning with Contrastive Predictive Coding},
      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
      year={2019},
      eprint={1807.03748},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1807.03748},
}
Downloads last month
49
Safetensors
Model size
22.7M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Kodikalaiyarasan/all-MiniLM-L6-v2-tech-code-search

Finetuned
(1,172)
this model
Finetunes
1 model

Papers for Kodikalaiyarasan/all-MiniLM-L6-v2-tech-code-search