Upload convert_to_gguf.py with huggingface_hub
Browse files- convert_to_gguf.py +21 -0
convert_to_gguf.py
CHANGED
|
@@ -11,6 +11,7 @@
|
|
| 11 |
# "numpy",
|
| 12 |
# "gguf",
|
| 13 |
# ]
|
|
|
|
| 14 |
# ///
|
| 15 |
|
| 16 |
"""
|
|
@@ -28,6 +29,23 @@ from huggingface_hub import HfApi
|
|
| 28 |
import subprocess
|
| 29 |
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def run_command(cmd, description):
|
| 32 |
"""Run a command with error handling."""
|
| 33 |
print(f" {description}...")
|
|
@@ -54,6 +72,9 @@ def run_command(cmd, description):
|
|
| 54 |
print("🔄 GGUF Conversion - Q4_K_M")
|
| 55 |
print("=" * 60)
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
# Configuration from environment variables
|
| 58 |
ADAPTER_MODEL = os.environ.get("ADAPTER_MODEL", "albertlieadrian/qwen3-0.6b-codeforces-sft")
|
| 59 |
BASE_MODEL = os.environ.get("BASE_MODEL", "Qwen/Qwen3-0.6B")
|
|
|
|
| 11 |
# "numpy",
|
| 12 |
# "gguf",
|
| 13 |
# ]
|
| 14 |
+
# system_dependencies = ["build-essential", "cmake", "git"]
|
| 15 |
# ///
|
| 16 |
|
| 17 |
"""
|
|
|
|
| 29 |
import subprocess
|
| 30 |
|
| 31 |
|
| 32 |
+
def install_build_tools():
|
| 33 |
+
"""Install build tools required for llama.cpp."""
|
| 34 |
+
print(" Installing build tools...")
|
| 35 |
+
try:
|
| 36 |
+
# Update and install build tools
|
| 37 |
+
subprocess.run(["apt-get", "update", "-qq"], check=True, capture_output=True)
|
| 38 |
+
subprocess.run([
|
| 39 |
+
"apt-get", "install", "-y", "-qq",
|
| 40 |
+
"build-essential", "cmake", "git"
|
| 41 |
+
], check=True, capture_output=True)
|
| 42 |
+
print(" ✅ Build tools installed")
|
| 43 |
+
return True
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f" ❌ Failed to install build tools: {e}")
|
| 46 |
+
return False
|
| 47 |
+
|
| 48 |
+
|
| 49 |
def run_command(cmd, description):
|
| 50 |
"""Run a command with error handling."""
|
| 51 |
print(f" {description}...")
|
|
|
|
| 72 |
print("🔄 GGUF Conversion - Q4_K_M")
|
| 73 |
print("=" * 60)
|
| 74 |
|
| 75 |
+
# Install build tools FIRST (before cloning llama.cpp)
|
| 76 |
+
install_build_tools()
|
| 77 |
+
|
| 78 |
# Configuration from environment variables
|
| 79 |
ADAPTER_MODEL = os.environ.get("ADAPTER_MODEL", "albertlieadrian/qwen3-0.6b-codeforces-sft")
|
| 80 |
BASE_MODEL = os.environ.get("BASE_MODEL", "Qwen/Qwen3-0.6B")
|