From c7ae1afd48f232a2cb6c05bb801221f628fffca7 Mon Sep 17 00:00:00 2001 From: whybe-choi Date: Sun, 9 Feb 2025 17:11:45 +0900 Subject: [PATCH] Fix typos in LLARA --- research/LLARA/README.md | 2 +- research/LLARA/finetune/arguments.py | 2 +- research/LLARA/finetune/modeling.py | 12 ++++++------ research/LLARA/finetune/run.py | 2 +- research/LLARA/finetune/trainer.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/research/LLARA/README.md b/research/LLARA/README.md index 93058948..95f0bae7 100644 --- a/research/LLARA/README.md +++ b/research/LLARA/README.md @@ -163,7 +163,7 @@ run.py \ --num_train_epochs 1 \ --per_device_train_batch_size 1 \ --dataloader_drop_last True \ ---normlized True \ +--normalized True \ --temperature 0.01 \ --query_max_len 64 \ --passage_max_len 160 \ diff --git a/research/LLARA/finetune/arguments.py b/research/LLARA/finetune/arguments.py index 2543d6e0..a8210a29 100644 --- a/research/LLARA/finetune/arguments.py +++ b/research/LLARA/finetune/arguments.py @@ -160,6 +160,6 @@ class RetrieverTrainingArguments(TrainingArguments): temperature: Optional[float] = field(default=0.02) fix_position_embedding: bool = field(default=False, metadata={"help": "Freeze the parameters of position embeddings"}) sentence_pooling_method: str = field(default='cls', metadata={"help": "the pooling method, should be cls or mean"}) - normlized: bool = field(default=True) + normalized: bool = field(default=True) sub_batch_size: int = field(default=None) cache_chunk_size: int = field(default=-1, metadata={"help": "用于缓存每一步的执行."}) \ No newline at end of file diff --git a/research/LLARA/finetune/modeling.py b/research/LLARA/finetune/modeling.py index fc5e342a..ae69ff56 100644 --- a/research/LLARA/finetune/modeling.py +++ b/research/LLARA/finetune/modeling.py @@ -27,7 +27,7 @@ class BiEncoderModel(nn.Module): def __init__(self, model: AutoModel = None, tokenizer: AutoTokenizer = None, - normlized: bool = False, + normalized: bool = False, negatives_cross_device: bool = False, temperature: float = 1.0, sub_batch_size: int = -1 @@ -38,9 +38,9 @@ def __init__(self, self.tokenizer = tokenizer self.cross_entropy = nn.CrossEntropyLoss(reduction='mean') - self.normlized = normlized + self.normalized = normalized self.temperature = temperature - if not normlized: + if not normalized: self.temperature = 1.0 logger.info("reset temperature = 1.0 due to using inner product to compute similarity") @@ -80,14 +80,14 @@ def encode(self, features): p_reps = torch.mean(p_reps, dim=1) all_p_reps.append(p_reps) all_p_reps = torch.cat(all_p_reps, 0).contiguous() - if self.normlized: + if self.normalized: all_p_reps = torch.nn.functional.normalize(all_p_reps, dim=-1) return all_p_reps.contiguous() else: psg_out = self.model(**features, return_dict=True, output_hidden_states=True) p_reps = psg_out.hidden_states[-1][:, -8:, :] p_reps = torch.mean(p_reps, dim=1) - if self.normlized: + if self.normalized: p_reps = torch.nn.functional.normalize(p_reps, dim=-1) return p_reps.contiguous() else: @@ -99,7 +99,7 @@ def encode(self, features): p_reps = torch.mean(p_reps, dim=1) all_p_reps.append(p_reps) all_p_reps = torch.cat(all_p_reps, 0).contiguous() - if self.normlized: + if self.normalized: all_p_reps = torch.nn.functional.normalize(all_p_reps, dim=-1) return all_p_reps.contiguous() diff --git a/research/LLARA/finetune/run.py b/research/LLARA/finetune/run.py index f2b4cd60..4f5efd8e 100644 --- a/research/LLARA/finetune/run.py +++ b/research/LLARA/finetune/run.py @@ -80,7 +80,7 @@ def main(): model = BiEncoderModel(model=base_model, tokenizer=tokenizer, - normlized=training_args.normlized, + normalized=training_args.normalized, negatives_cross_device=training_args.negatives_cross_device, temperature=training_args.temperature, sub_batch_size=training_args.sub_batch_size) diff --git a/research/LLARA/finetune/trainer.py b/research/LLARA/finetune/trainer.py index c1c6c0db..f012e8ce 100644 --- a/research/LLARA/finetune/trainer.py +++ b/research/LLARA/finetune/trainer.py @@ -23,7 +23,7 @@ def _save(self, output_dir: Optional[str] = None, state_dict=None): # if self.is_world_process_zero(): # save_ckpt_for_sentence_transformers(output_dir, # pooling_mode=self.args.sentence_pooling_method, - # normlized=self.args.normlized) + # normalized=self.args.normalized) def compute_loss(self, model, inputs, return_outputs=False): """