Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': '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})
(2): Normalize()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("along26/distilroberta-base-manglish-sentence-transformer")
5# Run inference
6sentences = [
7 "To construct a factor analysis model, we will follow these steps:\n\n1. Collect the data: In this case, we have the survey data from 50 students rating their satisfaction level on a scale of 1 to 10 for three aspects: academics (A), social life (S), and campus facilities (F).\n\n2. Create a correlation matrix: Calculate the correlation coefficients between each pair of variables (A, S, and F) using the collected data. The correlation matrix will look like this:\n\n```\n A S F\nA 1.000 r(A,S) r(A,F)\nS r(A,S) 1.000 r(S,F)\nF r(A,F) r(S,F) 1.000\n```\n\nwhere r(A,S), r(A,F), and r(S,F) are the correlation coefficients between academics and social life, academics and campus facilities, and social life and campus facilities, respectively.\n\n3. Determine the number of factors: To decide how many underlying factors can explain the correlations, we can use various methods, such as the Kaiser criterion (eigenvalues greater than 1), scree plot, or parallel analysis. For this example, let's use the Kaiser criterion.\n\n4. Extract the factors: Perform a factor analysis using a software or statistical tool (e.g., R, Python, SPSS) to extract the factors based on the chosen number of factors. The software will provide factor loadings, which represent the correlation between the original variables and the extracted factors.\n\n5. Interpret the factors: Analyze the factor loadings to understand the meaning of the extracted factors. If the loadings are high (e.g., greater than 0.5) for a particular variable, it means that the variable is strongly correlated with that factor.\n\nLet's assume we have calculated the correlation coefficients and performed the factor analysis. The results show that there is one underlying factor that explains the strong correlations between the three aspects (academics, social life, and campus facilities). This factor could be interpreted as the overall satisfaction with the college experience.\n\nIn conclusion, based on the factor analysis model, the three aspects of college experience (academics, social life, and campus facilities) are strongly correlated with each other, and one underlying factor can explain these correlations, which might represent the overall satisfaction with the college experience.",
8 'U',
9 'Suppose you have a dataset with 5 variables and you want to reduce the number of variables to 2. Using factor analysis, determine the two most important factors that explain the variation in the data. Include the factor loadings for each variable on each factor.',
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, -1.0000, 1.0000],
19# [-1.0000, 1.0000, -1.0000],
20# [ 1.0000, -1.0000, 1.0000]])sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
Sebagai pengguna, saya ingin tahu sama ada terdapat sebarang usaha atau tindakan yang diambil oleh kerajaan atau badan kehakiman Malaysia untuk menangani kebimbangan ini tentang kadar perbicaraan yang perlahan dan meningkatkan kepercayaan orang ramai dalam proses tersebut? | E | Mengapa kadar perbicaraan dan prosiding undang-undang berkaitan 1MDB yang perlahan mencetuskan kekecewaan dan kritikan dalam kalangan rakyat Malaysia? |
Pertama, mari kita layan 2 orang yang mesti duduk bersama sebagai satu unit. Jadi sekarang, kami mempunyai 4 unit untuk disusun (pasangan dan 3 individu yang lain).[object Object][object Object]Terdapat 4! (4 faktorial) cara menyusun 4 unit ini, iaitu 4! = 4 × 3 × 2 × 1 = 24 cara.[object Object][object Object]Kini, dalam pasangan itu, terdapat 2! (2 faktorial) cara untuk menyusun 2 orang, iaitu 2! = 2 × 1 = 2 cara.[object Object][object Object]Jadi, untuk mencari jumlah cara untuk menempatkan 5 orang, kita darabkan bilangan cara untuk menyusun 4 unit dengan bilangan cara untuk mengatur orang dalam pasangan:[object Object][object Object]Jumlah cara = 24 (susunan 4 unit) × 2 (susunan dalam pasangan) = 48 cara. | E | Apabila mengatur orang di sekitar meja bulat, kita biasanya menganggap satu orang sebagai titik rujukan untuk mengelakkan mengira susunan yang sama beberapa kali disebabkan oleh putaran. Oleh itu, kami mempunyai 7 orang kawan yang tinggal untuk mengatur meja.[object Object][object Object]Bilangan cara untuk mengatur 7 rakan ini ialah 7! (7 faktorial), iaitu:[object Object][object Object]7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040[object Object][object Object]Oleh itu, terdapat 5,040 cara yang berbeza untuk duduk 8 rakan di sekitar meja bulat. |
How have Malaysia's international partners and institutions responded to the 1MDB scandal and Najib Razak's prosecution, and what impact has this had on the country's reputation and standing in the global community? | B | How has the international community responded to the 1MDB scandal and the allegations of corruption against Najib Razak, and what impact has this had on Malaysia's reputation as a whole? |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
3 "triplet_margin": 5
4}per_device_train_batch_size: 32per_device_eval_batch_size: 32multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_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: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_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: Noneadafactor: Falsegroup_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: Trueuse_legacy_prediction_loop: Falsepush_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_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_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: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.0377 | 500 | 4.1322 |
| 0.0754 | 1000 | 3.2877 |
| 0.1131 | 1500 | 3.0609 |
| 0.1508 | 2000 | 3.047 |
| 0.1885 | 2500 | 3.0408 |
| 0.2262 | 3000 | 3.0383 |
| 0.2640 | 3500 | 3.0354 |
| 0.3017 | 4000 | 3.0329 |
| 0.3394 | 4500 | 3.0303 |
| 0.3771 | 5000 | 3.0269 |
| 0.4148 | 5500 | 3.023 |
| 0.4525 | 6000 | 3.0181 |
| 0.4902 | 6500 | 3.0128 |
| 0.5279 | 7000 | 3.0091 |
| 0.5656 | 7500 | 3.0066 |
| 0.6033 | 8000 | 3.0062 |
| 0.6410 | 8500 | 3.004 |
| 0.6787 | 9000 | 3.0032 |
| 0.7164 | 9500 | 3.0027 |
| 0.7541 | 10000 | 3.0022 |
| 0.7919 | 10500 | 3.0021 |
| 0.8296 | 11000 | 3.0016 |
| 0.8673 | 11500 | 3.0014 |
| 0.9050 | 12000 | 3.0012 |
| 0.9427 | 12500 | 3.001 |
| 0.9804 | 13000 | 3.0009 |
| 1.0181 | 13500 | 3.0008 |
| 1.0558 | 14000 | 3.0007 |
| 1.0935 | 14500 | 3.0011 |
| 1.1312 | 15000 | 3.0006 |
| 1.1689 | 15500 | 3.0005 |
| 1.2066 | 16000 | 3.0005 |
| 1.2443 | 16500 | 3.0004 |
| 1.2821 | 17000 | 3.0004 |
| 1.3198 | 17500 | 3.0004 |
| 1.3575 | 18000 | 3.0003 |
| 1.3952 | 18500 | 3.0003 |
| 1.4329 | 19000 | 3.0005 |
| 1.4706 | 19500 | 3.0003 |
| 1.5083 | 20000 | 3.0002 |
| 1.5460 | 20500 | 3.0002 |
| 1.5837 | 21000 | 3.0002 |
| 1.6214 | 21500 | 3.0002 |
| 1.6591 | 22000 | 3.0004 |
| 1.6968 | 22500 | 3.0002 |
| 1.7345 | 23000 | 3.0002 |
| 1.7722 | 23500 | 3.0001 |
| 1.8100 | 24000 | 3.0001 |
| 1.8477 | 24500 | 3.0001 |
| 1.8854 | 25000 | 3.0005 |
| 1.9231 | 25500 | 3.0001 |
| 1.9608 | 26000 | 3.0002 |
| 1.9985 | 26500 | 3.0002 |
| 2.0362 | 27000 | 3.0001 |
| 2.0739 | 27500 | 3.0001 |
| 2.1116 | 28000 | 3.0001 |
| 2.1493 | 28500 | 3.0001 |
| 2.1870 | 29000 | 3.0001 |
| 2.2247 | 29500 | 3.0001 |
| 2.2624 | 30000 | 3.0002 |
| 2.3002 | 30500 | 3.0001 |
| 2.3379 | 31000 | 3.0001 |
| 2.3756 | 31500 | 3.0001 |
| 2.4133 | 32000 | 3.0001 |
| 2.4510 | 32500 | 3.0001 |
| 2.4887 | 33000 | 3.0001 |
| 2.5264 | 33500 | 3.0001 |
| 2.5641 | 34000 | 3.0001 |
| 2.6018 | 34500 | 3.0001 |
| 2.6395 | 35000 | 3.0001 |
| 2.6772 | 35500 | 3.0003 |
| 2.7149 | 36000 | 3.0001 |
| 2.7526 | 36500 | 3.0001 |
| 2.7903 | 37000 | 3.0001 |
| 2.8281 | 37500 | 3.0003 |
| 2.8658 | 38000 | 3.0001 |
| 2.9035 | 38500 | 3.0001 |
| 2.9412 | 39000 | 3.0001 |
| 2.9789 | 39500 | 3.0001 |
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@misc{hermans2017defense,
2 title={In Defense of the Triplet Loss for Person Re-Identification},
3 author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
4 year={2017},
5 eprint={1703.07737},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}