Sentence Similarity
sentence-transformers
Safetensors
Hebrew
hebrew
semantic-retrieval
information-retrieval
dense-retrieval
reranking
bge-m3
competition
Instructions to use HebArabNlpProject/Semantic-Retrieval-3rd-place with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use HebArabNlpProject/Semantic-Retrieval-3rd-place with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("HebArabNlpProject/Semantic-Retrieval-3rd-place") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
uploading 3rd place model
Browse files- .gitattributes +2 -0
- model.py +400 -0
- models/test_encoder_only_base_bge_m3_new1/config.json +27 -0
- models/test_encoder_only_base_bge_m3_new1/model.safetensors +3 -0
- models/test_encoder_only_base_bge_m3_new1/sentencepiece.bpe.model +3 -0
- models/test_encoder_only_base_bge_m3_new1/special_tokens_map.json +51 -0
- models/test_encoder_only_base_bge_m3_new1/tokenizer.json +3 -0
- models/test_encoder_only_base_bge_m3_new1/tokenizer_config.json +56 -0
- models/test_encoder_only_base_bge_m3_new1/training_args.bin +3 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/config.json +33 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/model.safetensors +3 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/sentencepiece.bpe.model +3 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/special_tokens_map.json +51 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/tokenizer.json +3 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/tokenizer_config.json +56 -0
- models/test_encoder_only_base_bge_reranker_v2_m3_new1/training_args.bin +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ 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 |
+
models/test_encoder_only_base_bge_m3_new1/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
models/test_encoder_only_base_bge_reranker_v2_m3_new1/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
model.py
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
import numpy as np
|
| 5 |
+
#from sklearn.metrics.pairwise import cosine_similarity
|
| 6 |
+
from transformers import (
|
| 7 |
+
AutoTokenizer,
|
| 8 |
+
AutoModel,
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class BGERetriever:
|
| 13 |
+
def __init__(self, model_name=None, device=None, sentence_pooling_method="cls"):
|
| 14 |
+
"""
|
| 15 |
+
Initializes the BGE retriever using the multilingual BGE-m3 base model.
|
| 16 |
+
"""
|
| 17 |
+
# Use local model
|
| 18 |
+
if model_name is None:
|
| 19 |
+
model_suffix = "bge-m3"
|
| 20 |
+
model_suffix = "test_encoder_only_m3_bge-m3_sd"
|
| 21 |
+
model_suffix = "test_encoder_only_base_bge-large-en-v1.5_sd"
|
| 22 |
+
model_suffix = "test_encoder_only_base_bge_m3_new"
|
| 23 |
+
model_suffix = "test_encoder_only_base_bge_m3_new1"
|
| 24 |
+
local_model_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'models', model_suffix)
|
| 25 |
+
if os.path.isdir(local_model_path):
|
| 26 |
+
model_name = local_model_path
|
| 27 |
+
print(f"Using local BGE model from: {model_name}")
|
| 28 |
+
|
| 29 |
+
self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
|
| 30 |
+
|
| 31 |
+
self.return_dense: bool = True
|
| 32 |
+
self.return_sparse: bool = False
|
| 33 |
+
self.return_colbert_vecs: bool = False
|
| 34 |
+
self.return_sparse_embedding: bool = False
|
| 35 |
+
|
| 36 |
+
print(f"Loading BGE multilingual model on device: {self.device}")
|
| 37 |
+
self.sentence_pooling_method = sentence_pooling_method
|
| 38 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 39 |
+
self.model = AutoModel.from_pretrained(model_name, torch_dtype=torch.float16, device_map=self.device)
|
| 40 |
+
self.vocab_size = self.model.config.vocab_size
|
| 41 |
+
self.temperature = 1.0
|
| 42 |
+
self.model.eval()
|
| 43 |
+
|
| 44 |
+
self.corpus_ids = []
|
| 45 |
+
self.corpus_embeddings = None
|
| 46 |
+
|
| 47 |
+
def _dense_embedding(self, last_hidden_state, attention_mask):
|
| 48 |
+
"""Use the pooling method to get the dense embedding.
|
| 49 |
+
|
| 50 |
+
Args:
|
| 51 |
+
last_hidden_state (torch.Tensor): The model output's last hidden state.
|
| 52 |
+
attention_mask (torch.Tensor): Mask out padding tokens during pooling.
|
| 53 |
+
|
| 54 |
+
Raises:
|
| 55 |
+
NotImplementedError: Specified pooling method not implemented.
|
| 56 |
+
|
| 57 |
+
Returns:
|
| 58 |
+
torch.Tensor: The dense embeddings.
|
| 59 |
+
"""
|
| 60 |
+
if self.sentence_pooling_method == "cls":
|
| 61 |
+
return last_hidden_state[:, 0]
|
| 62 |
+
elif self.sentence_pooling_method == "mean":
|
| 63 |
+
s = torch.sum(
|
| 64 |
+
last_hidden_state * attention_mask.unsqueeze(-1).float(), dim=1
|
| 65 |
+
)
|
| 66 |
+
d = attention_mask.sum(dim=1, keepdim=True).float()
|
| 67 |
+
return s / d
|
| 68 |
+
elif self.sentence_pooling_method == "last_token":
|
| 69 |
+
left_padding = attention_mask[:, -1].sum() == attention_mask.shape[0]
|
| 70 |
+
if left_padding:
|
| 71 |
+
return last_hidden_state[:, -1]
|
| 72 |
+
else:
|
| 73 |
+
sequence_lengths = attention_mask.sum(dim=1) - 1
|
| 74 |
+
batch_size = last_hidden_state.shape[0]
|
| 75 |
+
return last_hidden_state[
|
| 76 |
+
torch.arange(batch_size, device=last_hidden_state.device),
|
| 77 |
+
sequence_lengths,
|
| 78 |
+
]
|
| 79 |
+
else:
|
| 80 |
+
raise NotImplementedError(f"pooling method {self.sentence_pooling_method} not implemented")
|
| 81 |
+
|
| 82 |
+
def _compute_similarity(self, q_reps, p_reps):
|
| 83 |
+
"""Computes the similarity between query and passage representations using inner product.
|
| 84 |
+
|
| 85 |
+
Args:
|
| 86 |
+
q_reps (torch.Tensor): Query representations.
|
| 87 |
+
p_reps (torch.Tensor): Passage representations.
|
| 88 |
+
|
| 89 |
+
Returns:
|
| 90 |
+
torch.Tensor: The computed similarity matrix.
|
| 91 |
+
"""
|
| 92 |
+
if len(p_reps.size()) == 2:
|
| 93 |
+
return torch.matmul(q_reps, p_reps.transpose(0, 1))
|
| 94 |
+
return torch.matmul(q_reps, p_reps.transpose(-2, -1))
|
| 95 |
+
|
| 96 |
+
def compute_dense_score(self, q_reps, p_reps):
|
| 97 |
+
"""Compute the dense score.
|
| 98 |
+
|
| 99 |
+
Args:
|
| 100 |
+
q_reps (torch.Tensor): Query representations.
|
| 101 |
+
p_reps (torch.Tensor): Passage representations.
|
| 102 |
+
|
| 103 |
+
Returns:
|
| 104 |
+
torch.Tensor: The computed dense scores, adjusted by temperature.
|
| 105 |
+
"""
|
| 106 |
+
cos_scores = q_reps @ p_reps.T
|
| 107 |
+
return cos_scores
|
| 108 |
+
scores = self._compute_similarity(q_reps, p_reps) / self.temperature
|
| 109 |
+
scores = scores.view(q_reps.size(0), -1)
|
| 110 |
+
return scores
|
| 111 |
+
|
| 112 |
+
@torch.inference_mode()
|
| 113 |
+
def embed_texts(
|
| 114 |
+
self,
|
| 115 |
+
texts,
|
| 116 |
+
is_query=False,
|
| 117 |
+
batch_size=64,
|
| 118 |
+
):
|
| 119 |
+
"""
|
| 120 |
+
Generates embeddings for texts using BGE model with proper prefixes.
|
| 121 |
+
BGE requires specific prefixes for queries vs passages.
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
prefixed_texts = [text.strip() for text in texts]
|
| 125 |
+
|
| 126 |
+
all_dense_embeddings = []
|
| 127 |
+
total_batches = (len(prefixed_texts) + batch_size - 1) // batch_size
|
| 128 |
+
|
| 129 |
+
for i in range(0, len(prefixed_texts), batch_size):
|
| 130 |
+
batch_num = i // batch_size + 1
|
| 131 |
+
if not is_query and batch_num % 50 == 0:
|
| 132 |
+
print(f"Processing batch {batch_num}/{total_batches} ({(batch_num/total_batches)*100:.1f}%)")
|
| 133 |
+
if torch.cuda.is_available():
|
| 134 |
+
torch.cuda.empty_cache()
|
| 135 |
+
|
| 136 |
+
batch_texts = prefixed_texts[i:i + batch_size]
|
| 137 |
+
|
| 138 |
+
encoded = self.tokenizer(
|
| 139 |
+
batch_texts,
|
| 140 |
+
padding=True,
|
| 141 |
+
truncation=True,
|
| 142 |
+
max_length=512,
|
| 143 |
+
return_tensors='pt',
|
| 144 |
+
).to(self.device)
|
| 145 |
+
|
| 146 |
+
model_output = self.model(**encoded)
|
| 147 |
+
|
| 148 |
+
last_hidden_state = model_output.last_hidden_state
|
| 149 |
+
dense_vecs = self._dense_embedding(last_hidden_state, encoded['attention_mask'])
|
| 150 |
+
dense_vecs = torch.nn.functional.normalize(dense_vecs, p=2, dim=1)
|
| 151 |
+
all_dense_embeddings.append(dense_vecs.cpu())
|
| 152 |
+
|
| 153 |
+
all_dense_embeddings = torch.cat(all_dense_embeddings, dim=0)
|
| 154 |
+
|
| 155 |
+
return all_dense_embeddings
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class BGEReranker:
|
| 159 |
+
def __init__(self, model_name=None, device=None):
|
| 160 |
+
"""
|
| 161 |
+
Initializes the BGE reranker for fine-grained relevance scoring.
|
| 162 |
+
"""
|
| 163 |
+
# Use local model
|
| 164 |
+
if model_name is None:
|
| 165 |
+
model_suffix = 'bge-reranker-v2-m3'
|
| 166 |
+
model_suffix = 'test_encoder_only_base_bge_reranker_v2_m3'
|
| 167 |
+
model_suffix = "test_encoder_only_base_bge_reranker_v2_m3_new"
|
| 168 |
+
model_suffix = "test_encoder_only_base_bge_reranker_v2_m3_new1"
|
| 169 |
+
local_model_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'models', model_suffix)
|
| 170 |
+
if os.path.isdir(local_model_path):
|
| 171 |
+
model_name = local_model_path
|
| 172 |
+
print(f"Using local BGE model from: {model_name}")
|
| 173 |
+
|
| 174 |
+
self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
|
| 175 |
+
|
| 176 |
+
print(f"Loading BGE reranker on device: {self.device}")
|
| 177 |
+
# BGE reranker is actually a special model type
|
| 178 |
+
from transformers import AutoModelForSequenceClassification
|
| 179 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 180 |
+
self.model = AutoModelForSequenceClassification.from_pretrained(
|
| 181 |
+
model_name,
|
| 182 |
+
torch_dtype=torch.float16,
|
| 183 |
+
trust_remote_code=True,
|
| 184 |
+
device_map=self.device,
|
| 185 |
+
)
|
| 186 |
+
self.model.eval()
|
| 187 |
+
|
| 188 |
+
@torch.inference_mode()
|
| 189 |
+
def rerank(self, query_text, passages, passage_ids, top_k=20, batch_size=32):
|
| 190 |
+
"""
|
| 191 |
+
Rerank the passages using BGE reranker - CORRECTED VERSION.
|
| 192 |
+
"""
|
| 193 |
+
if not passages:
|
| 194 |
+
return []
|
| 195 |
+
|
| 196 |
+
pairs = list(zip(passage_ids, passages))
|
| 197 |
+
pairs.sort(key=lambda x: len(x[1]))
|
| 198 |
+
passage_ids, passages = zip(*pairs)
|
| 199 |
+
|
| 200 |
+
scores = []
|
| 201 |
+
for i in range(0, len(passages), batch_size):
|
| 202 |
+
batch_passages = passages[i:i + batch_size]
|
| 203 |
+
|
| 204 |
+
try:
|
| 205 |
+
# BGE reranker expects SEPARATE query and passage inputs
|
| 206 |
+
# NOT concatenated strings
|
| 207 |
+
batch_queries = [query_text] * len(batch_passages)
|
| 208 |
+
|
| 209 |
+
# Tokenize query-passage pairs properly
|
| 210 |
+
inputs = self.tokenizer(
|
| 211 |
+
batch_queries,
|
| 212 |
+
batch_passages,
|
| 213 |
+
padding=True,
|
| 214 |
+
truncation=True,
|
| 215 |
+
max_length=512,
|
| 216 |
+
return_tensors='pt'
|
| 217 |
+
).to(self.device)
|
| 218 |
+
|
| 219 |
+
# Get relevance scores from sequence classification model
|
| 220 |
+
outputs = self.model(**inputs)
|
| 221 |
+
|
| 222 |
+
# BGE reranker outputs logits for relevance classification
|
| 223 |
+
logits = outputs.logits
|
| 224 |
+
|
| 225 |
+
# Handle different output shapes
|
| 226 |
+
if len(logits.shape) == 1:
|
| 227 |
+
# Single score per pair
|
| 228 |
+
batch_scores = logits.cpu().numpy()
|
| 229 |
+
elif logits.shape[1] == 1:
|
| 230 |
+
# Single column output
|
| 231 |
+
batch_scores = logits.squeeze(-1).cpu().numpy()
|
| 232 |
+
else:
|
| 233 |
+
# Binary classification - take positive class (index 1)
|
| 234 |
+
batch_scores = logits[:, 1].cpu().numpy()
|
| 235 |
+
|
| 236 |
+
scores.extend(batch_scores.tolist())
|
| 237 |
+
|
| 238 |
+
except Exception as e:
|
| 239 |
+
print(f"Error in reranking batch {i//batch_size + 1}: {e}")
|
| 240 |
+
# Fallback: Use neutral scores for this batch
|
| 241 |
+
fallback_scores = [0.5] * len(batch_passages)
|
| 242 |
+
scores.extend(fallback_scores)
|
| 243 |
+
|
| 244 |
+
# Combine results and sort by reranking score
|
| 245 |
+
results = list(zip(passage_ids, scores))
|
| 246 |
+
results.sort(key=lambda x: x[1], reverse=True)
|
| 247 |
+
|
| 248 |
+
return results[:top_k]
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
# Global instances
|
| 252 |
+
retriever = None
|
| 253 |
+
reranker = None
|
| 254 |
+
corpus_texts = {} # Store original passage texts for reranking
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def preprocess(corpus_dict):
|
| 258 |
+
"""
|
| 259 |
+
Preprocessing function using BGE multilingual model + BGE reranker.
|
| 260 |
+
|
| 261 |
+
Input: corpus_dict - dict mapping document IDs to document objects with 'passage'/'text' field
|
| 262 |
+
Output: dict containing initialized models, embeddings, and corpus data
|
| 263 |
+
|
| 264 |
+
Note: Uses global variables (retriever, reranker, corpus_texts) for efficiency,
|
| 265 |
+
but also returns all required data via preprocessed_data for function interface.
|
| 266 |
+
"""
|
| 267 |
+
global retriever, reranker, corpus_texts
|
| 268 |
+
print("=" * 60)
|
| 269 |
+
print("PREPROCESSING: Initializing BGE Reranker Pipeline...")
|
| 270 |
+
print("=" * 60)
|
| 271 |
+
|
| 272 |
+
# Set GPU memory optimization
|
| 273 |
+
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
|
| 274 |
+
|
| 275 |
+
# Initialize BGE retriever
|
| 276 |
+
print("Loading BGE retriever...")
|
| 277 |
+
retriever = BGERetriever()
|
| 278 |
+
|
| 279 |
+
# Initialize BGE reranker
|
| 280 |
+
print("Loading BGE reranker...")
|
| 281 |
+
reranker = BGEReranker()
|
| 282 |
+
|
| 283 |
+
print(f"Preparing corpus with {len(corpus_dict)} documents...")
|
| 284 |
+
|
| 285 |
+
# Store corpus IDs, passages, and original texts
|
| 286 |
+
#retriever.corpus_ids = list(corpus_dict.keys())
|
| 287 |
+
corpus_ids = list(corpus_dict.keys())
|
| 288 |
+
passages = [doc.get('passage', doc.get('text', '')) for doc in corpus_dict.values()]
|
| 289 |
+
retriever.corpus_ids, passages = zip(*sorted(zip(corpus_ids, passages), key=lambda x: len(x[1])))
|
| 290 |
+
|
| 291 |
+
# Store original texts for reranking
|
| 292 |
+
corpus_texts = {doc_id: passages[i] for i, doc_id in enumerate(retriever.corpus_ids)}
|
| 293 |
+
|
| 294 |
+
# Compute embeddings with conservative batch size for retrieval
|
| 295 |
+
print("Computing BGE embeddings...")
|
| 296 |
+
retriever.corpus_embeddings = retriever.embed_texts(passages, is_query=False, batch_size=64)
|
| 297 |
+
|
| 298 |
+
print("✓ Corpus preprocessing complete!")
|
| 299 |
+
print(f"✓ Generated embeddings for {len(retriever.corpus_ids)} documents")
|
| 300 |
+
|
| 301 |
+
print(f"✓ Embedding matrix shape: {retriever.corpus_embeddings.shape}")
|
| 302 |
+
|
| 303 |
+
return {
|
| 304 |
+
'retriever': retriever,
|
| 305 |
+
'reranker': reranker,
|
| 306 |
+
'corpus_ids': retriever.corpus_ids,
|
| 307 |
+
'corpus_embeddings': retriever.corpus_embeddings,
|
| 308 |
+
'corpus_texts': corpus_texts,
|
| 309 |
+
'num_documents': len(corpus_dict)
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
def predict(query, preprocessed_data):
|
| 314 |
+
"""
|
| 315 |
+
Two-stage prediction: BGE retrieval + BGE reranking.
|
| 316 |
+
|
| 317 |
+
Input:
|
| 318 |
+
- query: dict with 'query' field containing query text
|
| 319 |
+
- preprocessed_data: dict from preprocess() containing models and corpus data
|
| 320 |
+
|
| 321 |
+
Output: list of dicts with 'paragraph_uuid' and 'score' fields, ranked by relevance
|
| 322 |
+
|
| 323 |
+
Note: Uses global variables for efficiency but can also extract required data
|
| 324 |
+
from preprocessed_data parameter for proper function interface.
|
| 325 |
+
"""
|
| 326 |
+
global retriever, reranker, corpus_texts
|
| 327 |
+
|
| 328 |
+
# Extract query text
|
| 329 |
+
query_text = query.get('query', '')
|
| 330 |
+
if not query_text:
|
| 331 |
+
return []
|
| 332 |
+
|
| 333 |
+
# Use global instances or get from preprocessed_data
|
| 334 |
+
if retriever is None:
|
| 335 |
+
retriever = preprocessed_data.get('retriever')
|
| 336 |
+
reranker = preprocessed_data.get('reranker')
|
| 337 |
+
corpus_texts = preprocessed_data.get('corpus_texts', {})
|
| 338 |
+
|
| 339 |
+
if retriever is None or reranker is None:
|
| 340 |
+
print("Error: Missing retriever or reranker in preprocessed data")
|
| 341 |
+
return []
|
| 342 |
+
|
| 343 |
+
try:
|
| 344 |
+
#raise
|
| 345 |
+
# STAGE 1: BGE Retrieval (get top 100 candidates)
|
| 346 |
+
print("Stage 1: BGE retrieval...")
|
| 347 |
+
query_embedding = retriever.embed_texts([query_text], is_query=True, batch_size=1)
|
| 348 |
+
|
| 349 |
+
# Compute cosine similarity with precomputed corpus embeddings
|
| 350 |
+
#e5_scores = cosine_similarity(query_embedding, retriever.corpus_embeddings)[0]
|
| 351 |
+
dense_scores = retriever.compute_dense_score(query_embedding, retriever.corpus_embeddings)
|
| 352 |
+
e5_scores = dense_scores.squeeze(0).numpy()
|
| 353 |
+
|
| 354 |
+
# Get top 100 candidates for reranking
|
| 355 |
+
top_100_indices = np.argsort(e5_scores)[::-1][:100]
|
| 356 |
+
|
| 357 |
+
# Get passages and IDs for reranking
|
| 358 |
+
candidate_ids = [retriever.corpus_ids[idx] for idx in top_100_indices]
|
| 359 |
+
candidate_passages = [corpus_texts.get(doc_id, '') for doc_id in candidate_ids]
|
| 360 |
+
|
| 361 |
+
# STAGE 2: BGE Reranking (rerank top 100 -> top 20)
|
| 362 |
+
print("Stage 2: BGE reranking...")
|
| 363 |
+
reranked_results = reranker.rerank(
|
| 364 |
+
query_text,
|
| 365 |
+
candidate_passages,
|
| 366 |
+
candidate_ids,
|
| 367 |
+
top_k=20,
|
| 368 |
+
batch_size=16,
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
# Build final results with ACTUAL reranking scores
|
| 372 |
+
results = []
|
| 373 |
+
for rank, (passage_id, rerank_score) in enumerate(reranked_results):
|
| 374 |
+
results.append({
|
| 375 |
+
'paragraph_uuid': passage_id,
|
| 376 |
+
'score': float(rerank_score) # Use actual BGE reranker score!
|
| 377 |
+
})
|
| 378 |
+
|
| 379 |
+
print(f"✓ Returned {len(results)} results with reranker scores")
|
| 380 |
+
return results
|
| 381 |
+
|
| 382 |
+
except Exception as e:
|
| 383 |
+
print(f"Error in prediction: {e}")
|
| 384 |
+
# Fallback to BGE-only retrieval with BGE scores
|
| 385 |
+
query_embedding = retriever.embed_texts([query_text], is_query=True, batch_size=1)
|
| 386 |
+
#e5_scores = cosine_similarity(query_embedding, retriever.corpus_embeddings)[0]
|
| 387 |
+
dense_scores = retriever.compute_dense_score(query_embedding, retriever.corpus_embeddings)
|
| 388 |
+
|
| 389 |
+
e5_scores = dense_scores.squeeze(0).numpy()
|
| 390 |
+
|
| 391 |
+
top_indices = np.argsort(e5_scores)[::-1][:20]
|
| 392 |
+
|
| 393 |
+
results = []
|
| 394 |
+
for idx in top_indices:
|
| 395 |
+
results.append({
|
| 396 |
+
'paragraph_uuid': retriever.corpus_ids[idx],
|
| 397 |
+
'score': float(e5_scores[idx]) # Use actual BGE cosine similarity score
|
| 398 |
+
})
|
| 399 |
+
|
| 400 |
+
return results
|
models/test_encoder_only_base_bge_m3_new1/config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"XLMRobertaModel"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"bos_token_id": 0,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"eos_token_id": 2,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 1024,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 4096,
|
| 14 |
+
"layer_norm_eps": 1e-05,
|
| 15 |
+
"max_position_embeddings": 8194,
|
| 16 |
+
"model_type": "xlm-roberta",
|
| 17 |
+
"num_attention_heads": 16,
|
| 18 |
+
"num_hidden_layers": 24,
|
| 19 |
+
"output_past": true,
|
| 20 |
+
"pad_token_id": 1,
|
| 21 |
+
"position_embedding_type": "absolute",
|
| 22 |
+
"torch_dtype": "float16",
|
| 23 |
+
"transformers_version": "4.55.4",
|
| 24 |
+
"type_vocab_size": 1,
|
| 25 |
+
"use_cache": true,
|
| 26 |
+
"vocab_size": 250002
|
| 27 |
+
}
|
models/test_encoder_only_base_bge_m3_new1/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:86993a0584e46bd11ed8dfa406fe270a4ebdaaaf9e39ccb5e317625ee955a6ca
|
| 3 |
+
size 1135554344
|
models/test_encoder_only_base_bge_m3_new1/sentencepiece.bpe.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
|
| 3 |
+
size 5069051
|
models/test_encoder_only_base_bge_m3_new1/special_tokens_map.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"cls_token": {
|
| 10 |
+
"content": "<s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"eos_token": {
|
| 17 |
+
"content": "</s>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"mask_token": {
|
| 24 |
+
"content": "<mask>",
|
| 25 |
+
"lstrip": true,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"pad_token": {
|
| 31 |
+
"content": "<pad>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
},
|
| 37 |
+
"sep_token": {
|
| 38 |
+
"content": "</s>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false
|
| 43 |
+
},
|
| 44 |
+
"unk_token": {
|
| 45 |
+
"content": "<unk>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false
|
| 50 |
+
}
|
| 51 |
+
}
|
models/test_encoder_only_base_bge_m3_new1/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33cd99e33ce09bdd8a6136fddfe90a1c47f85bafedf7309d0eecc19012d43586
|
| 3 |
+
size 17082897
|
models/test_encoder_only_base_bge_m3_new1/tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "<s>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "<pad>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "</s>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "<unk>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"250001": {
|
| 36 |
+
"content": "<mask>",
|
| 37 |
+
"lstrip": true,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"bos_token": "<s>",
|
| 45 |
+
"clean_up_tokenization_spaces": true,
|
| 46 |
+
"cls_token": "<s>",
|
| 47 |
+
"eos_token": "</s>",
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "<mask>",
|
| 50 |
+
"model_max_length": 8192,
|
| 51 |
+
"pad_token": "<pad>",
|
| 52 |
+
"sep_token": "</s>",
|
| 53 |
+
"sp_model_kwargs": {},
|
| 54 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 55 |
+
"unk_token": "<unk>"
|
| 56 |
+
}
|
models/test_encoder_only_base_bge_m3_new1/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98887f48be1b4da068e277e1b7af2ed224e2109f28f6709c40d8c2202ffe2c24
|
| 3 |
+
size 7953
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/config.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"XLMRobertaForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"bos_token_id": 0,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"eos_token_id": 2,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 1024,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "LABEL_0"
|
| 14 |
+
},
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 4096,
|
| 17 |
+
"label2id": {
|
| 18 |
+
"LABEL_0": 0
|
| 19 |
+
},
|
| 20 |
+
"layer_norm_eps": 1e-05,
|
| 21 |
+
"max_position_embeddings": 8194,
|
| 22 |
+
"model_type": "xlm-roberta",
|
| 23 |
+
"num_attention_heads": 16,
|
| 24 |
+
"num_hidden_layers": 24,
|
| 25 |
+
"output_past": true,
|
| 26 |
+
"pad_token_id": 1,
|
| 27 |
+
"position_embedding_type": "absolute",
|
| 28 |
+
"torch_dtype": "float16",
|
| 29 |
+
"transformers_version": "4.55.4",
|
| 30 |
+
"type_vocab_size": 1,
|
| 31 |
+
"use_cache": true,
|
| 32 |
+
"vocab_size": 250002
|
| 33 |
+
}
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b006c7269685d64ff0142e2b504bb5d7a0672d2b0f9ee06778388ac53cb6fa54
|
| 3 |
+
size 1135559698
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/sentencepiece.bpe.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
|
| 3 |
+
size 5069051
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/special_tokens_map.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"cls_token": {
|
| 10 |
+
"content": "<s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"eos_token": {
|
| 17 |
+
"content": "</s>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"mask_token": {
|
| 24 |
+
"content": "<mask>",
|
| 25 |
+
"lstrip": true,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"pad_token": {
|
| 31 |
+
"content": "<pad>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
},
|
| 37 |
+
"sep_token": {
|
| 38 |
+
"content": "</s>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false
|
| 43 |
+
},
|
| 44 |
+
"unk_token": {
|
| 45 |
+
"content": "<unk>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false
|
| 50 |
+
}
|
| 51 |
+
}
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:176d84e1bd0068c3f313202e23cc0ff7b22e88378ee316886bbd2f3e7ae156de
|
| 3 |
+
size 17082998
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "<s>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "<pad>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "</s>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "<unk>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"250001": {
|
| 36 |
+
"content": "<mask>",
|
| 37 |
+
"lstrip": true,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"bos_token": "<s>",
|
| 45 |
+
"clean_up_tokenization_spaces": true,
|
| 46 |
+
"cls_token": "<s>",
|
| 47 |
+
"eos_token": "</s>",
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "<mask>",
|
| 50 |
+
"model_max_length": 8192,
|
| 51 |
+
"pad_token": "<pad>",
|
| 52 |
+
"sep_token": "</s>",
|
| 53 |
+
"sp_model_kwargs": {},
|
| 54 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 55 |
+
"unk_token": "<unk>"
|
| 56 |
+
}
|
models/test_encoder_only_base_bge_reranker_v2_m3_new1/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e3bfec6fe2d9bd57a05c8f683a6cf3ffa069a34df025b2ae4934e55a249913b
|
| 3 |
+
size 7697
|