Views
No views yet
microsoft/deberta-v3-large, the model utilizes partial layer freezing, dynamic 3D sequence collating, 8-bit AdamW optimization, and custom Adversarial Weight Perturbation (AWP) to prevent overfitting and improve generalization across distribution shifts.dahaludba/QSolver_Encoder_V2microsoft/deberta-v3-largeAutoModelForMultipleChoiceoptim="adamw_8bit" via bitsandbytes)deberta.encoder.layer.0 through 11) out of 24 layers were completely frozen. Only the top 12 layers (12 through 23) and the multiple-choice classification head were fine-tuned.AWPTrainer.word_embeddings parameters.1e-31e-2 (limits weight perturbation magnitude to within 1% of original parameter weights).CustomDataCollator dynamically pads sequences within each batch and reshapes tensors into 3D shapes (batch_size, num_choices, max_seq_len) for compute-efficient batch passes through AutoModelForMultipleChoice.| Hyperparameter | Value |
|---|---|
| Peak Learning Rate | 8e-6 |
| LR Scheduler | Cosine Decay |
| Warmup Steps | 30 |
| Optimizer | adamw_8bit (bitsandbytes) |
| Weight Decay | 0.01 |
| Per Device Train Batch Size | 1 |
| Per Device Eval Batch Size | 1 |
| Gradient Accumulation Steps | 16 (Effective Batch Size = 16) |
| Training Epochs | 4 per fold |
| Floating Point Precision | Full FP32 (fp16=False) |
| Gradient Checkpointing | Enabled (use_reentrant=False, use_cache=False) |
| Frozen Layers | Encoder layers 0 to 11 |
| Metric Monitored | MAP@3 (eval_map@3) |
| Seed | 42 |
1import torch
2import numpy as np
3import itertools
4from transformers import AutoTokenizer, AutoModelForMultipleChoice
5
6REPO_ID = "dahaludba/QSolver_Encoder_V2"
7SUBFOLDER = "fold_1"
8
9# Load Tokenizer & Model
10tokenizer = AutoTokenizer.from_pretrained("microsoft/deberta-v3-large")
11model = AutoModelForMultipleChoice.from_pretrained(REPO_ID, subfolder=SUBFOLDER)
12model.eval()
13
14# Sample Question and Options
15question = "Which organelle is responsible for cellular respiration in eukaryotic cells?"
16options = [
17 "Lysosome",
18 "Mitochondria",
19 "Chloroplast",
20 "Golgi Apparatus",
21 "Peroxisome"
22]
23
24# Pair Question with Options
25first_sentences = [question] * 5
26second_sentences = options
27
28# Tokenize paired sequences
29inputs = tokenizer(
30 first_sentences,
31 second_sentences,
32 truncation=True,
33 max_length=512,
34 padding=True,
35 return_tensors="pt"
36)
37
38# Reshape inputs to 3D tensors (batch_size=1, num_choices=5, seq_len)
39batch_inputs = {
40 k: v.unsqueeze(0) for k, v in inputs.items()
41}
42
43with torch.no_grad():
44 outputs = model(**batch_inputs)
45 logits = outputs.logits.cpu().numpy()[0]
46
47# Rank top choices
48option_letters = ["A", "B", "C", "D", "E"]
49top3_indices = np.argsort(-logits)[:3]
50top3_predictions = [f"{option_letters[idx]}: {options[idx]}" for idx in top3_indices]
51
52print("Top 3 Predictions:", top3_predictions)