|
|
from unsloth import FastLanguageModel |
|
|
import torch |
|
|
import os |
|
|
import glob |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(">>> [System] GGUF λ³ν μμ
μ μμν©λλ€...") |
|
|
|
|
|
|
|
|
output_dir = "outputs_final" |
|
|
|
|
|
if not os.path.exists(output_dir): |
|
|
print(f">>> [Error] '{output_dir}' ν΄λκ° μμ΅λλ€!") |
|
|
exit() |
|
|
|
|
|
|
|
|
subfolders = [f.path for f in os.scandir(output_dir) if f.is_dir() and "checkpoint" in f.name] |
|
|
|
|
|
if not subfolders: |
|
|
print(">>> [Error] 체ν¬ν¬μΈνΈ ν΄λλ₯Ό μ°Ύμ μ μμ΅λλ€!") |
|
|
exit() |
|
|
|
|
|
|
|
|
latest_checkpoint = max(subfolders, key=lambda x: int(x.split('-')[-1])) |
|
|
|
|
|
print(f">>> [Found] κ°μ₯ νμ΅μ΄ μ λ λͺ¨λΈμ μ°Ύμμ΅λλ€: {latest_checkpoint}") |
|
|
print(">>> [Model] λͺ¨λΈ λ‘λ μ€... (xFormers κ²½κ³ λ 무μνμΈμ)") |
|
|
|
|
|
|
|
|
model, tokenizer = FastLanguageModel.from_pretrained( |
|
|
model_name = latest_checkpoint, |
|
|
max_seq_length = 2048, |
|
|
dtype = None, |
|
|
load_in_4bit = True, |
|
|
) |
|
|
|
|
|
|
|
|
print(f">>> [Convert] '{latest_checkpoint}' -> GGUF λ³ν μμ (5~10λΆ μμ)") |
|
|
|
|
|
|
|
|
model.save_pretrained_gguf("BiddinMate_Model", tokenizer, quantization_method = "q4_k_m") |
|
|
|
|
|
print(">>> [Success] λ³ν μλ£!") |
|
|
print(f">>> 'BiddinMate_Model' ν΄λ μμ .gguf νμΌμ΄ μμ±λμμ΅λλ€.") |
|
|
|