jstAnotherCapi commited on
Commit
ba3ecf1
·
verified ·
1 Parent(s): 6a6c260

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +14 -0
  2. sbert_training/.ipynb_checkpoints/4epochs_evaluation_post_training-checkpoint.ipynb +0 -0
  3. sbert_training/.ipynb_checkpoints/Evaluation_post_training-checkpoint.ipynb +0 -0
  4. sbert_training/.ipynb_checkpoints/evaulate_ms_marco-checkpoint.ipynb +0 -0
  5. sbert_training/.ipynb_checkpoints/preprocessing_bert_training-checkpoint.ipynb +0 -0
  6. sbert_training/.ipynb_checkpoints/prompt_multiloss_training_model_eval-checkpoint.ipynb +6 -0
  7. sbert_training/.ipynb_checkpoints/testing_E5-checkpoint.ipynb +0 -0
  8. sbert_training/4epochs_evaluation_post_training.ipynb +0 -0
  9. sbert_training/Evaluation_post_training.ipynb +0 -0
  10. sbert_training/Node_allocation.pbs +20 -0
  11. sbert_training/continue.pbs +16 -0
  12. sbert_training/continue.py +122 -0
  13. sbert_training/continue_msmarco.pbs +16 -0
  14. sbert_training/continue_msmarco.py +112 -0
  15. sbert_training/epoch2+2_Epochs_Ms_marco/error.log +3 -0
  16. sbert_training/epoch2+2_Epochs_Ms_marco/logs_ds36.txt +0 -0
  17. sbert_training/epoch2+2_Epochs_Ms_marco/model/1_Pooling/config.json +10 -0
  18. sbert_training/epoch2+2_Epochs_Ms_marco/model/README.md +0 -0
  19. sbert_training/epoch2+2_Epochs_Ms_marco/model/config.json +28 -0
  20. sbert_training/epoch2+2_Epochs_Ms_marco/model/config_sentence_transformers.json +14 -0
  21. sbert_training/epoch2+2_Epochs_Ms_marco/model/model.safetensors +3 -0
  22. sbert_training/epoch2+2_Epochs_Ms_marco/model/modules.json +14 -0
  23. sbert_training/epoch2+2_Epochs_Ms_marco/model/sentence_bert_config.json +4 -0
  24. sbert_training/epoch2+2_Epochs_Ms_marco/model/tokenizer.json +0 -0
  25. sbert_training/epoch2+2_Epochs_Ms_marco/model/tokenizer_config.json +21 -0
  26. sbert_training/epoch2+2_Epochs_Ms_marco/output.log +0 -0
  27. sbert_training/epoch2/error.log +3 -0
  28. sbert_training/epoch2/logs.txt +500 -0
  29. sbert_training/epoch2/model/1_Pooling/config.json +10 -0
  30. sbert_training/epoch2/model/README.md +773 -0
  31. sbert_training/epoch2/model/config.json +28 -0
  32. sbert_training/epoch2/model/config_sentence_transformers.json +14 -0
  33. sbert_training/epoch2/model/model.safetensors +3 -0
  34. sbert_training/epoch2/model/modules.json +14 -0
  35. sbert_training/epoch2/model/sentence_bert_config.json +4 -0
  36. sbert_training/epoch2/model/tokenizer.json +0 -0
  37. sbert_training/epoch2/model/tokenizer_config.json +21 -0
  38. sbert_training/epoch2/output.log +228 -0
  39. sbert_training/evaulate_ms_marco.ipynb +0 -0
  40. sbert_training/fourth_training/.ipynb_checkpoints/Benchmarking_02_04-checkpoint.ipynb +1072 -0
  41. sbert_training/fourth_training/Benchmarking_02_04.ipynb +1072 -0
  42. sbert_training/fourth_training/arabvert02_results.csv +2 -0
  43. sbert_training/fourth_training/bert-base-arabertv02/.gitattributes +11 -0
  44. sbert_training/fourth_training/bert-base-arabertv02/README.md +135 -0
  45. sbert_training/fourth_training/bert-base-arabertv02/config.json +17 -0
  46. sbert_training/fourth_training/bert-base-arabertv02/flax_model.msgpack +3 -0
  47. sbert_training/fourth_training/bert-base-arabertv02/model.safetensors +3 -0
  48. sbert_training/fourth_training/bert-base-arabertv02/pytorch_model.bin +3 -0
  49. sbert_training/fourth_training/bert-base-arabertv02/runs/eval/events.out.tfevents.1607681029.tpu-mother +3 -0
  50. sbert_training/fourth_training/bert-base-arabertv02/runs/eval/events.out.tfevents.1607686495.tpu-mother +3 -0
.gitattributes CHANGED
@@ -33,3 +33,17 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sbert_training/epoch2/error.log filter=lfs diff=lfs merge=lfs -text
37
+ sbert_training/epoch2+2_Epochs_Ms_marco/error.log filter=lfs diff=lfs merge=lfs -text
38
+ sbert_training/fourth_training/data/pre_train_arcd_SQuAD_triplets.csv filter=lfs diff=lfs merge=lfs -text
39
+ sbert_training/fourth_training/data/train_arcd_SQuAD_dataset.csv filter=lfs diff=lfs merge=lfs -text
40
+ sbert_training/fourth_training/data/train_arcd_SQuAD_triplets.csv filter=lfs diff=lfs merge=lfs -text
41
+ sbert_training/third_training/benchmark/ArabicaQA_test.json filter=lfs diff=lfs merge=lfs -text
42
+ sbert_training/third_training/clean_data/MultiNeg_30_ss.csv filter=lfs diff=lfs merge=lfs -text
43
+ sbert_training/third_training/clean_data/a_p_n_ss.csv filter=lfs diff=lfs merge=lfs -text
44
+ sbert_training/third_training/clean_data/a_p_n_sts.csv filter=lfs diff=lfs merge=lfs -text
45
+ sbert_training/third_training/clean_data/a_p_ss.csv filter=lfs diff=lfs merge=lfs -text
46
+ sbert_training/third_training/clean_data/ms_marco_clean_dataset36_train.csv filter=lfs diff=lfs merge=lfs -text
47
+ sbert_training/third_training/clean_data/ms_marco_clean_dataset36_val.csv filter=lfs diff=lfs merge=lfs -text
48
+ sbert_training/third_training/logs/error.log filter=lfs diff=lfs merge=lfs -text
49
+ sbert_training/third_training/logs.txt filter=lfs diff=lfs merge=lfs -text
sbert_training/.ipynb_checkpoints/4epochs_evaluation_post_training-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/.ipynb_checkpoints/Evaluation_post_training-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/.ipynb_checkpoints/evaulate_ms_marco-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/.ipynb_checkpoints/preprocessing_bert_training-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/.ipynb_checkpoints/prompt_multiloss_training_model_eval-checkpoint.ipynb ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [],
3
+ "metadata": {},
4
+ "nbformat": 4,
5
+ "nbformat_minor": 5
6
+ }
sbert_training/.ipynb_checkpoints/testing_E5-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/4epochs_evaluation_post_training.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/Evaluation_post_training.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/Node_allocation.pbs ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ #PBS -N khalil_vmstat_monitoring
3
+ #PBS -l select=1:ncpus=20:mem=180gb:ngpus=1
4
+ #PBS -q gpu_1d
5
+ #PBS -o vmstat_logs/vmstat_output.log
6
+ #PBS -e vmstat_logs/vmstat_error.log
7
+
8
+ # === Load modules & activate conda (optional, can remove if not needed) ===
9
+ module use /app/common/modules
10
+ module load anaconda3-2024.10
11
+
12
+ # === Move to working directory ===
13
+ cd /home/skiredj.abderrahman/khalil/sbert_training
14
+ echo "==== Job running on node: $(hostname -s) ===="
15
+ echo "==== Monitoring started at $(date) ===="
16
+
17
+ # === Collect vmstat every 30 minutes (1800 seconds) ===
18
+ # This runs until the PBS job ends
19
+ vmstat 1800 >> vmstat_logs/vmstat_30min_%J.txt
20
+
sbert_training/continue.pbs ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ #PBS -N sbert_train_khalil
3
+ #PBS -l select=1:ncpus=20:mem=180gb:ngpus=1
4
+ #PBS -q gpu_1w
5
+ #PBS -o logs/output.log
6
+ #PBS -e logs/error.log
7
+
8
+ # === Load modules & activate conda ===
9
+ module use /app/common/modules
10
+ module load anaconda3-2024.10
11
+ source activate sbert_khalil
12
+
13
+ # === Move to working directory ===
14
+ cd /home/skiredj.abderrahman/khalil/sbert_training
15
+
16
+ python continue.py
sbert_training/continue.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import torch
4
+ import logging
5
+ from datetime import datetime
6
+ from datasets import load_dataset
7
+ from sentence_transformers import SentenceTransformer, losses
8
+ from sentence_transformers.evaluation import TripletEvaluator, SequentialEvaluator
9
+ from sentence_transformers.trainer import SentenceTransformerTrainer
10
+ from sentence_transformers.training_args import SentenceTransformerTrainingArguments, BatchSamplers
11
+
12
+ # --- MANUAL CHECKPOINT CONFIG ---
13
+ # PASTE YOUR CHECKPOINT PATH HERE to resume. Example: "output/arabert_20240520_1530/checkpoint-6000"
14
+ # Set to None if you want to start a brand new training run.
15
+ CHECKPOINT_PATH = "/home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-102000"
16
+
17
+ model_name = "bert-base-arabertv02"
18
+ model_nickname = "arabert"
19
+ train_batch_size = 64
20
+
21
+ # Logic to maintain the same output directory if resuming
22
+ if CHECKPOINT_PATH and os.path.exists(CHECKPOINT_PATH):
23
+ output_dir = str(os.path.dirname(CHECKPOINT_PATH))
24
+ print(f"--- RESUMING FROM: {CHECKPOINT_PATH} ---")
25
+ else:
26
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M")
27
+ output_dir = f"output/{model_nickname}_{timestamp}"
28
+ CHECKPOINT_PATH = None
29
+ print(f"--- STARTING NEW RUN: {output_dir} ---")
30
+
31
+ # --- LOGGING ---
32
+ logging.basicConfig(
33
+ format="%(asctime)s - %(message)s",
34
+ datefmt="%Y-%m-%d %H:%M:%S",
35
+ level=logging.INFO,
36
+ handlers=[logging.FileHandler("logs.txt")]
37
+ )
38
+
39
+ class Tee:
40
+ def __init__(self, *files): self.files = files
41
+ def write(self, obj):
42
+ for f in self.files: f.write(obj); f.flush()
43
+ def flush(self):
44
+ for f in self.files: f.flush()
45
+ def isatty(self): return False
46
+
47
+ sys.stdout = Tee(sys.stdout, open("logs.txt", "a"))
48
+
49
+ # --- MODEL & DATA ---
50
+ device = "cuda" if torch.cuda.is_available() else "cpu"
51
+ model = SentenceTransformer(model_name, device=device)
52
+
53
+ train_dataset = load_dataset("csv", data_files="train.csv")
54
+ eval_dataset = load_dataset("csv", data_files="val.csv")
55
+ test_dataset = load_dataset("csv", data_files="test.csv")
56
+
57
+ eval_subset = eval_dataset["train"].shuffle(seed=42).select(range(min(250000, len(eval_dataset["train"]))))
58
+
59
+ # --- LOSS & EVALUATORS ---
60
+ matryoshka_dims = [768, 512, 256, 128, 64]
61
+ inner_train_loss = losses.MultipleNegativesRankingLoss(model=model)
62
+ train_loss = losses.MatryoshkaLoss(model, inner_train_loss, matryoshka_dims=matryoshka_dims)
63
+
64
+ evaluators = [
65
+ TripletEvaluator(
66
+ anchors=eval_subset["anchor"],
67
+ positives=eval_subset["positive"],
68
+ negatives=eval_subset["negative"],
69
+ name=f"dev-{dim}",
70
+ truncate_dim=dim,
71
+ ) for dim in matryoshka_dims
72
+ ]
73
+ dev_evaluator = SequentialEvaluator(evaluators, main_score_function=lambda scores: scores[0])
74
+
75
+ # --- TRAINING ARGS ---
76
+ args = SentenceTransformerTrainingArguments(
77
+ output_dir=output_dir,
78
+ num_train_epochs=4,
79
+ per_device_train_batch_size=train_batch_size,
80
+ gradient_accumulation_steps=2,
81
+ bf16=True,
82
+ learning_rate=2e-5,
83
+ warmup_ratio=0.1,
84
+ batch_sampler=BatchSamplers.NO_DUPLICATES,
85
+ eval_strategy="steps",
86
+ eval_steps=6000,
87
+ save_strategy="steps",
88
+ save_steps=6000,
89
+ save_total_limit=2,
90
+ logging_steps=200,
91
+ )
92
+
93
+ trainer = SentenceTransformerTrainer(
94
+ model=model,
95
+ args=args,
96
+ train_dataset=train_dataset,
97
+ eval_dataset=eval_dataset,
98
+ loss=train_loss,
99
+ evaluator=dev_evaluator,
100
+ )
101
+
102
+ # --- THE TRAIN CALL ---
103
+ trainer.train(resume_from_checkpoint=CHECKPOINT_PATH)
104
+ # Save final model
105
+ final_output_dir = "/home/skiredj.abderrahman/khalil/sbert_training/output/final_epoch4"
106
+ model.save(final_output_dir)
107
+ print("model saved successfully")
108
+
109
+ # Test evaluation
110
+ evaluators = []
111
+ for dim in matryoshka_dims:
112
+ evaluators.append(
113
+ TripletEvaluator(
114
+ anchors=test_dataset["train"]["anchor"],
115
+ positives=test_dataset["train"]["positive"],
116
+ negatives=test_dataset["train"]["negative"],
117
+ name=f"test-{dim}",
118
+ truncate_dim=dim,
119
+ )
120
+ )
121
+ test_evaluator = SequentialEvaluator(evaluators)
122
+ test_evaluator(model)
sbert_training/continue_msmarco.pbs ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ #PBS -N sbert_train_khalil
3
+ #PBS -l select=1:ncpus=20:mem=180gb:ngpus=1
4
+ #PBS -q gpu_1w
5
+ #PBS -o logs/output.log
6
+ #PBS -e logs/error.log
7
+
8
+ # === Load modules & activate conda ===
9
+ module use /app/common/modules
10
+ module load anaconda3-2024.10
11
+ source activate sbert_khalil
12
+
13
+ # === Move to working directory ===
14
+ cd /home/skiredj.abderrahman/khalil/sbert_training
15
+
16
+ python continue_msmarco.py
sbert_training/continue_msmarco.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import torch
4
+ import logging
5
+ from datasets import load_dataset
6
+ from sentence_transformers import SentenceTransformer, losses
7
+ from sentence_transformers.evaluation import TripletEvaluator, SequentialEvaluator
8
+ from sentence_transformers.trainer import SentenceTransformerTrainer
9
+ from sentence_transformers.training_args import SentenceTransformerTrainingArguments, BatchSamplers
10
+ import glob
11
+
12
+ # --- CONFIG ---
13
+ MODEL_PATH = "/home/skiredj.abderrahman/khalil/sbert_training/epoch2/model/"
14
+ train_batch_size = 64
15
+ output_dir = "output/arabert_ms_marco"
16
+
17
+ # --- LOGGING ---
18
+ logging.basicConfig(
19
+ format="%(asctime)s - %(message)s",
20
+ datefmt="%Y-%m-%d %H:%M:%S",
21
+ level=logging.INFO,
22
+ handlers=[logging.FileHandler("logs_ds36.txt")]
23
+ )
24
+
25
+ class Tee:
26
+ def __init__(self, *files): self.files = files
27
+ def write(self, obj):
28
+ for f in self.files: f.write(obj); f.flush()
29
+ def flush(self):
30
+ for f in self.files: f.flush()
31
+ def isatty(self): return False
32
+
33
+ sys.stdout = Tee(sys.stdout, open("logs_ds36.txt", "a"))
34
+
35
+ # --- LOAD DATA ---
36
+ train_dataset = load_dataset("csv", data_files="clean_dataset36_train.csv")["train"]
37
+ val_dataset = load_dataset("csv", data_files="clean_dataset36_val.csv")["train"]
38
+ print(f"Train size: {len(train_dataset)} | Val size: {len(val_dataset)}")
39
+
40
+ # --- MODEL ---
41
+ device = "cuda" if torch.cuda.is_available() else "cpu"
42
+ model = SentenceTransformer(MODEL_PATH, device=device)
43
+
44
+ # --- LOSS & EVALUATORS ---
45
+ matryoshka_dims = [768, 512, 256, 128, 64]
46
+ inner_train_loss = losses.MultipleNegativesRankingLoss(model=model)
47
+ train_loss = losses.MatryoshkaLoss(model, inner_train_loss, matryoshka_dims=matryoshka_dims)
48
+
49
+ evaluators = [
50
+ TripletEvaluator(
51
+ anchors=val_dataset["anchor"],
52
+ positives=val_dataset["positive"],
53
+ negatives=val_dataset["negative"],
54
+ name=f"dev-{dim}",
55
+ truncate_dim=dim,
56
+ ) for dim in matryoshka_dims
57
+ ]
58
+ dev_evaluator = SequentialEvaluator(evaluators, main_score_function=lambda scores: scores[0])
59
+
60
+ # --- TRAINING ARGS ---
61
+ args = SentenceTransformerTrainingArguments(
62
+ output_dir=output_dir,
63
+ num_train_epochs=2,
64
+ per_device_train_batch_size=train_batch_size,
65
+ gradient_accumulation_steps=2,
66
+ bf16=True,
67
+ learning_rate=1e-5,
68
+ warmup_ratio=0.1,
69
+ batch_sampler=BatchSamplers.NO_DUPLICATES,
70
+ eval_strategy="steps",
71
+ eval_steps=12000,
72
+ save_strategy="steps",
73
+ save_steps=12000,
74
+ save_total_limit=2,
75
+ logging_steps=200,
76
+ )
77
+
78
+ # --- RESUME IF CHECKPOINT EXISTS ---
79
+ existing_checkpoints = sorted(glob.glob(f"{output_dir}/checkpoint-*"))
80
+ resume_from = existing_checkpoints[-1] if existing_checkpoints else None
81
+ if resume_from:
82
+ print(f"Resuming from: {resume_from}")
83
+ else:
84
+ print("Starting fresh")
85
+
86
+ # --- TRAIN ---
87
+ trainer = SentenceTransformerTrainer(
88
+ model=model,
89
+ args=args,
90
+ train_dataset=train_dataset,
91
+ eval_dataset=val_dataset,
92
+ loss=train_loss,
93
+ evaluator=dev_evaluator,
94
+ )
95
+ trainer.train(resume_from_checkpoint=resume_from)
96
+
97
+ # --- SAVE FINAL ---
98
+ final_output_dir = "/home/skiredj.abderrahman/khalil/sbert_training/output/final_ms_marco"
99
+ model.save(final_output_dir)
100
+ print(f"Model saved to {final_output_dir}")
101
+
102
+ # --- FINAL EVAL ---
103
+ test_evaluators = [
104
+ TripletEvaluator(
105
+ anchors=val_dataset["anchor"],
106
+ positives=val_dataset["positive"],
107
+ negatives=val_dataset["negative"],
108
+ name=f"final-{dim}",
109
+ truncate_dim=dim,
110
+ ) for dim in matryoshka_dims
111
+ ]
112
+ SequentialEvaluator(test_evaluators)(model)
sbert_training/epoch2+2_Epochs_Ms_marco/error.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:696633f99ae7fde85ab63798fbbe9238c07a92dd84adc392ca30b46a17c4d148
3
+ size 21585268
sbert_training/epoch2+2_Epochs_Ms_marco/logs_ds36.txt ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/epoch2+2_Epochs_Ms_marco/model/1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
sbert_training/epoch2+2_Epochs_Ms_marco/model/README.md ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/epoch2+2_Epochs_Ms_marco/model/config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_cross_attention": false,
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": null,
8
+ "classifier_dropout": null,
9
+ "dtype": "float32",
10
+ "eos_token_id": null,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "is_decoder": false,
17
+ "layer_norm_eps": 1e-12,
18
+ "max_position_embeddings": 512,
19
+ "model_type": "bert",
20
+ "num_attention_heads": 12,
21
+ "num_hidden_layers": 12,
22
+ "pad_token_id": 0,
23
+ "tie_word_embeddings": true,
24
+ "transformers_version": "5.2.0",
25
+ "type_vocab_size": 2,
26
+ "use_cache": true,
27
+ "vocab_size": 64000
28
+ }
sbert_training/epoch2+2_Epochs_Ms_marco/model/config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "SentenceTransformer",
3
+ "__version__": {
4
+ "sentence_transformers": "5.2.3",
5
+ "transformers": "5.2.0",
6
+ "pytorch": "2.6.0+cu124"
7
+ },
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
sbert_training/epoch2+2_Epochs_Ms_marco/model/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:180ef0bee915b99dd2ff1ea50b89a5fe7778669ddc68670da7e40377f3be5872
3
+ size 540795728
sbert_training/epoch2+2_Epochs_Ms_marco/model/modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
sbert_training/epoch2+2_Epochs_Ms_marco/model/sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
sbert_training/epoch2+2_Epochs_Ms_marco/model/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/epoch2+2_Epochs_Ms_marco/model/tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": false,
6
+ "is_local": true,
7
+ "mask_token": "[MASK]",
8
+ "max_len": 512,
9
+ "model_max_length": 512,
10
+ "never_split": [
11
+ "[بريد]",
12
+ "[مستخدم]",
13
+ "[رابط]"
14
+ ],
15
+ "pad_token": "[PAD]",
16
+ "sep_token": "[SEP]",
17
+ "strip_accents": null,
18
+ "tokenize_chinese_chars": true,
19
+ "tokenizer_class": "BertTokenizer",
20
+ "unk_token": "[UNK]"
21
+ }
sbert_training/epoch2+2_Epochs_Ms_marco/output.log ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/epoch2/error.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e13044c2943acf7de381650f9b9e82eda0a8d8450ec29408f75290a3cdfe487
3
+ size 17162506
sbert_training/epoch2/logs.txt ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2026-02-24 17:30:09 - Load pretrained SentenceTransformer: bert-base-arabertv02
2
+ 2026-02-24 17:30:19 - '[Errno -2] Name or service not known' thrown while requesting HEAD https://huggingface.co/bert-base-arabertv02/resolve/main/./modules.json
3
+ 2026-02-24 17:30:19 - Retrying in 1s [Retry 1/5].
4
+ 2026-02-24 17:30:20 - No sentence-transformers model found with name bert-base-arabertv02. Creating a new one with mean pooling.
5
+ Model is running on: cuda
6
+ 2026-02-24 17:30:25 - Reading the training and eval dataset
7
+ 2026-02-24 17:31:43 - DatasetDict({
8
+ train: Dataset({
9
+ features: ['anchor', 'positive', 'negative'],
10
+ num_rows: 3954179
11
+ })
12
+ })
13
+ 2026-02-24 17:31:43 - DatasetDict({
14
+ train: Dataset({
15
+ features: ['anchor', 'positive', 'negative'],
16
+ num_rows: 1129759
17
+ })
18
+ })
19
+ 2026-02-24 17:31:43 - DatasetDict({
20
+ train: Dataset({
21
+ features: ['anchor', 'positive', 'negative'],
22
+ num_rows: 564877
23
+ })
24
+ })
25
+ 2026-02-24 17:31:43 - TripletEvaluator: Evaluating the model on the dev-768 dataset (truncated to 768):
26
+ 2026-02-24 17:55:01 - Accuracy Cosine Similarity: 79.01%
27
+ 2026-02-24 17:55:01 - TripletEvaluator: Evaluating the model on the dev-512 dataset (truncated to 512):
28
+ 2026-02-24 18:17:34 - Accuracy Cosine Similarity: 77.91%
29
+ 2026-02-24 18:17:34 - TripletEvaluator: Evaluating the model on the dev-256 dataset (truncated to 256):
30
+ 2026-02-24 18:39:41 - Accuracy Cosine Similarity: 79.57%
31
+ 2026-02-24 18:39:41 - TripletEvaluator: Evaluating the model on the dev-128 dataset (truncated to 128):
32
+ 2026-02-24 19:02:02 - Accuracy Cosine Similarity: 78.63%
33
+ 2026-02-24 19:02:02 - TripletEvaluator: Evaluating the model on the dev-64 dataset (truncated to 64):
34
+ 2026-02-24 19:24:20 - Accuracy Cosine Similarity: 76.00%
35
+ {'loss': '13.01', 'grad_norm': '27.4', 'learning_rate': '6.441e-07', 'epoch': '0.006474'}
36
+ {'loss': '6.428', 'grad_norm': '19.47', 'learning_rate': '1.291e-06', 'epoch': '0.01295'}
37
+ {'loss': '4.365', 'grad_norm': '17.72', 'learning_rate': '1.939e-06', 'epoch': '0.01942'}
38
+ {'loss': '3.585', 'grad_norm': '14.64', 'learning_rate': '2.586e-06', 'epoch': '0.0259'}
39
+ {'loss': '3.183', 'grad_norm': '13.4', 'learning_rate': '3.234e-06', 'epoch': '0.03237'}
40
+ {'loss': '2.873', 'grad_norm': '10.47', 'learning_rate': '3.881e-06', 'epoch': '0.03884'}
41
+ {'loss': '2.634', 'grad_norm': '12.2', 'learning_rate': '4.528e-06', 'epoch': '0.04532'}
42
+ {'loss': '2.605', 'grad_norm': '12.74', 'learning_rate': '5.176e-06', 'epoch': '0.05179'}
43
+ {'loss': '2.31', 'grad_norm': '12.29', 'learning_rate': '5.823e-06', 'epoch': '0.05827'}
44
+ {'loss': '2.236', 'grad_norm': '10.22', 'learning_rate': '6.47e-06', 'epoch': '0.06474'}
45
+ {'loss': '2.155', 'grad_norm': '9.492', 'learning_rate': '7.118e-06', 'epoch': '0.07121'}
46
+ {'loss': '2.019', 'grad_norm': '9.747', 'learning_rate': '7.765e-06', 'epoch': '0.07769'}
47
+ {'loss': '1.926', 'grad_norm': '9.491', 'learning_rate': '8.412e-06', 'epoch': '0.08416'}
48
+ {'loss': '1.927', 'grad_norm': '8.972', 'learning_rate': '9.06e-06', 'epoch': '0.09064'}
49
+ {'loss': '1.866', 'grad_norm': '10.02', 'learning_rate': '9.707e-06', 'epoch': '0.09711'}
50
+ {'loss': '1.796', 'grad_norm': '9.32', 'learning_rate': '1.035e-05', 'epoch': '0.1036'}
51
+ {'loss': '1.731', 'grad_norm': '8.47', 'learning_rate': '1.1e-05', 'epoch': '0.1101'}
52
+ {'loss': '1.725', 'grad_norm': '7.867', 'learning_rate': '1.165e-05', 'epoch': '0.1165'}
53
+ {'loss': '1.619', 'grad_norm': '9.521', 'learning_rate': '1.23e-05', 'epoch': '0.123'}
54
+ {'loss': '1.634', 'grad_norm': '9.193', 'learning_rate': '1.294e-05', 'epoch': '0.1295'}
55
+ {'loss': '1.604', 'grad_norm': '9.547', 'learning_rate': '1.359e-05', 'epoch': '0.136'}
56
+ {'loss': '1.548', 'grad_norm': '8.025', 'learning_rate': '1.424e-05', 'epoch': '0.1424'}
57
+ {'loss': '1.542', 'grad_norm': '8.197', 'learning_rate': '1.489e-05', 'epoch': '0.1489'}
58
+ {'loss': '1.507', 'grad_norm': '7.923', 'learning_rate': '1.553e-05', 'epoch': '0.1554'}
59
+ {'loss': '1.48', 'grad_norm': '7.746', 'learning_rate': '1.618e-05', 'epoch': '0.1619'}
60
+ {'loss': '1.462', 'grad_norm': '10.12', 'learning_rate': '1.683e-05', 'epoch': '0.1683'}
61
+ {'loss': '1.446', 'grad_norm': '7.806', 'learning_rate': '1.748e-05', 'epoch': '0.1748'}
62
+ {'loss': '1.424', 'grad_norm': '6.649', 'learning_rate': '1.812e-05', 'epoch': '0.1813'}
63
+ {'loss': '1.393', 'grad_norm': '7.031', 'learning_rate': '1.877e-05', 'epoch': '0.1877'}
64
+ {'loss': '1.352', 'grad_norm': '6.146', 'learning_rate': '1.942e-05', 'epoch': '0.1942'}
65
+ 2026-02-24 20:40:33 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 0.19422189851905802 after 6000 steps (truncated to 768):
66
+ 2026-02-24 21:08:51 - Accuracy Cosine Similarity: 95.64%
67
+ 2026-02-24 21:08:51 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 0.19422189851905802 after 6000 steps (truncated to 512):
68
+ 2026-02-24 21:36:55 - Accuracy Cosine Similarity: 95.66%
69
+ 2026-02-24 21:36:55 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 0.19422189851905802 after 6000 steps (truncated to 256):
70
+ 2026-02-24 22:05:02 - Accuracy Cosine Similarity: 95.60%
71
+ 2026-02-24 22:05:02 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 0.19422189851905802 after 6000 steps (truncated to 128):
72
+ 2026-02-24 22:33:12 - Accuracy Cosine Similarity: 95.46%
73
+ 2026-02-24 22:33:12 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 0.19422189851905802 after 6000 steps (truncated to 64):
74
+ 2026-02-24 23:01:40 - Accuracy Cosine Similarity: 95.13%
75
+ {'eval_train_loss': '1.216', 'eval_dev-768_cosine_accuracy': '0.9564', 'eval_dev-512_cosine_accuracy': '0.9566', 'eval_dev-256_cosine_accuracy': '0.956', 'eval_dev-128_cosine_accuracy': '0.9546', 'eval_dev-64_cosine_accuracy': '0.9513', 'eval_sequential_score': '0.9564', 'eval_train_runtime': '9876', 'eval_train_samples_per_second': '114.4', 'eval_train_steps_per_second': '1.787', 'epoch': '0.1942'}
76
+ 2026-02-24 23:01:40 - Saving model checkpoint to output/arabert_20260224_1730/checkpoint-6000
77
+ 2026-02-24 23:01:40 - Save model to output/arabert_20260224_1730/checkpoint-6000
78
+ {'loss': '1.372', 'grad_norm': '8.833', 'learning_rate': '1.999e-05', 'epoch': '0.2007'}
79
+ {'loss': '1.37', 'grad_norm': '6.729', 'learning_rate': '1.992e-05', 'epoch': '0.2072'}
80
+ {'loss': '1.352', 'grad_norm': '6.586', 'learning_rate': '1.985e-05', 'epoch': '0.2136'}
81
+ {'loss': '1.288', 'grad_norm': '6.568', 'learning_rate': '1.978e-05', 'epoch': '0.2201'}
82
+ {'loss': '1.271', 'grad_norm': '6.606', 'learning_rate': '1.971e-05', 'epoch': '0.2266'}
83
+ {'loss': '1.243', 'grad_norm': '7.913', 'learning_rate': '1.963e-05', 'epoch': '0.2331'}
84
+ {'loss': '1.23', 'grad_norm': '6.931', 'learning_rate': '1.956e-05', 'epoch': '0.2395'}
85
+ {'loss': '1.212', 'grad_norm': '6.979', 'learning_rate': '1.949e-05', 'epoch': '0.246'}
86
+ {'loss':{'loss': '1.37', 'grad_norm': '6.732', 'learning_rate': '1.992e-05', 'epoch': '0.2072'}
87
+ {'loss': '1.352', 'grad_norm': '6.583', 'learning_rate': '1.985e-05'{'loss': '1.288', 'grad_norm': '6.564', 'learning_rate': '1.978e-05', 'epoch': '0.2201'}
88
+ ':{'loss': '1.271', 'grad_norm': '6.606', 'learning_rate': '1.971e-05', 'epoch': '0.2266'}
89
+ {'loss': '1.243', 'grad_norm': '7.906', 'learning_rate': '1.963e-05', 'epoch': '0.2331'}
90
+ {'loss': '1.23', 'grad_norm': '6.921', 'learning_rate': '1.956e-05', 'epoch': '0.2395'}
91
+ {'loss': '1.212', 'grad_norm': '6.985', 'learning_rate': '1.949e-05', 'epoch': '0.246'}
92
+ {'loss': '1.222', 'grad_norm': '7.511', 'learning_rate': '1.942e-05', 'epoch': '0.2525'}
93
+ {'loss': '1.212', 'grad_norm': '7.834', 'learning_rate': '1.935e-05', 'epoch': '0.259'}
94
+ {'loss': '1.199', 'grad_norm': '5.273', 'learning_rate': '1.927e-05', 'epoch': '0.2654'}
95
+ {'loss': '1.207', 'grad_norm': '7.454', 'learning_rate': '1.92e-05', 'epoch': '0.2719'}
96
+ {'loss': '1.197', 'grad_norm': '7.585', 'learning_rate': '1.913e-05', 'epoch': '0.2784'}
97
+ {'loss': '1.128', 'grad_norm': '7.16', 'learning_rate': '1.906e-05', 'epoch': '0.2849'}
98
+ {'loss': '1.139', 'grad_norm': '6.354', 'learning_rate': '1.899e-05', 'epoch': '0.2913'}
99
+ {'loss': '1.197', 'grad_norm': '8.433', 'learning_rate': '1.891e-05', 'epoch': '0.2978'}
100
+ {'loss': '1.099', 'grad_norm': '5.537', 'learning_rate': '1.884e-05', 'epoch': '0.3043'}
101
+ {'loss': '1.133', 'grad_norm': '7.014', 'learning_rate': '1.877e-05', 'epoch': '0.3108'}
102
+ {'loss': '1.104', 'grad_norm': '7.172', 'learning_rate': '1.87e-05', 'epoch': '0.3172'}
103
+ {'loss': '1.116', 'grad_norm': '7.246', 'learning_rate': '1.863e-05', 'epoch': '0.3237'}
104
+ {'loss': '1.083', 'grad_norm': '7.252', 'learning_rate': '1.855e-05', 'epoch': '0.3302'}
105
+ {'loss': '1.043', 'grad_norm': '9.376', 'learning_rate': '1.848e-05', 'epoch': '0.3367'}
106
+ {'loss': '1.104', 'grad_norm': '6.334', 'learning_rate': '1.841e-05', 'epoch': '0.3431'}
107
+ {'loss': '1.074', 'grad_norm': '8.013', 'learning_rate': '1.834e-05', 'epoch': '0.3496'}
108
+ {'loss': '1.075', 'grad_norm': '6.887', 'learning_rate': '1.827e-05', 'epoch': '0.3561'}
109
+ {'loss': '1.059', 'grad_norm': '6.77', 'learning_rate': '1.819e-05', 'epoch': '0.3625'}
110
+ {'loss': '1.063', 'grad_norm': '5.884', 'learning_rate': '1.812e-05', 'epoch': '0.369'}
111
+ {'loss': '1.025', 'grad_norm': '4.584', 'learning_rate': '1.805e-05', 'epoch': '0.3755'}
112
+ {'loss': '1.049', 'grad_norm': '5.729', 'learning_rate': '1.798e-05', 'epoch': '0.382'}
113
+ {'loss': '1.045', 'grad_norm': '4.304', 'learning_rate': '1.791e-05', 'epoch': '0.3884'}
114
+ 2026-02-25 16:31:58 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 0.38844379703811605 after 12000 steps (truncated to 768):
115
+ 2026-02-25 16:53:08 - Accuracy Cosine Similarity: 96.68%
116
+ 2026-02-25 16:53:08 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 0.38844379703811605 after 12000 steps (truncated to 512):
117
+ 2026-02-25 17:13:37 - Accuracy Cosine Similarity: 96.67%
118
+ 2026-02-25 17:13:37 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 0.38844379703811605 after 12000 steps (truncated to 256):
119
+ 2026-02-25 17:34:09 - Accuracy Cosine Similarity: 96.64%
120
+ 2026-02-25 17:34:09 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 0.38844379703811605 after 12000 steps (truncated to 128):
121
+ 2026-02-25 17:54:44 - Accuracy Cosine Similarity: 96.56%
122
+ 2026-02-25 17:54:44 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 0.38844379703811605 after 12000 steps (truncated to 64):
123
+ 2026-02-25 18:15:17 - Accuracy Cosine Similarity: 96.28%
124
+ {'eval_train_loss': '0.5325', 'eval_dev-768_cosine_accuracy': '0.9668', 'eval_dev-512_cosine_accuracy': '0.9667', 'eval_dev-256_cosine_accuracy': '0.9664', 'eval_dev-128_cosine_accuracy': '0.9656', 'eval_dev-64_cosine_accuracy': '0.9628', 'eval_sequential_score': '0.9668', 'eval_train_runtime': '9281', 'eval_train_samples_per_second': '121.7', 'eval_train_steps_per_second': '15.22', 'epoch': '0.3884'}
125
+ 2026-02-25 18:15:17 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-12000
126
+ 2026-02-25 18:15:17 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-12000
127
+ {'loss': '0.9883', 'grad_norm': '5.449', 'learning_rate': '1.783e-05', 'epoch': '0.3949'}
128
+ {'loss': '0.9907', 'grad_norm': '5.808', 'learning_rate': '1.776e-05', 'epoch': '0.4014'}
129
+ {'loss': '1.022', 'grad_norm': '6.168', 'learning_rate': '1.769e-05', 'epoch': '0.4079'}
130
+ {'loss': '0.987', 'grad_norm': '5.675', 'learning_rate': '1.762e-05', 'epoch': '0.4143'}
131
+ {'loss': '1.033', 'grad_norm': '5.961', 'learning_rate': '1.755e-05', 'epoch': '0.4208'}
132
+ {'loss': '0.9989', 'grad_norm': '7.682', 'learning_rate': '1.748e-05', 'epoch': '0.4273'}
133
+ {'loss': '0.9805', 'grad_norm': '6.046', 'learning_rate': '1.74e-05', 'epoch': '0.4338'}
134
+ {'loss': '0.9484', 'grad_norm': '6.129', 'learning_rate': '1.733e-05', 'epoch': '0.4402'}
135
+ {'loss': '0.9937', 'grad_norm': '4.2', 'learning_rate': '1.726e-05', 'epoch': '0.4467'}
136
+ {'loss': '1.016', 'grad_norm': '7.164', 'learning_rate': '1.719e-05', 'epoch': '0.4532'}
137
+ {'loss': '0.9726', 'grad_norm': '5.905', 'learning_rate': '1.712e-05', 'epoch': '0.4597'}
138
+ {'loss': '0.96', 'grad_norm': '5.824', 'learning_rate': '1.704e-05', 'epoch': '0.4661'}
139
+ {'loss': '0.9528', 'grad_norm': '6.058', 'learning_rate': '1.697e-05', 'epoch': '0.4726'}
140
+ {'loss': '0.9292', 'grad_norm': '4.911', 'learning_rate': '1.69e-05', 'epoch': '0.4791'}
141
+ {'loss': '0.9157', 'grad_norm': '6.308', 'learning_rate': '1.683e-05', 'epoch': '0.4856'}
142
+ {'loss': '0.9244', 'grad_norm': '5.036', 'learning_rate': '1.676e-05', 'epoch': '0.492'}
143
+ {'loss': '0.9192', 'grad_norm': '3.666', 'learning_rate': '1.668e-05', 'epoch': '0.4985'}
144
+ {'loss': '0.9424', 'grad_norm': '4.06', 'learning_rate': '1.661e-05', 'epoch': '0.505'}
145
+ {'loss': '0.9067', 'grad_norm': '5.872', 'learning_rate': '1.654e-05', 'epoch': '0.5115'}
146
+ {'loss': '0.9334', 'grad_norm': '5.868', 'learning_rate': '1.647e-05', 'epoch': '0.5179'}
147
+ {'loss': '0.8922', 'grad_norm': '6.681', 'learning_rate': '1.64e-05', 'epoch': '0.5244'}
148
+ {'loss': '0.9122', 'grad_norm': '7.907', 'learning_rate': '1.632e-05', 'epoch': '0.5309'}
149
+ {'loss': '0.8825', 'grad_norm': '6.144', 'learning_rate': '1.625e-05', 'epoch': '0.5373'}
150
+ {'loss': '0.9069', 'grad_norm': '6.138', 'learning_rate': '1.618e-05', 'epoch': '0.5438'}
151
+ {'loss': '0.894', 'grad_norm': '6.968', 'learning_rate': '1.611e-05', 'epoch': '0.5503'}
152
+ {'loss': '0.8898', 'grad_norm': '6.487', 'learning_rate': '1.604e-05', 'epoch': '0.5568'}
153
+ {'loss': '0.8735', 'grad_norm': '4.058', 'learning_rate': '1.596e-05', 'epoch': '0.5632'}
154
+ {'loss': '0.8694', 'grad_norm': '5.403', 'learning_rate': '1.589e-05', 'epoch': '0.5697'}
155
+ {'loss': '0.8776', 'grad_norm': '6.723', 'learning_rate': '1.582e-05', 'epoch': '0.5762'}
156
+ {'loss': '0.8664', 'grad_norm': '4.427', 'learning_rate': '1.575e-05', 'epoch': '0.5827'}
157
+ 2026-02-25 20:05:35 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 0.5826656955571741 after 18000 steps (truncated to 768):
158
+ 2026-02-25 20:26:21 - Accuracy Cosine Similarity: 97.12%
159
+ 2026-02-25 20:26:21 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 0.5826656955571741 after 18000 steps (truncated to 512):
160
+ 2026-02-25 20:46:59 - Accuracy Cosine Similarity: 97.11%
161
+ 2026-02-25 20:46:59 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 0.5826656955571741 after 18000 steps (truncated to 256):
162
+ 2026-02-25 21:07:40 - Accuracy Cosine Similarity: 97.09%
163
+ 2026-02-25 21:07:40 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 0.5826656955571741 after 18000 steps (truncated to 128):
164
+ 2026-02-25 21:28:20 - Accuracy Cosine Similarity: 97.03%
165
+ 2026-02-25 21:28:20 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 0.5826656955571741 after 18000 steps (truncated to 64):
166
+ 2026-02-25 21:49:02 - Accuracy Cosine Similarity: 96.82%
167
+ {'eval_train_loss': '0.4541', 'eval_dev-768_cosine_accuracy': '0.9712', 'eval_dev-512_cosine_accuracy': '0.9711', 'eval_dev-256_cosine_accuracy': '0.9709', 'eval_dev-128_cosine_accuracy': '0.9703', 'eval_dev-64_cosine_accuracy': '0.9682', 'eval_sequential_score': '0.9712', 'eval_train_runtime': '9294', 'eval_train_samples_per_second': '121.6', 'eval_train_steps_per_second': '15.19', 'epoch': '0.5827'}
168
+ 2026-02-25 21:49:02 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-18000
169
+ 2026-02-25 21:49:02 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-18000
170
+
171
+ 2026-02-26 14:22:01 - Load pretrained SentenceTransformer: bert-base-arabertv02
172
+ 2026-02-26 14:22:14 - '[Errno -2] Name or service not known' thrown while requesting HEAD https://huggingface.co/bert-base-arabertv02/resolve/main/./modules.json
173
+ 2026-02-26 14:22:14 - Retrying in 1s [Retry 1/5].
174
+ 2026-02-26 14:22:15 - No sentence-transformers model found with name bert-base-arabertv02. Creating a new one with mean pooling.
175
+ 2026-02-26 14:23:53 - Use pytorch device_name: cuda:0
176
+ 2026-02-26 14:23:53 - Load pretrained SentenceTransformer: /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-18000
177
+ {'loss': '0.8727', 'grad_norm': '5.438', 'learning_rate': '1.568e-05', 'epoch': '0.5891'}
178
+ {'loss': '0.8524', 'grad_norm': '5.458', 'learning_rate': '1.56e-05', 'epoch': '0.5956'}
179
+ {'loss': '0.8995', 'grad_norm': '6.666', 'learning_rate': '1.553e-05', 'epoch': '0.6021'}
180
+ {'loss': '0.836', 'grad_norm': '5.681', 'learning_rate': '1.546e-05', 'epoch': '0.6086'}
181
+ {'loss': '0.8628', 'grad_norm': '6.571', 'learning_rate': '1.539e-05', 'epoch': '0.615'}
182
+ {'loss': '0.8244', 'grad_norm': '6.389', 'learning_rate': '1.532e-05', 'epoch': '0.6215'}
183
+ {'loss': '0.8647', 'grad_norm': '4.987', 'learning_rate': '1.525e-05', 'epoch': '0.628'}
184
+ {'loss': '0.8479', 'grad_norm': '4.451', 'learning_rate': '1.517e-05', 'epoch': '0.6345'}
185
+ {'loss': '0.8204', 'grad_norm': '5.356', 'learning_rate': '1.51e-05', 'epoch': '0.6409'}
186
+ {'loss': '0.8359', 'grad_norm': '5.146', 'learning_rate': '1.503e-05', 'epoch': '0.6474'}
187
+ {'loss': '0.7952', 'grad_norm': '4.308', 'learning_rate': '1.496e-05', 'epoch': '0.6539'}
188
+ {'loss': '0.8375', 'grad_norm': '5.216', 'learning_rate': '1.489e-05', 'epoch': '0.6604'}
189
+ {'loss': '0.8364', 'grad_norm': '5.812', 'learning_rate': '1.481e-05', 'epoch': '0.6668'}
190
+ {'loss': '0.8131', 'grad_norm': '5.52', 'learning_rate': '1.474e-05', 'epoch': '0.6733'}
191
+ {'loss': '0.831', 'grad_norm': '6.452', 'learning_rate': '1.467e-05', 'epoch': '0.6798'}
192
+ {'loss': '0.8295', 'grad_norm': '4.274', 'learning_rate': '1.46e-05', 'epoch': '0.6863'}
193
+ {'loss': '0.7865', 'grad_norm': '4.77', 'learning_rate': '1.453e-05', 'epoch': '0.6927'}
194
+ {'loss': '0.796', 'grad_norm': '5.027', 'learning_rate': '1.445e-05', 'epoch': '0.6992'}
195
+ {'loss': '0.8287', 'grad_norm': '4.826', 'learning_rate': '1.438e-05', 'epoch': '0.7057'}
196
+ {'loss': '0.8214', 'grad_norm': '4.381', 'learning_rate': '1.431e-05', 'epoch': '0.7121'}
197
+ {'loss': '0.7879', 'grad_norm': '6.475', 'learning_rate': '1.424e-05', 'epoch': '0.7186'}
198
+ {'loss': '0.8139', 'grad_norm': '5.295', 'learning_rate': '1.417e-05', 'epoch': '0.7251'}
199
+ {'loss': '0.7849', 'grad_norm': '5.051', 'learning_rate': '1.409e-05', 'epoch': '0.7316'}
200
+ {'loss': '0.788', 'grad_norm': '5.113', 'learning_rate': '1.402e-05', 'epoch': '0.738'}
201
+ {'loss': '0.7725', 'grad_norm': '4.049', 'learning_rate': '1.395e-05', 'epoch': '0.7445'}
202
+ {'loss': '0.8086', 'grad_norm': '4.646', 'learning_rate': '1.388e-05', 'epoch': '0.751'}
203
+ {'loss': '0.7687', 'grad_norm': '5.049', 'learning_rate': '1.381e-05', 'epoch': '0.7575'}
204
+ {'loss': '0.7828', 'grad_norm': '6.568', 'learning_rate': '1.373e-05', 'epoch': '0.7639'}
205
+ {'loss': '0.7518', 'grad_norm': '5.9', 'learning_rate': '1.366e-05', 'epoch': '0.7704'}
206
+ {'loss': '0.7599', 'grad_norm': '6.338', 'learning_rate': '1.359e-05', 'epoch': '0.7769'}
207
+ 2026-02-26 16:19:09 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 0.7768875940762321 after 24000 steps (truncated to 768):
208
+ 2026-02-26 16:40:53 - Accuracy Cosine Similarity: 97.37%
209
+ 2026-02-26 16:40:53 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 0.7768875940762321 after 24000 steps (truncated to 512):
210
+ 2026-02-26 17:02:09 - Accuracy Cosine Similarity: 97.38%
211
+ 2026-02-26 17:02:09 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 0.7768875940762321 after 24000 steps (truncated to 256):
212
+ 2026-02-26 17:23:27 - Accuracy Cosine Similarity: 97.38%
213
+ 2026-02-26 17:23:27 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 0.7768875940762321 after 24000 steps (truncated to 128):
214
+ 2026-02-26 17:44:42 - Accuracy Cosine Similarity: 97.34%
215
+ 2026-02-26 17:44:42 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 0.7768875940762321 after 24000 steps (truncated to 64):
216
+ 2026-02-26 18:06:06 - Accuracy Cosine Similarity: 97.18%
217
+ {'eval_train_loss': '0.4041', 'eval_dev-768_cosine_accuracy': '0.9737', 'eval_dev-512_cosine_accuracy': '0.9738', 'eval_dev-256_cosine_accuracy': '0.9738', 'eval_dev-128_cosine_accuracy': '0.9734', 'eval_dev-64_cosine_accuracy': '0.9718', 'eval_sequential_score': '0.9737', 'eval_train_runtime': '9673', 'eval_train_samples_per_second': '116.8', 'eval_train_steps_per_second': '14.6', 'epoch': '0.7769'}
218
+ 2026-02-26 18:06:06 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-24000
219
+ 2026-02-26 18:06:06 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-24000
220
+ {'loss': '0.7332', 'grad_norm': '4.95', 'learning_rate': '1.352e-05', 'epoch': '0.7834'}
221
+ {'loss': '0.7476', 'grad_norm': '4.513', 'learning_rate': '1.345e-05', 'epoch': '0.7898'}
222
+ {'loss': '0.7806', 'grad_norm': '5.095', 'learning_rate': '1.337e-05', 'epoch': '0.7963'}
223
+ {'loss': '0.7511', 'grad_norm': '5.826', 'learning_rate': '1.33e-05', 'epoch': '0.8028'}
224
+ {'loss': '0.7652', 'grad_norm': '6.09', 'learning_rate': '1.323e-05', 'epoch': '0.8093'}
225
+ {'loss': '0.7883', 'grad_norm': '4.332', 'learning_rate': '1.316e-05', 'epoch': '0.8157'}
226
+ {'loss': '0.7305', 'grad_norm': '5.749', 'learning_rate': '1.309e-05', 'epoch': '0.8222'}
227
+ {'loss': '0.7308', 'grad_norm': '4.871', 'learning_rate': '1.302e-05', 'epoch': '0.8287'}
228
+ {'loss': '0.7368', 'grad_norm': '4.618', 'learning_rate': '1.294e-05', 'epoch': '0.8352'}
229
+ {'loss': '0.7432', 'grad_norm': '4.836', 'learning_rate': '1.287e-05', 'epoch': '0.8416'}
230
+ {'loss': '0.7046', 'grad_norm': '4.988', 'learning_rate': '1.28e-05', 'epoch': '0.8481'}
231
+ {'loss': '0.7476', 'grad_norm': '4.596', 'learning_rate': '1.273e-05', 'epoch': '0.8546'}
232
+ {'loss': '0.7212', 'grad_norm': '5.712', 'learning_rate': '1.266e-05', 'epoch': '0.8611'}
233
+ {'loss': '0.7335', 'grad_norm': '3.99', 'learning_rate': '1.258e-05', 'epoch': '0.8675'}
234
+ {'loss': '0.7415', 'grad_norm': '5.446', 'learning_rate': '1.251e-05', 'epoch': '0.874'}
235
+ {'loss': '0.6937', 'grad_norm': '5.257', 'learning_rate': '1.244e-05', 'epoch': '0.8805'}
236
+ {'loss': '0.7294', 'grad_norm': '5.302', 'learning_rate': '1.237e-05', 'epoch': '0.8869'}
237
+ {'loss': '0.7436', 'grad_norm': '3.847', 'learning_rate': '1.23e-05', 'epoch': '0.8934'}
238
+ {'loss': '0.7093', 'grad_norm': '6.182', 'learning_rate': '1.222e-05', 'epoch': '0.8999'}
239
+ {'loss': '0.748', 'grad_norm': '5.445', 'learning_rate': '1.215e-05', 'epoch': '0.9064'}
240
+ {'loss': '0.7039', 'grad_norm': '5.002', 'learning_rate': '1.208e-05', 'epoch': '0.9128'}
241
+ {'loss': '0.7091', 'grad_norm': '5.085', 'learning_rate': '1.201e-05', 'epoch': '0.9193'}
242
+ {'loss': '0.7019', 'grad_norm': '5.379', 'learning_rate': '1.194e-05', 'epoch': '0.9258'}
243
+ {'loss': '0.7081', 'grad_norm': '5.63', 'learning_rate': '1.186e-05', 'epoch': '0.9323'}
244
+ {'loss': '0.6833', 'grad_norm': '2.541', 'learning_rate': '1.179e-05', 'epoch': '0.9387'}
245
+ {'loss': '0.6982', 'grad_norm': '5.714', 'learning_rate': '1.172e-05', 'epoch': '0.9452'}
246
+ {'loss': '0.7249', 'grad_norm': '5.051', 'learning_rate': '1.165e-05', 'epoch': '0.9517'}
247
+ {'loss': '0.7282', 'grad_norm': '6.322', 'learning_rate': '1.158e-05', 'epoch': '0.9582'}
248
+ {'loss': '0.7147', 'grad_norm': '4.961', 'learning_rate': '1.15e-05', 'epoch': '0.9646'}
249
+ {'loss': '0.6742', 'grad_norm': '4.871', 'learning_rate': '1.143e-05', 'epoch': '0.9711'}
250
+ 2026-02-26 19:59:22 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 0.9711094925952901 after 30000 steps (truncated to 768):
251
+ 2026-02-26 20:20:41 - Accuracy Cosine Similarity: 97.58%
252
+ 2026-02-26 20:20:41 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 0.9711094925952901 after 30000 steps (truncated to 512):
253
+ 2026-02-26 20:42:02 - Accuracy Cosine Similarity: 97.59%
254
+ 2026-02-26 20:42:02 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 0.9711094925952901 after 30000 steps (truncated to 256):
255
+ 2026-02-26 21:03:17 - Accuracy Cosine Similarity: 97.61%
256
+ 2026-02-26 21:03:17 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 0.9711094925952901 after 30000 steps (truncated to 128):
257
+ 2026-02-26 21:24:42 - Accuracy Cosine Similarity: 97.57%
258
+ 2026-02-26 21:24:42 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 0.9711094925952901 after 30000 steps (truncated to 64):
259
+ 2026-02-26 21:46:03 - Accuracy Cosine Similarity: 97.42%
260
+ {'eval_train_loss': '0.364', 'eval_dev-768_cosine_accuracy': '0.9758', 'eval_dev-512_cosine_accuracy': '0.9759', 'eval_dev-256_cosine_accuracy': '0.9761', 'eval_dev-128_cosine_accuracy': '0.9757', 'eval_dev-64_cosine_accuracy': '0.9742', 'eval_sequential_score': '0.9758', 'eval_train_runtime': '9649', 'eval_train_samples_per_second': '117.1', 'eval_train_steps_per_second': '14.64', 'epoch': '0.9711'}
261
+ 2026-02-26 21:46:03 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-30000
262
+ 2026-02-26 21:46:03 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-30000
263
+ {'loss': '0.6901', 'grad_norm': '3.348', 'learning_rate': '1.136e-05', 'epoch': '0.9776'}
264
+ {'loss': '0.7067', 'grad_norm': '3.76', 'learning_rate': '1.129e-05', 'epoch': '0.9841'}
265
+ {'loss': '0.7166', 'grad_norm': '4.729', 'learning_rate': '1.122e-05', 'epoch': '0.9905'}
266
+ {'loss': '0.68', 'grad_norm': '4.648', 'learning_rate': '1.114e-05', 'epoch': '0.997'}
267
+ {'loss': '0.6846', 'grad_norm': '4.427', 'learning_rate': '1.107e-05', 'epoch': '1.003'}
268
+ {'loss': '0.6723', 'grad_norm': '4.459', 'learning_rate': '1.1e-05', 'epoch': '1.01'}
269
+ {'loss': '0.6573', 'grad_norm': '6.387', 'learning_rate': '1.093e-05', 'epoch': '1.016'}
270
+ {'loss': '0.6895', 'grad_norm': '4.1', 'learning_rate': '1.086e-05', 'epoch': '1.023'}
271
+ {'loss': '0.6588', 'grad_norm': '5.927', 'learning_rate': '1.079e-05', 'epoch': '1.029'}
272
+ {'loss': '0.6517', 'grad_norm': '5.9', 'learning_rate': '1.071e-05', 'epoch': '1.036'}
273
+ {'loss': '0.6498', 'grad_norm': '4.736', 'learning_rate': '1.064e-05', 'epoch': '1.042'}
274
+ {'loss': '0.6836', 'grad_norm': '5.029', 'learning_rate': '1.057e-05', 'epoch': '1.049'}
275
+ {'loss': '0.6819', 'grad_norm': '2.595', 'learning_rate': '1.05e-05', 'epoch': '1.055'}
276
+ {'loss': '0.6463', 'grad_norm': '4.963', 'learning_rate': '1.043e-05', 'epoch': '1.062'}
277
+ {'loss': '0.6645', 'grad_norm': '5.046', 'learning_rate': '1.035e-05', 'epoch': '1.068'}
278
+ {'loss': '0.6518', 'grad_norm': '3.307', 'learning_rate': '1.028e-05', 'epoch': '1.075'}
279
+ {'loss': '0.6235', 'grad_norm': '3.848', 'learning_rate': '1.021e-05', 'epoch': '1.081'}
280
+ {'loss': '0.6302', 'grad_norm': '4.664', 'learning_rate': '1.014e-05', 'epoch': '1.088'}
281
+ {'loss': '0.6452', 'grad_norm': '5.47', 'learning_rate': '1.007e-05', 'epoch': '1.094'}
282
+ {'loss': '0.6477', 'grad_norm': '5.26', 'learning_rate': '9.994e-06', 'epoch': '1.101'}
283
+ {'loss': '0.6084', 'grad_norm': '4.313', 'learning_rate': '9.922e-06', 'epoch': '1.107'}
284
+ {'loss': '0.6259', 'grad_norm': '6.499', 'learning_rate': '9.85e-06', 'epoch': '1.114'}
285
+ {'loss': '0.607', 'grad_norm': '3.922', 'learning_rate': '9.778e-06', 'epoch': '1.12'}
286
+ {'loss': '0.5977', 'grad_norm': '5.37', 'learning_rate': '9.706e-06', 'epoch': '1.126'}
287
+ {'loss': '0.6044', 'grad_norm': '5.068', 'learning_rate': '9.634e-06', 'epoch': '1.133'}
288
+ {'loss': '0.6007', 'grad_norm': '4.109', 'learning_rate': '9.562e-06', 'epoch': '1.139'}
289
+ {'loss': '0.5628', 'grad_norm': '4.954', 'learning_rate': '9.491e-06', 'epoch': '1.146'}
290
+ {'loss': '0.5732', 'grad_norm': '4.068', 'learning_rate': '9.419e-06', 'epoch': '1.152'}
291
+ {'loss': '0.5773', 'grad_norm': '4.939', 'learning_rate': '9.347e-06', 'epoch': '1.159'}
292
+ {'loss': '0.5719', 'grad_norm': '4.418', 'learning_rate': '9.275e-06', 'epoch': '1.165'}
293
+ 2026-02-26 23:38:18 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 1.1653152059561382 after 36000 steps (truncated to 768):
294
+ 2026-02-27 00:01:17 - Accuracy Cosine Similarity: 97.75%
295
+ 2026-02-27 00:01:17 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 1.1653152059561382 after 36000 steps (truncated to 512):
296
+ 2026-02-27 00:23:59 - Accuracy Cosine Similarity: 97.77%
297
+ 2026-02-27 00:23:59 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 1.1653152059561382 after 36000 steps (truncated to 256):
298
+ 2026-02-27 00:46:38 - Accuracy Cosine Similarity: 97.77%
299
+ 2026-02-27 00:46:38 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 1.1653152059561382 after 36000 steps (truncated to 128):
300
+ 2026-02-27 01:09:18 - Accuracy Cosine Similarity: 97.74%
301
+ 2026-02-27 01:09:18 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 1.1653152059561382 after 36000 steps (truncated to 64):
302
+ 2026-02-27 01:32:14 - Accuracy Cosine Similarity: 97.60%
303
+ {'eval_train_loss': '0.3356', 'eval_dev-768_cosine_accuracy': '0.9775', 'eval_dev-512_cosine_accuracy': '0.9777', 'eval_dev-256_cosine_accuracy': '0.9777', 'eval_dev-128_cosine_accuracy': '0.9774', 'eval_dev-64_cosine_accuracy': '0.976', 'eval_sequential_score': '0.9775', 'eval_train_runtime': '1.01e+04', 'eval_train_samples_per_second': '111.8', 'eval_train_steps_per_second': '13.98', 'epoch': '1.165'}
304
+ 2026-02-27 01:32:14 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-36000
305
+ 2026-02-27 01:32:14 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-36000
306
+ {'loss': '0.5471', 'grad_norm': '3.58', 'learning_rate': '9.203e-06', 'epoch': '1.172'}
307
+ {'loss': '0.5635', 'grad_norm': '5.198', 'learning_rate': '9.131e-06', 'epoch': '1.178'}
308
+ {'loss': '0.539', 'grad_norm': '4.468', 'learning_rate': '9.059e-06', 'epoch': '1.185'}
309
+ {'loss': '0.5428', 'grad_norm': '4.349', 'learning_rate': '8.987e-06', 'epoch': '1.191'}
310
+ {'loss': '0.5205', 'grad_norm': '2.936', 'learning_rate': '8.915e-06', 'epoch': '1.198'}
311
+ {'loss': '0.5362', 'grad_norm': '3.337', 'learning_rate': '8.843e-06', 'epoch': '1.204'}
312
+ {'loss': '0.5386', 'grad_norm': '5.76', 'learning_rate': '8.771e-06', 'epoch': '1.211'}
313
+ {'loss': '0.5203', 'grad_norm': '3.261', 'learning_rate': '8.699e-06', 'epoch': '1.217'}
314
+ {'loss': '0.5301', 'grad_norm': '3.732', 'learning_rate': '8.627e-06', 'epoch': '1.224'}
315
+ {'loss': '0.5232', 'grad_norm': '4.54', 'learning_rate': '8.555e-06', 'epoch': '1.23'}
316
+ {'loss': '0.4922', 'grad_norm': '4.291', 'learning_rate': '8.483e-06', 'epoch': '1.237'}
317
+ {'loss': '0.5029', 'grad_norm': '3.979', 'learning_rate': '8.412e-06', 'epoch': '1.243'}
318
+ {'loss': '0.4989', 'grad_norm': '7.829', 'learning_rate': '8.34e-06', 'epoch': '1.249'}
319
+ {'loss': '0.5053', 'grad_norm': '2.903', 'learning_rate': '8.268e-06', 'epoch': '1.256'}
320
+ {'loss': '0.5081', 'grad_norm': '5.471', 'learning_rate': '8.196e-06', 'epoch': '1.262'}
321
+ {'loss': '0.496', 'grad_norm': '5.204', 'learning_rate': '8.124e-06', 'epoch': '1.269'}
322
+ {'loss': '0.5052', 'grad_norm': '4.377', 'learning_rate': '8.052e-06', 'epoch': '1.275'}
323
+ {'loss': '0.4984', 'grad_norm': '4.184', 'learning_rate': '7.98e-06', 'epoch': '1.282'}
324
+ {'loss': '0.4909', 'grad_norm': '4.991', 'learning_rate': '7.908e-06', 'epoch': '1.288'}
325
+ {'loss': '0.512', 'grad_norm': '3.76', 'learning_rate': '7.836e-06', 'epoch': '1.295'}
326
+ {'loss': '0.4873', 'grad_norm': '3.844', 'learning_rate': '7.764e-06', 'epoch': '1.301'}
327
+ {'loss': '0.4896', 'grad_norm': '6.987', 'learning_rate': '7.692e-06', 'epoch': '1.308'}
328
+ {'loss': '0.49', 'grad_norm': '6.267', 'learning_rate': '7.62e-06', 'epoch': '1.314'}
329
+ {'loss': '0.5036', 'grad_norm': '3.776', 'learning_rate': '7.548e-06', 'epoch': '1.321'}
330
+ {'loss': '0.4876', 'grad_norm': '3.42', 'learning_rate': '7.476e-06', 'epoch': '1.327'}
331
+ {'loss': '0.4705', 'grad_norm': '5.478', 'learning_rate': '7.404e-06', 'epoch': '1.334'}
332
+ {'loss': '0.4786', 'grad_norm': '3.313', 'learning_rate': '7.333e-06', 'epoch': '1.34'}
333
+ {'loss': '0.4998', 'grad_norm': '3.13', 'learning_rate': '7.261e-06', 'epoch': '1.347'}
334
+ {'loss': '0.4692', 'grad_norm': '3.971', 'learning_rate': '7.189e-06', 'epoch': '1.353'}
335
+ {'loss': '0.5064', 'grad_norm': '6.238', 'learning_rate': '7.117e-06', 'epoch': '1.36'}
336
+ 2026-02-27 03:24:31 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 1.3595371044751963 after 42000 steps (truncated to 768):
337
+ 2026-02-27 03:47:24 - Accuracy Cosine Similarity: 97.88%
338
+ 2026-02-27 03:47:24 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 1.3595371044751963 after 42000 steps (truncated to 512):
339
+ 2026-02-27 04:10:18 - Accuracy Cosine Similarity: 97.90%
340
+ 2026-02-27 04:10:18 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 1.3595371044751963 after 42000 steps (truncated to 256):
341
+ 2026-02-27 04:33:12 - Accuracy Cosine Similarity: 97.90%
342
+ 2026-02-27 04:33:12 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 1.3595371044751963 after 42000 steps (truncated to 128):
343
+ 2026-02-27 04:56:07 - Accuracy Cosine Similarity: 97.85%
344
+ 2026-02-27 04:56:07 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 1.3595371044751963 after 42000 steps (truncated to 64):
345
+ 2026-02-27 05:19:11 - Accuracy Cosine Similarity: 97.74%
346
+ {'eval_train_loss': '0.316', 'eval_dev-768_cosine_accuracy': '0.9788', 'eval_dev-512_cosine_accuracy': '0.979', 'eval_dev-256_cosine_accuracy': '0.979', 'eval_dev-128_cosine_accuracy': '0.9785', 'eval_dev-64_cosine_accuracy': '0.9774', 'eval_sequential_score': '0.9788', 'eval_train_runtime': '1.014e+04', 'eval_train_samples_per_second': '111.5', 'eval_train_steps_per_second': '13.93', 'epoch': '1.36'}
347
+ 2026-02-27 05:19:11 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-42000
348
+ 2026-02-27 05:19:11 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-42000
349
+ {'loss': '0.4925', 'grad_norm': '5.158', 'learning_rate': '7.045e-06', 'epoch': '1.366'}
350
+ {'loss': '0.4601', 'grad_norm': '4.139', 'learning_rate': '6.973e-06', 'epoch': '1.372'}
351
+ {'loss': '0.4762', 'grad_norm': '3.411', 'learning_rate': '6.901e-06', 'epoch': '1.379'}
352
+ {'loss': '0.4986', 'grad_norm': '4.23', 'learning_rate': '6.829e-06', 'epoch': '1.385'}
353
+ {'loss': '0.4656', 'grad_norm': '5.326', 'learning_rate': '6.757e-06', 'epoch': '1.392'}
354
+ {'loss': '0.4507', 'grad_norm': '3.826', 'learning_rate': '6.685e-06', 'epoch': '1.398'}
355
+ {'loss': '0.4862', 'grad_norm': '3.509', 'learning_rate': '6.613e-06', 'epoch': '1.405'}
356
+ {'loss': '0.4596', 'grad_norm': '4.734', 'learning_rate': '6.541e-06', 'epoch': '1.411'}
357
+ {'loss': '0.4696', 'grad_norm': '4.799', 'learning_rate': '6.469e-06', 'epoch': '1.418'}
358
+ {'loss': '0.4925', 'grad_norm': '4.942', 'learning_rate': '6.397e-06', 'epoch': '1.424'}
359
+ {'loss': '0.4796', 'grad_norm': '4.147', 'learning_rate': '6.325e-06', 'epoch': '1.431'}
360
+ {'loss': '0.4525', 'grad_norm': '5.146', 'learning_rate': '6.254e-06', 'epoch': '1.437'}
361
+ {'loss': '0.4717', 'grad_norm': '3.52', 'learning_rate': '6.182e-06', 'epoch': '1.444'}
362
+ {'loss': '0.4803', 'grad_norm': '3.25', 'learning_rate': '6.11e-06', 'epoch': '1.45'}
363
+ {'loss': '0.4675', 'grad_norm': '7.35', 'learning_rate': '6.038e-06', 'epoch': '1.457'}
364
+ {'loss': '0.4631', 'grad_norm': '3.847', 'learning_rate': '5.966e-06', 'epoch': '1.463'}
365
+ {'loss': '0.4622', 'grad_norm': '4.57', 'learning_rate': '5.894e-06', 'epoch': '1.47'}
366
+ {'loss': '0.4496', 'grad_norm': '1.997', 'learning_rate': '5.822e-06', 'epoch': '1.476'}
367
+ {'loss': '0.4678', 'grad_norm': '4.266', 'learning_rate': '5.75e-06', 'epoch': '1.483'}
368
+ {'loss': '0.4495', 'grad_norm': '5.948', 'learning_rate': '5.678e-06', 'epoch': '1.489'}
369
+ {'loss': '0.4474', 'grad_norm': '3.7', 'learning_rate': '5.606e-06', 'epoch': '1.495'}
370
+ {'loss': '0.4587', 'grad_norm': '2.877', 'learning_rate': '5.534e-06', 'epoch': '1.502'}
371
+ {'loss': '0.4591', 'grad_norm': '4.245', 'learning_rate': '5.462e-06', 'epoch': '1.508'}
372
+ {'loss': '0.4573', 'grad_norm': '5.431', 'learning_rate': '5.39e-06', 'epoch': '1.515'}
373
+ {'loss': '0.4442', 'grad_norm': '3.338', 'learning_rate': '5.318e-06', 'epoch': '1.521'}
374
+ {'loss': '0.455', 'grad_norm': '4.723', 'learning_rate': '5.246e-06', 'epoch': '1.528'}
375
+ {'loss': '0.4493', 'grad_norm': '4.226', 'learning_rate': '5.175e-06', 'epoch': '1.534'}
376
+ {'loss': '0.4485', 'grad_norm': '4.451', 'learning_rate': '5.103e-06', 'epoch': '1.541'}
377
+ {'loss': '0.4569', 'grad_norm': '4.297', 'learning_rate': '5.031e-06', 'epoch': '1.547'}
378
+ {'loss': '0.4346', 'grad_norm': '4.199', 'learning_rate': '4.959e-06', 'epoch': '1.554'}
379
+ 2026-02-27 07:11:49 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 1.5537590029942543 after 48000 steps (truncated to 768):
380
+ 2026-02-27 07:34:37 - Accuracy Cosine Similarity: 97.99%
381
+ 2026-02-27 07:34:37 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 1.5537590029942543 after 48000 steps (truncated to 512):
382
+ 2026-02-27 07:57:13 - Accuracy Cosine Similarity: 98.02%
383
+ 2026-02-27 07:57:13 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 1.5537590029942543 after 48000 steps (truncated to 256):
384
+ 2026-02-27 08:20:07 - Accuracy Cosine Similarity: 98.02%
385
+ 2026-02-27 08:20:07 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 1.5537590029942543 after 48000 steps (truncated to 128):
386
+ 2026-02-27 08:42:52 - Accuracy Cosine Similarity: 97.98%
387
+ 2026-02-27 08:42:52 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 1.5537590029942543 after 48000 steps (truncated to 64):
388
+ 2026-02-27 09:05:32 - Accuracy Cosine Similarity: 97.88%
389
+ {'eval_train_loss': '0.3001', 'eval_dev-768_cosine_accuracy': '0.9799', 'eval_dev-512_cosine_accuracy': '0.9802', 'eval_dev-256_cosine_accuracy': '0.9802', 'eval_dev-128_cosine_accuracy': '0.9798', 'eval_dev-64_cosine_accuracy': '0.9788', 'eval_sequential_score': '0.9799', 'eval_train_runtime': '1.008e+04', 'eval_train_samples_per_second': '112.1', 'eval_train_steps_per_second': '14.02', 'epoch': '1.554'}
390
+ 2026-02-27 09:05:32 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-48000
391
+ 2026-02-27 09:05:32 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-48000
392
+ {'loss': '0.4469', 'grad_norm': '3.364', 'learning_rate': '4.887e-06', 'epoch': '1.56'}
393
+ {'loss': '0.4602', 'grad_norm': '5.309', 'learning_rate': '4.815e-06', 'epoch': '1.567'}
394
+ {'loss': '0.443', 'grad_norm': '3.875', 'learning_rate': '4.743e-06', 'epoch': '1.573'}
395
+ {'loss': '0.4524', 'grad_norm': '4.824', 'learning_rate': '4.671e-06', 'epoch': '1.58'}
396
+ {'loss': '0.4528', 'grad_norm': '4.996', 'learning_rate': '4.599e-06', 'epoch': '1.586'}
397
+ {'loss': '0.4348', 'grad_norm': '4.96', 'learning_rate': '4.527e-06', 'epoch': '1.593'}
398
+ {'loss': '0.4533', 'grad_norm': '5.219', 'learning_rate': '4.455e-06', 'epoch': '1.599'}
399
+ {'loss': '0.4523', 'grad_norm': '3.444', 'learning_rate': '4.383e-06', 'epoch': '1.606'}
400
+ {'loss': '0.4509', 'grad_norm': '5.647', 'learning_rate': '4.311e-06', 'epoch': '1.612'}
401
+ {'loss': '0.4365', 'grad_norm': '5.052', 'learning_rate': '4.239e-06', 'epoch': '1.618'}
402
+ {'loss': '0.4504', 'grad_norm': '5.786', 'learning_rate': '4.167e-06', 'epoch': '1.625'}
403
+ {'loss': '0.4292', 'grad_norm': '4.353', 'learning_rate': '4.096e-06', 'epoch': '1.631'}
404
+ {'loss': '0.4406', 'grad_norm': '2.976', 'learning_rate': '4.024e-06', 'epoch': '1.638'}
405
+ {'loss': '0.4333', 'grad_norm': '3.685', 'learning_rate': '3.952e-06', 'epoch': '1.644'}
406
+ {'loss': '0.4361', 'grad_norm': '4.107', 'learning_rate': '3.88e-06', 'epoch': '1.651'}
407
+ {'loss': '0.4065', 'grad_norm': '3.636', 'learning_rate': '3.808e-06', 'epoch': '1.657'}
408
+ {'loss': '0.4671', 'grad_norm': '3.464', 'learning_rate': '3.736e-06', 'epoch': '1.664'}
409
+ {'loss': '0.4328', 'grad_norm': '3.129', 'learning_rate': '3.664e-06', 'epoch': '1.67'}
410
+ {'loss': '0.431', 'grad_norm': '2.453', 'learning_rate': '3.592e-06', 'epoch': '1.677'}
411
+ {'loss': '0.4523', 'grad_norm': '3.727', 'learning_rate': '3.52e-06', 'epoch': '1.683'}
412
+ {'loss': '0.4232', 'grad_norm': '4.398', 'learning_rate': '3.448e-06', 'epoch': '1.69'}
413
+ {'loss': '0.4257', 'grad_norm': '2.861', 'learning_rate': '3.376e-06', 'epoch': '1.696'}
414
+ {'loss': '0.4448', 'grad_norm': '3.523', 'learning_rate': '3.304e-06', 'epoch': '1.703'}
415
+ {'loss': '0.4491', 'grad_norm': '3.893', 'learning_rate': '3.232e-06', 'epoch': '1.709'}
416
+ {'loss': '0.4224', 'grad_norm': '3.399', 'learning_rate': '3.16e-06', 'epoch': '1.716'}
417
+ {'loss': '0.4297', 'grad_norm': '4.703', 'learning_rate': '3.088e-06', 'epoch': '1.722'}
418
+ {'loss': '0.4522', 'grad_norm': '4.29', 'learning_rate': '3.017e-06', 'epoch': '1.729'}
419
+ {'loss': '0.4195', 'grad_norm': '4.29', 'learning_rate': '2.945e-06', 'epoch': '1.735'}
420
+ {'loss': '0.4227', 'grad_norm': '3.841', 'learning_rate': '2.873e-06', 'epoch': '1.742'}
421
+ {'loss': '0.4381', 'grad_norm': '4.086', 'learning_rate': '2.801e-06', 'epoch': '1.748'}
422
+ 2026-02-27 10:59:10 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 1.7479809015133123 after 54000 steps (truncated to 768):
423
+ 2026-02-27 11:22:08 - Accuracy Cosine Similarity: 98.07%
424
+ 2026-02-27 11:22:08 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 1.7479809015133123 after 54000 steps (truncated to 512):
425
+ 2026-02-27 11:44:57 - Accuracy Cosine Similarity: 98.08%
426
+ 2026-02-27 11:44:57 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 1.7479809015133123 after 54000 steps (truncated to 256):
427
+ 2026-02-27 12:07:55 - Accuracy Cosine Similarity: 98.08%
428
+ 2026-02-27 12:07:55 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 1.7479809015133123 after 54000 steps (truncated to 128):
429
+ 2026-02-27 12:30:35 - Accuracy Cosine Similarity: 98.05%
430
+ 2026-02-27 12:30:35 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 1.7479809015133123 after 54000 steps (truncated to 64):
431
+ 2026-02-27 12:53:24 - Accuracy Cosine Similarity: 97.94%
432
+ {'eval_train_loss': '0.2875', 'eval_dev-768_cosine_accuracy': '0.9807', 'eval_dev-512_cosine_accuracy': '0.9808', 'eval_dev-256_cosine_accuracy': '0.9808', 'eval_dev-128_cosine_accuracy': '0.9805', 'eval_dev-64_cosine_accuracy': '0.9794', 'eval_sequential_score': '0.9807', 'eval_train_runtime': '1.012e+04', 'eval_train_samples_per_second': '111.6', 'eval_train_steps_per_second': '13.95', 'epoch': '1.748'}
433
+ 2026-02-27 12:53:24 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-54000
434
+ 2026-02-27 12:53:24 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-54000
435
+ {'loss': '0.446', 'grad_norm': '4.176', 'learning_rate': '2.729e-06', 'epoch': '1.754'}
436
+ {'loss': '0.426', 'grad_norm': '4.261', 'learning_rate': '2.657e-06', 'epoch': '1.761'}
437
+ {'loss': '0.4299', 'grad_norm': '4.676', 'learning_rate': '2.585e-06', 'epoch': '1.767'}
438
+ {'loss': '0.4247', 'grad_norm': '3.933', 'learning_rate': '2.513e-06', 'epoch': '1.774'}
439
+ {'loss': '0.4244', 'grad_norm': '4.853', 'learning_rate': '2.441e-06', 'epoch': '1.78'}
440
+ {'loss': '0.4185', 'grad_norm': '2.985', 'learning_rate': '2.369e-06', 'epoch': '1.787'}
441
+ {'loss': '0.4292', 'grad_norm': '3.804', 'learning_rate': '2.297e-06', 'epoch': '1.793'}
442
+ {'loss': '0.4468', 'grad_norm': '3.187', 'learning_rate': '2.225e-06', 'epoch': '1.8'}
443
+ {'loss': '0.4118', 'grad_norm': '4.004', 'learning_rate': '2.153e-06', 'epoch': '1.806'}
444
+ {'loss': '0.4306', 'grad_norm': '4.007', 'learning_rate': '2.081e-06', 'epoch': '1.813'}
445
+ {'loss': '0.4447', 'grad_norm': '4.323', 'learning_rate': '2.009e-06', 'epoch': '1.819'}
446
+ {'loss': '0.4147', 'grad_norm': '3.863', 'learning_rate': '1.938e-06', 'epoch': '1.826'}
447
+ {'loss': '0.4189', 'grad_norm': '4.788', 'learning_rate': '1.866e-06', 'epoch': '1.832'}
448
+ {'loss': '0.4167', 'grad_norm': '4.276', 'learning_rate': '1.794e-06', 'epoch': '1.839'}
449
+ {'loss': '0.4022', 'grad_norm': '3.887', 'learning_rate': '1.722e-06', 'epoch': '1.845'}
450
+ {'loss': '0.4158', 'grad_norm': '3.075', 'learning_rate': '1.65e-06', 'epoch': '1.852'}
451
+ {'loss': '0.4228', 'grad_norm': '3.993', 'learning_rate': '1.578e-06', 'epoch': '1.858'}
452
+ {'loss': '0.4256', 'grad_norm': '4.497', 'learning_rate': '1.506e-06', 'epoch': '1.865'}
453
+ {'loss': '0.4251', 'grad_norm': '4.539', 'learning_rate': '1.434e-06', 'epoch': '1.871'}
454
+ {'loss': '0.4232', 'grad_norm': '2.337', 'learning_rate': '1.362e-06', 'epoch': '1.877'}
455
+ {'loss': '0.4143', 'grad_norm': '3.389', 'learning_rate': '1.29e-06', 'epoch': '1.884'}
456
+ {'loss': '0.4331', 'grad_norm': '3.545', 'learning_rate': '1.218e-06', 'epoch': '1.89'}
457
+ {'loss': '0.4253', 'grad_norm': '5.606', 'learning_rate': '1.146e-06', 'epoch': '1.897'}
458
+ {'loss': '0.441', 'grad_norm': '4.453', 'learning_rate': '1.074e-06', 'epoch': '1.903'}
459
+ {'loss': '0.4337', 'grad_norm': '5.374', 'learning_rate': '1.002e-06', 'epoch': '1.91'}
460
+ {'loss': '0.4016', 'grad_norm': '2.246', 'learning_rate': '9.305e-07', 'epoch': '1.916'}
461
+ {'loss': '0.4249', 'grad_norm': '5.255', 'learning_rate': '8.585e-07', 'epoch': '1.923'}
462
+ {'loss': '0.4108', 'grad_norm': '3.59', 'learning_rate': '7.866e-07', 'epoch': '1.929'}
463
+ {'loss': '0.4272', 'grad_norm': '4.258', 'learning_rate': '7.147e-07', 'epoch': '1.936'}
464
+ {'loss': '0.3916', 'grad_norm': '3.476', 'learning_rate': '6.427e-07', 'epoch': '1.942'}
465
+ 2026-02-27 14:47:29 - TripletEvaluator: Evaluating the model on the dev-768 dataset in epoch 1.9422028000323703 after 60000 steps (truncated to 768):
466
+ 2026-02-27 15:10:59 - Accuracy Cosine Similarity: 98.10%
467
+ 2026-02-27 15:10:59 - TripletEvaluator: Evaluating the model on the dev-512 dataset in epoch 1.9422028000323703 after 60000 steps (truncated to 512):
468
+ 2026-02-27 15:34:30 - Accuracy Cosine Similarity: 98.11%
469
+ 2026-02-27 15:34:30 - TripletEvaluator: Evaluating the model on the dev-256 dataset in epoch 1.9422028000323703 after 60000 steps (truncated to 256):
470
+ 2026-02-27 15:58:10 - Accuracy Cosine Similarity: 98.13%
471
+ 2026-02-27 15:58:10 - TripletEvaluator: Evaluating the model on the dev-128 dataset in epoch 1.9422028000323703 after 60000 steps (truncated to 128):
472
+ 2026-02-27 16:21:18 - Accuracy Cosine Similarity: 98.11%
473
+ 2026-02-27 16:21:18 - TripletEvaluator: Evaluating the model on the dev-64 dataset in epoch 1.9422028000323703 after 60000 steps (truncated to 64):
474
+ 2026-02-27 16:44:14 - Accuracy Cosine Similarity: 97.97%
475
+ {'eval_train_loss': '0.2812', 'eval_dev-768_cosine_accuracy': '0.981', 'eval_dev-512_cosine_accuracy': '0.9811', 'eval_dev-256_cosine_accuracy': '0.9813', 'eval_dev-128_cosine_accuracy': '0.9811', 'eval_dev-64_cosine_accuracy': '0.9797', 'eval_sequential_score': '0.981', 'eval_train_runtime': '1.03e+04', 'eval_train_samples_per_second': '109.7', 'eval_train_steps_per_second': '13.71', 'epoch': '1.942'}
476
+ 2026-02-27 16:44:14 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-60000
477
+ 2026-02-27 16:44:14 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-60000
478
+ {'loss': '0.4334', 'grad_norm': '4.623', 'learning_rate': '5.708e-07', 'epoch': '1.949'}
479
+ {'loss': '0.4462', 'grad_norm': '5.31', 'learning_rate': '4.989e-07', 'epoch': '1.955'}
480
+ {'loss': '0.4436', 'grad_norm': '3.379', 'learning_rate': '4.269e-07', 'epoch': '1.962'}
481
+ {'loss': '0.4278', 'grad_norm': '5.471', 'learning_rate': '3.55e-07', 'epoch': '1.968'}
482
+ {'loss': '0.417', 'grad_norm': '3.435', 'learning_rate': '2.831e-07', 'epoch': '1.975'}
483
+ {'loss': '0.4376', 'grad_norm': '2.617', 'learning_rate': '2.111e-07', 'epoch': '1.981'}
484
+ {'loss': '0.4433', 'grad_norm': '3.465', 'learning_rate': '1.392e-07', 'epoch': '1.988'}
485
+ {'loss': '0.4292', 'grad_norm': '2.354', 'learning_rate': '6.726e-08', 'epoch': '1.994'}
486
+ 2026-02-27 17:01:56 - Saving model checkpoint to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-61786
487
+ 2026-02-27 17:01:56 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-61786
488
+ {'train_runtime': '9.588e+04', 'train_samples_per_second': '82.48', 'train_steps_per_second': '0.644', 'train_loss': '0.403', 'epoch': '2'}
489
+ 2026-02-27 17:01:58 - Save model to /home/skiredj.abderrahman/khalil/sbert_training/output/final
490
+ model saved successfully
491
+ 2026-02-27 17:01:59 - TripletEvaluator: Evaluating the model on the test-768 dataset (truncated to 768):
492
+ 2026-02-27 17:21:39 - Accuracy Cosine Similarity: 98.10%
493
+ 2026-02-27 17:21:39 - TripletEvaluator: Evaluating the model on the test-512 dataset (truncated to 512):
494
+ 2026-02-27 17:41:10 - Accuracy Cosine Similarity: 98.13%
495
+ 2026-02-27 17:41:10 - TripletEvaluator: Evaluating the model on the test-256 dataset (truncated to 256):
496
+ 2026-02-27 18:00:40 - Accuracy Cosine Similarity: 98.13%
497
+ 2026-02-27 18:00:40 - TripletEvaluator: Evaluating the model on the test-128 dataset (truncated to 128):
498
+ 2026-02-27 18:20:06 - Accuracy Cosine Similarity: 98.11%
499
+ 2026-02-27 18:20:06 - TripletEvaluator: Evaluating the model on the test-64 dataset (truncated to 64):
500
+ 2026-02-27 18:39:32 - Accuracy Cosine Similarity: 97.97%
sbert_training/epoch2/model/1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
sbert_training/epoch2/model/README.md ADDED
@@ -0,0 +1,773 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - dense
7
+ - generated_from_trainer
8
+ - dataset_size:3954179
9
+ - loss:MatryoshkaLoss
10
+ - loss:MultipleNegativesRankingLoss
11
+ widget:
12
+ - source_sentence: إذا لم تكن قد فعلت ذلك بالفعل ، تحقق من تصميمنا الجديد للمراسلات
13
+ والحوارات واليوميات .
14
+ sentences:
15
+ - تم إعادة تصميم الرسائل والحوارات .
16
+ - يقدم مقهى بارج كل من وجبات الغداء والإفطار .
17
+ - قبل ان نعرف اسماء بعضنا او اي شيء قد تعانقنا وبكىنا .
18
+ - source_sentence: أين تقع جامعة واينزبرج
19
+ sentences:
20
+ - جامعة دالاس بابتيست ( DBU ) ، المعروفة سابقا باسم كلية دالاس بابتيست ، هي جامعة
21
+ فنون ليبرالية مسيحية تقع في دالاس ، تكساس . يقع الحرم الجامعي الرئيسي على بعد
22
+ حوالي 12 ميلا ( 19 كم ) جنوب غرب وسط مدينة دالاس ويطل على بحيرة ماونتين كريك .
23
+ تأسست جامعة دالاس بابتيست عام 1898 باسم كلية ديكاتور بابتيست ، وتدير حاليا حرما
24
+ جامعيا في دالاس وبلانو وهيرست .
25
+ - الزوجان معا
26
+ - تقع جامعة واينسبرغ في حرم جامعي معاصر في تلال جنوب غرب ولاية بنسلفانيا ، مع ثلاثة
27
+ مراكز للبالغين تقع في مناطق بيتسبرغ في ساوثبوينت وكرانبيري ومونروفيل . تم إدراج
28
+ Hanna Hall و Miller Hall في السجل الوطني للأماكن التاريخية .
29
+ - source_sentence: The isolated Russian forces resisted in several areas for two more
30
+ days .
31
+ sentences:
32
+ - 'ياهو : كيف يمكنني معرفة ما إذا كان البريد الإلكتروني الذي أرسلته قد تم استلامه
33
+ أو قراءته ؟'
34
+ - واستمرت الاشتباكات الحدودية خلال اليومين المقبلين ، حيث استهدفت المخافر الحدودية
35
+ من الجانبين والتي أسفرت عن وقوع عشرات الإصابات .
36
+ - قاومت القوات الروسية المعزولة في عة مناطق لمدة يومين آخرين .
37
+ - source_sentence: فتاة هيبي بشعر أشقر وأرجواني على الجانب يرتدي قميص أبيض وملابس
38
+ سوداء
39
+ sentences:
40
+ - فتاة " هيبي " ترتدي قميصا أبيضا وملابس سوداء شعرها أشقر وأحمر
41
+ - المرأة تضع يدها في جيب الرجل
42
+ - فتاة لديها سترة حمراء وسوداء
43
+ - source_sentence: رجل وامرأة يجلسان في سيارة ووجههما في الاتجاه المعاكس من الكاميرا
44
+ sentences:
45
+ - هناك شخصان وسيارة
46
+ - سيارة صدئة هي الشيء الوحيد المرئي
47
+ - كان أفضل حالا
48
+ pipeline_tag: sentence-similarity
49
+ library_name: sentence-transformers
50
+ metrics:
51
+ - cosine_accuracy
52
+ model-index:
53
+ - name: SentenceTransformer
54
+ results:
55
+ - task:
56
+ type: triplet
57
+ name: Triplet
58
+ dataset:
59
+ name: dev 768
60
+ type: dev-768
61
+ metrics:
62
+ - type: cosine_accuracy
63
+ value: 0.9809960126876831
64
+ name: Cosine Accuracy
65
+ - task:
66
+ type: triplet
67
+ name: Triplet
68
+ dataset:
69
+ name: dev 512
70
+ type: dev-512
71
+ metrics:
72
+ - type: cosine_accuracy
73
+ value: 0.9811199903488159
74
+ name: Cosine Accuracy
75
+ - task:
76
+ type: triplet
77
+ name: Triplet
78
+ dataset:
79
+ name: dev 256
80
+ type: dev-256
81
+ metrics:
82
+ - type: cosine_accuracy
83
+ value: 0.9813200235366821
84
+ name: Cosine Accuracy
85
+ - task:
86
+ type: triplet
87
+ name: Triplet
88
+ dataset:
89
+ name: dev 128
90
+ type: dev-128
91
+ metrics:
92
+ - type: cosine_accuracy
93
+ value: 0.9811360239982605
94
+ name: Cosine Accuracy
95
+ - task:
96
+ type: triplet
97
+ name: Triplet
98
+ dataset:
99
+ name: dev 64
100
+ type: dev-64
101
+ metrics:
102
+ - type: cosine_accuracy
103
+ value: 0.9796760082244873
104
+ name: Cosine Accuracy
105
+ ---
106
+
107
+ # SentenceTransformer
108
+
109
+ This is a [sentence-transformers](https://www.SBERT.net) model trained on the train dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
110
+
111
+ ## Model Details
112
+
113
+ ### Model Description
114
+ - **Model Type:** Sentence Transformer
115
+ <!-- - **Base model:** [Unknown](https://huggingface.co/unknown) -->
116
+ - **Maximum Sequence Length:** 512 tokens
117
+ - **Output Dimensionality:** 768 dimensions
118
+ - **Similarity Function:** Cosine Similarity
119
+ - **Training Dataset:**
120
+ - train
121
+ <!-- - **Language:** Unknown -->
122
+ <!-- - **License:** Unknown -->
123
+
124
+ ### Model Sources
125
+
126
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
127
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
128
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
129
+
130
+ ### Full Model Architecture
131
+
132
+ ```
133
+ SentenceTransformer(
134
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'BertModel'})
135
+ (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})
136
+ )
137
+ ```
138
+
139
+ ## Usage
140
+
141
+ ### Direct Usage (Sentence Transformers)
142
+
143
+ First install the Sentence Transformers library:
144
+
145
+ ```bash
146
+ pip install -U sentence-transformers
147
+ ```
148
+
149
+ Then you can load this model and run inference.
150
+ ```python
151
+ from sentence_transformers import SentenceTransformer
152
+
153
+ # Download from the 🤗 Hub
154
+ model = SentenceTransformer("sentence_transformers_model_id")
155
+ # Run inference
156
+ sentences = [
157
+ 'رجل وامرأة يجلسان في سيارة ووجههما في الاتجاه المعاكس من الكاميرا',
158
+ 'هناك شخصان وسيارة',
159
+ 'سيارة صدئة هي الشيء الوحيد المرئي',
160
+ ]
161
+ embeddings = model.encode(sentences)
162
+ print(embeddings.shape)
163
+ # [3, 768]
164
+
165
+ # Get the similarity scores for the embeddings
166
+ similarities = model.similarity(embeddings, embeddings)
167
+ print(similarities)
168
+ # tensor([[1.0000, 0.6451, 0.3299],
169
+ # [0.6451, 1.0000, 0.4022],
170
+ # [0.3299, 0.4022, 1.0000]])
171
+ ```
172
+
173
+ <!--
174
+ ### Direct Usage (Transformers)
175
+
176
+ <details><summary>Click to see the direct usage in Transformers</summary>
177
+
178
+ </details>
179
+ -->
180
+
181
+ <!--
182
+ ### Downstream Usage (Sentence Transformers)
183
+
184
+ You can finetune this model on your own dataset.
185
+
186
+ <details><summary>Click to expand</summary>
187
+
188
+ </details>
189
+ -->
190
+
191
+ <!--
192
+ ### Out-of-Scope Use
193
+
194
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
195
+ -->
196
+
197
+ ## Evaluation
198
+
199
+ ### Metrics
200
+
201
+ #### Triplet
202
+
203
+ * Dataset: `dev-768`
204
+ * Evaluated with [<code>TripletEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator) with these parameters:
205
+ ```json
206
+ {
207
+ "truncate_dim": 768
208
+ }
209
+ ```
210
+
211
+ | Metric | Value |
212
+ |:--------------------|:----------|
213
+ | **cosine_accuracy** | **0.981** |
214
+
215
+ #### Triplet
216
+
217
+ * Dataset: `dev-512`
218
+ * Evaluated with [<code>TripletEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator) with these parameters:
219
+ ```json
220
+ {
221
+ "truncate_dim": 512
222
+ }
223
+ ```
224
+
225
+ | Metric | Value |
226
+ |:--------------------|:-----------|
227
+ | **cosine_accuracy** | **0.9811** |
228
+
229
+ #### Triplet
230
+
231
+ * Dataset: `dev-256`
232
+ * Evaluated with [<code>TripletEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator) with these parameters:
233
+ ```json
234
+ {
235
+ "truncate_dim": 256
236
+ }
237
+ ```
238
+
239
+ | Metric | Value |
240
+ |:--------------------|:-----------|
241
+ | **cosine_accuracy** | **0.9813** |
242
+
243
+ #### Triplet
244
+
245
+ * Dataset: `dev-128`
246
+ * Evaluated with [<code>TripletEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator) with these parameters:
247
+ ```json
248
+ {
249
+ "truncate_dim": 128
250
+ }
251
+ ```
252
+
253
+ | Metric | Value |
254
+ |:--------------------|:-----------|
255
+ | **cosine_accuracy** | **0.9811** |
256
+
257
+ #### Triplet
258
+
259
+ * Dataset: `dev-64`
260
+ * Evaluated with [<code>TripletEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator) with these parameters:
261
+ ```json
262
+ {
263
+ "truncate_dim": 64
264
+ }
265
+ ```
266
+
267
+ | Metric | Value |
268
+ |:--------------------|:-----------|
269
+ | **cosine_accuracy** | **0.9797** |
270
+
271
+ <!--
272
+ ## Bias, Risks and Limitations
273
+
274
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
275
+ -->
276
+
277
+ <!--
278
+ ### Recommendations
279
+
280
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
281
+ -->
282
+
283
+ ## Training Details
284
+
285
+ ### Training Dataset
286
+
287
+ #### train
288
+
289
+ * Dataset: train
290
+ * Size: 3,954,179 training samples
291
+ * Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
292
+ * Approximate statistics based on the first 1000 samples:
293
+ | | anchor | positive | negative |
294
+ |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
295
+ | type | string | string | string |
296
+ | details | <ul><li>min: 4 tokens</li><li>mean: 16.1 tokens</li><li>max: 113 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 41.85 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 41.99 tokens</li><li>max: 512 tokens</li></ul> |
297
+ * Samples:
298
+ | anchor | positive | negative |
299
+ |:----------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
300
+ | <code>في أي مقاطعة تقع لويسفيل أركنساس</code> | <code>لويسفيل هي بلدة في مقاطعة لافاييت ، أركنساس ، الولايات المتحدة . كان عدد السكان 1285 في تعداد عام 2000 . . المدينة هي مقر مقاطعة لافاييت .</code> | <code>ماونتن هوم ، أركنساس . ماونتن هوم هي مدينة صغيرة في مقاطعة باكستر ، أركنساس ، الولايات المتحدة ، في جبال أوزارك الجنوبية بالقرب من حدود الولاية الشمالية مع ميسوري . اعتبارا من تعداد عام 2010 ، بلغ عدد سكان المدينة 12448 نسمة .</code> |
301
+ | <code>متوسط سمك باب الخزانة</code> | <code>تتميز أبواب العالم القديم بميزات رائعة مثل السماكة المتزايدة ، والملامح الأعمق ، والأعمدة والقضبان الأوسع لإضفاء مظهر وإحساس أكثر دراماتيكية عند مقارنتها بأبواب الخزانة التقليدية . يبلغ عرض Stiles Rails القياسية 3 بوصات ويمكن تصنيعها في 1 و 1 1 - 8 و 1 سمك .</code> | <code>اعتمادا على الخطأ في اللوحة ، يبلغ متوسط أسعار الإصلاح 130 دولارا لإصلاح الأبواب الفولاذية و 190 دولارا للخشب و 170 دولارا للألمنيوم و 150 دولارا للألياف الزجاجية . مزيد من المعلومات حول كيفية استبدال لوحة باب المرآب . إذا تعطلت أداة فتح باب الجراج ، فقد تكون سلامتك في خطر . تريد التأكد من أن بابك يعمل بشكل صحيح حتى لا يغلق بطريق الخطأ على حيوان أليف أو شخص . تريد أيضا إغلاقها لإبعاد اللصوص عن منزلك .</code> |
302
+ | <code>ما هو تعريف الملء</code> | <code>اعادة تعبئه . اسم تخصيص ثان لوكيل الوصفات الطبية تم الحصول عليه من الصيدلية ، والذي يسمح به فعل الوصفة الأصلية علم الأدوية للحصول على المزيد من دواء معين ، بعد استخدام الكمية الموصوفة في البداية من الوكيل أو إعطائها . انظر الوصفة الطبية .</code> | <code>تعليمات إعادة الملء قم بإعادة الملء فقط باستخدام Spectracide ' Bug Stop Home Barrier Refill . قم بإزالة الغطاء . قم بقياس وصب 12 . 8 أونصة سائلة من المركز في حاوية فارغة سعة 1 جالون من Spectracide - Bug Stop - حاجز منزلي ، واملأه حتى 1 جالون بالماء ، استبدل الغطاء وأغلقه بإحكام . المنتج المنسكب قم بقياس 12 . 8 أونصة سائلة من المركز وصبها بحذر في حاوية فارغة سعة 1 جالون من Spectracide - حاجز منزلي من Spectracide - حاجز منزلي ، واملأه حتى 1 جالون بالماء . استبدل الغطاء وأغلقه بإحكام . امسح أي منتج مسكوب .</code> |
303
+ * Loss: [<code>MatryoshkaLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
304
+ ```json
305
+ {
306
+ "loss": "MultipleNegativesRankingLoss",
307
+ "matryoshka_dims": [
308
+ 768,
309
+ 512,
310
+ 256,
311
+ 128,
312
+ 64
313
+ ],
314
+ "matryoshka_weights": [
315
+ 1,
316
+ 1,
317
+ 1,
318
+ 1,
319
+ 1
320
+ ],
321
+ "n_dims_per_step": -1
322
+ }
323
+ ```
324
+
325
+ ### Evaluation Dataset
326
+
327
+ #### train
328
+
329
+ * Dataset: train
330
+ * Size: 1,129,759 evaluation samples
331
+ * Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
332
+ * Approximate statistics based on the first 1000 samples:
333
+ | | anchor | positive | negative |
334
+ |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
335
+ | type | string | string | string |
336
+ | details | <ul><li>min: 4 tokens</li><li>mean: 16.7 tokens</li><li>max: 150 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 36.54 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 35.42 tokens</li><li>max: 512 tokens</li></ul> |
337
+ * Samples:
338
+ | anchor | positive | negative |
339
+ |:---------------------------------------------------------------------|:---------------------------------|:----------------------------------------------------------------------|
340
+ | <code>رجل يرتدي سروال تنس أزرق وقميص بولو أبيض يضرب كرة التنس</code> | <code>رجل يلعب رياضة</code> | <code>هناك رجل يرتدي زي البيسبول يضرب كرة البيسبول بمضرب التنس</code> |
341
+ | <code>امرأة في ثوب أسود تبدو متفاجئة</code> | <code>امرأة تغيرت مشاعرها</code> | <code>امرأة تسبح في المحيط</code> |
342
+ | <code>رجل يرتدي قميص أبيض يقفز على شيء ما على دراجته الصفراء</code> | <code>رجل يركب دراجته</code> | <code>رجل يركب لوح التزلج فوق المنحدر</code> |
343
+ * Loss: [<code>MatryoshkaLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
344
+ ```json
345
+ {
346
+ "loss": "MultipleNegativesRankingLoss",
347
+ "matryoshka_dims": [
348
+ 768,
349
+ 512,
350
+ 256,
351
+ 128,
352
+ 64
353
+ ],
354
+ "matryoshka_weights": [
355
+ 1,
356
+ 1,
357
+ 1,
358
+ 1,
359
+ 1
360
+ ],
361
+ "n_dims_per_step": -1
362
+ }
363
+ ```
364
+
365
+ ### Training Hyperparameters
366
+ #### Non-Default Hyperparameters
367
+
368
+ - `per_device_train_batch_size`: 64
369
+ - `num_train_epochs`: 2
370
+ - `learning_rate`: 2e-05
371
+ - `warmup_steps`: 0.1
372
+ - `gradient_accumulation_steps`: 2
373
+ - `bf16`: True
374
+ - `eval_strategy`: steps
375
+ - `warmup_ratio`: 0.1
376
+ - `batch_sampler`: no_duplicates
377
+
378
+ #### All Hyperparameters
379
+ <details><summary>Click to expand</summary>
380
+
381
+ - `per_device_train_batch_size`: 64
382
+ - `num_train_epochs`: 2
383
+ - `max_steps`: -1
384
+ - `learning_rate`: 2e-05
385
+ - `lr_scheduler_type`: linear
386
+ - `lr_scheduler_kwargs`: None
387
+ - `warmup_steps`: 0.1
388
+ - `optim`: adamw_torch
389
+ - `optim_args`: None
390
+ - `weight_decay`: 0.0
391
+ - `adam_beta1`: 0.9
392
+ - `adam_beta2`: 0.999
393
+ - `adam_epsilon`: 1e-08
394
+ - `optim_target_modules`: None
395
+ - `gradient_accumulation_steps`: 2
396
+ - `average_tokens_across_devices`: True
397
+ - `max_grad_norm`: 1.0
398
+ - `label_smoothing_factor`: 0.0
399
+ - `bf16`: True
400
+ - `fp16`: False
401
+ - `bf16_full_eval`: False
402
+ - `fp16_full_eval`: False
403
+ - `tf32`: None
404
+ - `gradient_checkpointing`: False
405
+ - `gradient_checkpointing_kwargs`: None
406
+ - `torch_compile`: False
407
+ - `torch_compile_backend`: None
408
+ - `torch_compile_mode`: None
409
+ - `use_liger_kernel`: False
410
+ - `liger_kernel_config`: None
411
+ - `use_cache`: False
412
+ - `neftune_noise_alpha`: None
413
+ - `torch_empty_cache_steps`: None
414
+ - `auto_find_batch_size`: False
415
+ - `log_on_each_node`: True
416
+ - `logging_nan_inf_filter`: True
417
+ - `include_num_input_tokens_seen`: no
418
+ - `log_level`: passive
419
+ - `log_level_replica`: warning
420
+ - `disable_tqdm`: False
421
+ - `project`: huggingface
422
+ - `trackio_space_id`: trackio
423
+ - `eval_strategy`: steps
424
+ - `per_device_eval_batch_size`: 8
425
+ - `prediction_loss_only`: True
426
+ - `eval_on_start`: False
427
+ - `eval_do_concat_batches`: True
428
+ - `eval_use_gather_object`: False
429
+ - `eval_accumulation_steps`: None
430
+ - `include_for_metrics`: []
431
+ - `batch_eval_metrics`: False
432
+ - `save_only_model`: False
433
+ - `save_on_each_node`: False
434
+ - `enable_jit_checkpoint`: False
435
+ - `push_to_hub`: False
436
+ - `hub_private_repo`: None
437
+ - `hub_model_id`: None
438
+ - `hub_strategy`: every_save
439
+ - `hub_always_push`: False
440
+ - `hub_revision`: None
441
+ - `load_best_model_at_end`: False
442
+ - `ignore_data_skip`: False
443
+ - `restore_callback_states_from_checkpoint`: False
444
+ - `full_determinism`: False
445
+ - `seed`: 42
446
+ - `data_seed`: None
447
+ - `use_cpu`: False
448
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
449
+ - `parallelism_config`: None
450
+ - `dataloader_drop_last`: False
451
+ - `dataloader_num_workers`: 0
452
+ - `dataloader_pin_memory`: True
453
+ - `dataloader_persistent_workers`: False
454
+ - `dataloader_prefetch_factor`: None
455
+ - `remove_unused_columns`: True
456
+ - `label_names`: None
457
+ - `train_sampling_strategy`: random
458
+ - `length_column_name`: length
459
+ - `ddp_find_unused_parameters`: None
460
+ - `ddp_bucket_cap_mb`: None
461
+ - `ddp_broadcast_buffers`: False
462
+ - `ddp_backend`: None
463
+ - `ddp_timeout`: 1800
464
+ - `fsdp`: []
465
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
466
+ - `deepspeed`: None
467
+ - `debug`: []
468
+ - `skip_memory_metrics`: True
469
+ - `do_predict`: False
470
+ - `resume_from_checkpoint`: None
471
+ - `warmup_ratio`: 0.1
472
+ - `local_rank`: -1
473
+ - `prompts`: None
474
+ - `batch_sampler`: no_duplicates
475
+ - `multi_dataset_batch_sampler`: proportional
476
+ - `router_mapping`: {}
477
+ - `learning_rate_mapping`: {}
478
+
479
+ </details>
480
+
481
+ ### Training Logs
482
+ <details><summary>Click to expand</summary>
483
+
484
+ | Epoch | Step | Training Loss | train loss | dev-768_cosine_accuracy | dev-512_cosine_accuracy | dev-256_cosine_accuracy | dev-128_cosine_accuracy | dev-64_cosine_accuracy |
485
+ |:------:|:-----:|:-------------:|:----------:|:-----------------------:|:-----------------------:|:-----------------------:|:-----------------------:|:----------------------:|
486
+ | 0.5891 | 18200 | 0.8727 | - | - | - | - | - | - |
487
+ | 0.5956 | 18400 | 0.8524 | - | - | - | - | - | - |
488
+ | 0.6021 | 18600 | 0.8995 | - | - | - | - | - | - |
489
+ | 0.6086 | 18800 | 0.8360 | - | - | - | - | - | - |
490
+ | 0.6150 | 19000 | 0.8628 | - | - | - | - | - | - |
491
+ | 0.6215 | 19200 | 0.8244 | - | - | - | - | - | - |
492
+ | 0.6280 | 19400 | 0.8647 | - | - | - | - | - | - |
493
+ | 0.6345 | 19600 | 0.8479 | - | - | - | - | - | - |
494
+ | 0.6409 | 19800 | 0.8204 | - | - | - | - | - | - |
495
+ | 0.6474 | 20000 | 0.8359 | - | - | - | - | - | - |
496
+ | 0.6539 | 20200 | 0.7952 | - | - | - | - | - | - |
497
+ | 0.6604 | 20400 | 0.8375 | - | - | - | - | - | - |
498
+ | 0.6668 | 20600 | 0.8364 | - | - | - | - | - | - |
499
+ | 0.6733 | 20800 | 0.8131 | - | - | - | - | - | - |
500
+ | 0.6798 | 21000 | 0.8310 | - | - | - | - | - | - |
501
+ | 0.6863 | 21200 | 0.8295 | - | - | - | - | - | - |
502
+ | 0.6927 | 21400 | 0.7865 | - | - | - | - | - | - |
503
+ | 0.6992 | 21600 | 0.7960 | - | - | - | - | - | - |
504
+ | 0.7057 | 21800 | 0.8287 | - | - | - | - | - | - |
505
+ | 0.7121 | 22000 | 0.8214 | - | - | - | - | - | - |
506
+ | 0.7186 | 22200 | 0.7879 | - | - | - | - | - | - |
507
+ | 0.7251 | 22400 | 0.8139 | - | - | - | - | - | - |
508
+ | 0.7316 | 22600 | 0.7849 | - | - | - | - | - | - |
509
+ | 0.7380 | 22800 | 0.7880 | - | - | - | - | - | - |
510
+ | 0.7445 | 23000 | 0.7725 | - | - | - | - | - | - |
511
+ | 0.7510 | 23200 | 0.8086 | - | - | - | - | - | - |
512
+ | 0.7575 | 23400 | 0.7687 | - | - | - | - | - | - |
513
+ | 0.7639 | 23600 | 0.7828 | - | - | - | - | - | - |
514
+ | 0.7704 | 23800 | 0.7518 | - | - | - | - | - | - |
515
+ | 0.7769 | 24000 | 0.7599 | 0.4041 | 0.9737 | 0.9738 | 0.9738 | 0.9734 | 0.9718 |
516
+ | 0.7834 | 24200 | 0.7332 | - | - | - | - | - | - |
517
+ | 0.7898 | 24400 | 0.7476 | - | - | - | - | - | - |
518
+ | 0.7963 | 24600 | 0.7806 | - | - | - | - | - | - |
519
+ | 0.8028 | 24800 | 0.7511 | - | - | - | - | - | - |
520
+ | 0.8093 | 25000 | 0.7652 | - | - | - | - | - | - |
521
+ | 0.8157 | 25200 | 0.7883 | - | - | - | - | - | - |
522
+ | 0.8222 | 25400 | 0.7305 | - | - | - | - | - | - |
523
+ | 0.8287 | 25600 | 0.7308 | - | - | - | - | - | - |
524
+ | 0.8352 | 25800 | 0.7368 | - | - | - | - | - | - |
525
+ | 0.8416 | 26000 | 0.7432 | - | - | - | - | - | - |
526
+ | 0.8481 | 26200 | 0.7046 | - | - | - | - | - | - |
527
+ | 0.8546 | 26400 | 0.7476 | - | - | - | - | - | - |
528
+ | 0.8611 | 26600 | 0.7212 | - | - | - | - | - | - |
529
+ | 0.8675 | 26800 | 0.7335 | - | - | - | - | - | - |
530
+ | 0.8740 | 27000 | 0.7415 | - | - | - | - | - | - |
531
+ | 0.8805 | 27200 | 0.6937 | - | - | - | - | - | - |
532
+ | 0.8869 | 27400 | 0.7294 | - | - | - | - | - | - |
533
+ | 0.8934 | 27600 | 0.7436 | - | - | - | - | - | - |
534
+ | 0.8999 | 27800 | 0.7093 | - | - | - | - | - | - |
535
+ | 0.9064 | 28000 | 0.7480 | - | - | - | - | - | - |
536
+ | 0.9128 | 28200 | 0.7039 | - | - | - | - | - | - |
537
+ | 0.9193 | 28400 | 0.7091 | - | - | - | - | - | - |
538
+ | 0.9258 | 28600 | 0.7019 | - | - | - | - | - | - |
539
+ | 0.9323 | 28800 | 0.7081 | - | - | - | - | - | - |
540
+ | 0.9387 | 29000 | 0.6833 | - | - | - | - | - | - |
541
+ | 0.9452 | 29200 | 0.6982 | - | - | - | - | - | - |
542
+ | 0.9517 | 29400 | 0.7249 | - | - | - | - | - | - |
543
+ | 0.9582 | 29600 | 0.7282 | - | - | - | - | - | - |
544
+ | 0.9646 | 29800 | 0.7147 | - | - | - | - | - | - |
545
+ | 0.9711 | 30000 | 0.6742 | 0.3640 | 0.9758 | 0.9759 | 0.9761 | 0.9757 | 0.9742 |
546
+ | 0.9776 | 30200 | 0.6901 | - | - | - | - | - | - |
547
+ | 0.9841 | 30400 | 0.7067 | - | - | - | - | - | - |
548
+ | 0.9905 | 30600 | 0.7166 | - | - | - | - | - | - |
549
+ | 0.9970 | 30800 | 0.6800 | - | - | - | - | - | - |
550
+ | 1.0035 | 31000 | 0.6846 | - | - | - | - | - | - |
551
+ | 1.0099 | 31200 | 0.6723 | - | - | - | - | - | - |
552
+ | 1.0164 | 31400 | 0.6573 | - | - | - | - | - | - |
553
+ | 1.0229 | 31600 | 0.6895 | - | - | - | - | - | - |
554
+ | 1.0294 | 31800 | 0.6588 | - | - | - | - | - | - |
555
+ | 1.0358 | 32000 | 0.6517 | - | - | - | - | - | - |
556
+ | 1.0423 | 32200 | 0.6498 | - | - | - | - | - | - |
557
+ | 1.0488 | 32400 | 0.6836 | - | - | - | - | - | - |
558
+ | 1.0553 | 32600 | 0.6819 | - | - | - | - | - | - |
559
+ | 1.0617 | 32800 | 0.6463 | - | - | - | - | - | - |
560
+ | 1.0682 | 33000 | 0.6645 | - | - | - | - | - | - |
561
+ | 1.0747 | 33200 | 0.6518 | - | - | - | - | - | - |
562
+ | 1.0812 | 33400 | 0.6235 | - | - | - | - | - | - |
563
+ | 1.0876 | 33600 | 0.6302 | - | - | - | - | - | - |
564
+ | 1.0941 | 33800 | 0.6452 | - | - | - | - | - | - |
565
+ | 1.1006 | 34000 | 0.6477 | - | - | - | - | - | - |
566
+ | 1.1070 | 34200 | 0.6084 | - | - | - | - | - | - |
567
+ | 1.1135 | 34400 | 0.6259 | - | - | - | - | - | - |
568
+ | 1.1200 | 34600 | 0.6070 | - | - | - | - | - | - |
569
+ | 1.1265 | 34800 | 0.5977 | - | - | - | - | - | - |
570
+ | 1.1329 | 35000 | 0.6044 | - | - | - | - | - | - |
571
+ | 1.1394 | 35200 | 0.6007 | - | - | - | - | - | - |
572
+ | 1.1459 | 35400 | 0.5628 | - | - | - | - | - | - |
573
+ | 1.1524 | 35600 | 0.5732 | - | - | - | - | - | - |
574
+ | 1.1588 | 35800 | 0.5773 | - | - | - | - | - | - |
575
+ | 1.1653 | 36000 | 0.5719 | 0.3356 | 0.9775 | 0.9777 | 0.9777 | 0.9774 | 0.9760 |
576
+ | 1.1718 | 36200 | 0.5471 | - | - | - | - | - | - |
577
+ | 1.1783 | 36400 | 0.5635 | - | - | - | - | - | - |
578
+ | 1.1847 | 36600 | 0.5390 | - | - | - | - | - | - |
579
+ | 1.1912 | 36800 | 0.5428 | - | - | - | - | - | - |
580
+ | 1.1977 | 37000 | 0.5205 | - | - | - | - | - | - |
581
+ | 1.2042 | 37200 | 0.5362 | - | - | - | - | - | - |
582
+ | 1.2106 | 37400 | 0.5386 | - | - | - | - | - | - |
583
+ | 1.2171 | 37600 | 0.5203 | - | - | - | - | - | - |
584
+ | 1.2236 | 37800 | 0.5301 | - | - | - | - | - | - |
585
+ | 1.2301 | 38000 | 0.5232 | - | - | - | - | - | - |
586
+ | 1.2365 | 38200 | 0.4922 | - | - | - | - | - | - |
587
+ | 1.2430 | 38400 | 0.5029 | - | - | - | - | - | - |
588
+ | 1.2495 | 38600 | 0.4989 | - | - | - | - | - | - |
589
+ | 1.2560 | 38800 | 0.5053 | - | - | - | - | - | - |
590
+ | 1.2624 | 39000 | 0.5081 | - | - | - | - | - | - |
591
+ | 1.2689 | 39200 | 0.4960 | - | - | - | - | - | - |
592
+ | 1.2754 | 39400 | 0.5052 | - | - | - | - | - | - |
593
+ | 1.2818 | 39600 | 0.4984 | - | - | - | - | - | - |
594
+ | 1.2883 | 39800 | 0.4909 | - | - | - | - | - | - |
595
+ | 1.2948 | 40000 | 0.5120 | - | - | - | - | - | - |
596
+ | 1.3013 | 40200 | 0.4873 | - | - | - | - | - | - |
597
+ | 1.3077 | 40400 | 0.4896 | - | - | - | - | - | - |
598
+ | 1.3142 | 40600 | 0.4900 | - | - | - | - | - | - |
599
+ | 1.3207 | 40800 | 0.5036 | - | - | - | - | - | - |
600
+ | 1.3272 | 41000 | 0.4876 | - | - | - | - | - | - |
601
+ | 1.3336 | 41200 | 0.4705 | - | - | - | - | - | - |
602
+ | 1.3401 | 41400 | 0.4786 | - | - | - | - | - | - |
603
+ | 1.3466 | 41600 | 0.4998 | - | - | - | - | - | - |
604
+ | 1.3531 | 41800 | 0.4692 | - | - | - | - | - | - |
605
+ | 1.3595 | 42000 | 0.5064 | 0.3160 | 0.9788 | 0.9790 | 0.9790 | 0.9785 | 0.9774 |
606
+ | 1.3660 | 42200 | 0.4925 | - | - | - | - | - | - |
607
+ | 1.3725 | 42400 | 0.4601 | - | - | - | - | - | - |
608
+ | 1.3790 | 42600 | 0.4762 | - | - | - | - | - | - |
609
+ | 1.3854 | 42800 | 0.4986 | - | - | - | - | - | - |
610
+ | 1.3919 | 43000 | 0.4656 | - | - | - | - | - | - |
611
+ | 1.3984 | 43200 | 0.4507 | - | - | - | - | - | - |
612
+ | 1.4049 | 43400 | 0.4862 | - | - | - | - | - | - |
613
+ | 1.4113 | 43600 | 0.4596 | - | - | - | - | - | - |
614
+ | 1.4178 | 43800 | 0.4696 | - | - | - | - | - | - |
615
+ | 1.4243 | 44000 | 0.4925 | - | - | - | - | - | - |
616
+ | 1.4308 | 44200 | 0.4796 | - | - | - | - | - | - |
617
+ | 1.4372 | 44400 | 0.4525 | - | - | - | - | - | - |
618
+ | 1.4437 | 44600 | 0.4717 | - | - | - | - | - | - |
619
+ | 1.4502 | 44800 | 0.4803 | - | - | - | - | - | - |
620
+ | 1.4566 | 45000 | 0.4675 | - | - | - | - | - | - |
621
+ | 1.4631 | 45200 | 0.4631 | - | - | - | - | - | - |
622
+ | 1.4696 | 45400 | 0.4622 | - | - | - | - | - | - |
623
+ | 1.4761 | 45600 | 0.4496 | - | - | - | - | - | - |
624
+ | 1.4825 | 45800 | 0.4678 | - | - | - | - | - | - |
625
+ | 1.4890 | 46000 | 0.4495 | - | - | - | - | - | - |
626
+ | 1.4955 | 46200 | 0.4474 | - | - | - | - | - | - |
627
+ | 1.5020 | 46400 | 0.4587 | - | - | - | - | - | - |
628
+ | 1.5084 | 46600 | 0.4591 | - | - | - | - | - | - |
629
+ | 1.5149 | 46800 | 0.4573 | - | - | - | - | - | - |
630
+ | 1.5214 | 47000 | 0.4442 | - | - | - | - | - | - |
631
+ | 1.5279 | 47200 | 0.4550 | - | - | - | - | - | - |
632
+ | 1.5343 | 47400 | 0.4493 | - | - | - | - | - | - |
633
+ | 1.5408 | 47600 | 0.4485 | - | - | - | - | - | - |
634
+ | 1.5473 | 47800 | 0.4569 | - | - | - | - | - | - |
635
+ | 1.5538 | 48000 | 0.4346 | 0.3001 | 0.9799 | 0.9802 | 0.9802 | 0.9798 | 0.9788 |
636
+ | 1.5602 | 48200 | 0.4469 | - | - | - | - | - | - |
637
+ | 1.5667 | 48400 | 0.4602 | - | - | - | - | - | - |
638
+ | 1.5732 | 48600 | 0.4430 | - | - | - | - | - | - |
639
+ | 1.5797 | 48800 | 0.4524 | - | - | - | - | - | - |
640
+ | 1.5861 | 49000 | 0.4528 | - | - | - | - | - | - |
641
+ | 1.5926 | 49200 | 0.4348 | - | - | - | - | - | - |
642
+ | 1.5991 | 49400 | 0.4533 | - | - | - | - | - | - |
643
+ | 1.6056 | 49600 | 0.4523 | - | - | - | - | - | - |
644
+ | 1.6120 | 49800 | 0.4509 | - | - | - | - | - | - |
645
+ | 1.6185 | 50000 | 0.4365 | - | - | - | - | - | - |
646
+ | 1.6250 | 50200 | 0.4504 | - | - | - | - | - | - |
647
+ | 1.6314 | 50400 | 0.4292 | - | - | - | - | - | - |
648
+ | 1.6379 | 50600 | 0.4406 | - | - | - | - | - | - |
649
+ | 1.6444 | 50800 | 0.4333 | - | - | - | - | - | - |
650
+ | 1.6509 | 51000 | 0.4361 | - | - | - | - | - | - |
651
+ | 1.6573 | 51200 | 0.4065 | - | - | - | - | - | - |
652
+ | 1.6638 | 51400 | 0.4671 | - | - | - | - | - | - |
653
+ | 1.6703 | 51600 | 0.4328 | - | - | - | - | - | - |
654
+ | 1.6768 | 51800 | 0.4310 | - | - | - | - | - | - |
655
+ | 1.6832 | 52000 | 0.4523 | - | - | - | - | - | - |
656
+ | 1.6897 | 52200 | 0.4232 | - | - | - | - | - | - |
657
+ | 1.6962 | 52400 | 0.4257 | - | - | - | - | - | - |
658
+ | 1.7027 | 52600 | 0.4448 | - | - | - | - | - | - |
659
+ | 1.7091 | 52800 | 0.4491 | - | - | - | - | - | - |
660
+ | 1.7156 | 53000 | 0.4224 | - | - | - | - | - | - |
661
+ | 1.7221 | 53200 | 0.4297 | - | - | - | - | - | - |
662
+ | 1.7286 | 53400 | 0.4522 | - | - | - | - | - | - |
663
+ | 1.7350 | 53600 | 0.4195 | - | - | - | - | - | - |
664
+ | 1.7415 | 53800 | 0.4227 | - | - | - | - | - | - |
665
+ | 1.7480 | 54000 | 0.4381 | 0.2875 | 0.9807 | 0.9808 | 0.9808 | 0.9805 | 0.9794 |
666
+ | 1.7545 | 54200 | 0.4460 | - | - | - | - | - | - |
667
+ | 1.7609 | 54400 | 0.4260 | - | - | - | - | - | - |
668
+ | 1.7674 | 54600 | 0.4299 | - | - | - | - | - | - |
669
+ | 1.7739 | 54800 | 0.4247 | - | - | - | - | - | - |
670
+ | 1.7804 | 55000 | 0.4244 | - | - | - | - | - | - |
671
+ | 1.7868 | 55200 | 0.4185 | - | - | - | - | - | - |
672
+ | 1.7933 | 55400 | 0.4292 | - | - | - | - | - | - |
673
+ | 1.7998 | 55600 | 0.4468 | - | - | - | - | - | - |
674
+ | 1.8062 | 55800 | 0.4118 | - | - | - | - | - | - |
675
+ | 1.8127 | 56000 | 0.4306 | - | - | - | - | - | - |
676
+ | 1.8192 | 56200 | 0.4447 | - | - | - | - | - | - |
677
+ | 1.8257 | 56400 | 0.4147 | - | - | - | - | - | - |
678
+ | 1.8321 | 56600 | 0.4189 | - | - | - | - | - | - |
679
+ | 1.8386 | 56800 | 0.4167 | - | - | - | - | - | - |
680
+ | 1.8451 | 57000 | 0.4022 | - | - | - | - | - | - |
681
+ | 1.8516 | 57200 | 0.4158 | - | - | - | - | - | - |
682
+ | 1.8580 | 57400 | 0.4228 | - | - | - | - | - | - |
683
+ | 1.8645 | 57600 | 0.4256 | - | - | - | - | - | - |
684
+ | 1.8710 | 57800 | 0.4251 | - | - | - | - | - | - |
685
+ | 1.8775 | 58000 | 0.4232 | - | - | - | - | - | - |
686
+ | 1.8839 | 58200 | 0.4143 | - | - | - | - | - | - |
687
+ | 1.8904 | 58400 | 0.4331 | - | - | - | - | - | - |
688
+ | 1.8969 | 58600 | 0.4253 | - | - | - | - | - | - |
689
+ | 1.9034 | 58800 | 0.4410 | - | - | - | - | - | - |
690
+ | 1.9098 | 59000 | 0.4337 | - | - | - | - | - | - |
691
+ | 1.9163 | 59200 | 0.4016 | - | - | - | - | - | - |
692
+ | 1.9228 | 59400 | 0.4249 | - | - | - | - | - | - |
693
+ | 1.9293 | 59600 | 0.4108 | - | - | - | - | - | - |
694
+ | 1.9357 | 59800 | 0.4272 | - | - | - | - | - | - |
695
+ | 1.9422 | 60000 | 0.3916 | 0.2812 | 0.9810 | 0.9811 | 0.9813 | 0.9811 | 0.9797 |
696
+ | 1.9487 | 60200 | 0.4334 | - | - | - | - | - | - |
697
+ | 1.9552 | 60400 | 0.4462 | - | - | - | - | - | - |
698
+ | 1.9616 | 60600 | 0.4436 | - | - | - | - | - | - |
699
+ | 1.9681 | 60800 | 0.4278 | - | - | - | - | - | - |
700
+ | 1.9746 | 61000 | 0.4170 | - | - | - | - | - | - |
701
+ | 1.9810 | 61200 | 0.4376 | - | - | - | - | - | - |
702
+ | 1.9875 | 61400 | 0.4433 | - | - | - | - | - | - |
703
+ | 1.9940 | 61600 | 0.4292 | - | - | - | - | - | - |
704
+
705
+ </details>
706
+
707
+ ### Framework Versions
708
+ - Python: 3.10.19
709
+ - Sentence Transformers: 5.2.3
710
+ - Transformers: 5.2.0
711
+ - PyTorch: 2.6.0+cu124
712
+ - Accelerate: 1.12.0
713
+ - Datasets: 4.5.0
714
+ - Tokenizers: 0.22.2
715
+
716
+ ## Citation
717
+
718
+ ### BibTeX
719
+
720
+ #### Sentence Transformers
721
+ ```bibtex
722
+ @inproceedings{reimers-2019-sentence-bert,
723
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
724
+ author = "Reimers, Nils and Gurevych, Iryna",
725
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
726
+ month = "11",
727
+ year = "2019",
728
+ publisher = "Association for Computational Linguistics",
729
+ url = "https://arxiv.org/abs/1908.10084",
730
+ }
731
+ ```
732
+
733
+ #### MatryoshkaLoss
734
+ ```bibtex
735
+ @misc{kusupati2024matryoshka,
736
+ title={Matryoshka Representation Learning},
737
+ 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},
738
+ year={2024},
739
+ eprint={2205.13147},
740
+ archivePrefix={arXiv},
741
+ primaryClass={cs.LG}
742
+ }
743
+ ```
744
+
745
+ #### MultipleNegativesRankingLoss
746
+ ```bibtex
747
+ @misc{henderson2017efficient,
748
+ title={Efficient Natural Language Response Suggestion for Smart Reply},
749
+ 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},
750
+ year={2017},
751
+ eprint={1705.00652},
752
+ archivePrefix={arXiv},
753
+ primaryClass={cs.CL}
754
+ }
755
+ ```
756
+
757
+ <!--
758
+ ## Glossary
759
+
760
+ *Clearly define terms in order to be accessible across audiences.*
761
+ -->
762
+
763
+ <!--
764
+ ## Model Card Authors
765
+
766
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
767
+ -->
768
+
769
+ <!--
770
+ ## Model Card Contact
771
+
772
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
773
+ -->
sbert_training/epoch2/model/config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_cross_attention": false,
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": null,
8
+ "classifier_dropout": null,
9
+ "dtype": "float32",
10
+ "eos_token_id": null,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "is_decoder": false,
17
+ "layer_norm_eps": 1e-12,
18
+ "max_position_embeddings": 512,
19
+ "model_type": "bert",
20
+ "num_attention_heads": 12,
21
+ "num_hidden_layers": 12,
22
+ "pad_token_id": 0,
23
+ "tie_word_embeddings": true,
24
+ "transformers_version": "5.2.0",
25
+ "type_vocab_size": 2,
26
+ "use_cache": true,
27
+ "vocab_size": 64000
28
+ }
sbert_training/epoch2/model/config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "SentenceTransformer",
3
+ "__version__": {
4
+ "sentence_transformers": "5.2.3",
5
+ "transformers": "5.2.0",
6
+ "pytorch": "2.6.0+cu124"
7
+ },
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
sbert_training/epoch2/model/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:602c1647dc30e982f7f4b007ac82f3a97ef88b815b598d41e6c8d075be10730f
3
+ size 540795728
sbert_training/epoch2/model/modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
sbert_training/epoch2/model/sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
sbert_training/epoch2/model/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/epoch2/model/tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": false,
6
+ "is_local": true,
7
+ "mask_token": "[MASK]",
8
+ "max_len": 512,
9
+ "model_max_length": 512,
10
+ "never_split": [
11
+ "[بريد]",
12
+ "[مستخدم]",
13
+ "[رابط]"
14
+ ],
15
+ "pad_token": "[PAD]",
16
+ "sep_token": "[SEP]",
17
+ "strip_accents": null,
18
+ "tokenize_chinese_chars": true,
19
+ "tokenizer_class": "BertTokenizer",
20
+ "unk_token": "[UNK]"
21
+ }
sbert_training/epoch2/output.log ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --- RESUMING FROM: /home/skiredj.abderrahman/khalil/sbert_training/output/arabert_20260224_1730/checkpoint-18000 ---
2
+ {'loss': '0.8727', 'grad_norm': '5.438', 'learning_rate': '1.568e-05', 'epoch': '0.5891'}
3
+ {'loss': '0.8524', 'grad_norm': '5.458', 'learning_rate': '1.56e-05', 'epoch': '0.5956'}
4
+ {'loss': '0.8995', 'grad_norm': '6.666', 'learning_rate': '1.553e-05', 'epoch': '0.6021'}
5
+ {'loss': '0.836', 'grad_norm': '5.681', 'learning_rate': '1.546e-05', 'epoch': '0.6086'}
6
+ {'loss': '0.8628', 'grad_norm': '6.571', 'learning_rate': '1.539e-05', 'epoch': '0.615'}
7
+ {'loss': '0.8244', 'grad_norm': '6.389', 'learning_rate': '1.532e-05', 'epoch': '0.6215'}
8
+ {'loss': '0.8647', 'grad_norm': '4.987', 'learning_rate': '1.525e-05', 'epoch': '0.628'}
9
+ {'loss': '0.8479', 'grad_norm': '4.451', 'learning_rate': '1.517e-05', 'epoch': '0.6345'}
10
+ {'loss': '0.8204', 'grad_norm': '5.356', 'learning_rate': '1.51e-05', 'epoch': '0.6409'}
11
+ {'loss': '0.8359', 'grad_norm': '5.146', 'learning_rate': '1.503e-05', 'epoch': '0.6474'}
12
+ {'loss': '0.7952', 'grad_norm': '4.308', 'learning_rate': '1.496e-05', 'epoch': '0.6539'}
13
+ {'loss': '0.8375', 'grad_norm': '5.216', 'learning_rate': '1.489e-05', 'epoch': '0.6604'}
14
+ {'loss': '0.8364', 'grad_norm': '5.812', 'learning_rate': '1.481e-05', 'epoch': '0.6668'}
15
+ {'loss': '0.8131', 'grad_norm': '5.52', 'learning_rate': '1.474e-05', 'epoch': '0.6733'}
16
+ {'loss': '0.831', 'grad_norm': '6.452', 'learning_rate': '1.467e-05', 'epoch': '0.6798'}
17
+ {'loss': '0.8295', 'grad_norm': '4.274', 'learning_rate': '1.46e-05', 'epoch': '0.6863'}
18
+ {'loss': '0.7865', 'grad_norm': '4.77', 'learning_rate': '1.453e-05', 'epoch': '0.6927'}
19
+ {'loss': '0.796', 'grad_norm': '5.027', 'learning_rate': '1.445e-05', 'epoch': '0.6992'}
20
+ {'loss': '0.8287', 'grad_norm': '4.826', 'learning_rate': '1.438e-05', 'epoch': '0.7057'}
21
+ {'loss': '0.8214', 'grad_norm': '4.381', 'learning_rate': '1.431e-05', 'epoch': '0.7121'}
22
+ {'loss': '0.7879', 'grad_norm': '6.475', 'learning_rate': '1.424e-05', 'epoch': '0.7186'}
23
+ {'loss': '0.8139', 'grad_norm': '5.295', 'learning_rate': '1.417e-05', 'epoch': '0.7251'}
24
+ {'loss': '0.7849', 'grad_norm': '5.051', 'learning_rate': '1.409e-05', 'epoch': '0.7316'}
25
+ {'loss': '0.788', 'grad_norm': '5.113', 'learning_rate': '1.402e-05', 'epoch': '0.738'}
26
+ {'loss': '0.7725', 'grad_norm': '4.049', 'learning_rate': '1.395e-05', 'epoch': '0.7445'}
27
+ {'loss': '0.8086', 'grad_norm': '4.646', 'learning_rate': '1.388e-05', 'epoch': '0.751'}
28
+ {'loss': '0.7687', 'grad_norm': '5.049', 'learning_rate': '1.381e-05', 'epoch': '0.7575'}
29
+ {'loss': '0.7828', 'grad_norm': '6.568', 'learning_rate': '1.373e-05', 'epoch': '0.7639'}
30
+ {'loss': '0.7518', 'grad_norm': '5.9', 'learning_rate': '1.366e-05', 'epoch': '0.7704'}
31
+ {'loss': '0.7599', 'grad_norm': '6.338', 'learning_rate': '1.359e-05', 'epoch': '0.7769'}
32
+ {'eval_train_loss': '0.4041', 'eval_dev-768_cosine_accuracy': '0.9737', 'eval_dev-512_cosine_accuracy': '0.9738', 'eval_dev-256_cosine_accuracy': '0.9738', 'eval_dev-128_cosine_accuracy': '0.9734', 'eval_dev-64_cosine_accuracy': '0.9718', 'eval_sequential_score': '0.9737', 'eval_train_runtime': '9673', 'eval_train_samples_per_second': '116.8', 'eval_train_steps_per_second': '14.6', 'epoch': '0.7769'}
33
+ {'loss': '0.7332', 'grad_norm': '4.95', 'learning_rate': '1.352e-05', 'epoch': '0.7834'}
34
+ {'loss': '0.7476', 'grad_norm': '4.513', 'learning_rate': '1.345e-05', 'epoch': '0.7898'}
35
+ {'loss': '0.7806', 'grad_norm': '5.095', 'learning_rate': '1.337e-05', 'epoch': '0.7963'}
36
+ {'loss': '0.7511', 'grad_norm': '5.826', 'learning_rate': '1.33e-05', 'epoch': '0.8028'}
37
+ {'loss': '0.7652', 'grad_norm': '6.09', 'learning_rate': '1.323e-05', 'epoch': '0.8093'}
38
+ {'loss': '0.7883', 'grad_norm': '4.332', 'learning_rate': '1.316e-05', 'epoch': '0.8157'}
39
+ {'loss': '0.7305', 'grad_norm': '5.749', 'learning_rate': '1.309e-05', 'epoch': '0.8222'}
40
+ {'loss': '0.7308', 'grad_norm': '4.871', 'learning_rate': '1.302e-05', 'epoch': '0.8287'}
41
+ {'loss': '0.7368', 'grad_norm': '4.618', 'learning_rate': '1.294e-05', 'epoch': '0.8352'}
42
+ {'loss': '0.7432', 'grad_norm': '4.836', 'learning_rate': '1.287e-05', 'epoch': '0.8416'}
43
+ {'loss': '0.7046', 'grad_norm': '4.988', 'learning_rate': '1.28e-05', 'epoch': '0.8481'}
44
+ {'loss': '0.7476', 'grad_norm': '4.596', 'learning_rate': '1.273e-05', 'epoch': '0.8546'}
45
+ {'loss': '0.7212', 'grad_norm': '5.712', 'learning_rate': '1.266e-05', 'epoch': '0.8611'}
46
+ {'loss': '0.7335', 'grad_norm': '3.99', 'learning_rate': '1.258e-05', 'epoch': '0.8675'}
47
+ {'loss': '0.7415', 'grad_norm': '5.446', 'learning_rate': '1.251e-05', 'epoch': '0.874'}
48
+ {'loss': '0.6937', 'grad_norm': '5.257', 'learning_rate': '1.244e-05', 'epoch': '0.8805'}
49
+ {'loss': '0.7294', 'grad_norm': '5.302', 'learning_rate': '1.237e-05', 'epoch': '0.8869'}
50
+ {'loss': '0.7436', 'grad_norm': '3.847', 'learning_rate': '1.23e-05', 'epoch': '0.8934'}
51
+ {'loss': '0.7093', 'grad_norm': '6.182', 'learning_rate': '1.222e-05', 'epoch': '0.8999'}
52
+ {'loss': '0.748', 'grad_norm': '5.445', 'learning_rate': '1.215e-05', 'epoch': '0.9064'}
53
+ {'loss': '0.7039', 'grad_norm': '5.002', 'learning_rate': '1.208e-05', 'epoch': '0.9128'}
54
+ {'loss': '0.7091', 'grad_norm': '5.085', 'learning_rate': '1.201e-05', 'epoch': '0.9193'}
55
+ {'loss': '0.7019', 'grad_norm': '5.379', 'learning_rate': '1.194e-05', 'epoch': '0.9258'}
56
+ {'loss': '0.7081', 'grad_norm': '5.63', 'learning_rate': '1.186e-05', 'epoch': '0.9323'}
57
+ {'loss': '0.6833', 'grad_norm': '2.541', 'learning_rate': '1.179e-05', 'epoch': '0.9387'}
58
+ {'loss': '0.6982', 'grad_norm': '5.714', 'learning_rate': '1.172e-05', 'epoch': '0.9452'}
59
+ {'loss': '0.7249', 'grad_norm': '5.051', 'learning_rate': '1.165e-05', 'epoch': '0.9517'}
60
+ {'loss': '0.7282', 'grad_norm': '6.322', 'learning_rate': '1.158e-05', 'epoch': '0.9582'}
61
+ {'loss': '0.7147', 'grad_norm': '4.961', 'learning_rate': '1.15e-05', 'epoch': '0.9646'}
62
+ {'loss': '0.6742', 'grad_norm': '4.871', 'learning_rate': '1.143e-05', 'epoch': '0.9711'}
63
+ {'eval_train_loss': '0.364', 'eval_dev-768_cosine_accuracy': '0.9758', 'eval_dev-512_cosine_accuracy': '0.9759', 'eval_dev-256_cosine_accuracy': '0.9761', 'eval_dev-128_cosine_accuracy': '0.9757', 'eval_dev-64_cosine_accuracy': '0.9742', 'eval_sequential_score': '0.9758', 'eval_train_runtime': '9649', 'eval_train_samples_per_second': '117.1', 'eval_train_steps_per_second': '14.64', 'epoch': '0.9711'}
64
+ {'loss': '0.6901', 'grad_norm': '3.348', 'learning_rate': '1.136e-05', 'epoch': '0.9776'}
65
+ {'loss': '0.7067', 'grad_norm': '3.76', 'learning_rate': '1.129e-05', 'epoch': '0.9841'}
66
+ {'loss': '0.7166', 'grad_norm': '4.729', 'learning_rate': '1.122e-05', 'epoch': '0.9905'}
67
+ {'loss': '0.68', 'grad_norm': '4.648', 'learning_rate': '1.114e-05', 'epoch': '0.997'}
68
+ {'loss': '0.6846', 'grad_norm': '4.427', 'learning_rate': '1.107e-05', 'epoch': '1.003'}
69
+ {'loss': '0.6723', 'grad_norm': '4.459', 'learning_rate': '1.1e-05', 'epoch': '1.01'}
70
+ {'loss': '0.6573', 'grad_norm': '6.387', 'learning_rate': '1.093e-05', 'epoch': '1.016'}
71
+ {'loss': '0.6895', 'grad_norm': '4.1', 'learning_rate': '1.086e-05', 'epoch': '1.023'}
72
+ {'loss': '0.6588', 'grad_norm': '5.927', 'learning_rate': '1.079e-05', 'epoch': '1.029'}
73
+ {'loss': '0.6517', 'grad_norm': '5.9', 'learning_rate': '1.071e-05', 'epoch': '1.036'}
74
+ {'loss': '0.6498', 'grad_norm': '4.736', 'learning_rate': '1.064e-05', 'epoch': '1.042'}
75
+ {'loss': '0.6836', 'grad_norm': '5.029', 'learning_rate': '1.057e-05', 'epoch': '1.049'}
76
+ {'loss': '0.6819', 'grad_norm': '2.595', 'learning_rate': '1.05e-05', 'epoch': '1.055'}
77
+ {'loss': '0.6463', 'grad_norm': '4.963', 'learning_rate': '1.043e-05', 'epoch': '1.062'}
78
+ {'loss': '0.6645', 'grad_norm': '5.046', 'learning_rate': '1.035e-05', 'epoch': '1.068'}
79
+ {'loss': '0.6518', 'grad_norm': '3.307', 'learning_rate': '1.028e-05', 'epoch': '1.075'}
80
+ {'loss': '0.6235', 'grad_norm': '3.848', 'learning_rate': '1.021e-05', 'epoch': '1.081'}
81
+ {'loss': '0.6302', 'grad_norm': '4.664', 'learning_rate': '1.014e-05', 'epoch': '1.088'}
82
+ {'loss': '0.6452', 'grad_norm': '5.47', 'learning_rate': '1.007e-05', 'epoch': '1.094'}
83
+ {'loss': '0.6477', 'grad_norm': '5.26', 'learning_rate': '9.994e-06', 'epoch': '1.101'}
84
+ {'loss': '0.6084', 'grad_norm': '4.313', 'learning_rate': '9.922e-06', 'epoch': '1.107'}
85
+ {'loss': '0.6259', 'grad_norm': '6.499', 'learning_rate': '9.85e-06', 'epoch': '1.114'}
86
+ {'loss': '0.607', 'grad_norm': '3.922', 'learning_rate': '9.778e-06', 'epoch': '1.12'}
87
+ {'loss': '0.5977', 'grad_norm': '5.37', 'learning_rate': '9.706e-06', 'epoch': '1.126'}
88
+ {'loss': '0.6044', 'grad_norm': '5.068', 'learning_rate': '9.634e-06', 'epoch': '1.133'}
89
+ {'loss': '0.6007', 'grad_norm': '4.109', 'learning_rate': '9.562e-06', 'epoch': '1.139'}
90
+ {'loss': '0.5628', 'grad_norm': '4.954', 'learning_rate': '9.491e-06', 'epoch': '1.146'}
91
+ {'loss': '0.5732', 'grad_norm': '4.068', 'learning_rate': '9.419e-06', 'epoch': '1.152'}
92
+ {'loss': '0.5773', 'grad_norm': '4.939', 'learning_rate': '9.347e-06', 'epoch': '1.159'}
93
+ {'loss': '0.5719', 'grad_norm': '4.418', 'learning_rate': '9.275e-06', 'epoch': '1.165'}
94
+ {'eval_train_loss': '0.3356', 'eval_dev-768_cosine_accuracy': '0.9775', 'eval_dev-512_cosine_accuracy': '0.9777', 'eval_dev-256_cosine_accuracy': '0.9777', 'eval_dev-128_cosine_accuracy': '0.9774', 'eval_dev-64_cosine_accuracy': '0.976', 'eval_sequential_score': '0.9775', 'eval_train_runtime': '1.01e+04', 'eval_train_samples_per_second': '111.8', 'eval_train_steps_per_second': '13.98', 'epoch': '1.165'}
95
+ {'loss': '0.5471', 'grad_norm': '3.58', 'learning_rate': '9.203e-06', 'epoch': '1.172'}
96
+ {'loss': '0.5635', 'grad_norm': '5.198', 'learning_rate': '9.131e-06', 'epoch': '1.178'}
97
+ {'loss': '0.539', 'grad_norm': '4.468', 'learning_rate': '9.059e-06', 'epoch': '1.185'}
98
+ {'loss': '0.5428', 'grad_norm': '4.349', 'learning_rate': '8.987e-06', 'epoch': '1.191'}
99
+ {'loss': '0.5205', 'grad_norm': '2.936', 'learning_rate': '8.915e-06', 'epoch': '1.198'}
100
+ {'loss': '0.5362', 'grad_norm': '3.337', 'learning_rate': '8.843e-06', 'epoch': '1.204'}
101
+ {'loss': '0.5386', 'grad_norm': '5.76', 'learning_rate': '8.771e-06', 'epoch': '1.211'}
102
+ {'loss': '0.5203', 'grad_norm': '3.261', 'learning_rate': '8.699e-06', 'epoch': '1.217'}
103
+ {'loss': '0.5301', 'grad_norm': '3.732', 'learning_rate': '8.627e-06', 'epoch': '1.224'}
104
+ {'loss': '0.5232', 'grad_norm': '4.54', 'learning_rate': '8.555e-06', 'epoch': '1.23'}
105
+ {'loss': '0.4922', 'grad_norm': '4.291', 'learning_rate': '8.483e-06', 'epoch': '1.237'}
106
+ {'loss': '0.5029', 'grad_norm': '3.979', 'learning_rate': '8.412e-06', 'epoch': '1.243'}
107
+ {'loss': '0.4989', 'grad_norm': '7.829', 'learning_rate': '8.34e-06', 'epoch': '1.249'}
108
+ {'loss': '0.5053', 'grad_norm': '2.903', 'learning_rate': '8.268e-06', 'epoch': '1.256'}
109
+ {'loss': '0.5081', 'grad_norm': '5.471', 'learning_rate': '8.196e-06', 'epoch': '1.262'}
110
+ {'loss': '0.496', 'grad_norm': '5.204', 'learning_rate': '8.124e-06', 'epoch': '1.269'}
111
+ {'loss': '0.5052', 'grad_norm': '4.377', 'learning_rate': '8.052e-06', 'epoch': '1.275'}
112
+ {'loss': '0.4984', 'grad_norm': '4.184', 'learning_rate': '7.98e-06', 'epoch': '1.282'}
113
+ {'loss': '0.4909', 'grad_norm': '4.991', 'learning_rate': '7.908e-06', 'epoch': '1.288'}
114
+ {'loss': '0.512', 'grad_norm': '3.76', 'learning_rate': '7.836e-06', 'epoch': '1.295'}
115
+ {'loss': '0.4873', 'grad_norm': '3.844', 'learning_rate': '7.764e-06', 'epoch': '1.301'}
116
+ {'loss': '0.4896', 'grad_norm': '6.987', 'learning_rate': '7.692e-06', 'epoch': '1.308'}
117
+ {'loss': '0.49', 'grad_norm': '6.267', 'learning_rate': '7.62e-06', 'epoch': '1.314'}
118
+ {'loss': '0.5036', 'grad_norm': '3.776', 'learning_rate': '7.548e-06', 'epoch': '1.321'}
119
+ {'loss': '0.4876', 'grad_norm': '3.42', 'learning_rate': '7.476e-06', 'epoch': '1.327'}
120
+ {'loss': '0.4705', 'grad_norm': '5.478', 'learning_rate': '7.404e-06', 'epoch': '1.334'}
121
+ {'loss': '0.4786', 'grad_norm': '3.313', 'learning_rate': '7.333e-06', 'epoch': '1.34'}
122
+ {'loss': '0.4998', 'grad_norm': '3.13', 'learning_rate': '7.261e-06', 'epoch': '1.347'}
123
+ {'loss': '0.4692', 'grad_norm': '3.971', 'learning_rate': '7.189e-06', 'epoch': '1.353'}
124
+ {'loss': '0.5064', 'grad_norm': '6.238', 'learning_rate': '7.117e-06', 'epoch': '1.36'}
125
+ {'eval_train_loss': '0.316', 'eval_dev-768_cosine_accuracy': '0.9788', 'eval_dev-512_cosine_accuracy': '0.979', 'eval_dev-256_cosine_accuracy': '0.979', 'eval_dev-128_cosine_accuracy': '0.9785', 'eval_dev-64_cosine_accuracy': '0.9774', 'eval_sequential_score': '0.9788', 'eval_train_runtime': '1.014e+04', 'eval_train_samples_per_second': '111.5', 'eval_train_steps_per_second': '13.93', 'epoch': '1.36'}
126
+ {'loss': '0.4925', 'grad_norm': '5.158', 'learning_rate': '7.045e-06', 'epoch': '1.366'}
127
+ {'loss': '0.4601', 'grad_norm': '4.139', 'learning_rate': '6.973e-06', 'epoch': '1.372'}
128
+ {'loss': '0.4762', 'grad_norm': '3.411', 'learning_rate': '6.901e-06', 'epoch': '1.379'}
129
+ {'loss': '0.4986', 'grad_norm': '4.23', 'learning_rate': '6.829e-06', 'epoch': '1.385'}
130
+ {'loss': '0.4656', 'grad_norm': '5.326', 'learning_rate': '6.757e-06', 'epoch': '1.392'}
131
+ {'loss': '0.4507', 'grad_norm': '3.826', 'learning_rate': '6.685e-06', 'epoch': '1.398'}
132
+ {'loss': '0.4862', 'grad_norm': '3.509', 'learning_rate': '6.613e-06', 'epoch': '1.405'}
133
+ {'loss': '0.4596', 'grad_norm': '4.734', 'learning_rate': '6.541e-06', 'epoch': '1.411'}
134
+ {'loss': '0.4696', 'grad_norm': '4.799', 'learning_rate': '6.469e-06', 'epoch': '1.418'}
135
+ {'loss': '0.4925', 'grad_norm': '4.942', 'learning_rate': '6.397e-06', 'epoch': '1.424'}
136
+ {'loss': '0.4796', 'grad_norm': '4.147', 'learning_rate': '6.325e-06', 'epoch': '1.431'}
137
+ {'loss': '0.4525', 'grad_norm': '5.146', 'learning_rate': '6.254e-06', 'epoch': '1.437'}
138
+ {'loss': '0.4717', 'grad_norm': '3.52', 'learning_rate': '6.182e-06', 'epoch': '1.444'}
139
+ {'loss': '0.4803', 'grad_norm': '3.25', 'learning_rate': '6.11e-06', 'epoch': '1.45'}
140
+ {'loss': '0.4675', 'grad_norm': '7.35', 'learning_rate': '6.038e-06', 'epoch': '1.457'}
141
+ {'loss': '0.4631', 'grad_norm': '3.847', 'learning_rate': '5.966e-06', 'epoch': '1.463'}
142
+ {'loss': '0.4622', 'grad_norm': '4.57', 'learning_rate': '5.894e-06', 'epoch': '1.47'}
143
+ {'loss': '0.4496', 'grad_norm': '1.997', 'learning_rate': '5.822e-06', 'epoch': '1.476'}
144
+ {'loss': '0.4678', 'grad_norm': '4.266', 'learning_rate': '5.75e-06', 'epoch': '1.483'}
145
+ {'loss': '0.4495', 'grad_norm': '5.948', 'learning_rate': '5.678e-06', 'epoch': '1.489'}
146
+ {'loss': '0.4474', 'grad_norm': '3.7', 'learning_rate': '5.606e-06', 'epoch': '1.495'}
147
+ {'loss': '0.4587', 'grad_norm': '2.877', 'learning_rate': '5.534e-06', 'epoch': '1.502'}
148
+ {'loss': '0.4591', 'grad_norm': '4.245', 'learning_rate': '5.462e-06', 'epoch': '1.508'}
149
+ {'loss': '0.4573', 'grad_norm': '5.431', 'learning_rate': '5.39e-06', 'epoch': '1.515'}
150
+ {'loss': '0.4442', 'grad_norm': '3.338', 'learning_rate': '5.318e-06', 'epoch': '1.521'}
151
+ {'loss': '0.455', 'grad_norm': '4.723', 'learning_rate': '5.246e-06', 'epoch': '1.528'}
152
+ {'loss': '0.4493', 'grad_norm': '4.226', 'learning_rate': '5.175e-06', 'epoch': '1.534'}
153
+ {'loss': '0.4485', 'grad_norm': '4.451', 'learning_rate': '5.103e-06', 'epoch': '1.541'}
154
+ {'loss': '0.4569', 'grad_norm': '4.297', 'learning_rate': '5.031e-06', 'epoch': '1.547'}
155
+ {'loss': '0.4346', 'grad_norm': '4.199', 'learning_rate': '4.959e-06', 'epoch': '1.554'}
156
+ {'eval_train_loss': '0.3001', 'eval_dev-768_cosine_accuracy': '0.9799', 'eval_dev-512_cosine_accuracy': '0.9802', 'eval_dev-256_cosine_accuracy': '0.9802', 'eval_dev-128_cosine_accuracy': '0.9798', 'eval_dev-64_cosine_accuracy': '0.9788', 'eval_sequential_score': '0.9799', 'eval_train_runtime': '1.008e+04', 'eval_train_samples_per_second': '112.1', 'eval_train_steps_per_second': '14.02', 'epoch': '1.554'}
157
+ {'loss': '0.4469', 'grad_norm': '3.364', 'learning_rate': '4.887e-06', 'epoch': '1.56'}
158
+ {'loss': '0.4602', 'grad_norm': '5.309', 'learning_rate': '4.815e-06', 'epoch': '1.567'}
159
+ {'loss': '0.443', 'grad_norm': '3.875', 'learning_rate': '4.743e-06', 'epoch': '1.573'}
160
+ {'loss': '0.4524', 'grad_norm': '4.824', 'learning_rate': '4.671e-06', 'epoch': '1.58'}
161
+ {'loss': '0.4528', 'grad_norm': '4.996', 'learning_rate': '4.599e-06', 'epoch': '1.586'}
162
+ {'loss': '0.4348', 'grad_norm': '4.96', 'learning_rate': '4.527e-06', 'epoch': '1.593'}
163
+ {'loss': '0.4533', 'grad_norm': '5.219', 'learning_rate': '4.455e-06', 'epoch': '1.599'}
164
+ {'loss': '0.4523', 'grad_norm': '3.444', 'learning_rate': '4.383e-06', 'epoch': '1.606'}
165
+ {'loss': '0.4509', 'grad_norm': '5.647', 'learning_rate': '4.311e-06', 'epoch': '1.612'}
166
+ {'loss': '0.4365', 'grad_norm': '5.052', 'learning_rate': '4.239e-06', 'epoch': '1.618'}
167
+ {'loss': '0.4504', 'grad_norm': '5.786', 'learning_rate': '4.167e-06', 'epoch': '1.625'}
168
+ {'loss': '0.4292', 'grad_norm': '4.353', 'learning_rate': '4.096e-06', 'epoch': '1.631'}
169
+ {'loss': '0.4406', 'grad_norm': '2.976', 'learning_rate': '4.024e-06', 'epoch': '1.638'}
170
+ {'loss': '0.4333', 'grad_norm': '3.685', 'learning_rate': '3.952e-06', 'epoch': '1.644'}
171
+ {'loss': '0.4361', 'grad_norm': '4.107', 'learning_rate': '3.88e-06', 'epoch': '1.651'}
172
+ {'loss': '0.4065', 'grad_norm': '3.636', 'learning_rate': '3.808e-06', 'epoch': '1.657'}
173
+ {'loss': '0.4671', 'grad_norm': '3.464', 'learning_rate': '3.736e-06', 'epoch': '1.664'}
174
+ {'loss': '0.4328', 'grad_norm': '3.129', 'learning_rate': '3.664e-06', 'epoch': '1.67'}
175
+ {'loss': '0.431', 'grad_norm': '2.453', 'learning_rate': '3.592e-06', 'epoch': '1.677'}
176
+ {'loss': '0.4523', 'grad_norm': '3.727', 'learning_rate': '3.52e-06', 'epoch': '1.683'}
177
+ {'loss': '0.4232', 'grad_norm': '4.398', 'learning_rate': '3.448e-06', 'epoch': '1.69'}
178
+ {'loss': '0.4257', 'grad_norm': '2.861', 'learning_rate': '3.376e-06', 'epoch': '1.696'}
179
+ {'loss': '0.4448', 'grad_norm': '3.523', 'learning_rate': '3.304e-06', 'epoch': '1.703'}
180
+ {'loss': '0.4491', 'grad_norm': '3.893', 'learning_rate': '3.232e-06', 'epoch': '1.709'}
181
+ {'loss': '0.4224', 'grad_norm': '3.399', 'learning_rate': '3.16e-06', 'epoch': '1.716'}
182
+ {'loss': '0.4297', 'grad_norm': '4.703', 'learning_rate': '3.088e-06', 'epoch': '1.722'}
183
+ {'loss': '0.4522', 'grad_norm': '4.29', 'learning_rate': '3.017e-06', 'epoch': '1.729'}
184
+ {'loss': '0.4195', 'grad_norm': '4.29', 'learning_rate': '2.945e-06', 'epoch': '1.735'}
185
+ {'loss': '0.4227', 'grad_norm': '3.841', 'learning_rate': '2.873e-06', 'epoch': '1.742'}
186
+ {'loss': '0.4381', 'grad_norm': '4.086', 'learning_rate': '2.801e-06', 'epoch': '1.748'}
187
+ {'eval_train_loss': '0.2875', 'eval_dev-768_cosine_accuracy': '0.9807', 'eval_dev-512_cosine_accuracy': '0.9808', 'eval_dev-256_cosine_accuracy': '0.9808', 'eval_dev-128_cosine_accuracy': '0.9805', 'eval_dev-64_cosine_accuracy': '0.9794', 'eval_sequential_score': '0.9807', 'eval_train_runtime': '1.012e+04', 'eval_train_samples_per_second': '111.6', 'eval_train_steps_per_second': '13.95', 'epoch': '1.748'}
188
+ {'loss': '0.446', 'grad_norm': '4.176', 'learning_rate': '2.729e-06', 'epoch': '1.754'}
189
+ {'loss': '0.426', 'grad_norm': '4.261', 'learning_rate': '2.657e-06', 'epoch': '1.761'}
190
+ {'loss': '0.4299', 'grad_norm': '4.676', 'learning_rate': '2.585e-06', 'epoch': '1.767'}
191
+ {'loss': '0.4247', 'grad_norm': '3.933', 'learning_rate': '2.513e-06', 'epoch': '1.774'}
192
+ {'loss': '0.4244', 'grad_norm': '4.853', 'learning_rate': '2.441e-06', 'epoch': '1.78'}
193
+ {'loss': '0.4185', 'grad_norm': '2.985', 'learning_rate': '2.369e-06', 'epoch': '1.787'}
194
+ {'loss': '0.4292', 'grad_norm': '3.804', 'learning_rate': '2.297e-06', 'epoch': '1.793'}
195
+ {'loss': '0.4468', 'grad_norm': '3.187', 'learning_rate': '2.225e-06', 'epoch': '1.8'}
196
+ {'loss': '0.4118', 'grad_norm': '4.004', 'learning_rate': '2.153e-06', 'epoch': '1.806'}
197
+ {'loss': '0.4306', 'grad_norm': '4.007', 'learning_rate': '2.081e-06', 'epoch': '1.813'}
198
+ {'loss': '0.4447', 'grad_norm': '4.323', 'learning_rate': '2.009e-06', 'epoch': '1.819'}
199
+ {'loss': '0.4147', 'grad_norm': '3.863', 'learning_rate': '1.938e-06', 'epoch': '1.826'}
200
+ {'loss': '0.4189', 'grad_norm': '4.788', 'learning_rate': '1.866e-06', 'epoch': '1.832'}
201
+ {'loss': '0.4167', 'grad_norm': '4.276', 'learning_rate': '1.794e-06', 'epoch': '1.839'}
202
+ {'loss': '0.4022', 'grad_norm': '3.887', 'learning_rate': '1.722e-06', 'epoch': '1.845'}
203
+ {'loss': '0.4158', 'grad_norm': '3.075', 'learning_rate': '1.65e-06', 'epoch': '1.852'}
204
+ {'loss': '0.4228', 'grad_norm': '3.993', 'learning_rate': '1.578e-06', 'epoch': '1.858'}
205
+ {'loss': '0.4256', 'grad_norm': '4.497', 'learning_rate': '1.506e-06', 'epoch': '1.865'}
206
+ {'loss': '0.4251', 'grad_norm': '4.539', 'learning_rate': '1.434e-06', 'epoch': '1.871'}
207
+ {'loss': '0.4232', 'grad_norm': '2.337', 'learning_rate': '1.362e-06', 'epoch': '1.877'}
208
+ {'loss': '0.4143', 'grad_norm': '3.389', 'learning_rate': '1.29e-06', 'epoch': '1.884'}
209
+ {'loss': '0.4331', 'grad_norm': '3.545', 'learning_rate': '1.218e-06', 'epoch': '1.89'}
210
+ {'loss': '0.4253', 'grad_norm': '5.606', 'learning_rate': '1.146e-06', 'epoch': '1.897'}
211
+ {'loss': '0.441', 'grad_norm': '4.453', 'learning_rate': '1.074e-06', 'epoch': '1.903'}
212
+ {'loss': '0.4337', 'grad_norm': '5.374', 'learning_rate': '1.002e-06', 'epoch': '1.91'}
213
+ {'loss': '0.4016', 'grad_norm': '2.246', 'learning_rate': '9.305e-07', 'epoch': '1.916'}
214
+ {'loss': '0.4249', 'grad_norm': '5.255', 'learning_rate': '8.585e-07', 'epoch': '1.923'}
215
+ {'loss': '0.4108', 'grad_norm': '3.59', 'learning_rate': '7.866e-07', 'epoch': '1.929'}
216
+ {'loss': '0.4272', 'grad_norm': '4.258', 'learning_rate': '7.147e-07', 'epoch': '1.936'}
217
+ {'loss': '0.3916', 'grad_norm': '3.476', 'learning_rate': '6.427e-07', 'epoch': '1.942'}
218
+ {'eval_train_loss': '0.2812', 'eval_dev-768_cosine_accuracy': '0.981', 'eval_dev-512_cosine_accuracy': '0.9811', 'eval_dev-256_cosine_accuracy': '0.9813', 'eval_dev-128_cosine_accuracy': '0.9811', 'eval_dev-64_cosine_accuracy': '0.9797', 'eval_sequential_score': '0.981', 'eval_train_runtime': '1.03e+04', 'eval_train_samples_per_second': '109.7', 'eval_train_steps_per_second': '13.71', 'epoch': '1.942'}
219
+ {'loss': '0.4334', 'grad_norm': '4.623', 'learning_rate': '5.708e-07', 'epoch': '1.949'}
220
+ {'loss': '0.4462', 'grad_norm': '5.31', 'learning_rate': '4.989e-07', 'epoch': '1.955'}
221
+ {'loss': '0.4436', 'grad_norm': '3.379', 'learning_rate': '4.269e-07', 'epoch': '1.962'}
222
+ {'loss': '0.4278', 'grad_norm': '5.471', 'learning_rate': '3.55e-07', 'epoch': '1.968'}
223
+ {'loss': '0.417', 'grad_norm': '3.435', 'learning_rate': '2.831e-07', 'epoch': '1.975'}
224
+ {'loss': '0.4376', 'grad_norm': '2.617', 'learning_rate': '2.111e-07', 'epoch': '1.981'}
225
+ {'loss': '0.4433', 'grad_norm': '3.465', 'learning_rate': '1.392e-07', 'epoch': '1.988'}
226
+ {'loss': '0.4292', 'grad_norm': '2.354', 'learning_rate': '6.726e-08', 'epoch': '1.994'}
227
+ {'train_runtime': '9.588e+04', 'train_samples_per_second': '82.48', 'train_steps_per_second': '0.644', 'train_loss': '0.403', 'epoch': '2'}
228
+ model saved successfully
sbert_training/evaulate_ms_marco.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
sbert_training/fourth_training/.ipynb_checkpoints/Benchmarking_02_04-checkpoint.ipynb ADDED
@@ -0,0 +1,1072 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "5d927cd4-3481-4a09-b152-9e16b2414910",
6
+ "metadata": {},
7
+ "source": [
8
+ "# benchmarking on arcd_SQuAD data and STS on benchmark 17 and finally lahcen data "
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 8,
14
+ "id": "81dff6f6-810b-4176-b744-96b04179f5f2",
15
+ "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "Loaded 1046 triplets from /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/test_arcd_SQuAD_triplets.csv\n"
22
+ ]
23
+ },
24
+ {
25
+ "name": "stderr",
26
+ "output_type": "stream",
27
+ "text": [
28
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 778.24it/s, Materializing param=pooler.dense.weight]\n",
29
+ "\u001b[1mXLMRobertaModel LOAD REPORT\u001b[0m from: intfloat/multilingual-e5-base\n",
30
+ "Key | Status | | \n",
31
+ "------------------------+------------+--+-\n",
32
+ "embeddings.position_ids | UNEXPECTED | | \n",
33
+ "\n",
34
+ "\u001b[3mNotes:\n",
35
+ "- UNEXPECTED\u001b[3m\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n"
36
+ ]
37
+ },
38
+ {
39
+ "name": "stdout",
40
+ "output_type": "stream",
41
+ "text": [
42
+ "\n",
43
+ "Shared corpus size: 572 unique documents\n",
44
+ "\n",
45
+ "Encoding queries ...\n"
46
+ ]
47
+ },
48
+ {
49
+ "name": "stderr",
50
+ "output_type": "stream",
51
+ "text": [
52
+ "Batches: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 17/17 [00:00<00:00, 85.05it/s]\n"
53
+ ]
54
+ },
55
+ {
56
+ "name": "stdout",
57
+ "output_type": "stream",
58
+ "text": [
59
+ "Encoding corpus ...\n"
60
+ ]
61
+ },
62
+ {
63
+ "name": "stderr",
64
+ "output_type": "stream",
65
+ "text": [
66
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:01<00:00, 8.80it/s]\n"
67
+ ]
68
+ },
69
+ {
70
+ "name": "stdout",
71
+ "output_type": "stream",
72
+ "text": [
73
+ "\n",
74
+ "Ranking ...\n",
75
+ "\n",
76
+ "==================================================\n",
77
+ "Model : E5-Base\n",
78
+ "Corpus size : 572 docs\n",
79
+ "Queries : 1046\n",
80
+ "Hit Rate @ 10 : 0.9512 (995/1046)\n",
81
+ "MRR @ 10 : 0.8013\n",
82
+ "==================================================\n",
83
+ "\n",
84
+ "Results saved to e5_base_results.csv\n"
85
+ ]
86
+ }
87
+ ],
88
+ "source": [
89
+ "\"\"\"\n",
90
+ "Semantic Search Evaluation: Hit Rate & MRR\n",
91
+ "Model: E5-Base\n",
92
+ "Corpus: all positives + negatives pooled (realistic retrieval setting)\n",
93
+ "\"\"\"\n",
94
+ "\n",
95
+ "import pandas as pd\n",
96
+ "import numpy as np\n",
97
+ "import torch\n",
98
+ "from sentence_transformers import SentenceTransformer\n",
99
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
100
+ "\n",
101
+ "# ──────────────────────────────────────────────\n",
102
+ "# CONFIG — update paths here\n",
103
+ "# ──────────────────────────────────────────────\n",
104
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/test_arcd_SQuAD_triplets.csv\" \n",
105
+ "MODEL_PATH = 'intfloat/multilingual-e5-base' # or local fine-tuned path\n",
106
+ "\n",
107
+ "ANCHOR_COL = \"anchor\"\n",
108
+ "POSITIVE_COL = \"positive\"\n",
109
+ "NEGATIVE_COL = \"negative\"\n",
110
+ "\n",
111
+ "TOP_K = 10\n",
112
+ "BATCH_SIZE = 64\n",
113
+ "DEVICE = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
114
+ "# ──────────────────────────────────────────────\n",
115
+ "E5_STYLE = True\n",
116
+ "\n",
117
+ "def load_data(csv_path: str) -> pd.DataFrame:\n",
118
+ " df = pd.read_csv(csv_path)\n",
119
+ " missing = {ANCHOR_COL, POSITIVE_COL, NEGATIVE_COL} - set(df.columns)\n",
120
+ " if missing:\n",
121
+ " raise ValueError(f\"CSV is missing columns: {missing}\")\n",
122
+ " print(f\"Loaded {len(df)} triplets from {csv_path}\")\n",
123
+ " return df\n",
124
+ "\n",
125
+ "\n",
126
+ "def encode(model: SentenceTransformer, texts: list, prefix: str = \"\") -> np.ndarray:\n",
127
+ " if prefix:\n",
128
+ " texts = [prefix + t for t in texts]\n",
129
+ " return model.encode(\n",
130
+ " texts,\n",
131
+ " batch_size=BATCH_SIZE,\n",
132
+ " show_progress_bar=True,\n",
133
+ " convert_to_numpy=True,\n",
134
+ " normalize_embeddings=True,\n",
135
+ " device=DEVICE,\n",
136
+ " )\n",
137
+ "\n",
138
+ "\n",
139
+ "def evaluate(model: SentenceTransformer, df: pd.DataFrame) -> dict:\n",
140
+ " queries = df[ANCHOR_COL].tolist()\n",
141
+ " positives = df[POSITIVE_COL].tolist()\n",
142
+ " negatives = df[NEGATIVE_COL].tolist()\n",
143
+ "\n",
144
+ " # ── Build shared corpus ───────────────────\n",
145
+ " # Deduplicate so the same doc isn't indexed twice\n",
146
+ " all_docs = list(set(positives + negatives))\n",
147
+ " doc_index = {doc: i for i, doc in enumerate(all_docs)}\n",
148
+ " corpus_size = len(all_docs)\n",
149
+ " print(f\"\\nShared corpus size: {corpus_size} unique documents\")\n",
150
+ "\n",
151
+ " # ── Encode everything ─────────────────────\n",
152
+ " print(\"\\nEncoding queries ...\")\n",
153
+ " q_embs = encode(model, queries, prefix=\"query: \")\n",
154
+ "\n",
155
+ " print(\"Encoding corpus ...\")\n",
156
+ " doc_embs = encode(model, all_docs, prefix=\"passage: \") # (corpus_size, dim)\n",
157
+ "\n",
158
+ " # ── Rank & score ──────────────────────────\n",
159
+ " hits, reciprocal_ranks = 0, []\n",
160
+ "\n",
161
+ " print(\"\\nRanking ...\")\n",
162
+ " for i in range(len(df)):\n",
163
+ " q = q_embs[i].reshape(1, -1)\n",
164
+ " scores = cosine_similarity(q, doc_embs)[0] # (corpus_size,)\n",
165
+ " ranked = np.argsort(-scores) # sorted doc indices\n",
166
+ "\n",
167
+ " pos_idx = doc_index[positives[i]]\n",
168
+ " positive_rank = int(np.where(ranked == pos_idx)[0][0]) + 1 # 1-based\n",
169
+ "\n",
170
+ " if positive_rank <= TOP_K:\n",
171
+ " hits += 1\n",
172
+ " reciprocal_ranks.append(1.0 / positive_rank)\n",
173
+ " else:\n",
174
+ " reciprocal_ranks.append(0.0)\n",
175
+ "\n",
176
+ " n = len(df)\n",
177
+ " hit_rate = hits / n\n",
178
+ " mrr = float(np.mean(reciprocal_ranks))\n",
179
+ "\n",
180
+ " print(f\"\\n{'='*50}\")\n",
181
+ " print(f\"Model : E5-Base\")\n",
182
+ " print(f\"Corpus size : {corpus_size} docs\")\n",
183
+ " print(f\"Queries : {n}\")\n",
184
+ " print(f\"Hit Rate @ {TOP_K} : {hit_rate:.4f} ({hits}/{n})\")\n",
185
+ " print(f\"MRR @ {TOP_K} : {mrr:.4f}\")\n",
186
+ " print(f\"{'='*50}\")\n",
187
+ "\n",
188
+ " return {\n",
189
+ " \"model\": \"E5-Base\",\n",
190
+ " \"corpus_size\": corpus_size,\n",
191
+ " f\"hit_rate@{TOP_K}\": round(hit_rate, 4),\n",
192
+ " f\"mrr@{TOP_K}\": round(mrr, 4),\n",
193
+ " \"n\": n,\n",
194
+ " }\n",
195
+ "\n",
196
+ "\n",
197
+ "def main():\n",
198
+ " df = load_data(CSV_PATH)\n",
199
+ " model = SentenceTransformer(MODEL_PATH, device=DEVICE)\n",
200
+ " res = evaluate(model, df)\n",
201
+ "\n",
202
+ " out = pd.DataFrame([res])\n",
203
+ " out.to_csv(\"e5_base_results.csv\", index=False)\n",
204
+ " print(\"\\nResults saved to e5_base_results.csv\")\n",
205
+ "\n",
206
+ "\n",
207
+ "if __name__ == \"__main__\":\n",
208
+ " main()"
209
+ ]
210
+ },
211
+ {
212
+ "cell_type": "code",
213
+ "execution_count": 9,
214
+ "id": "11529e91-fe4e-40b7-9f79-00b663f2f2ba",
215
+ "metadata": {},
216
+ "outputs": [
217
+ {
218
+ "name": "stdout",
219
+ "output_type": "stream",
220
+ "text": [
221
+ "Loaded 1046 triplets from /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/pre_test_arcd_SQuAD_triplets.csv\n"
222
+ ]
223
+ },
224
+ {
225
+ "name": "stderr",
226
+ "output_type": "stream",
227
+ "text": [
228
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 906.79it/s, Materializing param=pooler.dense.weight]\n"
229
+ ]
230
+ },
231
+ {
232
+ "name": "stdout",
233
+ "output_type": "stream",
234
+ "text": [
235
+ "\n",
236
+ "Shared corpus size: 572 unique documents\n",
237
+ "\n",
238
+ "Encoding queries ...\n"
239
+ ]
240
+ },
241
+ {
242
+ "name": "stderr",
243
+ "output_type": "stream",
244
+ "text": [
245
+ "Batches: 100%|██████████████████████████████████████████████████████████████���██████████████████████████████████████████████████████████████████| 17/17 [00:00<00:00, 98.66it/s]\n"
246
+ ]
247
+ },
248
+ {
249
+ "name": "stdout",
250
+ "output_type": "stream",
251
+ "text": [
252
+ "Encoding corpus ...\n"
253
+ ]
254
+ },
255
+ {
256
+ "name": "stderr",
257
+ "output_type": "stream",
258
+ "text": [
259
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 10.93it/s]\n"
260
+ ]
261
+ },
262
+ {
263
+ "name": "stdout",
264
+ "output_type": "stream",
265
+ "text": [
266
+ "\n",
267
+ "Ranking ...\n",
268
+ "\n",
269
+ "==================================================\n",
270
+ "Model : ArabVert02 (fine-tuned)\n",
271
+ "Corpus size : 572 docs\n",
272
+ "Queries : 1046\n",
273
+ "Hit Rate @ 10 : 0.9522 (996/1046)\n",
274
+ "MRR @ 10 : 0.7896\n",
275
+ "==================================================\n",
276
+ "\n",
277
+ "Results saved to arabvert02_results.csv\n"
278
+ ]
279
+ }
280
+ ],
281
+ "source": [
282
+ "\"\"\"\n",
283
+ "Semantic Search Evaluation: Hit Rate & MRR\n",
284
+ "Model: Fine-tuned ArabVert02\n",
285
+ "Corpus: all positives + negatives pooled (realistic retrieval setting)\n",
286
+ "\"\"\"\n",
287
+ "\n",
288
+ "import pandas as pd\n",
289
+ "import numpy as np\n",
290
+ "import torch\n",
291
+ "from sentence_transformers import SentenceTransformer\n",
292
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
293
+ "\n",
294
+ "# ──────────────────────────────────────────────\n",
295
+ "# CONFIG — update paths here\n",
296
+ "# ──────────────────────────────────────────────\n",
297
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/pre_test_arcd_SQuAD_triplets.csv\" \n",
298
+ "MODEL_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\" # local path or HF model ID\n",
299
+ "\n",
300
+ "ANCHOR_COL = \"anchor\"\n",
301
+ "POSITIVE_COL = \"positive\"\n",
302
+ "NEGATIVE_COL = \"negative\"\n",
303
+ "\n",
304
+ "TOP_K = 10\n",
305
+ "BATCH_SIZE = 64\n",
306
+ "DEVICE = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
307
+ "E5_STYLE = False # set True if your arabvert variant uses query:/passage: prefixes\n",
308
+ "# ──────────────────────────────────────────────\n",
309
+ "\n",
310
+ "\n",
311
+ "def load_data(csv_path: str) -> pd.DataFrame:\n",
312
+ " df = pd.read_csv(csv_path)\n",
313
+ " missing = {ANCHOR_COL, POSITIVE_COL, NEGATIVE_COL} - set(df.columns)\n",
314
+ " if missing:\n",
315
+ " raise ValueError(f\"CSV is missing columns: {missing}\")\n",
316
+ " print(f\"Loaded {len(df)} triplets from {csv_path}\")\n",
317
+ " return df\n",
318
+ "\n",
319
+ "\n",
320
+ "def encode(model: SentenceTransformer, texts: list, prefix: str = \"\") -> np.ndarray:\n",
321
+ " if prefix:\n",
322
+ " texts = [prefix + t for t in texts]\n",
323
+ " return model.encode(\n",
324
+ " texts,\n",
325
+ " batch_size=BATCH_SIZE,\n",
326
+ " show_progress_bar=True,\n",
327
+ " convert_to_numpy=True,\n",
328
+ " normalize_embeddings=True,\n",
329
+ " device=DEVICE,\n",
330
+ " )\n",
331
+ "\n",
332
+ "\n",
333
+ "def evaluate(model: SentenceTransformer, df: pd.DataFrame) -> dict:\n",
334
+ " queries = df[ANCHOR_COL].tolist()\n",
335
+ " positives = df[POSITIVE_COL].tolist()\n",
336
+ " negatives = df[NEGATIVE_COL].tolist()\n",
337
+ "\n",
338
+ " query_prefix = \"query: \" if E5_STYLE else \"\"\n",
339
+ " passage_prefix = \"passage: \" if E5_STYLE else \"\"\n",
340
+ "\n",
341
+ " # ── Build shared corpus ───────────────────\n",
342
+ " # Deduplicate so the same doc isn't indexed twice\n",
343
+ " all_docs = list(set(positives + negatives))\n",
344
+ " doc_index = {doc: i for i, doc in enumerate(all_docs)}\n",
345
+ " corpus_size = len(all_docs)\n",
346
+ " print(f\"\\nShared corpus size: {corpus_size} unique documents\")\n",
347
+ "\n",
348
+ " # ── Encode everything ─────────────────────\n",
349
+ " print(\"\\nEncoding queries ...\")\n",
350
+ " q_embs = encode(model, queries, prefix=query_prefix)\n",
351
+ "\n",
352
+ " print(\"Encoding corpus ...\")\n",
353
+ " doc_embs = encode(model, all_docs, prefix=passage_prefix) # (corpus_size, dim)\n",
354
+ "\n",
355
+ " # ── Rank & score ──────────────────────────\n",
356
+ " hits, reciprocal_ranks = 0, []\n",
357
+ "\n",
358
+ " print(\"\\nRanking ...\")\n",
359
+ " for i in range(len(df)):\n",
360
+ " q = q_embs[i].reshape(1, -1)\n",
361
+ " scores = cosine_similarity(q, doc_embs)[0] # (corpus_size,)\n",
362
+ " ranked = np.argsort(-scores) # sorted doc indices\n",
363
+ "\n",
364
+ " pos_idx = doc_index[positives[i]]\n",
365
+ " positive_rank = int(np.where(ranked == pos_idx)[0][0]) + 1 # 1-based\n",
366
+ "\n",
367
+ " if positive_rank <= TOP_K:\n",
368
+ " hits += 1\n",
369
+ " reciprocal_ranks.append(1.0 / positive_rank)\n",
370
+ " else:\n",
371
+ " reciprocal_ranks.append(0.0)\n",
372
+ "\n",
373
+ " n = len(df)\n",
374
+ " hit_rate = hits / n\n",
375
+ " mrr = float(np.mean(reciprocal_ranks))\n",
376
+ "\n",
377
+ " print(f\"\\n{'='*50}\")\n",
378
+ " print(f\"Model : ArabVert02 (fine-tuned)\")\n",
379
+ " print(f\"Corpus size : {corpus_size} docs\")\n",
380
+ " print(f\"Queries : {n}\")\n",
381
+ " print(f\"Hit Rate @ {TOP_K} : {hit_rate:.4f} ({hits}/{n})\")\n",
382
+ " print(f\"MRR @ {TOP_K} : {mrr:.4f}\")\n",
383
+ " print(f\"{'='*50}\")\n",
384
+ "\n",
385
+ " return {\n",
386
+ " \"model\": \"ArabVert02 (fine-tuned)\",\n",
387
+ " \"corpus_size\": corpus_size,\n",
388
+ " f\"hit_rate@{TOP_K}\": round(hit_rate, 4),\n",
389
+ " f\"mrr@{TOP_K}\": round(mrr, 4),\n",
390
+ " \"n\": n,\n",
391
+ " }\n",
392
+ "\n",
393
+ "\n",
394
+ "def main():\n",
395
+ " df = load_data(CSV_PATH)\n",
396
+ " model = SentenceTransformer(MODEL_PATH, device=DEVICE)\n",
397
+ " res = evaluate(model, df)\n",
398
+ "\n",
399
+ " out = pd.DataFrame([res])\n",
400
+ " out.to_csv(\"arabvert02_results.csv\", index=False)\n",
401
+ " print(\"\\nResults saved to arabvert02_results.csv\")\n",
402
+ "\n",
403
+ "\n",
404
+ "if __name__ == \"__main__\":\n",
405
+ " main()"
406
+ ]
407
+ },
408
+ {
409
+ "cell_type": "markdown",
410
+ "id": "88210c5d-bdbf-4650-bd70-74772d948aa6",
411
+ "metadata": {},
412
+ "source": [
413
+ "# sts "
414
+ ]
415
+ },
416
+ {
417
+ "cell_type": "code",
418
+ "execution_count": 10,
419
+ "id": "1659e63a-c3ef-4b16-9aea-bf0fe060a44b",
420
+ "metadata": {},
421
+ "outputs": [
422
+ {
423
+ "name": "stdout",
424
+ "output_type": "stream",
425
+ "text": [
426
+ "Loading CSV...\n",
427
+ " 250 pairs loaded.\n",
428
+ " sentence1 \\\n",
429
+ "0 شخص ما يحمل لوح التزلج ليلا على الرصيف . \n",
430
+ "1 تتسابق النساء في سباق الدايتونا 500 . \n",
431
+ "2 تمشي النساء جنبا إلى جنب . \n",
432
+ "3 يقفز الرجل ذو القميص الأخضر عاليا على العشب . \n",
433
+ "4 رجلان يجلسان على العشب ومعهما موز . \n",
434
+ "\n",
435
+ " sentence2 score \n",
436
+ "0 رجل جالس بمفرده يقرأ على طاولة مستديرة ، خارج ... 0.8 \n",
437
+ "1 يتسابق بعض الرجال ضمن مسابقة التزلج . 1.0 \n",
438
+ "2 هناك فتيات يمشين متجاورات 2.6 \n",
439
+ "3 يمشي الرجل ذو القميص الأبيض على العشب الطويل م... 2.2 \n",
440
+ "4 ثلاثة رجال يتسكعون عند فرشة بيع الفاكهة . 1.4 \n",
441
+ "\n",
442
+ "Loading SBERT model and encoding sentences...\n"
443
+ ]
444
+ },
445
+ {
446
+ "name": "stderr",
447
+ "output_type": "stream",
448
+ "text": [
449
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 805.46it/s, Materializing param=pooler.dense.weight]\n",
450
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 148.44it/s]\n",
451
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 165.65it/s]\n"
452
+ ]
453
+ },
454
+ {
455
+ "name": "stdout",
456
+ "output_type": "stream",
457
+ "text": [
458
+ "\n",
459
+ "Computing cosine similarities...\n",
460
+ "\n",
461
+ "─── STS Correlation Results ───────────────────────────────\n",
462
+ " Pearson r : 0.8178 (p=1.9527e-61)\n",
463
+ " Spearman r : 0.8182 (p=1.5160e-61)\n",
464
+ "\n",
465
+ "─── Hit Rate & MRR ────────────────────────────────────────\n",
466
+ " (Relevance threshold on gold score: >= 0.5)\n",
467
+ " Hit Rate @ 1 : 0.5853 (127/217)\n",
468
+ " Hit Rate @ 3 : 0.7281 (158/217)\n",
469
+ " Hit Rate @ 5 : 0.7742 (168/217)\n",
470
+ " MRR : 0.6735\n",
471
+ "\n",
472
+ "Results saved to: /home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15_preprocessed_arabertv02_benchmark_results.csv\n"
473
+ ]
474
+ }
475
+ ],
476
+ "source": [
477
+ "import pandas as pd\n",
478
+ "import numpy as np\n",
479
+ "from sentence_transformers import SentenceTransformer\n",
480
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
481
+ "from scipy.stats import pearsonr, spearmanr\n",
482
+ "\n",
483
+ "# ─── CONFIG ───────────────────────────────────────────────────────────────────\n",
484
+ "\n",
485
+ "MODEL_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\" \n",
486
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15_preprocessed_arabertv02.csv\"\n",
487
+ "TOP_K = [1, 3, 5]\n",
488
+ "SCORE_THRESHOLD = 0.5 # adjust if your score scale is not [0,1]\n",
489
+ "# ──────────────────────────────────────────────────────────────────────────────\n",
490
+ "\n",
491
+ "# 1. Load CSV\n",
492
+ "print(\"Loading CSV...\")\n",
493
+ "df = pd.read_csv(CSV_PATH)\n",
494
+ "if 'lang' in df.columns:\n",
495
+ " df = df.drop(columns=['lang'])\n",
496
+ "\n",
497
+ "print(f\" {len(df)} pairs loaded.\")\n",
498
+ "print(df.head())\n",
499
+ "\n",
500
+ "# 2. Encode\n",
501
+ "print(\"\\nLoading SBERT model and encoding sentences...\")\n",
502
+ "model = SentenceTransformer(MODEL_PATH)\n",
503
+ "emb1 = model.encode(df['sentence1'].tolist(), batch_size=32, show_progress_bar=True, convert_to_numpy=True)\n",
504
+ "emb2 = model.encode(df['sentence2'].tolist(), batch_size=32, show_progress_bar=True, convert_to_numpy=True)\n",
505
+ "\n",
506
+ "# 3. Cosine similarity per pair\n",
507
+ "print(\"\\nComputing cosine similarities...\")\n",
508
+ "cos_scores = np.array([\n",
509
+ " cosine_similarity(emb1[i].reshape(1, -1), emb2[i].reshape(1, -1))[0][0]\n",
510
+ " for i in range(len(df))\n",
511
+ "])\n",
512
+ "\n",
513
+ "# 4. Pearson & Spearman\n",
514
+ "gold_scores = df['score'].astype(float).values\n",
515
+ "pearson_corr, p_val_p = pearsonr(cos_scores, gold_scores)\n",
516
+ "spearman_corr, p_val_s = spearmanr(cos_scores, gold_scores)\n",
517
+ "\n",
518
+ "print(\"\\n─── STS Correlation Results ───────────────────────────────\")\n",
519
+ "print(f\" Pearson r : {pearson_corr:.4f} (p={p_val_p:.4e})\")\n",
520
+ "print(f\" Spearman r : {spearman_corr:.4f} (p={p_val_s:.4e})\")\n",
521
+ "\n",
522
+ "# 5. Hit Rate & MRR\n",
523
+ "print(\"\\n─── Hit Rate & MRR ────────────────────────────────────────\")\n",
524
+ "print(f\" (Relevance threshold on gold score: >= {SCORE_THRESHOLD})\")\n",
525
+ "\n",
526
+ "hit_counts = {k: 0 for k in TOP_K}\n",
527
+ "reciprocal_ranks = []\n",
528
+ "n_queries = 0\n",
529
+ "\n",
530
+ "for i in range(len(df)):\n",
531
+ " if gold_scores[i] < SCORE_THRESHOLD:\n",
532
+ " continue\n",
533
+ "\n",
534
+ " query_emb = emb1[i].reshape(1, -1)\n",
535
+ " sims = cosine_similarity(query_emb, emb2)[0]\n",
536
+ " ranked_idxs = np.argsort(sims)[::-1]\n",
537
+ "\n",
538
+ " rank = np.where(ranked_idxs == i)[0][0] + 1 # 1-based\n",
539
+ "\n",
540
+ " for k in TOP_K:\n",
541
+ " if rank <= k:\n",
542
+ " hit_counts[k] += 1\n",
543
+ "\n",
544
+ " reciprocal_ranks.append(1.0 / rank)\n",
545
+ " n_queries += 1\n",
546
+ "\n",
547
+ "if n_queries == 0:\n",
548
+ " print(\" No relevant pairs found — lower SCORE_THRESHOLD.\")\n",
549
+ "else:\n",
550
+ " for k in TOP_K:\n",
551
+ " hr = hit_counts[k] / n_queries\n",
552
+ " print(f\" Hit Rate @{k:2d} : {hr:.4f} ({hit_counts[k]}/{n_queries})\")\n",
553
+ "\n",
554
+ " mrr = np.mean(reciprocal_ranks)\n",
555
+ " print(f\" MRR : {mrr:.4f}\")\n",
556
+ "\n",
557
+ "# 6. Save results\n",
558
+ "df['predicted_cos_sim'] = cos_scores\n",
559
+ "output_path = CSV_PATH.replace('.csv', '_benchmark_results.csv')\n",
560
+ "df.to_csv(output_path, index=False)\n",
561
+ "print(f\"\\nResults saved to: {output_path}\")"
562
+ ]
563
+ },
564
+ {
565
+ "cell_type": "code",
566
+ "execution_count": 11,
567
+ "id": "fdb3d5d1-be16-4ad6-a5ed-b7be866cabbf",
568
+ "metadata": {},
569
+ "outputs": [
570
+ {
571
+ "name": "stdout",
572
+ "output_type": "stream",
573
+ "text": [
574
+ "Loading CSV...\n",
575
+ " 250 pairs loaded.\n",
576
+ " sentence1 \\\n",
577
+ "0 شخص ما يحمل لوح التزلج ليلا على الرصيف. \n",
578
+ "1 تتسابق النساء في سباق الدايتونا 500. \n",
579
+ "2 تمشي النساء جنبا إلى جنب. \n",
580
+ "3 يقفز الرجل ذو القميص الأخضر عاليا على العشب. \n",
581
+ "4 رجلان يجلسان على العشب ومعهما موز. \n",
582
+ "\n",
583
+ " sentence2 score \n",
584
+ "0 رجل جالس بمفرده يقرأ على طاولة مستديرة ، خارج ... 0.8 \n",
585
+ "1 يتسابق بعض الرجال ضمن مسابقة التزلج. 1.0 \n",
586
+ "2 هناك فتيات يمشين متجاورات 2.6 \n",
587
+ "3 يمشي الرجل ذو القميص الأبيض على العشب الطويل م... 2.2 \n",
588
+ "4 ثلاثة رجال يتسكعون عند فرشة بيع الفاكهة. 1.4 \n",
589
+ "\n",
590
+ "Loading multilingual-e5-base and encoding sentences...\n"
591
+ ]
592
+ },
593
+ {
594
+ "name": "stderr",
595
+ "output_type": "stream",
596
+ "text": [
597
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 925.58it/s, Materializing param=pooler.dense.weight]\n",
598
+ "\u001b[1mXLMRobertaModel LOAD REPORT\u001b[0m from: intfloat/multilingual-e5-base\n",
599
+ "Key | Status | | \n",
600
+ "------------------------+------------+--+-\n",
601
+ "embeddings.position_ids | UNEXPECTED | | \n",
602
+ "\n",
603
+ "\u001b[3mNotes:\n",
604
+ "- UNEXPECTED\u001b[3m\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n",
605
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 126.89it/s]\n",
606
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 126.29it/s]\n"
607
+ ]
608
+ },
609
+ {
610
+ "name": "stdout",
611
+ "output_type": "stream",
612
+ "text": [
613
+ "\n",
614
+ "Computing cosine similarities...\n",
615
+ "\n",
616
+ "─── STS Correlation Results ───────────────────────────────\n",
617
+ " Pearson r : 0.7446 (p=1.9457e-45)\n",
618
+ " Spearman r : 0.7450 (p=1.6963e-45)\n",
619
+ "\n",
620
+ "─── Hit Rate & MRR ────────────────────────────────────────\n",
621
+ " (Relevance threshold on gold score: >= 0.5)\n",
622
+ " Hit Rate @ 1 : 0.5991 (130/217)\n",
623
+ " Hit Rate @ 3 : 0.7327 (159/217)\n",
624
+ " Hit Rate @ 5 : 0.7696 (167/217)\n",
625
+ " MRR : 0.6794\n",
626
+ "\n",
627
+ "Results saved to: /home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15_e5_benchmark_results.csv\n"
628
+ ]
629
+ }
630
+ ],
631
+ "source": [
632
+ "import pandas as pd\n",
633
+ "import numpy as np\n",
634
+ "from sentence_transformers import SentenceTransformer\n",
635
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
636
+ "from scipy.stats import pearsonr, spearmanr\n",
637
+ "\n",
638
+ "# ─── CONFIG ───────────────────────────────────────────────────────────────────\n",
639
+ "MODEL_NAME = \"intfloat/multilingual-e5-base\"\n",
640
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15.csv\"\n",
641
+ "TOP_K = [1, 3, 5]\n",
642
+ "SCORE_THRESHOLD = 0.5 # adjust to your score scale\n",
643
+ "PREFIX = \"query: \" # symmetric STS — same prefix for both sides\n",
644
+ "# ──────────────────────────────────────────────────────────────────────────────\n",
645
+ "\n",
646
+ "# 1. Load CSV\n",
647
+ "print(\"Loading CSV...\")\n",
648
+ "df = pd.read_csv(CSV_PATH)\n",
649
+ "if 'lang' in df.columns:\n",
650
+ " df = df.drop(columns=['lang'])\n",
651
+ "\n",
652
+ "print(f\" {len(df)} pairs loaded.\")\n",
653
+ "print(df.head())\n",
654
+ "\n",
655
+ "# 2. Apply E5 prefix\n",
656
+ "sentences1 = [PREFIX + str(s) for s in df['sentence1'].tolist()]\n",
657
+ "sentences2 = [PREFIX + str(s) for s in df['sentence2'].tolist()]\n",
658
+ "\n",
659
+ "# 3. Encode\n",
660
+ "print(\"\\nLoading multilingual-e5-base and encoding sentences...\")\n",
661
+ "model = SentenceTransformer(MODEL_NAME)\n",
662
+ "emb1 = model.encode(sentences1, batch_size=32, show_progress_bar=True, normalize_embeddings=True, convert_to_numpy=True)\n",
663
+ "emb2 = model.encode(sentences2, batch_size=32, show_progress_bar=True, normalize_embeddings=True, convert_to_numpy=True)\n",
664
+ "\n",
665
+ "# 4. Cosine similarity per pair\n",
666
+ "# Note: since embeddings are L2-normalized, cosine sim == dot product\n",
667
+ "print(\"\\nComputing cosine similarities...\")\n",
668
+ "cos_scores = np.array([\n",
669
+ " cosine_similarity(emb1[i].reshape(1, -1), emb2[i].reshape(1, -1))[0][0]\n",
670
+ " for i in range(len(df))\n",
671
+ "])\n",
672
+ "\n",
673
+ "# 5. Pearson & Spearman\n",
674
+ "gold_scores = df['score'].astype(float).values\n",
675
+ "pearson_corr, p_val_p = pearsonr(cos_scores, gold_scores)\n",
676
+ "spearman_corr, p_val_s = spearmanr(cos_scores, gold_scores)\n",
677
+ "\n",
678
+ "print(\"\\n─── STS Correlation Results ───────────────────────────────\")\n",
679
+ "print(f\" Pearson r : {pearson_corr:.4f} (p={p_val_p:.4e})\")\n",
680
+ "print(f\" Spearman r : {spearman_corr:.4f} (p={p_val_s:.4e})\")\n",
681
+ "\n",
682
+ "# 6. Hit Rate & MRR\n",
683
+ "print(\"\\n─── Hit Rate & MRR ────────────────────────────────────────\")\n",
684
+ "print(f\" (Relevance threshold on gold score: >= {SCORE_THRESHOLD})\")\n",
685
+ "\n",
686
+ "hit_counts = {k: 0 for k in TOP_K}\n",
687
+ "reciprocal_ranks = []\n",
688
+ "n_queries = 0\n",
689
+ "\n",
690
+ "for i in range(len(df)):\n",
691
+ " if gold_scores[i] < SCORE_THRESHOLD:\n",
692
+ " continue\n",
693
+ "\n",
694
+ " query_emb = emb1[i].reshape(1, -1)\n",
695
+ " sims = cosine_similarity(query_emb, emb2)[0]\n",
696
+ " ranked_idxs = np.argsort(sims)[::-1]\n",
697
+ "\n",
698
+ " rank = np.where(ranked_idxs == i)[0][0] + 1 # 1-based\n",
699
+ "\n",
700
+ " for k in TOP_K:\n",
701
+ " if rank <= k:\n",
702
+ " hit_counts[k] += 1\n",
703
+ "\n",
704
+ " reciprocal_ranks.append(1.0 / rank)\n",
705
+ " n_queries += 1\n",
706
+ "\n",
707
+ "if n_queries == 0:\n",
708
+ " print(\" No relevant pairs found — lower SCORE_THRESHOLD.\")\n",
709
+ "else:\n",
710
+ " for k in TOP_K:\n",
711
+ " hr = hit_counts[k] / n_queries\n",
712
+ " print(f\" Hit Rate @{k:2d} : {hr:.4f} ({hit_counts[k]}/{n_queries})\")\n",
713
+ "\n",
714
+ " mrr = np.mean(reciprocal_ranks)\n",
715
+ " print(f\" MRR : {mrr:.4f}\")\n",
716
+ "\n",
717
+ "# 7. Save results\n",
718
+ "df['predicted_cos_sim'] = cos_scores\n",
719
+ "output_path = CSV_PATH.replace('.csv', '_e5_benchmark_results.csv')\n",
720
+ "df.to_csv(output_path, index=False)\n",
721
+ "print(f\"\\nResults saved to: {output_path}\")"
722
+ ]
723
+ },
724
+ {
725
+ "cell_type": "markdown",
726
+ "id": "50861e84-dc7b-4a8e-9ad1-3da5f8307718",
727
+ "metadata": {},
728
+ "source": [
729
+ "# hsn data "
730
+ ]
731
+ },
732
+ {
733
+ "cell_type": "code",
734
+ "execution_count": 12,
735
+ "id": "039cb79b-df7f-47de-9025-fc60d7464d05",
736
+ "metadata": {},
737
+ "outputs": [],
738
+ "source": [
739
+ "import pandas as pd\n",
740
+ "import numpy as np\n",
741
+ "from sentence_transformers import SentenceTransformer\n",
742
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
743
+ "import logging\n",
744
+ "from pathlib import Path\n",
745
+ "import torch"
746
+ ]
747
+ },
748
+ {
749
+ "cell_type": "code",
750
+ "execution_count": 17,
751
+ "id": "dfcd6f83-12de-4080-9c91-7da95633c393",
752
+ "metadata": {},
753
+ "outputs": [
754
+ {
755
+ "name": "stderr",
756
+ "output_type": "stream",
757
+ "text": [
758
+ "2026-04-02 14:48:18,062 - INFO - Loading parquet: /home/skiredj.abderrahman/khalil/sbert_training/shamela_cleaned.parquet\n",
759
+ "2026-04-02 14:48:23,486 - INFO - Using random sample of 10000 rows.\n",
760
+ "2026-04-02 14:48:23,487 - INFO - Dataset size: 10000 rows\n",
761
+ "2026-04-02 14:48:23,488 - INFO - Loading model: /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\n",
762
+ "2026-04-02 14:48:23,495 - INFO - Use pytorch device_name: cuda:0\n",
763
+ "2026-04-02 14:48:23,496 - INFO - Load pretrained SentenceTransformer: /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\n",
764
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 855.39it/s, Materializing param=pooler.dense.weight]\n",
765
+ "2026-04-02 14:48:23,998 - INFO - Encoding 10000 corpus texts ...\n",
766
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:26<00:00, 5.92it/s]\n",
767
+ "2026-04-02 14:48:50,970 - INFO - Encoding queries from 'q1' ...\n",
768
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:02<00:00, 76.59it/s]\n"
769
+ ]
770
+ },
771
+ {
772
+ "name": "stdout",
773
+ "output_type": "stream",
774
+ "text": [
775
+ "\n",
776
+ "=============================================\n",
777
+ " SBERT Evaluation Results\n",
778
+ "=============================================\n",
779
+ " Hit Rate @ 1: 2885/10000 = 28.85%\n",
780
+ " Hit Rate @ 5: 4709/10000 = 47.09%\n",
781
+ " Hit Rate @ 10: 5548/10000 = 55.48%\n",
782
+ " MRR : 0.3789\n",
783
+ "=============================================\n",
784
+ "\n"
785
+ ]
786
+ }
787
+ ],
788
+ "source": [
789
+ "logging.basicConfig(level=logging.INFO, format=\"%(asctime)s - %(levelname)s - %(message)s\")\n",
790
+ "logger = logging.getLogger(__name__)\n",
791
+ "\n",
792
+ "# ── Config ───────────────────────────────────────────────────────────────────\n",
793
+ "PARQUET_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/shamela_cleaned.parquet\"\n",
794
+ "MODEL_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\" \n",
795
+ "BATCH_SIZE = 64\n",
796
+ "TOP_K = (1, 5, 10)\n",
797
+ "SAMPLE_N = 10000 # set e.g. 5000 to run on a subset; None = full file\n",
798
+ "# ─────────────────────────────────────────────────────────────────────────────\n",
799
+ "\n",
800
+ "QUERY_COLS = [\"q1\"]\n",
801
+ "TEXT_COL = \"text\"\n",
802
+ "\n",
803
+ "\n",
804
+ "def evaluate(df: pd.DataFrame, model: SentenceTransformer):\n",
805
+ " texts = df[TEXT_COL].tolist()\n",
806
+ "\n",
807
+ " # Encode corpus\n",
808
+ " logger.info(f\"Encoding {len(texts)} corpus texts ...\")\n",
809
+ " text_embs = model.encode(\n",
810
+ " texts,\n",
811
+ " batch_size=BATCH_SIZE,\n",
812
+ " show_progress_bar=True,\n",
813
+ " convert_to_numpy=True,\n",
814
+ " normalize_embeddings=True,\n",
815
+ " )\n",
816
+ "\n",
817
+ " hit_counts = {k: 0 for k in TOP_K}\n",
818
+ " mrr_scores = []\n",
819
+ " total = 0\n",
820
+ "\n",
821
+ " for col in QUERY_COLS:\n",
822
+ " queries = df[col].tolist()\n",
823
+ " logger.info(f\"Encoding queries from '{col}' ...\")\n",
824
+ "\n",
825
+ " q_embs = model.encode(\n",
826
+ " queries,\n",
827
+ " batch_size=BATCH_SIZE,\n",
828
+ " show_progress_bar=True,\n",
829
+ " convert_to_numpy=True,\n",
830
+ " normalize_embeddings=True,\n",
831
+ " )\n",
832
+ "\n",
833
+ " sims = cosine_similarity(q_embs, text_embs) # (n, n)\n",
834
+ "\n",
835
+ " for i in range(len(texts)):\n",
836
+ " ranked = np.argsort(-sims[i]) # numpy array, descending\n",
837
+ "\n",
838
+ " # MRR — find where index i appears in ranked\n",
839
+ " rank_pos = np.where(ranked == i)[0][0] + 1 # 1-based\n",
840
+ " mrr_scores.append(1.0 / rank_pos)\n",
841
+ "\n",
842
+ " # Hit Rate @ K\n",
843
+ " for k in TOP_K:\n",
844
+ " if i in ranked[:k]:\n",
845
+ " hit_counts[k] += 1\n",
846
+ "\n",
847
+ " total += 1\n",
848
+ "\n",
849
+ " return hit_counts, mrr_scores, total\n",
850
+ "\n",
851
+ "\n",
852
+ "def main():\n",
853
+ " logger.info(f\"Loading parquet: {PARQUET_PATH}\")\n",
854
+ " df = pd.read_parquet(PARQUET_PATH, columns=[TEXT_COL] + QUERY_COLS)\n",
855
+ " df = df.dropna(subset=[TEXT_COL] + QUERY_COLS).reset_index(drop=True)\n",
856
+ "\n",
857
+ " if SAMPLE_N and SAMPLE_N < len(df):\n",
858
+ " df = df.sample(n=SAMPLE_N, random_state=42).reset_index(drop=True)\n",
859
+ " logger.info(f\"Using random sample of {SAMPLE_N} rows.\")\n",
860
+ "\n",
861
+ " logger.info(f\"Dataset size: {len(df)} rows\")\n",
862
+ "\n",
863
+ " logger.info(f\"Loading model: {MODEL_PATH}\")\n",
864
+ " model = SentenceTransformer(MODEL_PATH)\n",
865
+ "\n",
866
+ " hit_counts, mrr_scores, total = evaluate(df, model)\n",
867
+ "\n",
868
+ " print(\"\\n\" + \"=\" * 45)\n",
869
+ " print(\" SBERT Evaluation Results\")\n",
870
+ " print(\"=\" * 45)\n",
871
+ " for k in TOP_K:\n",
872
+ " h = hit_counts[k]\n",
873
+ " print(f\" Hit Rate @ {k:2d}: {h}/{total} = {h/total*100:.2f}%\")\n",
874
+ " print(f\" MRR : {np.mean(mrr_scores):.4f}\")\n",
875
+ " print(\"=\" * 45 + \"\\n\")\n",
876
+ "\n",
877
+ "main()"
878
+ ]
879
+ },
880
+ {
881
+ "cell_type": "code",
882
+ "execution_count": 18,
883
+ "id": "afc485b0-efe7-4b79-ba37-76f8b72c6f7b",
884
+ "metadata": {},
885
+ "outputs": [
886
+ {
887
+ "name": "stderr",
888
+ "output_type": "stream",
889
+ "text": [
890
+ "2026-04-02 14:48:54,535 - INFO - Loading parquet: /home/skiredj.abderrahman/khalil/sbert_training/shamela_q_chunk_00_0_500000.parquet\n",
891
+ "2026-04-02 14:48:57,956 - INFO - Using random sample of 10000 rows.\n",
892
+ "2026-04-02 14:48:57,957 - INFO - Dataset size: 10000 rows\n",
893
+ "2026-04-02 14:48:57,958 - INFO - Loading model: intfloat/multilingual-e5-base\n",
894
+ "2026-04-02 14:48:57,963 - INFO - Use pytorch device_name: cuda:0\n",
895
+ "2026-04-02 14:48:57,963 - INFO - Load pretrained SentenceTransformer: intfloat/multilingual-e5-base\n",
896
+ "2026-04-02 14:48:58,199 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/modules.json \"HTTP/1.1 307 Temporary Redirect\"\n",
897
+ "2026-04-02 14:48:58,218 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/modules.json \"HTTP/1.1 200 OK\"\n",
898
+ "2026-04-02 14:48:58,353 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config_sentence_transformers.json \"HTTP/1.1 404 Not Found\"\n",
899
+ "2026-04-02 14:48:58,487 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config_sentence_transformers.json \"HTTP/1.1 404 Not Found\"\n",
900
+ "2026-04-02 14:48:58,806 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/README.md \"HTTP/1.1 307 Temporary Redirect\"\n",
901
+ "2026-04-02 14:48:58,826 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/README.md \"HTTP/1.1 200 OK\"\n",
902
+ "2026-04-02 14:48:58,962 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/modules.json \"HTTP/1.1 307 Temporary Redirect\"\n",
903
+ "2026-04-02 14:48:58,982 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/modules.json \"HTTP/1.1 200 OK\"\n",
904
+ "2026-04-02 14:48:59,215 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/sentence_bert_config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
905
+ "2026-04-02 14:48:59,235 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/sentence_bert_config.json \"HTTP/1.1 200 OK\"\n",
906
+ "2026-04-02 14:48:59,373 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/adapter_config.json \"HTTP/1.1 404 Not Found\"\n",
907
+ "2026-04-02 14:48:59,509 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
908
+ "2026-04-02 14:48:59,528 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/config.json \"HTTP/1.1 200 OK\"\n",
909
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 825.43it/s, Materializing param=pooler.dense.weight]\n",
910
+ "\u001b[1mXLMRobertaModel LOAD REPORT\u001b[0m from: intfloat/multilingual-e5-base\n",
911
+ "Key | Status | | \n",
912
+ "------------------------+------------+--+-\n",
913
+ "embeddings.position_ids | UNEXPECTED | | \n",
914
+ "\n",
915
+ "\u001b[3mNotes:\n",
916
+ "- UNEXPECTED\u001b[3m\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n",
917
+ "2026-04-02 14:48:59,954 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
918
+ "2026-04-02 14:48:59,974 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/config.json \"HTTP/1.1 200 OK\"\n",
919
+ "2026-04-02 14:49:00,110 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/tokenizer_config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
920
+ "2026-04-02 14:49:00,129 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/tokenizer_config.json \"HTTP/1.1 200 OK\"\n",
921
+ "2026-04-02 14:49:00,270 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base/tree/main/additional_chat_templates?recursive=false&expand=false \"HTTP/1.1 404 Not Found\"\n",
922
+ "2026-04-02 14:49:00,406 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base/tree/main?recursive=true&expand=false \"HTTP/1.1 200 OK\"\n",
923
+ "2026-04-02 14:49:02,428 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base \"HTTP/1.1 200 OK\"\n",
924
+ "2026-04-02 14:49:02,594 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/1_Pooling/config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
925
+ "2026-04-02 14:49:02,613 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/1_Pooling%2Fconfig.json \"HTTP/1.1 200 OK\"\n",
926
+ "2026-04-02 14:49:02,757 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base \"HTTP/1.1 200 OK\"\n",
927
+ "2026-04-02 14:49:02,947 - INFO - Encoding 10000 corpus texts ...\n",
928
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:36<00:00, 4.31it/s]\n",
929
+ "2026-04-02 14:49:39,918 - INFO - Encoding queries from 'q1' ...\n",
930
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:02<00:00, 54.14it/s]\n"
931
+ ]
932
+ },
933
+ {
934
+ "name": "stdout",
935
+ "output_type": "stream",
936
+ "text": [
937
+ "\n",
938
+ "=============================================\n",
939
+ " SBERT Evaluation Results\n",
940
+ "=============================================\n",
941
+ " Hit Rate @ 1: 2959/10000 = 29.59%\n",
942
+ " Hit Rate @ 5: 4296/10000 = 42.96%\n",
943
+ " Hit Rate @ 10: 4803/10000 = 48.03%\n",
944
+ " MRR : 0.3597\n",
945
+ "=============================================\n",
946
+ "\n"
947
+ ]
948
+ }
949
+ ],
950
+ "source": [
951
+ "logging.basicConfig(level=logging.INFO, format=\"%(asctime)s - %(levelname)s - %(message)s\")\n",
952
+ "logger = logging.getLogger(__name__)\n",
953
+ "\n",
954
+ "# ── Config ───────────────────────────────────────────────────────────────────\n",
955
+ "PARQUET_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/shamela_q_chunk_00_0_500000.parquet\"\n",
956
+ "MODEL_PATH = \"intfloat/multilingual-e5-base\"\n",
957
+ "BATCH_SIZE = 64\n",
958
+ "TOP_K = (1, 5, 10)\n",
959
+ "SAMPLE_N = 10000 # set e.g. 5000 to run on a subset; None = full file\n",
960
+ "# ─────────────────────────────────────────────────────────────────────────────\n",
961
+ "\n",
962
+ "QUERY_COLS = [\"q1\"]\n",
963
+ "TEXT_COL = \"text\"\n",
964
+ "\n",
965
+ "\n",
966
+ "def evaluate(df: pd.DataFrame, model: SentenceTransformer):\n",
967
+ " texts = df[TEXT_COL].tolist()\n",
968
+ "\n",
969
+ " # Encode corpus\n",
970
+ " logger.info(f\"Encoding {len(texts)} corpus texts ...\")\n",
971
+ " text_embs = model.encode(\n",
972
+ " texts,\n",
973
+ " batch_size=BATCH_SIZE,\n",
974
+ " show_progress_bar=True,\n",
975
+ " convert_to_numpy=True,\n",
976
+ " normalize_embeddings=True,\n",
977
+ " )\n",
978
+ "\n",
979
+ " hit_counts = {k: 0 for k in TOP_K}\n",
980
+ " mrr_scores = []\n",
981
+ " total = 0\n",
982
+ "\n",
983
+ " for col in QUERY_COLS:\n",
984
+ " queries = df[col].tolist()\n",
985
+ " logger.info(f\"Encoding queries from '{col}' ...\")\n",
986
+ "\n",
987
+ " q_embs = model.encode(\n",
988
+ " queries,\n",
989
+ " batch_size=BATCH_SIZE,\n",
990
+ " show_progress_bar=True,\n",
991
+ " convert_to_numpy=True,\n",
992
+ " normalize_embeddings=True,\n",
993
+ " )\n",
994
+ "\n",
995
+ " sims = cosine_similarity(q_embs, text_embs) # (n, n)\n",
996
+ "\n",
997
+ " for i in range(len(texts)):\n",
998
+ " ranked = np.argsort(-sims[i]) # numpy array, descending\n",
999
+ "\n",
1000
+ " # MRR — find where index i appears in ranked\n",
1001
+ " rank_pos = np.where(ranked == i)[0][0] + 1 # 1-based\n",
1002
+ " mrr_scores.append(1.0 / rank_pos)\n",
1003
+ "\n",
1004
+ " # Hit Rate @ K\n",
1005
+ " for k in TOP_K:\n",
1006
+ " if i in ranked[:k]:\n",
1007
+ " hit_counts[k] += 1\n",
1008
+ "\n",
1009
+ " total += 1\n",
1010
+ "\n",
1011
+ " return hit_counts, mrr_scores, total\n",
1012
+ "\n",
1013
+ "\n",
1014
+ "def main():\n",
1015
+ " logger.info(f\"Loading parquet: {PARQUET_PATH}\")\n",
1016
+ " df = pd.read_parquet(PARQUET_PATH, columns=[TEXT_COL] + QUERY_COLS)\n",
1017
+ " df = df.dropna(subset=[TEXT_COL] + QUERY_COLS).reset_index(drop=True)\n",
1018
+ "\n",
1019
+ " if SAMPLE_N and SAMPLE_N < len(df):\n",
1020
+ " df = df.sample(n=SAMPLE_N, random_state=42).reset_index(drop=True)\n",
1021
+ " logger.info(f\"Using random sample of {SAMPLE_N} rows.\")\n",
1022
+ "\n",
1023
+ " logger.info(f\"Dataset size: {len(df)} rows\")\n",
1024
+ "\n",
1025
+ " logger.info(f\"Loading model: {MODEL_PATH}\")\n",
1026
+ " model = SentenceTransformer(MODEL_PATH)\n",
1027
+ "\n",
1028
+ " hit_counts, mrr_scores, total = evaluate(df, model)\n",
1029
+ "\n",
1030
+ " print(\"\\n\" + \"=\" * 45)\n",
1031
+ " print(\" SBERT Evaluation Results\")\n",
1032
+ " print(\"=\" * 45)\n",
1033
+ " for k in TOP_K:\n",
1034
+ " h = hit_counts[k]\n",
1035
+ " print(f\" Hit Rate @ {k:2d}: {h}/{total} = {h/total*100:.2f}%\")\n",
1036
+ " print(f\" MRR : {np.mean(mrr_scores):.4f}\")\n",
1037
+ " print(\"=\" * 45 + \"\\n\")\n",
1038
+ "\n",
1039
+ "main()"
1040
+ ]
1041
+ },
1042
+ {
1043
+ "cell_type": "code",
1044
+ "execution_count": null,
1045
+ "id": "5c8738b8-659c-4a1d-8b90-1c76aaae159e",
1046
+ "metadata": {},
1047
+ "outputs": [],
1048
+ "source": []
1049
+ }
1050
+ ],
1051
+ "metadata": {
1052
+ "kernelspec": {
1053
+ "display_name": "Python 3 (ipykernel)",
1054
+ "language": "python",
1055
+ "name": "python3"
1056
+ },
1057
+ "language_info": {
1058
+ "codemirror_mode": {
1059
+ "name": "ipython",
1060
+ "version": 3
1061
+ },
1062
+ "file_extension": ".py",
1063
+ "mimetype": "text/x-python",
1064
+ "name": "python",
1065
+ "nbconvert_exporter": "python",
1066
+ "pygments_lexer": "ipython3",
1067
+ "version": "3.10.19"
1068
+ }
1069
+ },
1070
+ "nbformat": 4,
1071
+ "nbformat_minor": 5
1072
+ }
sbert_training/fourth_training/Benchmarking_02_04.ipynb ADDED
@@ -0,0 +1,1072 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "5d927cd4-3481-4a09-b152-9e16b2414910",
6
+ "metadata": {},
7
+ "source": [
8
+ "# benchmarking on arcd_SQuAD data and STS on benchmark 17 and finally lahcen data "
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 8,
14
+ "id": "81dff6f6-810b-4176-b744-96b04179f5f2",
15
+ "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "Loaded 1046 triplets from /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/test_arcd_SQuAD_triplets.csv\n"
22
+ ]
23
+ },
24
+ {
25
+ "name": "stderr",
26
+ "output_type": "stream",
27
+ "text": [
28
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 778.24it/s, Materializing param=pooler.dense.weight]\n",
29
+ "\u001b[1mXLMRobertaModel LOAD REPORT\u001b[0m from: intfloat/multilingual-e5-base\n",
30
+ "Key | Status | | \n",
31
+ "------------------------+------------+--+-\n",
32
+ "embeddings.position_ids | UNEXPECTED | | \n",
33
+ "\n",
34
+ "\u001b[3mNotes:\n",
35
+ "- UNEXPECTED\u001b[3m\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n"
36
+ ]
37
+ },
38
+ {
39
+ "name": "stdout",
40
+ "output_type": "stream",
41
+ "text": [
42
+ "\n",
43
+ "Shared corpus size: 572 unique documents\n",
44
+ "\n",
45
+ "Encoding queries ...\n"
46
+ ]
47
+ },
48
+ {
49
+ "name": "stderr",
50
+ "output_type": "stream",
51
+ "text": [
52
+ "Batches: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 17/17 [00:00<00:00, 85.05it/s]\n"
53
+ ]
54
+ },
55
+ {
56
+ "name": "stdout",
57
+ "output_type": "stream",
58
+ "text": [
59
+ "Encoding corpus ...\n"
60
+ ]
61
+ },
62
+ {
63
+ "name": "stderr",
64
+ "output_type": "stream",
65
+ "text": [
66
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:01<00:00, 8.80it/s]\n"
67
+ ]
68
+ },
69
+ {
70
+ "name": "stdout",
71
+ "output_type": "stream",
72
+ "text": [
73
+ "\n",
74
+ "Ranking ...\n",
75
+ "\n",
76
+ "==================================================\n",
77
+ "Model : E5-Base\n",
78
+ "Corpus size : 572 docs\n",
79
+ "Queries : 1046\n",
80
+ "Hit Rate @ 10 : 0.9512 (995/1046)\n",
81
+ "MRR @ 10 : 0.8013\n",
82
+ "==================================================\n",
83
+ "\n",
84
+ "Results saved to e5_base_results.csv\n"
85
+ ]
86
+ }
87
+ ],
88
+ "source": [
89
+ "\"\"\"\n",
90
+ "Semantic Search Evaluation: Hit Rate & MRR\n",
91
+ "Model: E5-Base\n",
92
+ "Corpus: all positives + negatives pooled (realistic retrieval setting)\n",
93
+ "\"\"\"\n",
94
+ "\n",
95
+ "import pandas as pd\n",
96
+ "import numpy as np\n",
97
+ "import torch\n",
98
+ "from sentence_transformers import SentenceTransformer\n",
99
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
100
+ "\n",
101
+ "# ──────────────────────────────────────────────\n",
102
+ "# CONFIG — update paths here\n",
103
+ "# ──────────────────────────────────────────────\n",
104
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/test_arcd_SQuAD_triplets.csv\" \n",
105
+ "MODEL_PATH = 'intfloat/multilingual-e5-base' # or local fine-tuned path\n",
106
+ "\n",
107
+ "ANCHOR_COL = \"anchor\"\n",
108
+ "POSITIVE_COL = \"positive\"\n",
109
+ "NEGATIVE_COL = \"negative\"\n",
110
+ "\n",
111
+ "TOP_K = 10\n",
112
+ "BATCH_SIZE = 64\n",
113
+ "DEVICE = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
114
+ "# ──────────────────────────────────────────────\n",
115
+ "E5_STYLE = True\n",
116
+ "\n",
117
+ "def load_data(csv_path: str) -> pd.DataFrame:\n",
118
+ " df = pd.read_csv(csv_path)\n",
119
+ " missing = {ANCHOR_COL, POSITIVE_COL, NEGATIVE_COL} - set(df.columns)\n",
120
+ " if missing:\n",
121
+ " raise ValueError(f\"CSV is missing columns: {missing}\")\n",
122
+ " print(f\"Loaded {len(df)} triplets from {csv_path}\")\n",
123
+ " return df\n",
124
+ "\n",
125
+ "\n",
126
+ "def encode(model: SentenceTransformer, texts: list, prefix: str = \"\") -> np.ndarray:\n",
127
+ " if prefix:\n",
128
+ " texts = [prefix + t for t in texts]\n",
129
+ " return model.encode(\n",
130
+ " texts,\n",
131
+ " batch_size=BATCH_SIZE,\n",
132
+ " show_progress_bar=True,\n",
133
+ " convert_to_numpy=True,\n",
134
+ " normalize_embeddings=True,\n",
135
+ " device=DEVICE,\n",
136
+ " )\n",
137
+ "\n",
138
+ "\n",
139
+ "def evaluate(model: SentenceTransformer, df: pd.DataFrame) -> dict:\n",
140
+ " queries = df[ANCHOR_COL].tolist()\n",
141
+ " positives = df[POSITIVE_COL].tolist()\n",
142
+ " negatives = df[NEGATIVE_COL].tolist()\n",
143
+ "\n",
144
+ " # ── Build shared corpus ───────────────────\n",
145
+ " # Deduplicate so the same doc isn't indexed twice\n",
146
+ " all_docs = list(set(positives + negatives))\n",
147
+ " doc_index = {doc: i for i, doc in enumerate(all_docs)}\n",
148
+ " corpus_size = len(all_docs)\n",
149
+ " print(f\"\\nShared corpus size: {corpus_size} unique documents\")\n",
150
+ "\n",
151
+ " # ── Encode everything ─────────────────────\n",
152
+ " print(\"\\nEncoding queries ...\")\n",
153
+ " q_embs = encode(model, queries, prefix=\"query: \")\n",
154
+ "\n",
155
+ " print(\"Encoding corpus ...\")\n",
156
+ " doc_embs = encode(model, all_docs, prefix=\"passage: \") # (corpus_size, dim)\n",
157
+ "\n",
158
+ " # ── Rank & score ──────────────────────────\n",
159
+ " hits, reciprocal_ranks = 0, []\n",
160
+ "\n",
161
+ " print(\"\\nRanking ...\")\n",
162
+ " for i in range(len(df)):\n",
163
+ " q = q_embs[i].reshape(1, -1)\n",
164
+ " scores = cosine_similarity(q, doc_embs)[0] # (corpus_size,)\n",
165
+ " ranked = np.argsort(-scores) # sorted doc indices\n",
166
+ "\n",
167
+ " pos_idx = doc_index[positives[i]]\n",
168
+ " positive_rank = int(np.where(ranked == pos_idx)[0][0]) + 1 # 1-based\n",
169
+ "\n",
170
+ " if positive_rank <= TOP_K:\n",
171
+ " hits += 1\n",
172
+ " reciprocal_ranks.append(1.0 / positive_rank)\n",
173
+ " else:\n",
174
+ " reciprocal_ranks.append(0.0)\n",
175
+ "\n",
176
+ " n = len(df)\n",
177
+ " hit_rate = hits / n\n",
178
+ " mrr = float(np.mean(reciprocal_ranks))\n",
179
+ "\n",
180
+ " print(f\"\\n{'='*50}\")\n",
181
+ " print(f\"Model : E5-Base\")\n",
182
+ " print(f\"Corpus size : {corpus_size} docs\")\n",
183
+ " print(f\"Queries : {n}\")\n",
184
+ " print(f\"Hit Rate @ {TOP_K} : {hit_rate:.4f} ({hits}/{n})\")\n",
185
+ " print(f\"MRR @ {TOP_K} : {mrr:.4f}\")\n",
186
+ " print(f\"{'='*50}\")\n",
187
+ "\n",
188
+ " return {\n",
189
+ " \"model\": \"E5-Base\",\n",
190
+ " \"corpus_size\": corpus_size,\n",
191
+ " f\"hit_rate@{TOP_K}\": round(hit_rate, 4),\n",
192
+ " f\"mrr@{TOP_K}\": round(mrr, 4),\n",
193
+ " \"n\": n,\n",
194
+ " }\n",
195
+ "\n",
196
+ "\n",
197
+ "def main():\n",
198
+ " df = load_data(CSV_PATH)\n",
199
+ " model = SentenceTransformer(MODEL_PATH, device=DEVICE)\n",
200
+ " res = evaluate(model, df)\n",
201
+ "\n",
202
+ " out = pd.DataFrame([res])\n",
203
+ " out.to_csv(\"e5_base_results.csv\", index=False)\n",
204
+ " print(\"\\nResults saved to e5_base_results.csv\")\n",
205
+ "\n",
206
+ "\n",
207
+ "if __name__ == \"__main__\":\n",
208
+ " main()"
209
+ ]
210
+ },
211
+ {
212
+ "cell_type": "code",
213
+ "execution_count": 9,
214
+ "id": "11529e91-fe4e-40b7-9f79-00b663f2f2ba",
215
+ "metadata": {},
216
+ "outputs": [
217
+ {
218
+ "name": "stdout",
219
+ "output_type": "stream",
220
+ "text": [
221
+ "Loaded 1046 triplets from /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/pre_test_arcd_SQuAD_triplets.csv\n"
222
+ ]
223
+ },
224
+ {
225
+ "name": "stderr",
226
+ "output_type": "stream",
227
+ "text": [
228
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 906.79it/s, Materializing param=pooler.dense.weight]\n"
229
+ ]
230
+ },
231
+ {
232
+ "name": "stdout",
233
+ "output_type": "stream",
234
+ "text": [
235
+ "\n",
236
+ "Shared corpus size: 572 unique documents\n",
237
+ "\n",
238
+ "Encoding queries ...\n"
239
+ ]
240
+ },
241
+ {
242
+ "name": "stderr",
243
+ "output_type": "stream",
244
+ "text": [
245
+ "Batches: 100%|██████████████████████████████████████████████████████████████���██████████████████████████████████████████████████████████████████| 17/17 [00:00<00:00, 98.66it/s]\n"
246
+ ]
247
+ },
248
+ {
249
+ "name": "stdout",
250
+ "output_type": "stream",
251
+ "text": [
252
+ "Encoding corpus ...\n"
253
+ ]
254
+ },
255
+ {
256
+ "name": "stderr",
257
+ "output_type": "stream",
258
+ "text": [
259
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 10.93it/s]\n"
260
+ ]
261
+ },
262
+ {
263
+ "name": "stdout",
264
+ "output_type": "stream",
265
+ "text": [
266
+ "\n",
267
+ "Ranking ...\n",
268
+ "\n",
269
+ "==================================================\n",
270
+ "Model : ArabVert02 (fine-tuned)\n",
271
+ "Corpus size : 572 docs\n",
272
+ "Queries : 1046\n",
273
+ "Hit Rate @ 10 : 0.9522 (996/1046)\n",
274
+ "MRR @ 10 : 0.7896\n",
275
+ "==================================================\n",
276
+ "\n",
277
+ "Results saved to arabvert02_results.csv\n"
278
+ ]
279
+ }
280
+ ],
281
+ "source": [
282
+ "\"\"\"\n",
283
+ "Semantic Search Evaluation: Hit Rate & MRR\n",
284
+ "Model: Fine-tuned ArabVert02\n",
285
+ "Corpus: all positives + negatives pooled (realistic retrieval setting)\n",
286
+ "\"\"\"\n",
287
+ "\n",
288
+ "import pandas as pd\n",
289
+ "import numpy as np\n",
290
+ "import torch\n",
291
+ "from sentence_transformers import SentenceTransformer\n",
292
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
293
+ "\n",
294
+ "# ──────────────────────────────────────────────\n",
295
+ "# CONFIG — update paths here\n",
296
+ "# ──────────────────────────────────────────────\n",
297
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/data/pre_test_arcd_SQuAD_triplets.csv\" \n",
298
+ "MODEL_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\" # local path or HF model ID\n",
299
+ "\n",
300
+ "ANCHOR_COL = \"anchor\"\n",
301
+ "POSITIVE_COL = \"positive\"\n",
302
+ "NEGATIVE_COL = \"negative\"\n",
303
+ "\n",
304
+ "TOP_K = 10\n",
305
+ "BATCH_SIZE = 64\n",
306
+ "DEVICE = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
307
+ "E5_STYLE = False # set True if your arabvert variant uses query:/passage: prefixes\n",
308
+ "# ──────────────────────────────────────────────\n",
309
+ "\n",
310
+ "\n",
311
+ "def load_data(csv_path: str) -> pd.DataFrame:\n",
312
+ " df = pd.read_csv(csv_path)\n",
313
+ " missing = {ANCHOR_COL, POSITIVE_COL, NEGATIVE_COL} - set(df.columns)\n",
314
+ " if missing:\n",
315
+ " raise ValueError(f\"CSV is missing columns: {missing}\")\n",
316
+ " print(f\"Loaded {len(df)} triplets from {csv_path}\")\n",
317
+ " return df\n",
318
+ "\n",
319
+ "\n",
320
+ "def encode(model: SentenceTransformer, texts: list, prefix: str = \"\") -> np.ndarray:\n",
321
+ " if prefix:\n",
322
+ " texts = [prefix + t for t in texts]\n",
323
+ " return model.encode(\n",
324
+ " texts,\n",
325
+ " batch_size=BATCH_SIZE,\n",
326
+ " show_progress_bar=True,\n",
327
+ " convert_to_numpy=True,\n",
328
+ " normalize_embeddings=True,\n",
329
+ " device=DEVICE,\n",
330
+ " )\n",
331
+ "\n",
332
+ "\n",
333
+ "def evaluate(model: SentenceTransformer, df: pd.DataFrame) -> dict:\n",
334
+ " queries = df[ANCHOR_COL].tolist()\n",
335
+ " positives = df[POSITIVE_COL].tolist()\n",
336
+ " negatives = df[NEGATIVE_COL].tolist()\n",
337
+ "\n",
338
+ " query_prefix = \"query: \" if E5_STYLE else \"\"\n",
339
+ " passage_prefix = \"passage: \" if E5_STYLE else \"\"\n",
340
+ "\n",
341
+ " # ── Build shared corpus ───────────────────\n",
342
+ " # Deduplicate so the same doc isn't indexed twice\n",
343
+ " all_docs = list(set(positives + negatives))\n",
344
+ " doc_index = {doc: i for i, doc in enumerate(all_docs)}\n",
345
+ " corpus_size = len(all_docs)\n",
346
+ " print(f\"\\nShared corpus size: {corpus_size} unique documents\")\n",
347
+ "\n",
348
+ " # ── Encode everything ─────────────────────\n",
349
+ " print(\"\\nEncoding queries ...\")\n",
350
+ " q_embs = encode(model, queries, prefix=query_prefix)\n",
351
+ "\n",
352
+ " print(\"Encoding corpus ...\")\n",
353
+ " doc_embs = encode(model, all_docs, prefix=passage_prefix) # (corpus_size, dim)\n",
354
+ "\n",
355
+ " # ── Rank & score ──────────────────────────\n",
356
+ " hits, reciprocal_ranks = 0, []\n",
357
+ "\n",
358
+ " print(\"\\nRanking ...\")\n",
359
+ " for i in range(len(df)):\n",
360
+ " q = q_embs[i].reshape(1, -1)\n",
361
+ " scores = cosine_similarity(q, doc_embs)[0] # (corpus_size,)\n",
362
+ " ranked = np.argsort(-scores) # sorted doc indices\n",
363
+ "\n",
364
+ " pos_idx = doc_index[positives[i]]\n",
365
+ " positive_rank = int(np.where(ranked == pos_idx)[0][0]) + 1 # 1-based\n",
366
+ "\n",
367
+ " if positive_rank <= TOP_K:\n",
368
+ " hits += 1\n",
369
+ " reciprocal_ranks.append(1.0 / positive_rank)\n",
370
+ " else:\n",
371
+ " reciprocal_ranks.append(0.0)\n",
372
+ "\n",
373
+ " n = len(df)\n",
374
+ " hit_rate = hits / n\n",
375
+ " mrr = float(np.mean(reciprocal_ranks))\n",
376
+ "\n",
377
+ " print(f\"\\n{'='*50}\")\n",
378
+ " print(f\"Model : ArabVert02 (fine-tuned)\")\n",
379
+ " print(f\"Corpus size : {corpus_size} docs\")\n",
380
+ " print(f\"Queries : {n}\")\n",
381
+ " print(f\"Hit Rate @ {TOP_K} : {hit_rate:.4f} ({hits}/{n})\")\n",
382
+ " print(f\"MRR @ {TOP_K} : {mrr:.4f}\")\n",
383
+ " print(f\"{'='*50}\")\n",
384
+ "\n",
385
+ " return {\n",
386
+ " \"model\": \"ArabVert02 (fine-tuned)\",\n",
387
+ " \"corpus_size\": corpus_size,\n",
388
+ " f\"hit_rate@{TOP_K}\": round(hit_rate, 4),\n",
389
+ " f\"mrr@{TOP_K}\": round(mrr, 4),\n",
390
+ " \"n\": n,\n",
391
+ " }\n",
392
+ "\n",
393
+ "\n",
394
+ "def main():\n",
395
+ " df = load_data(CSV_PATH)\n",
396
+ " model = SentenceTransformer(MODEL_PATH, device=DEVICE)\n",
397
+ " res = evaluate(model, df)\n",
398
+ "\n",
399
+ " out = pd.DataFrame([res])\n",
400
+ " out.to_csv(\"arabvert02_results.csv\", index=False)\n",
401
+ " print(\"\\nResults saved to arabvert02_results.csv\")\n",
402
+ "\n",
403
+ "\n",
404
+ "if __name__ == \"__main__\":\n",
405
+ " main()"
406
+ ]
407
+ },
408
+ {
409
+ "cell_type": "markdown",
410
+ "id": "88210c5d-bdbf-4650-bd70-74772d948aa6",
411
+ "metadata": {},
412
+ "source": [
413
+ "# sts "
414
+ ]
415
+ },
416
+ {
417
+ "cell_type": "code",
418
+ "execution_count": 10,
419
+ "id": "1659e63a-c3ef-4b16-9aea-bf0fe060a44b",
420
+ "metadata": {},
421
+ "outputs": [
422
+ {
423
+ "name": "stdout",
424
+ "output_type": "stream",
425
+ "text": [
426
+ "Loading CSV...\n",
427
+ " 250 pairs loaded.\n",
428
+ " sentence1 \\\n",
429
+ "0 شخص ما يحمل لوح التزلج ليلا على الرصيف . \n",
430
+ "1 تتسابق النساء في سباق الدايتونا 500 . \n",
431
+ "2 تمشي النساء جنبا إلى جنب . \n",
432
+ "3 يقفز الرجل ذو القميص الأخضر عاليا على العشب . \n",
433
+ "4 رجلان يجلسان على العشب ومعهما موز . \n",
434
+ "\n",
435
+ " sentence2 score \n",
436
+ "0 رجل جالس بمفرده يقرأ على طاولة مستديرة ، خارج ... 0.8 \n",
437
+ "1 يتسابق بعض الرجال ضمن مسابقة التزلج . 1.0 \n",
438
+ "2 هناك فتيات يمشين متجاورات 2.6 \n",
439
+ "3 يمشي الرجل ذو القميص الأبيض على العشب الطويل م... 2.2 \n",
440
+ "4 ثلاثة رجال يتسكعون عند فرشة بيع الفاكهة . 1.4 \n",
441
+ "\n",
442
+ "Loading SBERT model and encoding sentences...\n"
443
+ ]
444
+ },
445
+ {
446
+ "name": "stderr",
447
+ "output_type": "stream",
448
+ "text": [
449
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 805.46it/s, Materializing param=pooler.dense.weight]\n",
450
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 148.44it/s]\n",
451
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 165.65it/s]\n"
452
+ ]
453
+ },
454
+ {
455
+ "name": "stdout",
456
+ "output_type": "stream",
457
+ "text": [
458
+ "\n",
459
+ "Computing cosine similarities...\n",
460
+ "\n",
461
+ "─── STS Correlation Results ───────────────────────────────\n",
462
+ " Pearson r : 0.8178 (p=1.9527e-61)\n",
463
+ " Spearman r : 0.8182 (p=1.5160e-61)\n",
464
+ "\n",
465
+ "─── Hit Rate & MRR ────────────────────────────────────────\n",
466
+ " (Relevance threshold on gold score: >= 0.5)\n",
467
+ " Hit Rate @ 1 : 0.5853 (127/217)\n",
468
+ " Hit Rate @ 3 : 0.7281 (158/217)\n",
469
+ " Hit Rate @ 5 : 0.7742 (168/217)\n",
470
+ " MRR : 0.6735\n",
471
+ "\n",
472
+ "Results saved to: /home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15_preprocessed_arabertv02_benchmark_results.csv\n"
473
+ ]
474
+ }
475
+ ],
476
+ "source": [
477
+ "import pandas as pd\n",
478
+ "import numpy as np\n",
479
+ "from sentence_transformers import SentenceTransformer\n",
480
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
481
+ "from scipy.stats import pearsonr, spearmanr\n",
482
+ "\n",
483
+ "# ─── CONFIG ───────────────────────────────────────────────────────────────────\n",
484
+ "\n",
485
+ "MODEL_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\" \n",
486
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15_preprocessed_arabertv02.csv\"\n",
487
+ "TOP_K = [1, 3, 5]\n",
488
+ "SCORE_THRESHOLD = 0.5 # adjust if your score scale is not [0,1]\n",
489
+ "# ──────────────────────────────────────────────────────────────────────────────\n",
490
+ "\n",
491
+ "# 1. Load CSV\n",
492
+ "print(\"Loading CSV...\")\n",
493
+ "df = pd.read_csv(CSV_PATH)\n",
494
+ "if 'lang' in df.columns:\n",
495
+ " df = df.drop(columns=['lang'])\n",
496
+ "\n",
497
+ "print(f\" {len(df)} pairs loaded.\")\n",
498
+ "print(df.head())\n",
499
+ "\n",
500
+ "# 2. Encode\n",
501
+ "print(\"\\nLoading SBERT model and encoding sentences...\")\n",
502
+ "model = SentenceTransformer(MODEL_PATH)\n",
503
+ "emb1 = model.encode(df['sentence1'].tolist(), batch_size=32, show_progress_bar=True, convert_to_numpy=True)\n",
504
+ "emb2 = model.encode(df['sentence2'].tolist(), batch_size=32, show_progress_bar=True, convert_to_numpy=True)\n",
505
+ "\n",
506
+ "# 3. Cosine similarity per pair\n",
507
+ "print(\"\\nComputing cosine similarities...\")\n",
508
+ "cos_scores = np.array([\n",
509
+ " cosine_similarity(emb1[i].reshape(1, -1), emb2[i].reshape(1, -1))[0][0]\n",
510
+ " for i in range(len(df))\n",
511
+ "])\n",
512
+ "\n",
513
+ "# 4. Pearson & Spearman\n",
514
+ "gold_scores = df['score'].astype(float).values\n",
515
+ "pearson_corr, p_val_p = pearsonr(cos_scores, gold_scores)\n",
516
+ "spearman_corr, p_val_s = spearmanr(cos_scores, gold_scores)\n",
517
+ "\n",
518
+ "print(\"\\n─── STS Correlation Results ───────────────────────────────\")\n",
519
+ "print(f\" Pearson r : {pearson_corr:.4f} (p={p_val_p:.4e})\")\n",
520
+ "print(f\" Spearman r : {spearman_corr:.4f} (p={p_val_s:.4e})\")\n",
521
+ "\n",
522
+ "# 5. Hit Rate & MRR\n",
523
+ "print(\"\\n─── Hit Rate & MRR ────────────────────────────────────────\")\n",
524
+ "print(f\" (Relevance threshold on gold score: >= {SCORE_THRESHOLD})\")\n",
525
+ "\n",
526
+ "hit_counts = {k: 0 for k in TOP_K}\n",
527
+ "reciprocal_ranks = []\n",
528
+ "n_queries = 0\n",
529
+ "\n",
530
+ "for i in range(len(df)):\n",
531
+ " if gold_scores[i] < SCORE_THRESHOLD:\n",
532
+ " continue\n",
533
+ "\n",
534
+ " query_emb = emb1[i].reshape(1, -1)\n",
535
+ " sims = cosine_similarity(query_emb, emb2)[0]\n",
536
+ " ranked_idxs = np.argsort(sims)[::-1]\n",
537
+ "\n",
538
+ " rank = np.where(ranked_idxs == i)[0][0] + 1 # 1-based\n",
539
+ "\n",
540
+ " for k in TOP_K:\n",
541
+ " if rank <= k:\n",
542
+ " hit_counts[k] += 1\n",
543
+ "\n",
544
+ " reciprocal_ranks.append(1.0 / rank)\n",
545
+ " n_queries += 1\n",
546
+ "\n",
547
+ "if n_queries == 0:\n",
548
+ " print(\" No relevant pairs found — lower SCORE_THRESHOLD.\")\n",
549
+ "else:\n",
550
+ " for k in TOP_K:\n",
551
+ " hr = hit_counts[k] / n_queries\n",
552
+ " print(f\" Hit Rate @{k:2d} : {hr:.4f} ({hit_counts[k]}/{n_queries})\")\n",
553
+ "\n",
554
+ " mrr = np.mean(reciprocal_ranks)\n",
555
+ " print(f\" MRR : {mrr:.4f}\")\n",
556
+ "\n",
557
+ "# 6. Save results\n",
558
+ "df['predicted_cos_sim'] = cos_scores\n",
559
+ "output_path = CSV_PATH.replace('.csv', '_benchmark_results.csv')\n",
560
+ "df.to_csv(output_path, index=False)\n",
561
+ "print(f\"\\nResults saved to: {output_path}\")"
562
+ ]
563
+ },
564
+ {
565
+ "cell_type": "code",
566
+ "execution_count": 11,
567
+ "id": "fdb3d5d1-be16-4ad6-a5ed-b7be866cabbf",
568
+ "metadata": {},
569
+ "outputs": [
570
+ {
571
+ "name": "stdout",
572
+ "output_type": "stream",
573
+ "text": [
574
+ "Loading CSV...\n",
575
+ " 250 pairs loaded.\n",
576
+ " sentence1 \\\n",
577
+ "0 شخص ما يحمل لوح التزلج ليلا على الرصيف. \n",
578
+ "1 تتسابق النساء في سباق الدايتونا 500. \n",
579
+ "2 تمشي النساء جنبا إلى جنب. \n",
580
+ "3 يقفز الرجل ذو القميص الأخضر عاليا على العشب. \n",
581
+ "4 رجلان يجلسان على العشب ومعهما موز. \n",
582
+ "\n",
583
+ " sentence2 score \n",
584
+ "0 رجل جالس بمفرده يقرأ على طاولة مستديرة ، خارج ... 0.8 \n",
585
+ "1 يتسابق بعض الرجال ضمن مسابقة التزلج. 1.0 \n",
586
+ "2 هناك فتيات يمشين متجاورات 2.6 \n",
587
+ "3 يمشي الرجل ذو القميص الأبيض على العشب الطويل م... 2.2 \n",
588
+ "4 ثلاثة رجال يتسكعون عند فرشة بيع الفاكهة. 1.4 \n",
589
+ "\n",
590
+ "Loading multilingual-e5-base and encoding sentences...\n"
591
+ ]
592
+ },
593
+ {
594
+ "name": "stderr",
595
+ "output_type": "stream",
596
+ "text": [
597
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 925.58it/s, Materializing param=pooler.dense.weight]\n",
598
+ "\u001b[1mXLMRobertaModel LOAD REPORT\u001b[0m from: intfloat/multilingual-e5-base\n",
599
+ "Key | Status | | \n",
600
+ "------------------------+------------+--+-\n",
601
+ "embeddings.position_ids | UNEXPECTED | | \n",
602
+ "\n",
603
+ "\u001b[3mNotes:\n",
604
+ "- UNEXPECTED\u001b[3m\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n",
605
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 126.89it/s]\n",
606
+ "Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 126.29it/s]\n"
607
+ ]
608
+ },
609
+ {
610
+ "name": "stdout",
611
+ "output_type": "stream",
612
+ "text": [
613
+ "\n",
614
+ "Computing cosine similarities...\n",
615
+ "\n",
616
+ "─── STS Correlation Results ───────────────────────────────\n",
617
+ " Pearson r : 0.7446 (p=1.9457e-45)\n",
618
+ " Spearman r : 0.7450 (p=1.6963e-45)\n",
619
+ "\n",
620
+ "─── Hit Rate & MRR ────────────────────────────────────────\n",
621
+ " (Relevance threshold on gold score: >= 0.5)\n",
622
+ " Hit Rate @ 1 : 0.5991 (130/217)\n",
623
+ " Hit Rate @ 3 : 0.7327 (159/217)\n",
624
+ " Hit Rate @ 5 : 0.7696 (167/217)\n",
625
+ " MRR : 0.6794\n",
626
+ "\n",
627
+ "Results saved to: /home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15_e5_benchmark_results.csv\n"
628
+ ]
629
+ }
630
+ ],
631
+ "source": [
632
+ "import pandas as pd\n",
633
+ "import numpy as np\n",
634
+ "from sentence_transformers import SentenceTransformer\n",
635
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
636
+ "from scipy.stats import pearsonr, spearmanr\n",
637
+ "\n",
638
+ "# ─── CONFIG ───────────────────────────────────────────────────────────────────\n",
639
+ "MODEL_NAME = \"intfloat/multilingual-e5-base\"\n",
640
+ "CSV_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/third_training/benchmark/benchmark15.csv\"\n",
641
+ "TOP_K = [1, 3, 5]\n",
642
+ "SCORE_THRESHOLD = 0.5 # adjust to your score scale\n",
643
+ "PREFIX = \"query: \" # symmetric STS — same prefix for both sides\n",
644
+ "# ──────────────────────────────────────────────────────────────────────────────\n",
645
+ "\n",
646
+ "# 1. Load CSV\n",
647
+ "print(\"Loading CSV...\")\n",
648
+ "df = pd.read_csv(CSV_PATH)\n",
649
+ "if 'lang' in df.columns:\n",
650
+ " df = df.drop(columns=['lang'])\n",
651
+ "\n",
652
+ "print(f\" {len(df)} pairs loaded.\")\n",
653
+ "print(df.head())\n",
654
+ "\n",
655
+ "# 2. Apply E5 prefix\n",
656
+ "sentences1 = [PREFIX + str(s) for s in df['sentence1'].tolist()]\n",
657
+ "sentences2 = [PREFIX + str(s) for s in df['sentence2'].tolist()]\n",
658
+ "\n",
659
+ "# 3. Encode\n",
660
+ "print(\"\\nLoading multilingual-e5-base and encoding sentences...\")\n",
661
+ "model = SentenceTransformer(MODEL_NAME)\n",
662
+ "emb1 = model.encode(sentences1, batch_size=32, show_progress_bar=True, normalize_embeddings=True, convert_to_numpy=True)\n",
663
+ "emb2 = model.encode(sentences2, batch_size=32, show_progress_bar=True, normalize_embeddings=True, convert_to_numpy=True)\n",
664
+ "\n",
665
+ "# 4. Cosine similarity per pair\n",
666
+ "# Note: since embeddings are L2-normalized, cosine sim == dot product\n",
667
+ "print(\"\\nComputing cosine similarities...\")\n",
668
+ "cos_scores = np.array([\n",
669
+ " cosine_similarity(emb1[i].reshape(1, -1), emb2[i].reshape(1, -1))[0][0]\n",
670
+ " for i in range(len(df))\n",
671
+ "])\n",
672
+ "\n",
673
+ "# 5. Pearson & Spearman\n",
674
+ "gold_scores = df['score'].astype(float).values\n",
675
+ "pearson_corr, p_val_p = pearsonr(cos_scores, gold_scores)\n",
676
+ "spearman_corr, p_val_s = spearmanr(cos_scores, gold_scores)\n",
677
+ "\n",
678
+ "print(\"\\n─── STS Correlation Results ───────────────────────────────\")\n",
679
+ "print(f\" Pearson r : {pearson_corr:.4f} (p={p_val_p:.4e})\")\n",
680
+ "print(f\" Spearman r : {spearman_corr:.4f} (p={p_val_s:.4e})\")\n",
681
+ "\n",
682
+ "# 6. Hit Rate & MRR\n",
683
+ "print(\"\\n─── Hit Rate & MRR ────────────────────────────────────────\")\n",
684
+ "print(f\" (Relevance threshold on gold score: >= {SCORE_THRESHOLD})\")\n",
685
+ "\n",
686
+ "hit_counts = {k: 0 for k in TOP_K}\n",
687
+ "reciprocal_ranks = []\n",
688
+ "n_queries = 0\n",
689
+ "\n",
690
+ "for i in range(len(df)):\n",
691
+ " if gold_scores[i] < SCORE_THRESHOLD:\n",
692
+ " continue\n",
693
+ "\n",
694
+ " query_emb = emb1[i].reshape(1, -1)\n",
695
+ " sims = cosine_similarity(query_emb, emb2)[0]\n",
696
+ " ranked_idxs = np.argsort(sims)[::-1]\n",
697
+ "\n",
698
+ " rank = np.where(ranked_idxs == i)[0][0] + 1 # 1-based\n",
699
+ "\n",
700
+ " for k in TOP_K:\n",
701
+ " if rank <= k:\n",
702
+ " hit_counts[k] += 1\n",
703
+ "\n",
704
+ " reciprocal_ranks.append(1.0 / rank)\n",
705
+ " n_queries += 1\n",
706
+ "\n",
707
+ "if n_queries == 0:\n",
708
+ " print(\" No relevant pairs found — lower SCORE_THRESHOLD.\")\n",
709
+ "else:\n",
710
+ " for k in TOP_K:\n",
711
+ " hr = hit_counts[k] / n_queries\n",
712
+ " print(f\" Hit Rate @{k:2d} : {hr:.4f} ({hit_counts[k]}/{n_queries})\")\n",
713
+ "\n",
714
+ " mrr = np.mean(reciprocal_ranks)\n",
715
+ " print(f\" MRR : {mrr:.4f}\")\n",
716
+ "\n",
717
+ "# 7. Save results\n",
718
+ "df['predicted_cos_sim'] = cos_scores\n",
719
+ "output_path = CSV_PATH.replace('.csv', '_e5_benchmark_results.csv')\n",
720
+ "df.to_csv(output_path, index=False)\n",
721
+ "print(f\"\\nResults saved to: {output_path}\")"
722
+ ]
723
+ },
724
+ {
725
+ "cell_type": "markdown",
726
+ "id": "50861e84-dc7b-4a8e-9ad1-3da5f8307718",
727
+ "metadata": {},
728
+ "source": [
729
+ "# hsn data "
730
+ ]
731
+ },
732
+ {
733
+ "cell_type": "code",
734
+ "execution_count": 12,
735
+ "id": "039cb79b-df7f-47de-9025-fc60d7464d05",
736
+ "metadata": {},
737
+ "outputs": [],
738
+ "source": [
739
+ "import pandas as pd\n",
740
+ "import numpy as np\n",
741
+ "from sentence_transformers import SentenceTransformer\n",
742
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
743
+ "import logging\n",
744
+ "from pathlib import Path\n",
745
+ "import torch"
746
+ ]
747
+ },
748
+ {
749
+ "cell_type": "code",
750
+ "execution_count": 17,
751
+ "id": "dfcd6f83-12de-4080-9c91-7da95633c393",
752
+ "metadata": {},
753
+ "outputs": [
754
+ {
755
+ "name": "stderr",
756
+ "output_type": "stream",
757
+ "text": [
758
+ "2026-04-02 14:48:18,062 - INFO - Loading parquet: /home/skiredj.abderrahman/khalil/sbert_training/shamela_cleaned.parquet\n",
759
+ "2026-04-02 14:48:23,486 - INFO - Using random sample of 10000 rows.\n",
760
+ "2026-04-02 14:48:23,487 - INFO - Dataset size: 10000 rows\n",
761
+ "2026-04-02 14:48:23,488 - INFO - Loading model: /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\n",
762
+ "2026-04-02 14:48:23,495 - INFO - Use pytorch device_name: cuda:0\n",
763
+ "2026-04-02 14:48:23,496 - INFO - Load pretrained SentenceTransformer: /home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\n",
764
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 855.39it/s, Materializing param=pooler.dense.weight]\n",
765
+ "2026-04-02 14:48:23,998 - INFO - Encoding 10000 corpus texts ...\n",
766
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:26<00:00, 5.92it/s]\n",
767
+ "2026-04-02 14:48:50,970 - INFO - Encoding queries from 'q1' ...\n",
768
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:02<00:00, 76.59it/s]\n"
769
+ ]
770
+ },
771
+ {
772
+ "name": "stdout",
773
+ "output_type": "stream",
774
+ "text": [
775
+ "\n",
776
+ "=============================================\n",
777
+ " SBERT Evaluation Results\n",
778
+ "=============================================\n",
779
+ " Hit Rate @ 1: 2885/10000 = 28.85%\n",
780
+ " Hit Rate @ 5: 4709/10000 = 47.09%\n",
781
+ " Hit Rate @ 10: 5548/10000 = 55.48%\n",
782
+ " MRR : 0.3789\n",
783
+ "=============================================\n",
784
+ "\n"
785
+ ]
786
+ }
787
+ ],
788
+ "source": [
789
+ "logging.basicConfig(level=logging.INFO, format=\"%(asctime)s - %(levelname)s - %(message)s\")\n",
790
+ "logger = logging.getLogger(__name__)\n",
791
+ "\n",
792
+ "# ── Config ───────────────────────────────────────────────────────────────────\n",
793
+ "PARQUET_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/shamela_cleaned.parquet\"\n",
794
+ "MODEL_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/fourth_training/output/arabert_arcd_squad_20260402_0108/final\" \n",
795
+ "BATCH_SIZE = 64\n",
796
+ "TOP_K = (1, 5, 10)\n",
797
+ "SAMPLE_N = 10000 # set e.g. 5000 to run on a subset; None = full file\n",
798
+ "# ─────────────────────────────────────────────────────────────────────────────\n",
799
+ "\n",
800
+ "QUERY_COLS = [\"q1\"]\n",
801
+ "TEXT_COL = \"text\"\n",
802
+ "\n",
803
+ "\n",
804
+ "def evaluate(df: pd.DataFrame, model: SentenceTransformer):\n",
805
+ " texts = df[TEXT_COL].tolist()\n",
806
+ "\n",
807
+ " # Encode corpus\n",
808
+ " logger.info(f\"Encoding {len(texts)} corpus texts ...\")\n",
809
+ " text_embs = model.encode(\n",
810
+ " texts,\n",
811
+ " batch_size=BATCH_SIZE,\n",
812
+ " show_progress_bar=True,\n",
813
+ " convert_to_numpy=True,\n",
814
+ " normalize_embeddings=True,\n",
815
+ " )\n",
816
+ "\n",
817
+ " hit_counts = {k: 0 for k in TOP_K}\n",
818
+ " mrr_scores = []\n",
819
+ " total = 0\n",
820
+ "\n",
821
+ " for col in QUERY_COLS:\n",
822
+ " queries = df[col].tolist()\n",
823
+ " logger.info(f\"Encoding queries from '{col}' ...\")\n",
824
+ "\n",
825
+ " q_embs = model.encode(\n",
826
+ " queries,\n",
827
+ " batch_size=BATCH_SIZE,\n",
828
+ " show_progress_bar=True,\n",
829
+ " convert_to_numpy=True,\n",
830
+ " normalize_embeddings=True,\n",
831
+ " )\n",
832
+ "\n",
833
+ " sims = cosine_similarity(q_embs, text_embs) # (n, n)\n",
834
+ "\n",
835
+ " for i in range(len(texts)):\n",
836
+ " ranked = np.argsort(-sims[i]) # numpy array, descending\n",
837
+ "\n",
838
+ " # MRR — find where index i appears in ranked\n",
839
+ " rank_pos = np.where(ranked == i)[0][0] + 1 # 1-based\n",
840
+ " mrr_scores.append(1.0 / rank_pos)\n",
841
+ "\n",
842
+ " # Hit Rate @ K\n",
843
+ " for k in TOP_K:\n",
844
+ " if i in ranked[:k]:\n",
845
+ " hit_counts[k] += 1\n",
846
+ "\n",
847
+ " total += 1\n",
848
+ "\n",
849
+ " return hit_counts, mrr_scores, total\n",
850
+ "\n",
851
+ "\n",
852
+ "def main():\n",
853
+ " logger.info(f\"Loading parquet: {PARQUET_PATH}\")\n",
854
+ " df = pd.read_parquet(PARQUET_PATH, columns=[TEXT_COL] + QUERY_COLS)\n",
855
+ " df = df.dropna(subset=[TEXT_COL] + QUERY_COLS).reset_index(drop=True)\n",
856
+ "\n",
857
+ " if SAMPLE_N and SAMPLE_N < len(df):\n",
858
+ " df = df.sample(n=SAMPLE_N, random_state=42).reset_index(drop=True)\n",
859
+ " logger.info(f\"Using random sample of {SAMPLE_N} rows.\")\n",
860
+ "\n",
861
+ " logger.info(f\"Dataset size: {len(df)} rows\")\n",
862
+ "\n",
863
+ " logger.info(f\"Loading model: {MODEL_PATH}\")\n",
864
+ " model = SentenceTransformer(MODEL_PATH)\n",
865
+ "\n",
866
+ " hit_counts, mrr_scores, total = evaluate(df, model)\n",
867
+ "\n",
868
+ " print(\"\\n\" + \"=\" * 45)\n",
869
+ " print(\" SBERT Evaluation Results\")\n",
870
+ " print(\"=\" * 45)\n",
871
+ " for k in TOP_K:\n",
872
+ " h = hit_counts[k]\n",
873
+ " print(f\" Hit Rate @ {k:2d}: {h}/{total} = {h/total*100:.2f}%\")\n",
874
+ " print(f\" MRR : {np.mean(mrr_scores):.4f}\")\n",
875
+ " print(\"=\" * 45 + \"\\n\")\n",
876
+ "\n",
877
+ "main()"
878
+ ]
879
+ },
880
+ {
881
+ "cell_type": "code",
882
+ "execution_count": 18,
883
+ "id": "afc485b0-efe7-4b79-ba37-76f8b72c6f7b",
884
+ "metadata": {},
885
+ "outputs": [
886
+ {
887
+ "name": "stderr",
888
+ "output_type": "stream",
889
+ "text": [
890
+ "2026-04-02 14:48:54,535 - INFO - Loading parquet: /home/skiredj.abderrahman/khalil/sbert_training/shamela_q_chunk_00_0_500000.parquet\n",
891
+ "2026-04-02 14:48:57,956 - INFO - Using random sample of 10000 rows.\n",
892
+ "2026-04-02 14:48:57,957 - INFO - Dataset size: 10000 rows\n",
893
+ "2026-04-02 14:48:57,958 - INFO - Loading model: intfloat/multilingual-e5-base\n",
894
+ "2026-04-02 14:48:57,963 - INFO - Use pytorch device_name: cuda:0\n",
895
+ "2026-04-02 14:48:57,963 - INFO - Load pretrained SentenceTransformer: intfloat/multilingual-e5-base\n",
896
+ "2026-04-02 14:48:58,199 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/modules.json \"HTTP/1.1 307 Temporary Redirect\"\n",
897
+ "2026-04-02 14:48:58,218 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/modules.json \"HTTP/1.1 200 OK\"\n",
898
+ "2026-04-02 14:48:58,353 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config_sentence_transformers.json \"HTTP/1.1 404 Not Found\"\n",
899
+ "2026-04-02 14:48:58,487 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config_sentence_transformers.json \"HTTP/1.1 404 Not Found\"\n",
900
+ "2026-04-02 14:48:58,806 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/README.md \"HTTP/1.1 307 Temporary Redirect\"\n",
901
+ "2026-04-02 14:48:58,826 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/README.md \"HTTP/1.1 200 OK\"\n",
902
+ "2026-04-02 14:48:58,962 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/modules.json \"HTTP/1.1 307 Temporary Redirect\"\n",
903
+ "2026-04-02 14:48:58,982 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/modules.json \"HTTP/1.1 200 OK\"\n",
904
+ "2026-04-02 14:48:59,215 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/sentence_bert_config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
905
+ "2026-04-02 14:48:59,235 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/sentence_bert_config.json \"HTTP/1.1 200 OK\"\n",
906
+ "2026-04-02 14:48:59,373 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/adapter_config.json \"HTTP/1.1 404 Not Found\"\n",
907
+ "2026-04-02 14:48:59,509 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
908
+ "2026-04-02 14:48:59,528 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/config.json \"HTTP/1.1 200 OK\"\n",
909
+ "Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████| 199/199 [00:00<00:00, 825.43it/s, Materializing param=pooler.dense.weight]\n",
910
+ "\u001b[1mXLMRobertaModel LOAD REPORT\u001b[0m from: intfloat/multilingual-e5-base\n",
911
+ "Key | Status | | \n",
912
+ "------------------------+------------+--+-\n",
913
+ "embeddings.position_ids | UNEXPECTED | | \n",
914
+ "\n",
915
+ "\u001b[3mNotes:\n",
916
+ "- UNEXPECTED\u001b[3m\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n",
917
+ "2026-04-02 14:48:59,954 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
918
+ "2026-04-02 14:48:59,974 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/config.json \"HTTP/1.1 200 OK\"\n",
919
+ "2026-04-02 14:49:00,110 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/tokenizer_config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
920
+ "2026-04-02 14:49:00,129 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/tokenizer_config.json \"HTTP/1.1 200 OK\"\n",
921
+ "2026-04-02 14:49:00,270 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base/tree/main/additional_chat_templates?recursive=false&expand=false \"HTTP/1.1 404 Not Found\"\n",
922
+ "2026-04-02 14:49:00,406 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base/tree/main?recursive=true&expand=false \"HTTP/1.1 200 OK\"\n",
923
+ "2026-04-02 14:49:02,428 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base \"HTTP/1.1 200 OK\"\n",
924
+ "2026-04-02 14:49:02,594 - INFO - HTTP Request: HEAD https://huggingface.co/intfloat/multilingual-e5-base/resolve/main/1_Pooling/config.json \"HTTP/1.1 307 Temporary Redirect\"\n",
925
+ "2026-04-02 14:49:02,613 - INFO - HTTP Request: HEAD https://huggingface.co/api/resolve-cache/models/intfloat/multilingual-e5-base/d128750597153bb5987e10b1c3493a34e5a4502a/1_Pooling%2Fconfig.json \"HTTP/1.1 200 OK\"\n",
926
+ "2026-04-02 14:49:02,757 - INFO - HTTP Request: GET https://huggingface.co/api/models/intfloat/multilingual-e5-base \"HTTP/1.1 200 OK\"\n",
927
+ "2026-04-02 14:49:02,947 - INFO - Encoding 10000 corpus texts ...\n",
928
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:36<00:00, 4.31it/s]\n",
929
+ "2026-04-02 14:49:39,918 - INFO - Encoding queries from 'q1' ...\n",
930
+ "Batches: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 157/157 [00:02<00:00, 54.14it/s]\n"
931
+ ]
932
+ },
933
+ {
934
+ "name": "stdout",
935
+ "output_type": "stream",
936
+ "text": [
937
+ "\n",
938
+ "=============================================\n",
939
+ " SBERT Evaluation Results\n",
940
+ "=============================================\n",
941
+ " Hit Rate @ 1: 2959/10000 = 29.59%\n",
942
+ " Hit Rate @ 5: 4296/10000 = 42.96%\n",
943
+ " Hit Rate @ 10: 4803/10000 = 48.03%\n",
944
+ " MRR : 0.3597\n",
945
+ "=============================================\n",
946
+ "\n"
947
+ ]
948
+ }
949
+ ],
950
+ "source": [
951
+ "logging.basicConfig(level=logging.INFO, format=\"%(asctime)s - %(levelname)s - %(message)s\")\n",
952
+ "logger = logging.getLogger(__name__)\n",
953
+ "\n",
954
+ "# ── Config ───────────────────────────────────────────────────────────────────\n",
955
+ "PARQUET_PATH = \"/home/skiredj.abderrahman/khalil/sbert_training/shamela_q_chunk_00_0_500000.parquet\"\n",
956
+ "MODEL_PATH = \"intfloat/multilingual-e5-base\"\n",
957
+ "BATCH_SIZE = 64\n",
958
+ "TOP_K = (1, 5, 10)\n",
959
+ "SAMPLE_N = 10000 # set e.g. 5000 to run on a subset; None = full file\n",
960
+ "# ─────────────────────────────────────────────────────────────────────────────\n",
961
+ "\n",
962
+ "QUERY_COLS = [\"q1\"]\n",
963
+ "TEXT_COL = \"text\"\n",
964
+ "\n",
965
+ "\n",
966
+ "def evaluate(df: pd.DataFrame, model: SentenceTransformer):\n",
967
+ " texts = df[TEXT_COL].tolist()\n",
968
+ "\n",
969
+ " # Encode corpus\n",
970
+ " logger.info(f\"Encoding {len(texts)} corpus texts ...\")\n",
971
+ " text_embs = model.encode(\n",
972
+ " texts,\n",
973
+ " batch_size=BATCH_SIZE,\n",
974
+ " show_progress_bar=True,\n",
975
+ " convert_to_numpy=True,\n",
976
+ " normalize_embeddings=True,\n",
977
+ " )\n",
978
+ "\n",
979
+ " hit_counts = {k: 0 for k in TOP_K}\n",
980
+ " mrr_scores = []\n",
981
+ " total = 0\n",
982
+ "\n",
983
+ " for col in QUERY_COLS:\n",
984
+ " queries = df[col].tolist()\n",
985
+ " logger.info(f\"Encoding queries from '{col}' ...\")\n",
986
+ "\n",
987
+ " q_embs = model.encode(\n",
988
+ " queries,\n",
989
+ " batch_size=BATCH_SIZE,\n",
990
+ " show_progress_bar=True,\n",
991
+ " convert_to_numpy=True,\n",
992
+ " normalize_embeddings=True,\n",
993
+ " )\n",
994
+ "\n",
995
+ " sims = cosine_similarity(q_embs, text_embs) # (n, n)\n",
996
+ "\n",
997
+ " for i in range(len(texts)):\n",
998
+ " ranked = np.argsort(-sims[i]) # numpy array, descending\n",
999
+ "\n",
1000
+ " # MRR — find where index i appears in ranked\n",
1001
+ " rank_pos = np.where(ranked == i)[0][0] + 1 # 1-based\n",
1002
+ " mrr_scores.append(1.0 / rank_pos)\n",
1003
+ "\n",
1004
+ " # Hit Rate @ K\n",
1005
+ " for k in TOP_K:\n",
1006
+ " if i in ranked[:k]:\n",
1007
+ " hit_counts[k] += 1\n",
1008
+ "\n",
1009
+ " total += 1\n",
1010
+ "\n",
1011
+ " return hit_counts, mrr_scores, total\n",
1012
+ "\n",
1013
+ "\n",
1014
+ "def main():\n",
1015
+ " logger.info(f\"Loading parquet: {PARQUET_PATH}\")\n",
1016
+ " df = pd.read_parquet(PARQUET_PATH, columns=[TEXT_COL] + QUERY_COLS)\n",
1017
+ " df = df.dropna(subset=[TEXT_COL] + QUERY_COLS).reset_index(drop=True)\n",
1018
+ "\n",
1019
+ " if SAMPLE_N and SAMPLE_N < len(df):\n",
1020
+ " df = df.sample(n=SAMPLE_N, random_state=42).reset_index(drop=True)\n",
1021
+ " logger.info(f\"Using random sample of {SAMPLE_N} rows.\")\n",
1022
+ "\n",
1023
+ " logger.info(f\"Dataset size: {len(df)} rows\")\n",
1024
+ "\n",
1025
+ " logger.info(f\"Loading model: {MODEL_PATH}\")\n",
1026
+ " model = SentenceTransformer(MODEL_PATH)\n",
1027
+ "\n",
1028
+ " hit_counts, mrr_scores, total = evaluate(df, model)\n",
1029
+ "\n",
1030
+ " print(\"\\n\" + \"=\" * 45)\n",
1031
+ " print(\" SBERT Evaluation Results\")\n",
1032
+ " print(\"=\" * 45)\n",
1033
+ " for k in TOP_K:\n",
1034
+ " h = hit_counts[k]\n",
1035
+ " print(f\" Hit Rate @ {k:2d}: {h}/{total} = {h/total*100:.2f}%\")\n",
1036
+ " print(f\" MRR : {np.mean(mrr_scores):.4f}\")\n",
1037
+ " print(\"=\" * 45 + \"\\n\")\n",
1038
+ "\n",
1039
+ "main()"
1040
+ ]
1041
+ },
1042
+ {
1043
+ "cell_type": "code",
1044
+ "execution_count": null,
1045
+ "id": "5c8738b8-659c-4a1d-8b90-1c76aaae159e",
1046
+ "metadata": {},
1047
+ "outputs": [],
1048
+ "source": []
1049
+ }
1050
+ ],
1051
+ "metadata": {
1052
+ "kernelspec": {
1053
+ "display_name": "Python 3 (ipykernel)",
1054
+ "language": "python",
1055
+ "name": "python3"
1056
+ },
1057
+ "language_info": {
1058
+ "codemirror_mode": {
1059
+ "name": "ipython",
1060
+ "version": 3
1061
+ },
1062
+ "file_extension": ".py",
1063
+ "mimetype": "text/x-python",
1064
+ "name": "python",
1065
+ "nbconvert_exporter": "python",
1066
+ "pygments_lexer": "ipython3",
1067
+ "version": "3.11.15"
1068
+ }
1069
+ },
1070
+ "nbformat": 4,
1071
+ "nbformat_minor": 5
1072
+ }
sbert_training/fourth_training/arabvert02_results.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ model,corpus_size,hit_rate@10,mrr@10,n
2
+ ArabVert02 (fine-tuned),572,0.9522,0.7896,1046
sbert_training/fourth_training/bert-base-arabertv02/.gitattributes ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
10
+ events.out.tfevents* filter=lfs diff=lfs merge=lfs -text
11
+ model.safetensors filter=lfs diff=lfs merge=lfs -text
sbert_training/fourth_training/bert-base-arabertv02/README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: ar
3
+ datasets:
4
+ - wikipedia
5
+ - Osian
6
+ - 1.5B-Arabic-Corpus
7
+ - oscar-arabic-unshuffled
8
+ - Assafir-private
9
+ widget:
10
+ - text: ' عاصمة لبنان هي [MASK] .'
11
+ pipeline_tag: fill-mask
12
+ ---
13
+
14
+ # AraBERT v1 & v2 : Pre-training BERT for Arabic Language Understanding
15
+
16
+ <img src="https://raw.githubusercontent.com/aub-mind/arabert/master/arabert_logo.png" width="100" align="left"/>
17
+
18
+ **AraBERT** is an Arabic pretrained language model based on [Google's BERT architechture](https://github.com/google-research/bert). AraBERT uses the same BERT-Base config. More details are available in the [AraBERT Paper](https://arxiv.org/abs/2003.00104) and in the [AraBERT Meetup](https://github.com/WissamAntoun/pydata_khobar_meetup)
19
+
20
+ There are two versions of the model, AraBERTv0.1 and AraBERTv1, with the difference being that AraBERTv1 uses pre-segmented text where prefixes and suffixes were split using the [Farasa Segmenter](http://alt.qcri.org/farasa/segmenter.html).
21
+
22
+
23
+ We evaluate AraBERT models on different downstream tasks and compare them to [mBERT]((https://github.com/google-research/bert/blob/master/multilingual.md)), and other state of the art models (*To the extent of our knowledge*). The Tasks were Sentiment Analysis on 6 different datasets ([HARD](https://github.com/elnagara/HARD-Arabic-Dataset), [ASTD-Balanced](https://www.aclweb.org/anthology/D15-1299), [ArsenTD-Lev](https://staff.aub.edu.lb/~we07/Publications/ArSentD-LEV_Sentiment_Corpus.pdf), [LABR](https://github.com/mohamedadaly/LABR)), Named Entity Recognition with the [ANERcorp](http://curtis.ml.cmu.edu/w/courses/index.php/ANERcorp), and Arabic Question Answering on [Arabic-SQuAD and ARCD](https://github.com/husseinmozannar/SOQAL)
24
+
25
+ # AraBERTv2
26
+
27
+ ## What's New!
28
+
29
+ AraBERT now comes in 4 new variants to replace the old v1 versions:
30
+
31
+ More Detail in the AraBERT folder and in the [README](https://github.com/aub-mind/arabert/blob/master/AraBERT/README.md) and in the [AraBERT Paper](https://arxiv.org/abs/2003.00104v2)
32
+
33
+ Model | HuggingFace Model Name | Size (MB/Params)| Pre-Segmentation | DataSet (Sentences/Size/nWords) |
34
+ ---|:---:|:---:|:---:|:---:
35
+ AraBERTv0.2-base | [bert-base-arabertv02](https://huggingface.co/aubmindlab/bert-base-arabertv02) | 543MB / 136M | No | 200M / 77GB / 8.6B |
36
+ AraBERTv0.2-large| [bert-large-arabertv02](https://huggingface.co/aubmindlab/bert-large-arabertv02) | 1.38G 371M | No | 200M / 77GB / 8.6B |
37
+ AraBERTv2-base| [bert-base-arabertv2](https://huggingface.co/aubmindlab/bert-base-arabertv2) | 543MB 136M | Yes | 200M / 77GB / 8.6B |
38
+ AraBERTv2-large| [bert-large-arabertv2](https://huggingface.co/aubmindlab/bert-large-arabertv2) | 1.38G 371M | Yes | 200M / 77GB / 8.6B |
39
+ AraBERTv0.2-Twitter-base| [bert-base-arabertv02-twitter](https://huggingface.co/aubmindlab/bert-base-arabertv02-twitter) | 543MB / 136M | No | Same as v02 + 60M Multi-Dialect Tweets|
40
+ AraBERTv0.2-Twitter-large| [bert-large-arabertv02-twitter](https://huggingface.co/aubmindlab/bert-large-arabertv02-twitter) | 1.38G / 371M | No | Same as v02 + 60M Multi-Dialect Tweets|
41
+ AraBERTv0.1-base| [bert-base-arabertv01](https://huggingface.co/aubmindlab/bert-base-arabertv01) | 543MB 136M | No | 77M / 23GB / 2.7B |
42
+ AraBERTv1-base| [bert-base-arabert](https://huggingface.co/aubmindlab/bert-base-arabert) | 543MB 136M | Yes | 77M / 23GB / 2.7B |
43
+
44
+ All models are available in the `HuggingFace` model page under the [aubmindlab](https://huggingface.co/aubmindlab/) name. Checkpoints are available in PyTorch, TF2 and TF1 formats.
45
+
46
+ ## Better Pre-Processing and New Vocab
47
+
48
+ We identified an issue with AraBERTv1's wordpiece vocabulary. The issue came from punctuations and numbers that were still attached to words when learned the wordpiece vocab. We now insert a space between numbers and characters and around punctuation characters.
49
+
50
+ The new vocabulary was learned using the `BertWordpieceTokenizer` from the `tokenizers` library, and should now support the Fast tokenizer implementation from the `transformers` library.
51
+
52
+ **P.S.**: All the old BERT codes should work with the new BERT, just change the model name and check the new preprocessing function
53
+ **Please read the section on how to use the [preprocessing function](#Preprocessing)**
54
+
55
+ ## Bigger Dataset and More Compute
56
+
57
+ We used ~3.5 times more data, and trained for longer.
58
+ For Dataset Sources see the [Dataset Section](#Dataset)
59
+
60
+ Model | Hardware | num of examples with seq len (128 / 512) |128 (Batch Size/ Num of Steps) | 512 (Batch Size/ Num of Steps) | Total Steps | Total Time (in Days) |
61
+ ---|:---:|:---:|:---:|:---:|:---:|:---:
62
+ AraBERTv0.2-base | TPUv3-8 | 420M / 207M | 2560 / 1M | 384/ 2M | 3M | -
63
+ AraBERTv0.2-large | TPUv3-128 | 420M / 207M | 13440 / 250K | 2056 / 300K | 550K | 7
64
+ AraBERTv2-base | TPUv3-8 | 420M / 207M | 2560 / 1M | 384/ 2M | 3M | -
65
+ AraBERTv2-large | TPUv3-128 | 520M / 245M | 13440 / 250K | 2056 / 300K | 550K | 7
66
+ AraBERT-base (v1/v0.1) | TPUv2-8 | - |512 / 900K | 128 / 300K| 1.2M | 4
67
+
68
+ # Dataset
69
+
70
+ The pretraining data used for the new AraBERT model is also used for Arabic **GPT2 and ELECTRA**.
71
+
72
+ The dataset consists of 77GB or 200,095,961 lines or 8,655,948,860 words or 82,232,988,358 chars (before applying Farasa Segmentation)
73
+
74
+ For the new dataset we added the unshuffled OSCAR corpus, after we thoroughly filter it, to the previous dataset used in AraBERTv1 but with out the websites that we previously crawled:
75
+ - OSCAR unshuffled and filtered.
76
+ - [Arabic Wikipedia dump](https://archive.org/details/arwiki-20190201) from 2020/09/01
77
+ - [The 1.5B words Arabic Corpus](https://www.semanticscholar.org/paper/1.5-billion-words-Arabic-Corpus-El-Khair/f3eeef4afb81223df96575adadf808fe7fe440b4)
78
+ - [The OSIAN Corpus](https://www.aclweb.org/anthology/W19-4619)
79
+ - Assafir news articles. Huge thank you for Assafir for providing us the data
80
+
81
+ # Preprocessing
82
+
83
+ It is recommended to apply our preprocessing function before training/testing on any dataset.
84
+
85
+ **Install the arabert python package to segment text for AraBERT v1 & v2 or to clean your data `pip install arabert`**
86
+
87
+ ```python
88
+ from arabert.preprocess import ArabertPreprocessor
89
+
90
+ model_name="aubmindlab/bert-large-arabertv02"
91
+ arabert_prep = ArabertPreprocessor(model_name=model_name)
92
+
93
+ text = "ولن نبالغ إذا قلنا: إن هاتف أو كمبيوتر المكتب في زمننا هذا ضروري"
94
+ arabert_prep.preprocess(text)
95
+
96
+ >>> output: ولن نبالغ إذا قلنا : إن هاتف أو كمبيوتر المكتب في زمننا هذا ضروري
97
+ ```
98
+
99
+ # TensorFlow 1.x models
100
+
101
+ The TF1.x model are available in the HuggingFace models repo.
102
+ You can download them as follows:
103
+ - via git-lfs: clone all the models in a repo
104
+ ```bash
105
+ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
106
+ sudo apt-get install git-lfs
107
+ git lfs install
108
+ git clone https://huggingface.co/aubmindlab/MODEL_NAME
109
+ tar -C ./MODEL_NAME -zxvf /content/MODEL_NAME/tf1_model.tar.gz
110
+ ```
111
+ where `MODEL_NAME` is any model under the `aubmindlab` name
112
+
113
+ - via `wget`:
114
+ - Go to the tf1_model.tar.gz file on huggingface.co/models/aubmindlab/MODEL_NAME.
115
+ - copy the `oid sha256`
116
+ - then run `wget https://cdn-lfs.huggingface.co/aubmindlab/aragpt2-base/INSERT_THE_SHA_HERE` (ex: for `aragpt2-base`: `wget https://cdn-lfs.huggingface.co/aubmindlab/aragpt2-base/3766fc03d7c2593ff2fb991d275e96b81b0ecb2098b71ff315611d052ce65248`)
117
+
118
+
119
+ # If you used this model please cite us as :
120
+ Google Scholar has our Bibtex wrong (missing name), use this instead
121
+ ```
122
+ @inproceedings{antoun2020arabert,
123
+ title={AraBERT: Transformer-based Model for Arabic Language Understanding},
124
+ author={Antoun, Wissam and Baly, Fady and Hajj, Hazem},
125
+ booktitle={LREC 2020 Workshop Language Resources and Evaluation Conference 11--16 May 2020},
126
+ pages={9}
127
+ }
128
+ ```
129
+ # Acknowledgments
130
+ Thanks to TensorFlow Research Cloud (TFRC) for the free access to Cloud TPUs, couldn't have done it without this program, and to the [AUB MIND Lab](https://sites.aub.edu.lb/mindlab/) Members for the continuous support. Also thanks to [Yakshof](https://www.yakshof.com/#/) and Assafir for data and storage access. Another thanks for Habib Rahal (https://www.behance.net/rahalhabib), for putting a face to AraBERT.
131
+
132
+ # Contacts
133
+ **Wissam Antoun**: [Linkedin](https://www.linkedin.com/in/wissam-antoun-622142b4/) | [Twitter](https://twitter.com/wissam_antoun) | [Github](https://github.com/WissamAntoun) | <wfa07@mail.aub.edu> | <wissam.antoun@gmail.com>
134
+
135
+ **Fady Baly**: [Linkedin](https://www.linkedin.com/in/fadybaly/) | [Twitter](https://twitter.com/fadybaly) | [Github](https://github.com/fadybaly) | <fgb06@mail.aub.edu> | <baly.fady@gmail.com>
sbert_training/fourth_training/bert-base-arabertv02/config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "hidden_act": "gelu",
7
+ "hidden_dropout_prob": 0.1,
8
+ "hidden_size": 768,
9
+ "initializer_range": 0.02,
10
+ "intermediate_size": 3072,
11
+ "max_position_embeddings": 512,
12
+ "model_type": "bert",
13
+ "num_attention_heads": 12,
14
+ "num_hidden_layers": 12,
15
+ "type_vocab_size": 2,
16
+ "vocab_size": 64000
17
+ }
sbert_training/fourth_training/bert-base-arabertv02/flax_model.msgpack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0bbd3dffdc55c7adccafaf9c18eaaf2e992bb87e4787d4f580314a5b383e634
3
+ size 541042787
sbert_training/fourth_training/bert-base-arabertv02/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48873a2bb50cd5a481e9fbdb75ebff4717cb04496474b5a7c26f5377648d3141
3
+ size 543432324
sbert_training/fourth_training/bert-base-arabertv02/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eac91bc3c317f3624abb5d562f5a49180a8aa991fdb21c57ce6a5e1266968be1
3
+ size 543490667
sbert_training/fourth_training/bert-base-arabertv02/runs/eval/events.out.tfevents.1607681029.tpu-mother ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cd567fbe978c1ac779ec365fb4ad8a0f7b4eacc999b60459acc04e8bece5f8d
3
+ size 2649933
sbert_training/fourth_training/bert-base-arabertv02/runs/eval/events.out.tfevents.1607686495.tpu-mother ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:affcfcd40bb2e1bf20c90a24b44d23a1e5b72fdaac440cb097e4661f2b9f1716
3
+ size 2652817