CoolFace
Modelpublic

JianLiao/spectrum-doc-fine-tuned

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes84downloads
Model Card

SentenceTransformer based on BAAI/bge-large-en-v1.5

This is a sentence-transformers model finetuned from BAAI/bge-large-en-v1.5 on the spectrum-design-docs dataset. It maps sentences & paragraphs to a 1024-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: BAAI/bge-large-en-v1.5 <!-- at revision d4aa6901d3a41ba39fb536a557fa166f842b0e09 -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 1024 dimensions
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —spectrum-design-docs
  • —Language: en <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, '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("JianLiao/spectrum-doc-fine-tuned")
# Run inference
sentences = [
    'Represent this sentence for searching relevant passages: How can a designer balance the need for clear text links and the need for emphasized text in a user interface?',
    "Typography\nUsage guidelines\nDon't use underlines for adding emphasis: Underlines are reserved for text links only. They should not be used as a way for adding emphasis to words.\n\n",
    'Meter\nOptions\nPositive variant: The positive variant has a green fill to show the value. This can be used to represent a positive semantic value, such as when there’s a lot of space remaining.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]

# 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

Information Retrieval
MetricValue
cosine_accuracy@10.0075
cosine_accuracy@30.0156
cosine_accuracy@50.0475
cosine_accuracy@100.7815
cosine_precision@10.0075
cosine_precision@30.0052
cosine_precision@50.0095
cosine_precision@100.0782
cosine_recall@10.0075
cosine_recall@30.0156
cosine_recall@50.0475
cosine_recall@100.7815
cosine_ndcg@100.2544
cosine_mrr@100.1078
cosine_map@1000.1164

<!--

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

spectrum-design-docs
  • —Dataset: spectrum-design-docs at 23f5565
  • —Size: 14,737 training samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | |:--------|:-----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 20 tokens</li><li>mean: 30.87 tokens</li><li>max: 47 tokens</li></ul> | <ul><li>min: 18 tokens</li><li>mean: 97.17 tokens</li><li>max: 512 tokens</li></ul> |
  • —Samples: | anchor | positive | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Represent this sentence for searching relevant passages: Are there any specific guidelines or best practices provided by the Spectrum team for integrating Spectrum CSS into a new or existing project?</code> | <code>Spectrum CSS: An open source CSS-only implementation of Spectrum, maintained by the Spectrum team. <br><div class="well-box">Dependency chain: Spectrum DNA → Spectrum CSS</div><br><br>GitHub repository <br>Website <br>#spectrum_css</code> | | <code>Represent this sentence for searching relevant passages: How does the default setting for progress circles affect their behavior in a UI?</code> | <code>Progress circle<br>Options<br>Indeterminate: A progress circle can be either determinate or indeterminate. By default, progress circles are determinate. Use a determinate progress circle when progress can be calculated against a specific goal (e.g., downloading a file of a known size). Use an indeterminate progress circle when progress is happening but the time or effort to completion can’t be determined (e.g., attempting to reconnect to a server).</code> | | <code>Represent this sentence for searching relevant passages: What tools or methods can designers use to test the effectiveness of wrapped legends in their designs?</code> | <code>Legend<br>Behaviors<br>Wrapping: When there isn’t enough space, wrap legends to ensure that dimension values are shown.</code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: epoch
  • —per_device_train_batch_size: 22
  • —per_device_eval_batch_size: 16
  • —gradient_accumulation_steps: 16
  • —learning_rate: 2e-05
  • —num_train_epochs: 100
  • —lr_scheduler_type: cosine
  • —warmup_ratio: 0.1
  • —bf16: True
  • —tf32: True
  • —load_best_model_at_end: True
  • —optim: adamwtorchfused
  • —prompts: {'anchor': 'Represent this sentence for searching relevant passages: '}
  • —batch_sampler: no_duplicates
All Hyperparameters

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

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: epoch
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 22
  • —per_device_eval_batch_size: 16
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 16
  • —eval_accumulation_steps: None
  • —torch_empty_cache_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: 100
  • —max_steps: -1
  • —lr_scheduler_type: cosine
  • —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
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: True
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: True
  • —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: adamwtorchfused
  • —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: None
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —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
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: {'anchor': 'Represent this sentence for searching relevant passages: '}
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

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

EpochStepTraining Losssds_cosine_ndcg@10
1.07-0.2255
1.48100.2646-
2.014-0.2282
2.96200.1412-
3.021-0.2358
4.028-0.2397
4.32300.0638-
5.035-0.2430
5.8400.0425-
6.042-0.2449
7.049-0.2462
7.16500.0237-
8.056-0.2428
8.64600.015-
9.063-0.2456
10.0700.00820.2456
11.077-0.2498
11.48800.0052-
12.084-0.2474
12.96900.0035-
13.091-0.2455
14.098-0.2475
14.321000.0022-
15.0105-0.2472
15.81100.002-
16.0112-0.2486
17.0119-0.2506
17.161200.0015-
18.0126-0.2490
18.641300.0013-
19.0133-0.2489
20.01400.00120.2491
21.0147-0.2493
21.481500.0011-
22.0154-0.2487
22.961600.001-
23.0161-0.2486
24.0168-0.2490
24.321700.0008-
25.0175-0.2502
25.81800.0008-
26.0182-0.2505
27.0189-0.2523
27.161900.0008-
28.0196-0.2516
28.642000.0007-
29.0203-0.2509
30.02100.00070.2522
31.0217-0.2522
31.482200.0006-
32.0224-0.2534
32.962300.0007-
33.0231-0.2523
34.0238-0.2524
34.322400.0006-
35.0245-0.2518
35.82500.0006-
36.0252-0.2529
37.0259-0.2524
37.162600.0006-
38.0266-0.2530
38.642700.0005-
39.0273-0.2526
40.02800.00060.2539
41.0287-0.2529
41.482900.0005-
42.0294-0.2545
42.963000.0006-
43.0301-0.2534
44.0308-0.2536
44.323100.0004-
45.0315-0.2521
45.83200.0005-
46.0322-0.2532
47.0329-0.2519
47.163300.0005-
48.0336-0.2525
48.643400.0004-
49.0343-0.2535
50.03500.00050.2542
51.0357-0.2540
51.483600.0004-
52.0364-0.2542
52.963700.0005-
53.0371-0.2538
54.0378-0.2533
54.323800.0004-
55.0385-0.2544
55.83900.0004-
56.0392-0.2539
57.0399-0.2541
57.164000.0005-
58.0406-0.2532
58.644100.0004-
59.0413-0.2543
60.04200.00040.2532
61.0427-0.2541
61.484300.0004-
62.0434-0.2542
62.964400.0005-
63.0441-0.2546
64.0448-0.2549
64.324500.0003-
65.0455-0.2557
65.84600.0004-
66.0462-0.2557
67.0469-0.2539
67.164700.0004-
68.0476-0.2538
68.644800.0004-
69.0483-0.2538
70.04900.00040.2542
71.0497-0.2532
71.485000.0004-
72.0504-0.2538
72.965100.0004-
73.0511-0.2545
74.0518-0.2531
74.325200.0003-
75.0525-0.2534
75.85300.0004-
76.0532-0.2541
77.0539-0.2545
77.165400.0004-
78.0546-0.2536
78.645500.0004-
79.0553-0.2545
80.05600.00040.2540
81.0567-0.2545
81.485700.0004-
82.0574-0.2541
82.965800.0004-
83.0581-0.2545
84.0588-0.2538
84.325900.0004-
85.0595-0.2546
85.86000.00040.2544
  • —The bold row denotes the saved checkpoint. </details>

Framework Versions

  • —Python: 3.12.8
  • —Sentence Transformers: 3.3.1
  • —Transformers: 4.47.1
  • —PyTorch: 2.5.1+cu124
  • —Accelerate: 1.2.1
  • —Datasets: 3.2.0
  • —Tokenizers: 0.21.0

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",
}
MultipleNegativesRankingLoss
bibtex
@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

<!--

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