From a454c212d80fa0a228d707ff20fef570f6eba130 Mon Sep 17 00:00:00 2001 From: Aditya Ghai <119144814+adityaghai07@users.noreply.github.com> Date: Sat, 7 Mar 2026 20:01:30 +0530 Subject: [PATCH] Using a loop to handle the sequence classification parameters. git pull origin fix/bert-num-labels --rebase# pick 779c4b06 Using a loop to handle the sequence classification parameters. --- unsloth/models/vision.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py index 20e92207d8..6691770909 100644 --- a/unsloth/models/vision.py +++ b/unsloth/models/vision.py @@ -784,16 +784,10 @@ class FastBaseModel: # Handle sequence classification parameters (num_labels, id2label, label2id) # These need to be set in the config before model instantiation - num_labels = kwargs.pop("num_labels", None) - id2label = kwargs.pop("id2label", None) - label2id = kwargs.pop("label2id", None) - - if num_labels is not None: - model_config.num_labels = num_labels - if id2label is not None: - model_config.id2label = id2label - if label2id is not None: - model_config.label2id = label2id + for param in ("num_labels", "id2label", "label2id"): + value = kwargs.pop(param, None) + if value is not None: + setattr(model_config, param, value) verify_fp8_support_if_applicable(model_config)