Views
No views yet
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({})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("ronit01/final_golden_rag_tuned_minilm_contrastive_100epoch")
5# Run inference
6sentences = [
7 'How does RFPromptManager select few-shot examples for each input query?',
8 'Stop\n----\n\nThis IC Op earmarks a run to be stopped at the end of its current chunk. \nIt will still be alive but it will not use any GPU resources from the next chunk. \nYou will still see its minibatch-level plots advancing for the current chunk. \nYou cannot stop an already stopped or deleted run. \n\n\n.. raw:: html\n\n <img src="_static/icop-stop2.png" alt="IC Op Stop" \n style="cursor: zoom-in; max-width: 100%;" onclick="this.requestFullscreen()">\n\n <img src="_static/icop-stop.png" alt="IC Op Stop" \n style="cursor: zoom-in; max-width: 100%;" onclick="this.requestFullscreen()">\n',
9 'Eval Compute Metrics Function\n-------------------------\n\nMandatory user-provided function to compute eval metrics on a given batch of (postprocessed) examples, \nwhich is injected by the system. \nIt should return metrics computed over the batch as a whole. \n\nIt is invoked for each batch during the evaluation process after generation and postprocessing (if applicable). \nPass it directly to the :code:`compute_metrics_fn` key in your eval config dictionary.\n\n\n.. py:function:: eval.compute_metrics_fn(batch: dict[str, list]) -> dict[str, dict[str, Any]]\n\n :param batch: Dictionary containing a batch of examples, including all preprocessed fields, generated outputs, and any postprocessed fields\n :type batch: dict[str, list]\n\n :return: Dictionary with a metric\'s name as key and a dictionary as value inside which a reserved key :code:`"value"` must exist with that corresponding metric\'s value over this batch of examples.\n :rtype: dict[str, dict[str, Any]]\n\n\n**Example:**\n\n.. code-block:: python\n\n # Example 1 from FiQA use case: Metrics on retrieval accuracy\n def sample_compute_metrics_fn(batch: Dict[str, list]) -> Dict[str, Dict[str, Any]]:\n\t\t"""Function to compute all eval metrics based on retrievals and/or generations"""\n\n\t\ttrue_positives, precisions, recalls, f1_scores, ndcgs, rrs = 0, [], [], [], [], []\n\t\ttotal_queries = len(batch["query"])\n\n\t\tfor pred, gt in zip(batch["retrieved_documents"], batch["ground_truth_documents"]):\n\t\t\texpected_set = set(gt)\n\t\t\tretrieved_set = set(pred)\n\n\t\t\ttrue_positives = len(expected_set.intersection(retrieved_set))\n\t\t\tprecision = true_positives / len(retrieved_set) if len(retrieved_set) > 0 else 0\n\t\t\trecall = true_positives / len(expected_set) if len(expected_set) > 0 else 0\n\t\t\tf1 = (\n\t\t\t\t2 * precision * recall / (precision + recall)\n\t\t\t\tif (precision + recall) > 0\n\t\t\t\telse 0\n\t\t\t)\n\n\t\t\tprecisions.append(precision)\n\t\t\trecalls.append(recall)\n\t\t\tf1_scores.append(f1)\n\t\t\tndcgs.append(compute_ndcg_at_k(retrieved_set, expected_set, k=5))\n\t\t\trrs.append(compute_rr(retrieved_set, expected_set))\n\n\t\treturn {\n\t\t\t"Total": {"value": total_queries},\n\t\t\t"Precision": {"value": sum(precisions) / total_queries},\n\t\t\t"Recall": {"value": sum(recalls) / total_queries},\n\t\t\t"F1 Score": {"value": sum(f1_scores) / total_queries},\n\t\t\t"NDCG@5": {"value": sum(ndcgs) / total_queries},\n\t\t\t"MRR": {"value": sum(rrs) / total_queries},\n\t\t}\n\n.. code-block:: python\n\n # Example 2 from GSM8K use case: Direct answer correctness check\n def sample_compute_metrics_fn(batch: dict[str, list]) -> dict[str, dict[str, Any]]:\n """Function to compute all eval metrics based on retrievals and/or generations"""\n\n correct = sum(\n 1\n for pred, gt in zip(batch["model_answer"], batch["ground_truth"])\n if pred == gt\n )\n total = len(batch["model_answer"])\n return {\n "Correct": {"value": correct},\n "Total": {"value": total},\n }',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 384]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities)
18# tensor([[1.0000, 0.4287, 0.3777],
19# [0.4287, 1.0000, 0.3455],
20# [0.3777, 0.3455, 1.0000]])sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
How do you install and initialize RapidFire AI for fine-tuning workflows, and what steps are required to access gated Hugging Face models? | Eval Accumulate Metrics Function |
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.accumulate_metrics_fn key in your eval config dictionary."value" will exist t... | 0.0 |
| What are all the parameters accepted by the RFOpenAIAPIModelConfig class, and what does each one configure? | Clone-Modify
[object Object]
[object Object]You can also [object Object] a clone using its parent's weights if you'd like.
Warm-started clones inherit their parent's learning behavior so far and thus, they can reach better
eval metrics faster.
Note that warm starting is only allowed if t... | 0.0 |
| What rate limiting parameters does RFOpenAIAPIModelConfig provide, and why are they needed? | RapidFire AI transforms the status quo by adapting the powerful idea of [object Object]
from database systems research to LLM evals.
Our adaptive execution engine, :doc:[object Object], automatically
shards the data and processes multiple configs in parallel, one shard at a time, with
efficient swapping techniques.
[object Object]
[object Object]
[object Object].. list-table::
:widths: 50 50
:class... | 0.0 |ContrastiveLoss with these parameters:1{
2 "distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE",
3 "margin": 0.5,
4 "size_average": true
5}per_device_train_batch_size: 16per_device_eval_batch_size: 16num_train_epochs: 100multi_dataset_batch_sampler: round_robindo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 100max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': 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: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 27.7778 | 500 | 0.0025 |
| 55.5556 | 1000 | 0.0008 |
| 83.3333 | 1500 | 0.0007 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@inproceedings{hadsell2006dimensionality,
2 author={Hadsell, R. and Chopra, S. and LeCun, Y.},
3 booktitle={2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'06)},
4 title={Dimensionality Reduction by Learning an Invariant Mapping},
5 year={2006},
6 volume={2},
7 number={},
8 pages={1735-1742},
9 doi={10.1109/CVPR.2006.100}
10}