Upload convert_gguf.py with huggingface_hub
Browse files- convert_gguf.py +10 -6
convert_gguf.py
CHANGED
|
@@ -4,22 +4,26 @@
|
|
| 4 |
"""Convert LoRA adapter to GGUF using Unsloth's built-in conversion."""
|
| 5 |
|
| 6 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from huggingface_hub import HfApi, create_repo
|
| 8 |
|
| 9 |
# Config
|
| 10 |
-
BASE_MODEL = "unsloth/functiongemma-270m-it"
|
| 11 |
ADAPTER_MODEL = "victor/functiongemma-agent-finetuned"
|
| 12 |
OUTPUT_REPO = "victor/functiongemma-agent-gguf"
|
| 13 |
|
| 14 |
print("=" * 60)
|
| 15 |
print("GGUF Conversion with Unsloth")
|
| 16 |
-
print("=" * 60)
|
| 17 |
-
print(f"Base: {BASE_MODEL}")
|
| 18 |
print(f"Adapter: {ADAPTER_MODEL}")
|
| 19 |
print(f"Output: {OUTPUT_REPO}")
|
| 20 |
print("=" * 60)
|
| 21 |
|
| 22 |
-
# Load model with adapter
|
| 23 |
from unsloth import FastLanguageModel
|
| 24 |
|
| 25 |
print("Loading model with LoRA adapter...")
|
|
@@ -38,7 +42,7 @@ try:
|
|
| 38 |
except Exception as e:
|
| 39 |
print(f"Repo creation: {e}")
|
| 40 |
|
| 41 |
-
# Save as GGUF
|
| 42 |
print("Converting to GGUF (q4_k_m)...")
|
| 43 |
model.save_pretrained_gguf(
|
| 44 |
"model",
|
|
@@ -56,5 +60,5 @@ api.upload_folder(
|
|
| 56 |
|
| 57 |
print("=" * 60)
|
| 58 |
print("DONE!")
|
| 59 |
-
print(f"Model
|
| 60 |
print("=" * 60)
|
|
|
|
| 4 |
"""Convert LoRA adapter to GGUF using Unsloth's built-in conversion."""
|
| 5 |
|
| 6 |
import os
|
| 7 |
+
import subprocess
|
| 8 |
+
|
| 9 |
+
# Pre-install cmake to avoid interactive prompt
|
| 10 |
+
print("Installing cmake...")
|
| 11 |
+
subprocess.run(["apt-get", "update", "-qq"], check=True)
|
| 12 |
+
subprocess.run(["apt-get", "install", "-y", "-qq", "cmake", "build-essential"], check=True)
|
| 13 |
+
print("cmake installed!")
|
| 14 |
+
|
| 15 |
from huggingface_hub import HfApi, create_repo
|
| 16 |
|
| 17 |
# Config
|
|
|
|
| 18 |
ADAPTER_MODEL = "victor/functiongemma-agent-finetuned"
|
| 19 |
OUTPUT_REPO = "victor/functiongemma-agent-gguf"
|
| 20 |
|
| 21 |
print("=" * 60)
|
| 22 |
print("GGUF Conversion with Unsloth")
|
|
|
|
|
|
|
| 23 |
print(f"Adapter: {ADAPTER_MODEL}")
|
| 24 |
print(f"Output: {OUTPUT_REPO}")
|
| 25 |
print("=" * 60)
|
| 26 |
|
|
|
|
| 27 |
from unsloth import FastLanguageModel
|
| 28 |
|
| 29 |
print("Loading model with LoRA adapter...")
|
|
|
|
| 42 |
except Exception as e:
|
| 43 |
print(f"Repo creation: {e}")
|
| 44 |
|
| 45 |
+
# Save as GGUF
|
| 46 |
print("Converting to GGUF (q4_k_m)...")
|
| 47 |
model.save_pretrained_gguf(
|
| 48 |
"model",
|
|
|
|
| 60 |
|
| 61 |
print("=" * 60)
|
| 62 |
print("DONE!")
|
| 63 |
+
print(f"Model: https://huggingface.co/{OUTPUT_REPO}")
|
| 64 |
print("=" * 60)
|