spam-classifier-liquid / BuildGGUF.command
VoltageVagabond's picture
Update notebooks and project files
5a28a50 verified
raw
history blame
3.04 kB
#!/bin/bash
# =============================================================
# Spam Classifier — Rebuild GGUF + Reload Server
# Run this after retraining to bake the new adapter into
# spam-classifier-F16.gguf and reload the llama.cpp server.
# =============================================================
LIQUID_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJ_DIR="$(dirname "$LIQUID_DIR")"
GGUF_FILE="$PROJ_DIR/spam-classifier-F16.gguf"
MERGED_DIR="$PROJ_DIR/merged-liquid-full"
echo "============================================================"
echo " Spam Classifier — Rebuild GGUF"
echo "============================================================"
echo ""
echo " Adapter: $LIQUID_DIR/adapters"
echo " Output: $PROJ_DIR/spam-classifier-F16.gguf"
echo ""
# ── Check adapter exists ──
if [[ ! -d "$LIQUID_DIR/adapters" ]]; then
echo " ERROR: No adapter found at $LIQUID_DIR/adapters/"
echo " Run retrain.command first."
echo ""
read -n 1 -s -r -p "Press any key to close..."
exit 1
fi
# ── Remove cached merge so new adapter is actually baked in ──
if [[ -d "$MERGED_DIR" ]]; then
echo " Removing cached merged model (so new adapter is used)..."
rm -rf "$MERGED_DIR"
echo " Done."
echo ""
fi
# ── Run merge + GGUF conversion ──
echo " Merging adapter into base model and converting to GGUF..."
echo " (This takes ~5-10 minutes and uses ~8 GB of RAM)"
echo ""
cd "$PROJ_DIR"
source "$LIQUID_DIR/venv/bin/activate"
python3 merge_and_convert_gguf.py
BUILD_STATUS=$?
deactivate
echo ""
if [[ $BUILD_STATUS -ne 0 ]]; then
echo " ERROR: GGUF build failed (exit $BUILD_STATUS)."
echo ""
read -n 1 -s -r -p "Press any key to close..."
exit 1
fi
GGUF_SIZE_MB=$(du -m "$GGUF_FILE" 2>/dev/null | cut -f1)
echo " GGUF rebuilt: spam-classifier-F16.gguf (${GGUF_SIZE_MB} MB)"
echo ""
# ── Upload to HuggingFace ──
echo "------------------------------------------------------------"
echo " Upload new GGUF to HuggingFace? [y/N] "
read -n 1 -s -r hf_choice
echo "$hf_choice"
echo ""
if [[ "$hf_choice" == "y" || "$hf_choice" == "Y" ]]; then
echo " Uploading spam-classifier-F16.gguf..."
python3 - <<PYEOF
from huggingface_hub import HfApi
api = HfApi()
import os
gguf_file = "$GGUF_FILE"
repo_id = "VoltageVagabond/spam-classifier-liquid-GGUF"
print(f" Uploading to {repo_id}...")
api.upload_file(
path_or_fileobj=gguf_file,
path_in_repo="spam-classifier-F16.gguf",
repo_id=repo_id,
repo_type="model",
commit_message="Rebuild GGUF after full retrain",
)
print(f" Done! https://huggingface.co/{repo_id}")
PYEOF
echo ""
fi
# ── Remind to restart server ──
echo "============================================================"
echo " Done! To load the new model into llama.cpp:"
echo ""
echo " 1. Double-click StopServer.command"
echo " 2. Double-click StartServer.command"
echo "============================================================"
echo ""
read -n 1 -s -r -p "Press any key to close..."