CoolFace
Modelpublic

ManishThota/QueryRouter

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes78downloads
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 semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

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

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 384, '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("ManishThota/QueryRouter")
# Run inference
sentences = [
    'Research',
    'Can you provide the latest research insights on ABC?',
    'Who are the main rivals of ABC?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]

# 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

Semantic Similarity
MetricValue
pearson_cosinenan
spearman_cosinenan
pearson_manhattannan
spearman_manhattannan
pearson_euclideannan
spearman_euclideannan
pearson_dotnan
spearman_dotnan
pearson_maxnan
spearman_maxnan

<!--

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: 724 training samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | score | |:--------|:--------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:--------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 3 tokens</li><li>mean: 3.27 tokens</li><li>max: 4 tokens</li></ul> | <ul><li>min: 9 tokens</li><li>mean: 14.23 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 1.0</li><li>mean: 1.0</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | score | |:--------------------|:-------------------------------------------------|:-----------------| | <code>Rating</code> | <code>What rating does XYZ have?</code> | <code>1.0</code> | | <code>Rating</code> | <code>Can you provide the rating for XYZ?</code> | <code>1.0</code> | | <code>Rating</code> | <code>How is XYZ rated?</code> | <code>1.0</code> |
  • —Loss: <code>CoSENTLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "pairwise_cos_sim"
  }

Evaluation Dataset

Unnamed Dataset
  • —Size: 60 evaluation samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | score | |:--------|:--------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:--------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 3 tokens</li><li>mean: 3.25 tokens</li><li>max: 4 tokens</li></ul> | <ul><li>min: 9 tokens</li><li>mean: 12.48 tokens</li><li>max: 20 tokens</li></ul> | <ul><li>min: 1.0</li><li>mean: 1.0</li><li>max: 1.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | score | |:--------------------|:-------------------------------------------------|:-----------------| | <code>Rating</code> | <code>What is the current rating of ABC?</code> | <code>1.0</code> | | <code>Rating</code> | <code>Can you tell me the rating for ABC?</code> | <code>1.0</code> | | <code>Rating</code> | <code>What rating has ABC been assigned?</code> | <code>1.0</code> |
  • —Loss: <code>CoSENTLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "pairwise_cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: steps
  • —learning_rate: 2e-05
  • —num_train_epochs: 10
  • —warmup_ratio: 0.1
  • —save_only_model: True
  • —seed: 33
  • —fp16: True
  • —load_best_model_at_end: True
All Hyperparameters

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

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 8
  • —per_device_eval_batch_size: 8
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —learning_rate: 2e-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: 10
  • —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: True
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 33
  • —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: True
  • —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, 'nonblocking': False, 'gradientaccumulationkwargs': 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_eval_metrics: False
  • —batch_sampler: batch_sampler
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

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

EpochStepTraining Losslosssts-dev_spearman_cosine
0.02202-0.0nan
0.04404-0.0nan
0.06596-0.0nan
0.08798-0.0nan
0.109910-0.0nan
0.131912-0.0nan
0.153814-0.0nan
0.175816-0.0nan
0.197818-0.0nan
0.219820-0.0nan
0.241822-0.0nan
0.263724-0.0nan
0.285726-0.0nan
0.307728-0.0nan
0.329730-0.0nan
0.351632-0.0nan
0.373634-0.0nan
0.395636-0.0nan
0.417638-0.0nan
0.439640-0.0nan
0.461542-0.0nan
0.483544-0.0nan
0.505546-0.0nan
0.527548-0.0nan
0.549550-0.0nan
0.571452-0.0nan
0.593454-0.0nan
0.615456-0.0nan
0.637458-0.0nan
0.659360-0.0nan
0.681362-0.0nan
0.703364-0.0nan
0.725366-0.0nan
0.747368-0.0nan
0.769270-0.0nan
0.791272-0.0nan
0.813274-0.0nan
0.835276-0.0nan
0.857178-0.0nan
0.879180-0.0nan
0.901182-0.0nan
0.923184-0.0nan
0.945186-0.0nan
0.967088-0.0nan
0.989090-0.0nan
1.011092-0.0nan
1.033094-0.0nan
1.054996-0.0nan
1.076998-0.0nan
1.0989100-0.0nan
1.1209102-0.0nan
1.1429104-0.0nan
1.1648106-0.0nan
1.1868108-0.0nan
1.2088110-0.0nan
1.2308112-0.0nan
1.2527114-0.0nan
1.2747116-0.0nan
1.2967118-0.0nan
1.3187120-0.0nan
1.3407122-0.0nan
1.3626124-0.0nan
1.3846126-0.0nan
1.4066128-0.0nan
1.4286130-0.0nan
1.4505132-0.0nan
1.4725134-0.0nan
1.4945136-0.0nan
1.5165138-0.0nan
1.5385140-0.0nan
1.5604142-0.0nan
1.5824144-0.0nan
1.6044146-0.0nan
1.6264148-0.0nan
1.6484150-0.0nan
1.6703152-0.0nan
1.6923154-0.0nan
1.7143156-0.0nan
1.7363158-0.0nan
1.7582160-0.0nan
1.7802162-0.0nan
1.8022164-0.0nan
1.8242166-0.0nan
1.8462168-0.0nan
1.8681170-0.0nan
1.8901172-0.0nan
1.9121174-0.0nan
1.9341176-0.0nan
1.9560178-0.0nan
1.9780180-0.0nan
2.0182-0.0nan
2.0220184-0.0nan
2.0440186-0.0nan
2.0659188-0.0nan
2.0879190-0.0nan
2.1099192-0.0nan
2.1319194-0.0nan
2.1538196-0.0nan
2.1758198-0.0nan
2.1978200-0.0nan
2.2198202-0.0nan
2.2418204-0.0nan
2.2637206-0.0nan
2.2857208-0.0nan
2.3077210-0.0nan
2.3297212-0.0nan
2.3516214-0.0nan
2.3736216-0.0nan
2.3956218-0.0nan
2.4176220-0.0nan
2.4396222-0.0nan
2.4615224-0.0nan
2.4835226-0.0nan
2.5055228-0.0nan
2.5275230-0.0nan
2.5495232-0.0nan
2.5714234-0.0nan
2.5934236-0.0nan
2.6154238-0.0nan
2.6374240-0.0nan
2.6593242-0.0nan
2.6813244-0.0nan
2.7033246-0.0nan
2.7253248-0.0nan
2.7473250-0.0nan
2.7692252-0.0nan
2.7912254-0.0nan
2.8132256-0.0nan
2.8352258-0.0nan
2.8571260-0.0nan
2.8791262-0.0nan
2.9011264-0.0nan
2.9231266-0.0nan
2.9451268-0.0nan
2.9670270-0.0nan
2.9890272-0.0nan
3.0110274-0.0nan
3.0330276-0.0nan
3.0549278-0.0nan
3.0769280-0.0nan
3.0989282-0.0nan
3.1209284-0.0nan
3.1429286-0.0nan
3.1648288-0.0nan
3.1868290-0.0nan
3.2088292-0.0nan
3.2308294-0.0nan
3.2527296-0.0nan
3.2747298-0.0nan
3.2967300-0.0nan
3.3187302-0.0nan
3.3407304-0.0nan
3.3626306-0.0nan
3.3846308-0.0nan
3.4066310-0.0nan
3.4286312-0.0nan
3.4505314-0.0nan
3.4725316-0.0nan
3.4945318-0.0nan
3.5165320-0.0nan
3.5385322-0.0nan
3.5604324-0.0nan
3.5824326-0.0nan
3.6044328-0.0nan
3.6264330-0.0nan
3.6484332-0.0nan
3.6703334-0.0nan
3.6923336-0.0nan
3.7143338-0.0nan
3.7363340-0.0nan
3.7582342-0.0nan
3.7802344-0.0nan
3.8022346-0.0nan
3.8242348-0.0nan
3.8462350-0.0nan
3.8681352-0.0nan
3.8901354-0.0nan
3.9121356-0.0nan
3.9341358-0.0nan
3.9560360-0.0nan
3.9780362-0.0nan
4.0364-0.0nan
4.0220366-0.0nan
4.0440368-0.0nan
4.0659370-0.0nan
4.0879372-0.0nan
4.1099374-0.0nan
4.1319376-0.0nan
4.1538378-0.0nan
4.1758380-0.0nan
4.1978382-0.0nan
4.2198384-0.0nan
4.2418386-0.0nan
4.2637388-0.0nan
4.2857390-0.0nan
4.3077392-0.0nan
4.3297394-0.0nan
4.3516396-0.0nan
4.3736398-0.0nan
4.3956400-0.0nan
4.4176402-0.0nan
4.4396404-0.0nan
4.4615406-0.0nan
4.4835408-0.0nan
4.5055410-0.0nan
4.5275412-0.0nan
4.5495414-0.0nan
4.5714416-0.0nan
4.5934418-0.0nan
4.6154420-0.0nan
4.6374422-0.0nan
4.6593424-0.0nan
4.6813426-0.0nan
4.7033428-0.0nan
4.7253430-0.0nan
4.7473432-0.0nan
4.7692434-0.0nan
4.7912436-0.0nan
4.8132438-0.0nan
4.8352440-0.0nan
4.8571442-0.0nan
4.8791444-0.0nan
4.9011446-0.0nan
4.9231448-0.0nan
4.9451450-0.0nan
4.9670452-0.0nan
4.9890454-0.0nan
5.0110456-0.0nan
5.0330458-0.0nan
5.0549460-0.0nan
5.0769462-0.0nan
5.0989464-0.0nan
5.1209466-0.0nan
5.1429468-0.0nan
5.1648470-0.0nan
5.1868472-0.0nan
5.2088474-0.0nan
5.2308476-0.0nan
5.2527478-0.0nan
5.2747480-0.0nan
5.2967482-0.0nan
5.3187484-0.0nan
5.3407486-0.0nan
5.3626488-0.0nan
5.3846490-0.0nan
5.4066492-0.0nan
5.4286494-0.0nan
5.4505496-0.0nan
5.4725498-0.0nan
5.49455000.00.0nan
5.5165502-0.0nan
5.5385504-0.0nan
5.5604506-0.0nan
5.5824508-0.0nan
5.6044510-0.0nan
5.6264512-0.0nan
5.6484514-0.0nan
5.6703516-0.0nan
5.6923518-0.0nan
5.7143520-0.0nan
5.7363522-0.0nan
5.7582524-0.0nan
5.7802526-0.0nan
5.8022528-0.0nan
5.8242530-0.0nan
5.8462532-0.0nan
5.8681534-0.0nan
5.8901536-0.0nan
5.9121538-0.0nan
5.9341540-0.0nan
5.9560542-0.0nan
5.9780544-0.0nan
6.0546-0.0nan
6.0220548-0.0nan
6.0440550-0.0nan
6.0659552-0.0nan
6.0879554-0.0nan
6.1099556-0.0nan
6.1319558-0.0nan
6.1538560-0.0nan
6.1758562-0.0nan
6.1978564-0.0nan
6.2198566-0.0nan
6.2418568-0.0nan
6.2637570-0.0nan
6.2857572-0.0nan
6.3077574-0.0nan
6.3297576-0.0nan
6.3516578-0.0nan
6.3736580-0.0nan
6.3956582-0.0nan
6.4176584-0.0nan
6.4396586-0.0nan
6.4615588-0.0nan
6.4835590-0.0nan
6.5055592-0.0nan
6.5275594-0.0nan
6.5495596-0.0nan
6.5714598-0.0nan
6.5934600-0.0nan
6.6154602-0.0nan
6.6374604-0.0nan
6.6593606-0.0nan
6.6813608-0.0nan
6.7033610-0.0nan
6.7253612-0.0nan
6.7473614-0.0nan
6.7692616-0.0nan
6.7912618-0.0nan
6.8132620-0.0nan
6.8352622-0.0nan
6.8571624-0.0nan
6.8791626-0.0nan
6.9011628-0.0nan
6.9231630-0.0nan
6.9451632-0.0nan
6.9670634-0.0nan
6.9890636-0.0nan
7.0110638-0.0nan
7.0330640-0.0nan
7.0549642-0.0nan
7.0769644-0.0nan
7.0989646-0.0nan
7.1209648-0.0nan
7.1429650-0.0nan
7.1648652-0.0nan
7.1868654-0.0nan
7.2088656-0.0nan
7.2308658-0.0nan
7.2527660-0.0nan
7.2747662-0.0nan
7.2967664-0.0nan
7.3187666-0.0nan
7.3407668-0.0nan
7.3626670-0.0nan
7.3846672-0.0nan
7.4066674-0.0nan
7.4286676-0.0nan
7.4505678-0.0nan
7.4725680-0.0nan
7.4945682-0.0nan
7.5165684-0.0nan
7.5385686-0.0nan
7.5604688-0.0nan
7.5824690-0.0nan
7.6044692-0.0nan
7.6264694-0.0nan
7.6484696-0.0nan
7.6703698-0.0nan
7.6923700-0.0nan
7.7143702-0.0nan
7.7363704-0.0nan
7.7582706-0.0nan
7.7802708-0.0nan
7.8022710-0.0nan
7.8242712-0.0nan
7.8462714-0.0nan
7.8681716-0.0nan
7.8901718-0.0nan
7.9121720-0.0nan
7.9341722-0.0nan
7.9560724-0.0nan
7.9780726-0.0nan
8.0728-0.0nan
8.0220730-0.0nan
8.0440732-0.0nan
8.0659734-0.0nan
8.0879736-0.0nan
8.1099738-0.0nan
8.1319740-0.0nan
8.1538742-0.0nan
8.1758744-0.0nan
8.1978746-0.0nan
8.2198748-0.0nan
8.2418750-0.0nan
8.2637752-0.0nan
8.2857754-0.0nan
8.3077756-0.0nan
8.3297758-0.0nan
8.3516760-0.0nan
8.3736762-0.0nan
8.3956764-0.0nan
8.4176766-0.0nan
8.4396768-0.0nan
8.4615770-0.0nan
8.4835772-0.0nan
8.5055774-0.0nan
8.5275776-0.0nan
8.5495778-0.0nan
8.5714780-0.0nan
8.5934782-0.0nan
8.6154784-0.0nan
8.6374786-0.0nan
8.6593788-0.0nan
8.6813790-0.0nan
8.7033792-0.0nan
8.7253794-0.0nan
8.7473796-0.0nan
8.7692798-0.0nan
8.7912800-0.0nan
8.8132802-0.0nan
8.8352804-0.0nan
8.8571806-0.0nan
8.8791808-0.0nan
8.9011810-0.0nan
8.9231812-0.0nan
8.9451814-0.0nan
8.9670816-0.0nan
8.9890818-0.0nan
9.0110820-0.0nan
9.0330822-0.0nan
9.0549824-0.0nan
9.0769826-0.0nan
9.0989828-0.0nan
9.1209830-0.0nan
9.1429832-0.0nan
9.1648834-0.0nan
9.1868836-0.0nan
9.2088838-0.0nan
9.2308840-0.0nan
9.2527842-0.0nan
9.2747844-0.0nan
9.2967846-0.0nan
9.3187848-0.0nan
9.3407850-0.0nan
9.3626852-0.0nan
9.3846854-0.0nan
9.4066856-0.0nan
9.4286858-0.0nan
9.4505860-0.0nan
9.4725862-0.0nan
9.4945864-0.0nan
9.5165866-0.0nan
9.5385868-0.0nan
9.5604870-0.0nan
9.5824872-0.0nan
9.6044874-0.0nan
9.6264876-0.0nan
9.6484878-0.0nan
9.6703880-0.0nan
9.6923882-0.0nan
9.7143884-0.0nan
9.7363886-0.0nan
9.7582888-0.0nan
9.7802890-0.0nan
9.8022892-0.0nan
9.8242894-0.0nan
9.8462896-0.0nan
9.8681898-0.0nan
9.8901900-0.0nan
9.9121902-0.0nan
9.9341904-0.0nan
9.9560906-0.0nan
9.9780908-0.0nan
10.0910-0.0nan
  • —The bold row denotes the saved checkpoint. </details>

Framework Versions

  • —Python: 3.10.12
  • —Sentence Transformers: 3.0.1
  • —Transformers: 4.41.2
  • —PyTorch: 2.0.1+cu118
  • —Accelerate: 0.31.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",
}
CoSENTLoss
bibtex
@online{kexuefm-8847,
    title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
    author={Su Jianlin},
    year={2022},
    month={Jan},
    url={https://kexue.fm/archives/8847},
}

<!--

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