Skip to content

Commit 638bbfc

Browse files
committed
LET"SGO
1 parent 91d40b8 commit 638bbfc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/transformers/core_model_loading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ def convert_and_load_state_dict_in_model(
601601
_dtype = dtype
602602
new_target_key = [] # test_load_with_mismatched_shapes for AutoModel.from_pretrained(AutoForCausal, vocab=10)
603603
for t in target_key.split("|"):
604-
if t.startswith(prefix) and meta_model_state_dict.get(t.replace(f"{prefix}.", "")) is not None:
605-
t = t.replace(f"{prefix}.", "")
604+
if t.startswith(prefix) and meta_model_state_dict.get(re.sub(f"^{prefix}.", "", t, count=1)) is not None:
605+
t = re.sub(f"^{prefix}.", "", t, count=1)
606606
elif meta_model_state_dict.get(f"{prefix}.{t}") is not None:
607607
t = f"{prefix}.{t}"
608608
new_target_key.append(t)

0 commit comments

Comments
 (0)