#!/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 - <