Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, '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})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("ML5562/fine-tuned-scibert_scivocab_uncased-all-json-M1_testing_f16")
5# Run inference
6sentences = [
7 'Which of the following are part of the RDF schema language?',
8 'The RDF schema language specifically includes "domain," which defines the class of resources a property pertains to. This corresponds to option B.\n\nAnswer: *B: The « domain » statement for RDF properties?*',
9 'RDF schema language includes the "domain" statement for RDF properties, which specifies the class of subjects that can be used with a particular property. This matches option B. \n\nAnswer: *B: The « domain » statement for RDF properties?*',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]val-evalTripletEvaluator| Metric | Value |
|---|---|
| cosine_accuracy | 0.5934 |
sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
Let $f:\R^D | ||
| ightarrow\R$ be an $L$-hidden layer multi-layer perceptron (MLP) such that [ f(xv)=\sigma_{L+1}ig(\wv^ op\sigma_L(\Wm_L\sigma_{L-1}(\Wm_{L-1}\dots\sigma_1(\Wm_1xv)))ig), ] with $\wv\in\R^{M}$, $\Wm_1\in\R^{M imes D}$ and $\Wm_\ell\in\R^{M imes M}$ for $\ell=2,\dots, L$, and $\sigma_i$ for $i=1,\dots,L+1$ is an entry-wise activation function. For any MLP $f$ and a classification threshold $ au$ let $C_{f, au}$ be a binary classifier that outputs YES for a given input $xv$ if $f(xv) \leq au$ and NO otherwise. space{3mm} Assume $\sigma_{L+1}$ is the element-wise extbf{sigmoid} function and $C_{f, rac{1}{2}}$ is able to obtain a high accuracy on a given binary classification task $T$. Let $g$ be the MLP obtained by multiplying the parameters extbf{in the last layer} of $f$, i.e. $\wv$, by 2. Moreover, let $h$ be the MLP obtained by replacing $\sigma_{L+1}$ with elemen... | To analyze the options regarding the accuracy of the classifiers $C_{g, \frac{1}{2}}$, $C_{h, 0}$, and $C_{q, 0}$ compared to $C_{f, \frac{1}{2}}$, let’s go through each choice:[object Object][object Object]1. [object Object][object Object][object Object] This statement is [object Object]. The MLP $g$ is obtained by multiplying the weights of the last layer ($\wv$) by 2. Since the sigmoid activation function is monotonic, this transformation does not change the sign of the output, only scales it. The threshold of $\frac{1}{2}$ remains valid for classification because if $f(xv) > \frac{1}{2}$, then $g(xv) = 2f(xv) > 1$, which still results in a "YES" classification. Similarly, if $f(xv) < \frac{1}{2}$, then $g(xv) < 1$, leading to a "NO" classification. Therefore, the accuracy of $C_{g, \frac{1}{2}}$ should be the same as that of $C_{f, \frac{1}{2}}$.[object Object][object Object]2. [object Object][object Object][object Object]... | To evaluate the accuracy of the classifiers $C_{g, \frac{1}{2}}$, $C_{h, 0}$, and $C_{q, 0}$ in comparison to $C_{f, \frac{1}{2}}$, let's consider the transformations applied to the original multi-layer perceptron (MLP) $f$:[object Object][object Object]1. [object Object][object Object][object Object] This option raises a concern about the transformation applied to the last layer of the MLP. While it is true that multiplying the weights by 2 could affect the scale of the outputs, it does not necessarily imply a decrease in accuracy. The classification decision depends on the threshold and the relative position of the outputs. Hence, one could argue that the accuracy of $C_{g, \frac{1}{2}}$ might not diverge significantly from that of $C_{f, \frac{1}{2}}$, but the relationship is not straightforward without further analysis.[object Object][object Object]2. [object Object][object Object][object Object] Here, the concern is a... |
What is the complexity of concatenation of two conc-trees with heights $h_1$ and[object Object]$h_2$? | To analyze the complexity of concatenating two conc-trees with heights ( h_1 ) and ( h_2 ), we can refer to the provided concatenation algorithm. The algorithm performs concatenation based on the height difference between the two trees, defined as [object Object].[object Object][object Object]1. [object Object]: If the height difference, [object Object], is within the range ([-1, 1]), the algorithm creates a new root node that combines the two trees directly. This operation requires constant time, ( O(1) ).[object Object][object Object]2. [object Object]: If the height difference exceeds 1, the algorithm executes recursive calls to balance the trees:[object Object] - If [object Object] is shorter than [object Object], it recursively concatenates the right subtree of [object Object] with [object Object] and adjusts the structure accordingly.[object Object] - The recursion aims to reduce the height difference between the two trees, effectively addressing the taller tree until the heights are balanced.[object Object][object Object]3. [object Object]: Each recursive call focuses on reducing the h... | The complexity of concatenating two concatenation trees (or conc-trees) with heights ( h_1 ) and ( h_2 ) can be understood pretty easily. When you concatenate two trees, you essentially combine them into a single tree. [object Object][object Object]Let's think about it this way: the height of the resulting tree would be determined by the taller of the two trees, plus one for the new root that connects them. So, the height of the new tree would be ( \max(h_1, h_2) + 1 ).[object Object][object Object]Now, when it comes to the complexity of this operation, we can say it takes time proportional to the heights of the trees because you may need to traverse one of the trees to attach it to the other. This means the time complexity for concatenating these two trees is ( O(h_1 + h_2) ). [object Object][object Object]So, in summary, concatenating two conc-trees of heights ( h_1 ) and ( h_2 ) has a complexity of ( O(h_1 + h_2) ). This is pretty straightforward since you just combine them and adjust the height! |
Suppose you have a search engine that retrieves the top 100 documents and[object Object]achieves 90% precision and 20% recall. You modify the search engine to[object Object]retrieve the top 200 and mysteriously, the precision stays the same. Which one[object Object]is CORRECT? | To address the question, we need to analyze the implications of the changes made to the search engine regarding precision and recall, two critical metrics used in evaluating information retrieval systems.[object Object][object Object]### Definitions:[object Object]- [object Object] is defined as the ratio of relevant documents retrieved to the total number of documents retrieved. Mathematically, it is expressed as:[object Object] [[object Object] P = \frac{TP}{TP + FP}[object Object] ][object Object] where (TP) is the number of true positives (relevant documents retrieved) and (FP) is the number of false positives (irrelevant documents retrieved).[object Object][object Object]- [object Object] is defined as the ratio of relevant documents retrieved to the total number of relevant documents available. It is given by:[object Object] [[object Object] R = \frac{TP}{TP + FN}[object Object] ][object Object] where (FN) is the number of false negatives (relevant documents not retrieved).[object Object][object Object]### Given Information:[object Object]From the initial state of the search engine:[object Object]- Top 100 documents retrieved[object Object]- Precision = 90% (0.90)[object Object]- Recall = 20% (0.20)[object Object][object Object]Letâs derive some v... | To analyze the multiple-choice question regarding the search engine's precision and recall, we will follow the structured approach outlined in the instructions.[object Object][object Object]### Core Concepts[object Object]1. [object Object]: The ratio of relevant documents retrieved to the total documents retrieved. It is a measure of the accuracy of the search results.[object Object]2. [object Object]: The ratio of relevant documents retrieved to the total relevant documents available. It measures the ability of the search engine to find all relevant documents.[object Object]3. [object Object]: The harmonic mean of precision and recall, providing a single metric to evaluate the performance of a search engine.[object Object][object Object]### Given Information[object Object]- Initial retrieval: Top 100 documents[object Object]- Precision: 90% (0.9)[object Object]- Recall: 20% (0.2)[object Object]- Modified retrieval: Top 200 documents[object Object]- Precision remains at 90%[object Object][object Object]### Analyzing Each Option[object Object][object Object]1. [object Object][object Object] - [object Object]: Incorrect[object Object] - [object Object]: Recall is defined as the number of relevant documents retrieved divided by the ... |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
3 "triplet_margin": 5
4}eval_strategy: stepsper_device_train_batch_size: 2per_device_eval_batch_size: 2num_train_epochs: 1fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 2per_device_eval_batch_size: 2per_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: 1max_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: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_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: Falsegradient_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: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | Training Loss | val-eval_cosine_accuracy |
|---|---|---|---|
| 0.0516 | 500 | 4.7151 | 0.5590 |
| 0.1031 | 1000 | 4.6748 | 0.5340 |
| 0.1547 | 1500 | 4.7388 | 0.5924 |
| 0.2063 | 2000 | 4.4755 | 0.5590 |
| 0.2578 | 2500 | 4.645 | 0.5846 |
| 0.3094 | 3000 | 4.5311 | 0.5903 |
| 0.3610 | 3500 | 4.5999 | 0.5800 |
| 0.4125 | 4000 | 4.3705 | 0.5928 |
| 0.4641 | 4500 | 4.4468 | 0.5936 |
| 0.5157 | 5000 | 4.4595 | 0.5922 |
| 0.5672 | 5500 | 4.3324 | 0.5908 |
| 0.6188 | 6000 | 4.3597 | 0.6029 |
| 0.6704 | 6500 | 4.3104 | 0.5932 |
| 0.7219 | 7000 | 4.1767 | 0.5887 |
| 0.7735 | 7500 | 4.3307 | 0.5866 |
| 0.8251 | 8000 | 4.3836 | 0.5901 |
| 0.8767 | 8500 | 4.1641 | 0.5943 |
| 0.9282 | 9000 | 4.2697 | 0.5939 |
| 0.9798 | 9500 | 4.316 | 0.5939 |
| 1.0 | 9696 | - | 0.5934 |
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}