NemoVonNirgend commited on
Commit
7a9c4fd
·
verified ·
1 Parent(s): 381d23f

Upload merge_ministral.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. merge_ministral.py +7 -14
merge_ministral.py CHANGED
@@ -13,8 +13,7 @@ print("Base: mistralai/Ministral-3-14B-Base-2512")
13
  print("LoRA: RoleModel/ministral-14b-reasoning-merged")
14
  print("Output: RoleModel/ministral-14b-merged-official")
15
 
16
- print("
17
- [1/5] Loading base model...")
18
  base = AutoModelForCausalLM.from_pretrained(
19
  "mistralai/Ministral-3-14B-Base-2512",
20
  torch_dtype=torch.bfloat16,
@@ -23,29 +22,24 @@ base = AutoModelForCausalLM.from_pretrained(
23
  )
24
  print(f"Base model class: {base.__class__.__name__}")
25
 
26
- print("
27
- [2/5] Loading LoRA adapter...")
28
  model = PeftModel.from_pretrained(base, "RoleModel/ministral-14b-reasoning-merged")
29
  print("LoRA adapter loaded")
30
 
31
- print("
32
- [3/5] Merging weights...")
33
  merged = model.merge_and_unload()
34
  print("Merge complete")
35
 
36
- print("
37
- [4/5] Saving merged model...")
38
  merged.save_pretrained("./merged-model", safe_serialization=True)
39
  print("Model saved locally")
40
 
41
- print("
42
- [4b/5] Saving tokenizer...")
43
  tok = AutoTokenizer.from_pretrained("mistralai/Ministral-3-14B-Base-2512", trust_remote_code=True)
44
  tok.save_pretrained("./merged-model")
45
  print("Tokenizer saved")
46
 
47
- print("
48
- [5/5] Pushing to Hub...")
49
  api = HfApi()
50
  api.create_repo("RoleModel/ministral-14b-merged-official", exist_ok=True, private=True, token=os.environ.get("HF_TOKEN"))
51
  api.upload_folder(
@@ -55,6 +49,5 @@ api.upload_folder(
55
  token=os.environ.get("HF_TOKEN")
56
  )
57
 
58
- print("
59
- === DONE ===")
60
  print("Merged model: https://huggingface.co/RoleModel/ministral-14b-merged-official")
 
13
  print("LoRA: RoleModel/ministral-14b-reasoning-merged")
14
  print("Output: RoleModel/ministral-14b-merged-official")
15
 
16
+ print("[1/5] Loading base model...")
 
17
  base = AutoModelForCausalLM.from_pretrained(
18
  "mistralai/Ministral-3-14B-Base-2512",
19
  torch_dtype=torch.bfloat16,
 
22
  )
23
  print(f"Base model class: {base.__class__.__name__}")
24
 
25
+ print("[2/5] Loading LoRA adapter...")
 
26
  model = PeftModel.from_pretrained(base, "RoleModel/ministral-14b-reasoning-merged")
27
  print("LoRA adapter loaded")
28
 
29
+ print("[3/5] Merging weights...")
 
30
  merged = model.merge_and_unload()
31
  print("Merge complete")
32
 
33
+ print("[4/5] Saving merged model...")
 
34
  merged.save_pretrained("./merged-model", safe_serialization=True)
35
  print("Model saved locally")
36
 
37
+ print("[4b/5] Saving tokenizer...")
 
38
  tok = AutoTokenizer.from_pretrained("mistralai/Ministral-3-14B-Base-2512", trust_remote_code=True)
39
  tok.save_pretrained("./merged-model")
40
  print("Tokenizer saved")
41
 
42
+ print("[5/5] Pushing to Hub...")
 
43
  api = HfApi()
44
  api.create_repo("RoleModel/ministral-14b-merged-official", exist_ok=True, private=True, token=os.environ.get("HF_TOKEN"))
45
  api.upload_folder(
 
49
  token=os.environ.get("HF_TOKEN")
50
  )
51
 
52
+ print("=== DONE ===")
 
53
  print("Merged model: https://huggingface.co/RoleModel/ministral-14b-merged-official")