Text Generation
Transformers
Safetensors
GGUF
Korean
English
llama
3b
korean
from-scratch
orpo
instruction-tuned
preference-aligned
fp8
b200
Eval Results (legacy)
text-generation-inference
Instructions to use pathcosmos/frankenstallm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pathcosmos/frankenstallm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pathcosmos/frankenstallm")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("pathcosmos/frankenstallm") model = AutoModelForCausalLM.from_pretrained("pathcosmos/frankenstallm", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use pathcosmos/frankenstallm with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf pathcosmos/frankenstallm:Q4_K_M # Run inference directly in the terminal: llama cli -hf pathcosmos/frankenstallm:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf pathcosmos/frankenstallm:Q4_K_M # Run inference directly in the terminal: llama cli -hf pathcosmos/frankenstallm:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf pathcosmos/frankenstallm:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf pathcosmos/frankenstallm:Q4_K_M
Use Docker
docker model run hf.co/pathcosmos/frankenstallm:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use pathcosmos/frankenstallm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pathcosmos/frankenstallm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pathcosmos/frankenstallm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/pathcosmos/frankenstallm:Q4_K_M
- SGLang
How to use pathcosmos/frankenstallm with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "pathcosmos/frankenstallm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pathcosmos/frankenstallm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "pathcosmos/frankenstallm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pathcosmos/frankenstallm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use pathcosmos/frankenstallm with Ollama:
ollama run hf.co/pathcosmos/frankenstallm:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use pathcosmos/frankenstallm with Docker Model Runner:
docker model run hf.co/pathcosmos/frankenstallm:Q4_K_M
- Lemonade
How to use pathcosmos/frankenstallm with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull pathcosmos/frankenstallm:Q4_K_M
Run and chat with the model
lemonade run user.frankenstallm-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Download source/scripts/monitor_3b.sh from pathcosmos/frankenstallm: direct link, hf CLI and curl.
- Browser
- Download file 12.6 kB
-
https://huggingface.co/pathcosmos/frankenstallm/resolve/refs%2Fpr%2F17/source/scripts/monitor_3b.sh
- Command line
-
hf download hf://pathcosmos/frankenstallm@refs/pr/17/source/scripts/monitor_3b.sh
-
curl -L -o monitor_3b.sh https://huggingface.co/pathcosmos/frankenstallm/resolve/refs%2Fpr%2F17/source/scripts/monitor_3b.sh
12.6 kB
| # ============================================================================= | |
| # monitor_3b.sh โ 3B ํ์ต ์ค์๊ฐ ๋ชจ๋ํฐ๋ง + ์ด์ ๊ฐ์ง + ์๋ ์ฒดํฌํฌ์ธํธ ์ ๋ฆฌ | |
| # | |
| # Usage: | |
| # bash scripts/monitor_3b.sh # ๊ธฐ๋ณธ ๊ฐ์ | |
| # bash scripts/monitor_3b.sh --check-once # 1ํ ๊ฒ์ฌ | |
| # bash scripts/monitor_3b.sh --auto-cleanup # ์๋ ์ค๋๋ ์ฒดํฌํฌ์ธํธ ์ญ์ | |
| # | |
| # 3B ํนํ ์ฌํญ: | |
| # - ์ฒดํฌํฌ์ธํธ 27GB/๊ฐ โ ๋์คํฌ ๊ฐ์ ๊ฐํ | |
| # - NCCL hang ๊ฐ์ง + ์๋ ์ฌ์์ ์ต์ | |
| # - ์์ ์๋ฃ ์๊ฐ ์ค์๊ฐ ๊ณ์ฐ | |
| # - ํ๋ก์ธ์ค ์ค๋ณต ์คํ ๋ฐฉ์ง | |
| # ============================================================================= | |
| set -euo pipefail | |
| # ---- Configuration ---------------------------------------------------------- | |
| RUN_NAME="${RUN_NAME:-korean_3b_fp8_run1}" | |
| LOG_FILE="${1:-checkpoints/${RUN_NAME}/train.log}" | |
| CKPT_DIR="checkpoints/${RUN_NAME}" | |
| CHECK_INTERVAL=60 # 3B๋ step ๊ฐ๊ฒฉ ๋ ๊น โ 60์ด | |
| ZERO_LOSS_THRESHOLD=3 | |
| GNORM_WARN=10.0 | |
| GNORM_CRITICAL=50.0 | |
| LOSS_SPIKE_FACTOR=3.0 | |
| STALL_TIMEOUT=600 # 10๋ถ (3B๋ step ๋ ์ค๋ ๊ฑธ๋ฆผ) | |
| DISK_WARN_PCT=85 | |
| DISK_CRITICAL_PCT=92 | |
| GPU_UTIL_WARN=50 | |
| MAX_CHECKPOINTS=15 # ์ต๋ ๋ณด๊ด ์ฒดํฌํฌ์ธํธ ์ (15 ร 27GB = 405GB) | |
| CHECK_ONCE=false | |
| AUTO_CLEANUP=false | |
| AUTO_RESTART=false | |
| # Parse args | |
| for arg in "$@"; do | |
| case "$arg" in | |
| --check-once) CHECK_ONCE=true ;; | |
| --auto-cleanup) AUTO_CLEANUP=true ;; | |
| --auto-restart) AUTO_RESTART=true ;; | |
| esac | |
| done | |
| # Fix LOG_FILE if first arg was a flag | |
| if [[ "$LOG_FILE" == --* ]]; then | |
| LOG_FILE="checkpoints/${RUN_NAME}/train.log" | |
| fi | |
| # ---- Colors ----------------------------------------------------------------- | |
| RED='\033[0;31m'; YELLOW='\033[1;33m'; GREEN='\033[0;32m' | |
| CYAN='\033[0;36m'; MAGENTA='\033[0;35m'; NC='\033[0m' | |
| timestamp() { date '+%Y-%m-%d %H:%M:%S'; } | |
| alert() { | |
| local level="$1" msg="$2" | |
| case "$level" in | |
| CRITICAL) echo -e "${RED}๐ด [$(timestamp)] [CRITICAL] ${msg}${NC}" ;; | |
| WARNING) echo -e "${YELLOW}๐ [$(timestamp)] [WARNING] ${msg}${NC}" ;; | |
| INFO) echo -e "${CYAN}๐ก [$(timestamp)] [INFO] ${msg}${NC}" ;; | |
| OK) echo -e "${GREEN}โ [$(timestamp)] [OK] ${msg}${NC}" ;; | |
| esac | |
| } | |
| # ---- Parse metrics ---------------------------------------------------------- | |
| parse_metrics() { | |
| local n="${1:-20}" | |
| [[ -f "$LOG_FILE" ]] || return | |
| tail -n "$n" "$LOG_FILE" | grep "step.*loss.*gnorm" || true | |
| } | |
| extract_field() { | |
| echo "$1" | grep -oP "${2}\s+\K[0-9]+\.[0-9e+\-]+" | head -1 | |
| } | |
| extract_step() { | |
| echo "$1" | grep -oP "step\s+\K[0-9]+" | head -1 | |
| } | |
| # ---- Check: Loss = 0 ------------------------------------------------------- | |
| check_loss_zero() { | |
| local lines | |
| lines=$(parse_metrics "$ZERO_LOSS_THRESHOLD") | |
| [[ -z "$lines" ]] && return 0 | |
| local zero_count=0 | |
| while IFS= read -r line; do | |
| local loss=$(extract_field "$line" "loss") | |
| if [[ -n "$loss" ]] && (( $(echo "$loss < 0.001" | bc -l 2>/dev/null || echo 0) )); then | |
| ((zero_count++)) | |
| fi | |
| done <<< "$lines" | |
| if [[ $zero_count -ge $ZERO_LOSS_THRESHOLD ]]; then | |
| alert CRITICAL "Loss๊ฐ ${zero_count}ํ ์ฐ์ ~0! Labels ๋ฒ๊ทธ. ์ฆ์ ์ค๋จ!" | |
| return 1 | |
| fi | |
| } | |
| # ---- Check: Loss spike ----------------------------------------------------- | |
| check_loss_spike() { | |
| local lines=$(parse_metrics 20) | |
| [[ -z "$lines" ]] && return 0 | |
| local losses=() | |
| while IFS= read -r line; do | |
| local loss=$(extract_field "$line" "loss") | |
| [[ -n "$loss" ]] && losses+=("$loss") | |
| done <<< "$lines" | |
| local count=${#losses[@]} | |
| [[ $count -lt 5 ]] && return 0 | |
| local last="${losses[$((count-1))]}" | |
| local sum=0 | |
| for ((i=0; i<count-1; i++)); do | |
| sum=$(echo "$sum + ${losses[$i]}" | bc -l 2>/dev/null || echo "$sum") | |
| done | |
| local avg=$(echo "$sum / ($count - 1)" | bc -l 2>/dev/null || echo "0") | |
| if [[ "$avg" != "0" ]]; then | |
| local ratio=$(echo "$last / $avg" | bc -l 2>/dev/null || echo "1") | |
| if (( $(echo "$ratio > $LOSS_SPIKE_FACTOR" | bc -l 2>/dev/null || echo 0) )); then | |
| alert WARNING "Loss spike! ํ์ฌ=${last}, ํ๊ท =${avg}, ๋น์จ=${ratio}x" | |
| fi | |
| fi | |
| } | |
| # ---- Check: Gradient norm --------------------------------------------------- | |
| check_gnorm() { | |
| local lines=$(parse_metrics 5) | |
| [[ -z "$lines" ]] && return 0 | |
| local gnorm=$(extract_field "$(echo "$lines" | tail -1)" "gnorm") | |
| [[ -z "$gnorm" ]] && return 0 | |
| if (( $(echo "$gnorm > $GNORM_CRITICAL" | bc -l 2>/dev/null || echo 0) )); then | |
| alert CRITICAL "GNorm=${gnorm} > ${GNORM_CRITICAL}! ๋ฐ์ฐ ์ง์ ." | |
| elif (( $(echo "$gnorm > $GNORM_WARN" | bc -l 2>/dev/null || echo 0) )); then | |
| alert WARNING "GNorm=${gnorm} ๋ถ์์ ." | |
| fi | |
| } | |
| # ---- Check: Stall / NCCL hang ---------------------------------------------- | |
| check_stall() { | |
| [[ ! -f "$LOG_FILE" ]] && return 0 | |
| local last_mod=$(stat -c %Y "$LOG_FILE" 2>/dev/null || echo 0) | |
| local now=$(date +%s) | |
| local diff=$((now - last_mod)) | |
| if [[ $diff -gt $STALL_TIMEOUT ]]; then | |
| alert CRITICAL "๋ก๊ทธ ${diff}์ด ($(( diff/60 ))๋ถ) ๋ฉ์ถค! NCCL hang ๊ฐ๋ฅ์ฑ." | |
| # NCCL hang ์๋ ์ฌ์์ | |
| if $AUTO_RESTART; then | |
| alert WARNING "์๋ ์ฌ์์ ์๋..." | |
| local pid=$(pgrep -f "pretrain.py.*korean_3b" | head -1 || true) | |
| if [[ -n "$pid" ]]; then | |
| kill -9 "$pid" 2>/dev/null || true | |
| sleep 5 | |
| alert INFO "์ด์ ํ๋ก์ธ์ค ์ข ๋ฃ. launch_3b_pretrain.sh ์ฌ์คํ ํ์." | |
| fi | |
| fi | |
| fi | |
| } | |
| # ---- Check: Disk (3B ๊ฐํ) -------------------------------------------------- | |
| check_disk() { | |
| local usage=$(df /PROJECT 2>/dev/null | awk 'NR==2 {print $5}' | tr -d '%') | |
| if [[ -n "$usage" && "$usage" -gt "$DISK_CRITICAL_PCT" ]]; then | |
| alert CRITICAL "๋์คํฌ ${usage}% > ${DISK_CRITICAL_PCT}%! ์ฆ์ ์ ๋ฆฌ ํ์!" | |
| $AUTO_CLEANUP && cleanup_old_checkpoints | |
| elif [[ -n "$usage" && "$usage" -gt "$DISK_WARN_PCT" ]]; then | |
| alert WARNING "๋์คํฌ ${usage}% > ${DISK_WARN_PCT}%. ์ฒดํฌํฌ์ธํธ ์ ๋ฆฌ ๊ถ์ฅ." | |
| fi | |
| } | |
| # ---- Check: GPU utilization ------------------------------------------------- | |
| check_gpu() { | |
| command -v nvidia-smi &>/dev/null || return 0 | |
| local low=0 total=0 | |
| while IFS= read -r util; do | |
| ((total++)) | |
| [[ "$util" -lt "$GPU_UTIL_WARN" ]] && ((low++)) | |
| done < <(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits 2>/dev/null) | |
| [[ $total -gt 0 && $low -gt 0 ]] && alert INFO "${low}/${total} GPU util < ${GPU_UTIL_WARN}%" | |
| } | |
| # ---- Check: ์ฒดํฌํฌ์ธํธ ๋ฌด๊ฒฐ์ฑ ----------------------------------------------- | |
| check_checkpoint_integrity() { | |
| local latest=$(ls -d "${CKPT_DIR}"/checkpoint-* 2>/dev/null | sort -V | tail -1 || true) | |
| [[ -z "$latest" ]] && return 0 | |
| # ์ต์ ํ์ผ ์กด์ฌ ํ์ธ | |
| if [[ ! -f "${latest}/model.pt" ]] && [[ ! -f "${latest}/model.safetensors" ]]; then | |
| alert WARNING "์ต๊ทผ ์ฒดํฌํฌ์ธํธ์ ๋ชจ๋ธ ํ์ผ ์์: ${latest}" | |
| fi | |
| # ํฌ๊ธฐ ํ์ธ (3B model.pt๋ ์ต์ 2GB) | |
| local size=$(du -sb "${latest}" 2>/dev/null | awk '{print $1}') | |
| if [[ -n "$size" && "$size" -lt 2000000000 ]]; then | |
| alert WARNING "์ฒดํฌํฌ์ธํธ ํฌ๊ธฐ ๋น์ ์ (${size} bytes < 2GB): ${latest}" | |
| fi | |
| } | |
| # ---- Cleanup: ์ค๋๋ ์ฒดํฌํฌ์ธํธ ์๋ ์ญ์ ------------------------------------ | |
| cleanup_old_checkpoints() { | |
| local ckpts=($(ls -d "${CKPT_DIR}"/checkpoint-* 2>/dev/null | sort -V)) | |
| local count=${#ckpts[@]} | |
| if [[ $count -le $MAX_CHECKPOINTS ]]; then | |
| alert OK "์ฒดํฌํฌ์ธํธ ${count}๊ฐ โค ${MAX_CHECKPOINTS}. ์ ๋ฆฌ ๋ถํ์." | |
| return | |
| fi | |
| # ์ด์ ํ ์ฒดํฌํฌ์ธํธ ๋ณด์กด (๋งค 10K step) | |
| local deletable=() | |
| local preserved=() | |
| for ckpt in "${ckpts[@]}"; do | |
| local step_num=$(basename "$ckpt" | grep -oP '\d+' || echo "0") | |
| if (( step_num % 10000 == 0 && step_num > 0 )); then | |
| preserved+=("$ckpt") | |
| else | |
| deletable+=("$ckpt") | |
| fi | |
| done | |
| # ์ต๊ทผ MAX_CHECKPOINTS๊ฐ๋ ๋ฌด์กฐ๊ฑด ๋ณด์กด | |
| local n_deletable=${#deletable[@]} | |
| local total_keep=$(( ${#preserved[@]} + MAX_CHECKPOINTS )) | |
| local to_delete=$(( count - total_keep )) | |
| [[ $to_delete -le 0 ]] && { alert OK "์ ๋ฆฌ ๋ถํ์ (์ด์ ํ ${#preserved[@]}๊ฐ + ์ต๊ทผ ${MAX_CHECKPOINTS}๊ฐ ๋ณด์กด)."; return; } | |
| alert INFO "${count}๊ฐ ์ฒดํฌํฌ์ธํธ โ ${to_delete}๊ฐ ์ญ์ (์ด์ ํ ${#preserved[@]}๊ฐ ์๊ตฌ ๋ณด์กด)" | |
| local deleted=0 | |
| for ckpt in "${deletable[@]}"; do | |
| [[ $deleted -ge $to_delete ]] && break | |
| local ckpt_size=$(du -sh "$ckpt" 2>/dev/null | awk '{print $1}') | |
| echo " ์ญ์ : $ckpt (${ckpt_size})" | |
| rm -rf "$ckpt" | |
| ((deleted++)) | |
| done | |
| alert OK "์ฒดํฌํฌ์ธํธ ์ ๋ฆฌ ์๋ฃ. (${deleted}๊ฐ ์ญ์ )" | |
| } | |
| # ---- ETA ๊ณ์ฐ --------------------------------------------------------------- | |
| estimate_eta() { | |
| [[ ! -f "$LOG_FILE" ]] && return | |
| # ์ต๊ทผ step ๋ฒํธ + ์๊ฐ | |
| local lines=$(parse_metrics 50) | |
| [[ -z "$lines" ]] && return | |
| local last_line=$(echo "$lines" | tail -1) | |
| local first_line=$(echo "$lines" | head -1) | |
| local cur_step=$(extract_step "$last_line") | |
| local max_steps=$(grep -oP "max_steps.*?(\d+)" "${CKPT_DIR}/train.log" 2>/dev/null | head -1 | grep -oP '\d+$' || echo "57000") | |
| [[ -z "$cur_step" || "$cur_step" == "0" ]] && return | |
| # step/sec from log timestamps (approximate) | |
| local remaining=$((max_steps - cur_step)) | |
| if [[ $remaining -le 0 ]]; then | |
| echo -e "${MAGENTA}๐ ์งํ: ${cur_step}/${max_steps} (์๋ฃ!)${NC}" | |
| return | |
| fi | |
| # ํ์ผ ์์ ์๊ฐ ๊ธฐ๋ฐ rough ETA | |
| local first_time=$(head -20 "$LOG_FILE" 2>/dev/null | grep -oP '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}' | head -1 || true) | |
| if [[ -n "$first_time" ]]; then | |
| local start_epoch=$(date -d "$first_time" +%s 2>/dev/null || echo 0) | |
| local now=$(date +%s) | |
| if [[ $start_epoch -gt 0 && $cur_step -gt 0 ]]; then | |
| local elapsed=$((now - start_epoch)) | |
| local sec_per_step=$(echo "$elapsed / $cur_step" | bc -l 2>/dev/null || echo "0") | |
| local eta_sec=$(echo "$remaining * $sec_per_step" | bc 2>/dev/null | cut -d. -f1 || echo "0") | |
| local eta_hours=$(echo "$eta_sec / 3600" | bc 2>/dev/null || echo "?") | |
| local pct=$(echo "scale=1; $cur_step * 100 / $max_steps" | bc 2>/dev/null || echo "?") | |
| echo -e "${MAGENTA}๐ ์งํ: ${cur_step}/${max_steps} (${pct}%) | ๋จ์ ์๊ฐ: ~${eta_hours}h | ${sec_per_step}s/step${NC}" | |
| fi | |
| else | |
| echo -e "${MAGENTA}๐ ์งํ: ${cur_step}/${max_steps}${NC}" | |
| fi | |
| } | |
| # ---- Status summary --------------------------------------------------------- | |
| print_status() { | |
| local lines=$(parse_metrics 1) | |
| [[ -n "$lines" ]] && echo -e "${GREEN}์ต๊ทผ:${NC} $lines" | |
| estimate_eta | |
| if command -v nvidia-smi &>/dev/null; then | |
| echo -e "${CYAN}GPU:${NC}" | |
| nvidia-smi --query-gpu=index,memory.used,memory.total,utilization.gpu,temperature.gpu \ | |
| --format=csv,noheader 2>/dev/null | head -8 | |
| fi | |
| local ckpt_count=$(ls -d "${CKPT_DIR}"/checkpoint-* 2>/dev/null | wc -l) | |
| local ckpt_size=$(du -sh "${CKPT_DIR}" 2>/dev/null | awk '{print $1}') | |
| echo -e "${CYAN}์ฒดํฌํฌ์ธํธ:${NC} ${ckpt_count}๊ฐ (${ckpt_size})" | |
| local disk=$(df -h /PROJECT 2>/dev/null | awk 'NR==2 {print $3"/"$2" ("$5")"}') | |
| echo -e "${CYAN}๋์คํฌ:${NC} ${disk}" | |
| } | |
| # ---- Main ------------------------------------------------------------------- | |
| echo "==================================================================" | |
| echo " 3B Training Monitor" | |
| echo " Run: ${RUN_NAME}" | |
| echo " Log: ${LOG_FILE}" | |
| echo " Interval: ${CHECK_INTERVAL}s" | |
| echo " Auto-cleanup: ${AUTO_CLEANUP} | Auto-restart: ${AUTO_RESTART}" | |
| echo " Ctrl+C to stop" | |
| echo "==================================================================" | |
| run_all_checks() { | |
| check_loss_zero || true | |
| check_loss_spike || true | |
| check_gnorm || true | |
| check_stall || true | |
| check_disk || true | |
| check_gpu || true | |
| check_checkpoint_integrity || true | |
| echo "---" | |
| print_status | |
| echo "" | |
| } | |
| if $CHECK_ONCE; then | |
| run_all_checks | |
| exit 0 | |
| fi | |
| while true; do | |
| run_all_checks | |
| sleep "$CHECK_INTERVAL" | |
| done | |