CoolFace
Modelpublic

ronit01/final_golden_rag_tuned_minilm_contrastive_50epoch

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes82downloads
Model Card

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

This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: sentence-transformers/all-MiniLM-L6-v2 <!-- at revision c9745ed1d9f207416be6d2e6f8de32d1f16199bf -->
  • —Maximum Sequence Length: 256 tokens
  • —Output Dimensionality: 384 dimensions
  • —Similarity Function: Cosine Similarity
  • —Supported Modality: Text <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

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:

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("ronit01/final_golden_rag_tuned_minilm_contrastive_50epoch")
# Run inference
sentences = [
    'What are the two knob set generators currently supported by RapidFire AI for creating multi-config specifications?',
    'RapidFire AI offers a browser-based dashboard to automatically visualize all ML metrics and lets \nyou control runs on the fly from there. \nOur current default dashboard is a fork of the popular OSS tool `MLflow <https://mlflow.org/>`__, \nand it inherits much of MLflow\'s native features.\nThe dashboard URI is printed when the rapidfireai server is started; open it in a browser. \n\nAs of this writing, apart from MLflow, RapidFire AI also supports \n`TensorBoard  <https://www.tensorflow.org/tensorboard>`__\nand `Trackio <https://huggingface.co/docs/trackio/en/index>`__\nfor logging metrics plots. \nSpecify any one, two, or all three dashboards to use with the following server start argument. \n\n.. code-block:: bash\n\n   rapidfireai start --tracking-backends [mlflow | tensorboard | trackio]\n\nAlternatively, set the dashboard using its environment variable as below in your python code/notebook:\n\n.. code-block:: python\n\n   os.environ["RF_MLFLOW_ENABLED"] = "true"\n   os.environ["RF_TENSORBOARD_ENABLED"] = "true"\n   os.environ["RF_TRACKIO_ENABLED"] = "true"\n\nSupport for other popular dashboards such as Weights & Biases and CometML is coming soon. \nThe rest of this section explains the new features of our MLflow-fork dashboard.\nNote that these new features are not yet available on the other dashboards.',
    'Compute Metrics Function\n------\n\nOptional user-provided function specifying custom evaluation metrics based on the generated \noutputs and ground truth.\n\nIt is passed to the :code:`compute_metrics` argument of :class:`RFModelConfig`. \nAlso read: :doc:`the LoRA and Model Configs page</models>`.\nYou can create multiple variants of these functions and pass them all as a single \n:code:`List` to your :class:`RFModelConfig` to create a multi-config specification.\n\nThis function is invoked by the underlying HF trainer at a cadence controlled by the \n:code:`eval_strategy` and :code:`eval_steps` arguments.\nAlso read: :doc:`the Trainer Configs page</trainers>`.\n\n.. py:function:: fit.compute_metrics_fn(eval_preds: Tuple) -> Dict[str, float]\n\n   :param eval_preds: Tuple containing generated predictions and ground truth labels from the eval dataset.\n   :type eval_preds: Tuple[List[str], List[str]]\n\n   :return: Dictionary with user-defined metrics with names keys and numbers as values\n   :rtype: Dict[str, float]\n\n\n**Example:**\n\n.. code-block:: python\n\n\t# From the SFT tutorial notebook\n\tdef sample_compute_metrics(eval_preds):  \n\t\t"""Optional function to compute eval metrics based on predictions and labels"""\n\t\tpredictions, labels = eval_preds\n\n\t\t# Standard text-based eval metrics: Rouge and BLEU\n\t\timport evaluate\n\t\trouge = evaluate.load("rouge")\n\t\tbleu = evaluate.load("bleu")\n\n\t\trouge_output = rouge.compute(predictions=predictions, references=labels, use_stemmer=True)\n\t\trouge_l = rouge_output["rougeL"]\n\t\tbleu_output = bleu.compute(predictions=predictions, references=labels)\n\t\tbleu_score = bleu_output["bleu"]\n\n\t\treturn {"rougeL": round(rouge_l, 4), "bleu": round(bleu_score, 4)}',
]
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.3398, 0.4086],
#         [0.3398, 1.0000, 0.6458],
#         [0.4086, 0.6458, 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: 276 training samples
  • —Columns: <code>sentence0</code>, <code>sentence1</code>, and <code>label</code>
  • —Approximate statistics based on the first 276 samples: | | sentence0 | sentence1 | label | |:--------|:-----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 11 tokens</li><li>mean: 30.57 tokens</li><li>max: 48 tokens</li></ul> | <ul><li>min: 64 tokens</li><li>mean: 231.63 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.17</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence0 | sentence1 | label | |:--------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| | <code>How do you select specific GPUs for RapidFire AI to use, and how do you resolve port conflicts when starting the server?</code> | <code>Port conflicts (services already running)<br>----------------------------------------<br><br>If you encounter port conflicts, you can kill existing processes.<br><br>.. code-block:: bash<br><br> lsof -t -i:8852 \| xargs kill -9 # mlflow<br> lsof -t -i:8851 \| xargs kill -9 # dispatcher<br> lsof -t -i:8853 \| xargs kill -9 # frontend server<br><br>Select specific GPU(s) to use<br>-----------------------------<br><br>Set the `CUDA_VISIBLE_DEVICES environment variable BEFORE running rapidfireai start` to control which GPU(s) RapidFire can see and use.<br><br>.. code-block:: bash<br><br> export CUDAVISIBLEDEVICES=2 # use GPU index 2 only<br> rapidfireai start<br><br>Multiple GPUs (example: GPUs 0 and 2):<br><br>.. code-block:: bash<br><br> export CUDAVISIBLEDEVICES=0,2<br> rapidfireai start<br><br>From a Python script (set before importing/starting RapidFire):<br><br>.. code-block:: python<br><br> import os<br> os.environ["CUDAVISIBLEDEVICES"] = "2"<br> # then start your RapidFire workflow<br></code> | <code>1.0</code> | | <code>How do you install and initialize RapidFire AI for fine-tuning workflows, and what steps are required to access gated Hugging Face models?</code> | <code>Eval Accumulate Metrics Function ----------------------------

Optional user-provided function to aggregate algebraic eval metrics across all batches of the data. If this function is not provided, all metrics returned by :func:eval.compute_metrics_fn() will be assumed to be distributive (i.e., summed across batches) by default. Use this function when metrics require (weighted) averaging or other custom dataset-wide aggregation logic.

It is invoked once at the very end of the evaluation process after all batches have been processed. Pass it directly to the :code:accumulate_metrics_fn key in your eval config dictionary.

.. py:function:: eval.accumulatemetricsfn(aggregated_metrics: dict[str, list[dict[str, Any]]]) -> dict[str, dict[str, Any]]

:param aggregatedmetrics: Dictionary with a metric's name as key and a list of per-batch metric dictionaries as values from across all data batches. Inside each value dictionary, at least the reserved key :code:`"value"` will exist t...</code> | <code>0.0</code> | | <code>What are the two knob set generators currently supported by RapidFire AI for creating multi-config specifications?</code> | <code>RapidFire AI offers a browser-based dashboard to automatically visualize all ML metrics and lets you control runs on the fly from there. Our current default dashboard is a fork of the popular OSS tool `MLflow <https://mlflow.org/>`_, and it inherits much of MLflow's native features. The dashboard URI is printed when the rapidfireai server is started; open it in a browser.

As of this writing, apart from MLflow, RapidFire AI also supports TensorBoard <https://www.tensorflow.org/tensorboard>_ and `Trackio <https://huggingface.co/docs/trackio/en/index>`_ for logging metrics plots. Specify any one, two, or all three dashboards to use with the following server start argument.

.. code-block:: bash

rapidfireai start --tracking-backends [mlflow | tensorboard | trackio]

Alternatively, set the dashboard using its environment variable as below in your python code/notebook:

.. code-block:: python

os.environ["RFMLFLOWENABLED"] = "true" os.environ["RFTENSORBOARDENABLED...</code> | <code>0.0</code> |

json
  {
      "distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE",
      "margin": 0.5,
      "size_average": true
  }

Training Hyperparameters

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

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

  • —do_predict: False
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —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: 50
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: None
  • —warmup_ratio: None
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —enable_jit_checkpoint: False
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —use_cpu: False
  • —seed: 42
  • —data_seed: None
  • —bf16: False
  • —fp16: False
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: -1
  • —ddp_backend: None
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamwtorchfused
  • —optim_args: None
  • —group_by_length: False
  • —length_column_name: length
  • —project: huggingface
  • —trackio_space_id: trackio
  • —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
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —hub_revision: None
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —include_num_input_tokens_seen: no
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: True
  • —use_cache: False
  • —prompts: None
  • —batch_sampler: batch_sampler
  • —multi_dataset_batch_sampler: round_robin
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining Loss
27.77785000.0028

Training Time

  • —Training: 2.5 minutes

Framework Versions

  • —Python: 3.12.13
  • —Sentence Transformers: 5.4.1
  • —Transformers: 5.0.0
  • —PyTorch: 2.10.0+cu128
  • —Accelerate: 1.13.0
  • —Datasets: 4.0.0
  • —Tokenizers: 0.22.2

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",
}
ContrastiveLoss
bibtex
@inproceedings{hadsell2006dimensionality,
    author={Hadsell, R. and Chopra, S. and LeCun, Y.},
    booktitle={2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'06)},
    title={Dimensionality Reduction by Learning an Invariant Mapping},
    year={2006},
    volume={2},
    number={},
    pages={1735-1742},
    doi={10.1109/CVPR.2006.100}
}

<!--

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