Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, '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()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("cristiano-sartori/bge_ft")
5# Run inference
6sentences = [
7 'An expression is referentially transparent if it always returns the same value, no matter\nthe global state of the program. A referentially transparent expression can be replaced by its value without\nchanging the result of the program.\nSay we have a value representing a class of students and their GPAs. Given the following defintions:\n1 case class Student(gpa: Double)\n2\n3 def count(c: List[Student], student: Student): Double =\n4 c.filter(s => s == student).size\n5\n6 val students = List(\n7 Student(1.0), Student(2.0), Student(3.0),\n8 Student(4.0), Student(5.0), Student(6.0)\n9 )\nAnd the expression e:\n1 count(students, Student(6.0))',
8 "Let's break this down simply. The function `count` takes a list of students and a specific student, then counts how many times that student appears in the list. In our example, we have a list of students with different GPAs.\n\nWhen we call `count(students, Student(6.0))`, we are asking how many times a student with a GPA of 6.0 is in our list. Since we have `Student(6.0)` in the list only once, the function will return 1.\n\nNow, to understand referential transparency: if we replace the call `count(students, Student(6.0))` with its value (which is 1), the overall result of the program would still remain the same. So, the expression is referentially transparent because it consistently gives us the same output (1) regardless of the program's state.",
9 'To solve the problem of identifying a non-empty subset \\( S \\subsetneq V \\) in a \\( d \\)-regular graph \\( G \\) using the second eigenvector \\( v_2 \\) of the normalized adjacency matrix \\( M \\), we can follow these steps:\n\n### Step 1: Understanding Eigenvector \\( v_2 \\)\n\nThe second eigenvector \\( v_2 \\) is orthogonal to the all-ones vector \\( v_1 \\), indicating that it captures structural features of the graph related to its connected components. Its entries will have both positive and negative values, allowing us to partition the vertices.\n\n### Step 2: Properties of \\( v_2 \\)\n\n- The orthogonality to \\( v_1 \\) ensures that there are vertices with positive values (indicating one group) and negative values (indicating another group). Therefore, we can define two sets based on the sign of the entries in \\( v_2 \\).\n\n### Step 3: Designing the Procedure\n\n1. **Define the Sets:**\n - Let \\( S = \\{ i \\in V : v_2(i) > 0 \\} \\).\n - Let \\( T = \\{ i \\in V : v_2(i) < 0 \\} \\).\n\n2. **Check for Non-emptiness:**\n - Since \\( v_2 \\) is orthogonal to \\( v_1 \\), at least one vertex must have a positive value and at least one must have a negative value. Hence, \\( S \\) cannot be empty, and \\( S \\neq V \\).\n\n### Step 4: Showing that \\( S \\) Cuts 0 Edges\n\nWe need to demonstrate that the cut defined by \\( S \\) does not cross any edges:\n\n- **Edge Contributions:**\n - For any edge \\( (i, j) \\) in the graph, if one vertex belongs to \\( S \\) and the other to \\( T \\), the eigenvalue relationship \\( M \\cdot v_2 = v_2 \\) indicates that the edge would create a mismatched contribution, leading to a contradiction. This implies that no edges can exist between \\( S \\) and \\( T \\).\n\n### Final Procedure\n\nThe procedure can be summarized as follows:\n\n```plaintext\nProcedure FindDisconnectedSet(v_2):\n S = { i ∈ V : v_2(i) > 0 }\n T = { i ∈ V : v_2(i) < 0 }\n \n if S is empty:\n return T\n else:\n return S\n```\n\n### Conclusion\n\nThis algorithm ensures that we find a non-empty subset \\( S \\subsetneq V \\) that defines a cut with no edges crossing between \\( S \\) and \\( V \\setminus S \\), under the condition that \\( \\lambda_2 = 1 \\).',
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]dim_768InformationRetrievalEvaluator with these parameters:
1{
2 "truncate_dim": 768
3}| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.2737 |
| cosine_accuracy@3 | 0.786 |
| cosine_accuracy@5 | 0.8491 |
| cosine_accuracy@10 | 0.9439 |
| cosine_precision@1 | 0.2737 |
| cosine_precision@3 | 0.262 |
| cosine_precision@5 | 0.1698 |
| cosine_precision@10 | 0.0944 |
| cosine_recall@1 | 0.2737 |
| cosine_recall@3 | 0.786 |
| cosine_recall@5 | 0.8491 |
| cosine_recall@10 | 0.9439 |
| cosine_ndcg@10 | 0.6171 |
| cosine_mrr@10 | 0.5102 |
| cosine_map@100 | 0.5136 |
dim_512InformationRetrievalEvaluator with these parameters:
1{
2 "truncate_dim": 512
3}| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.2772 |
| cosine_accuracy@3 | 0.7754 |
| cosine_accuracy@5 | 0.8561 |
| cosine_accuracy@10 | 0.9474 |
| cosine_precision@1 | 0.2772 |
| cosine_precision@3 | 0.2585 |
| cosine_precision@5 | 0.1712 |
| cosine_precision@10 | 0.0947 |
| cosine_recall@1 | 0.2772 |
| cosine_recall@3 | 0.7754 |
| cosine_recall@5 | 0.8561 |
| cosine_recall@10 | 0.9474 |
| cosine_ndcg@10 | 0.6197 |
| cosine_mrr@10 | 0.5127 |
| cosine_map@100 | 0.5158 |
dim_256InformationRetrievalEvaluator with these parameters:
1{
2 "truncate_dim": 256
3}| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.2632 |
| cosine_accuracy@3 | 0.7649 |
| cosine_accuracy@5 | 0.8526 |
| cosine_accuracy@10 | 0.9368 |
| cosine_precision@1 | 0.2632 |
| cosine_precision@3 | 0.255 |
| cosine_precision@5 | 0.1705 |
| cosine_precision@10 | 0.0937 |
| cosine_recall@1 | 0.2632 |
| cosine_recall@3 | 0.7649 |
| cosine_recall@5 | 0.8526 |
| cosine_recall@10 | 0.9368 |
| cosine_ndcg@10 | 0.6108 |
| cosine_mrr@10 | 0.5039 |
| cosine_map@100 | 0.508 |
dim_128InformationRetrievalEvaluator with these parameters:
1{
2 "truncate_dim": 128
3}| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.2596 |
| cosine_accuracy@3 | 0.7544 |
| cosine_accuracy@5 | 0.8386 |
| cosine_accuracy@10 | 0.9263 |
| cosine_precision@1 | 0.2596 |
| cosine_precision@3 | 0.2515 |
| cosine_precision@5 | 0.1677 |
| cosine_precision@10 | 0.0926 |
| cosine_recall@1 | 0.2596 |
| cosine_recall@3 | 0.7544 |
| cosine_recall@5 | 0.8386 |
| cosine_recall@10 | 0.9263 |
| cosine_ndcg@10 | 0.6009 |
| cosine_mrr@10 | 0.4944 |
| cosine_map@100 | 0.4987 |
dim_64InformationRetrievalEvaluator with these parameters:
1{
2 "truncate_dim": 64
3}| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.2596 |
| cosine_accuracy@3 | 0.7439 |
| cosine_accuracy@5 | 0.8351 |
| cosine_accuracy@10 | 0.9298 |
| cosine_precision@1 | 0.2596 |
| cosine_precision@3 | 0.248 |
| cosine_precision@5 | 0.167 |
| cosine_precision@10 | 0.093 |
| cosine_recall@1 | 0.2596 |
| cosine_recall@3 | 0.7439 |
| cosine_recall@5 | 0.8351 |
| cosine_recall@10 | 0.9298 |
| cosine_ndcg@10 | 0.597 |
| cosine_mrr@10 | 0.4888 |
| cosine_map@100 | 0.4924 |
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
Consider the task of classifying reviews as positive or negative. To create a reference for this task, two human annotators were asked to rate 1000 movie reviews as positive or negative.The first annotator rated {a} reviews as positive and the rest as negative. The second annotator rated {b} reviews as positive and the rest as negative. 80 reviews were rated as positive by both annotators. What is the raw agreement between the two annotators?Give your answer as a numerical value to three decimal places. | To calculate the raw agreement between the two annotators, we can use the following formula:[object Object][object Object][[object Object]\text{Raw Agreement} = \frac{\text{Number of agreements}}{\text{Total number of reviews}}[object Object]][object Object][object Object]1. [object Object]: In this case, it is given that there are 1000 movie reviews.[object Object][object Object]2. [object Object]: The agreements consist of the reviews that both annotators rated as positive or both rated as negative. We know that:[object Object] - Both annotators rated 80 reviews as positive.[object Object] - To find the number of reviews both rated as negative, we need to calculate how many reviews each annotator rated as negative.[object Object][object Object] Let’s denote:[object Object] - ( a ): the number of positive reviews by Annotator 1[object Object] - ( b ): the number of positive reviews by Annotator 2[object Object][object Object] Thus, the number of negative reviews for each annotator would be:[object Object] - Negative reviews by Annotator 1 = ( 1000 - a )[object Object] - Negative reviews by Annotator 2 = ( 1000 - b )[object Object][object Object]3. [object Object]:[object Object] -... |
Let $y_1, y_2, \ldots, y_n$ be uniform random bits. For each non-empty subset $S\subseteq {1,2, \ldots, n}$, define $X_S = \oplus_{i\in S}:y_i$. Show that the bits ${X_S: \emptyset \neq S\subseteq {1,2, \ldots, n} }$ are pairwise independent. This shows how to stretch $n$ truly random bits to $2^n-1$ pairwise independent bits. \ \emph{Hint: Observe that it is sufficient to prove $\mathbb{E}[X_S] = 1/2$ and $\mathbb{E}[X_S X_T] = 1/4$ to show that they are pairwise independent. Also use the identity $\oplus_{i\in A}: y_i = \frac{1}{2}\left( 1 - \prod_{i\in A} (-1)^{y_i} \right)$.} | To demonstrate that the random variables ( {X_S : S \subseteq {1, 2, \ldots, n}, S \neq \emptyset} ) are pairwise independent, we need to show two things:[object Object][object Object]1. The expected value ( \mathbb{E}[X_S] = \frac{1}{2} ) for any non-empty subset ( S ).[object Object]2. The expected value of the product of any two variables ( X_S ) and ( X_T ) (where ( S ) and ( T ) are non-empty subsets of ({1,2,\ldots,n})) satisfies ( \mathbb{E}[X_S X_T] = \frac{1}{4} ).[object Object][object Object]### Step 1: Calculate ( \mathbb{E}[X_S] )[object Object][object Object]The random variable ( X_S ) is defined as the XOR (exclusive OR) of bits indexed by elements of ( S ):[object Object][object Object][[object Object]X_S = \oplus_{i \in S} y_i[object Object]][object Object][object Object]For each ( y_i ), since it is a uniform random bit, we have:[object Object][object Object][[object Object]\mathbb{E}[y_i] = \frac{1}{2}[object Object]][object Object][object Object]The XOR operation ( X_S = y_{i_1} \oplus y_{i_2} \oplus \ldots \oplus y_{i_k} ) (where ( S = {i_1, i_2, \ldots, i_k} )) can take the value 0 or 1. The expected value of ( X_S ) can be computed as follows:[object Object][object Object]1. The outcome ( X_S = 0 ) occurs ... |
We have a collection of rectangles in a plane, whose sides are aligned with the coordinate axes. Each rectangle is represented by its lower left corner $(x_1,y_1)$ and its upper right corner $(x_2,y_2)$. All coordinates are of type Long. We require $x_1 \le x_2$ and $y_1 \le y_2$. Define a case class Rectangle storing two corners. | ### Summary[object Object][object Object]To represent rectangles in a plane with aligned sides, we can define a case class in Scala that captures the necessary properties while enforcing the required constraints on the coordinates. Each rectangle will be defined by its lower left corner ((x_1, y_1)) and its upper right corner ((x_2, y_2)). We will ensure that (x_1 \le x_2) and (y_1 \le y_2) through constructor validation.[object Object][object Object]### Implementation[object Object][object Object]Here’s a concise implementation of the [object Object] case class with validation:[object Object][object Object][object Object][object Object][object Object]### Explanation[object Object][object Object]1. [object Object]: The [object Object] case class is defined with four parameters: [object Object], [object Object], [object Object], and [object Object], all of type [object Object].[object Object][object Object]2. [object Object]: The [object Object] statements in the constructor ensure that the specified conditions (x_1 \le x_2) and (y_1 ... |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 768,
5 512,
6 256,
7 128,
8 64
9 ],
10 "matryoshka_weights": [
11 1,
12 1,
13 1,
14 1,
15 1
16 ],
17 "n_dims_per_step": -1
18}eval_strategy: epochper_device_train_batch_size: 2per_device_eval_batch_size: 2gradient_accumulation_steps: 16learning_rate: 2e-05num_train_epochs: 5lr_scheduler_type: cosinewarmup_ratio: 0.1bf16: Truetf32: Falseload_best_model_at_end: Trueoptim: adamw_torch_fusedbatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_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: 16eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 5max_steps: -1lr_scheduler_type: cosinelr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_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: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Falselocal_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: Trueignore_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_torch_fusedoptim_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: 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: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | dim_768_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 | dim_128_cosine_ndcg@10 | dim_64_cosine_ndcg@10 |
|---|---|---|---|---|---|---|---|
| 0.2807 | 10 | 2.2566 | - | - | - | - | - |
| 0.5614 | 20 | 0.7721 | - | - | - | - | - |
| 0.8421 | 30 | 0.339 | - | - | - | - | - |
| 1.0 | 36 | - | 0.6171 | 0.6157 | 0.6205 | 0.6049 | 0.5968 |
| 1.1123 | 40 | 0.5523 | - | - | - | - | - |
| 1.3930 | 50 | 0.14 | - | - | - | - | - |
| 1.6737 | 60 | 0.0521 | - | - | - | - | - |
| 1.9544 | 70 | 0.0242 | - | - | - | - | - |
| 2.0 | 72 | - | 0.6153 | 0.6131 | 0.6077 | 0.6042 | 0.5929 |
| 2.2246 | 80 | 0.5093 | - | - | - | - | - |
| 2.5053 | 90 | 0.0524 | - | - | - | - | - |
| 2.7860 | 100 | 0.0772 | - | - | - | - | - |
| 3.0 | 108 | - | 0.6141 | 0.6182 | 0.6108 | 0.6042 | 0.5901 |
| 3.0561 | 110 | 0.0347 | - | - | - | - | - |
| 3.3368 | 120 | 0.1168 | - | - | - | - | - |
| 3.6175 | 130 | 0.8566 | - | - | - | - | - |
| 3.8982 | 140 | 0.0254 | - | - | - | - | - |
| 4.0 | 144 | - | 0.6160 | 0.6177 | 0.6091 | 0.6020 | 0.5927 |
| 4.1684 | 150 | 0.2141 | - | - | - | - | - |
| 4.4491 | 160 | 0.0344 | - | - | - | - | - |
| 4.7298 | 170 | 0.8643 | - | - | - | - | - |
| 5.0 | 180 | 0.019 | 0.6171 | 0.6197 | 0.6108 | 0.6009 | 0.5970 |
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{kusupati2024matryoshka,
2 title={Matryoshka Representation Learning},
3 author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
4 year={2024},
5 eprint={2205.13147},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 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},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}