Text Generation
llama-cpp-python
GGUF
llama.cpp
Mixture of Experts
ssd-offload
smallthinker
expert-paging
low-ram
Instructions to use HelloSun/SmallThinker4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use HelloSun/SmallThinker4b with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="HelloSun/SmallThinker4b", filename="{{GGUF_FILE}}", )output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
File size: 2,849 Bytes
faea13d 9460178 faea13d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/usr/bin/env bash
# ==============================================================================
# sync.sh — 把工作成果推回 Hugging Face(agent 崩潰後的唯一保險)
#
# ./sync.sh "訊息" # 提交並推到 HelloSun/SmallThinker4b
# ./sync.sh --status # 只看狀態
# ./sync.sh --pull # 從遠端拉回最新(崩潰後續作第一步)
#
# 原則:**每改完程式並編譯過就上傳,不要累積。**
# Token: 環境變數 HF_TOKEN,或檔案 .hf_token
# ==============================================================================
set -uo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
STORAGE_REPO="${ST_STORAGE_REPO:-HelloSun/SmallThinker4b}"
MODE=push
MSG=""
for a in "$@"; do
case "$a" in
--status) MODE=status ;;
--pull) MODE=pull ;;
*) MSG="$a" ;;
esac
done
[[ -z "$MSG" ]] && MSG="sync: $(date -Iseconds)"
cd "$REPO_DIR" || { echo "[sync] 沒有 repo 目錄"; exit 1; }
# ── token ──
if [[ -z "${HF_TOKEN:-}" && -f "$REPO_DIR/.hf_token" ]]; then
HF_TOKEN="$(tr -d ' \n\r' < "$REPO_DIR/.hf_token")"
fi
if [[ -z "${HF_TOKEN:-}" ]]; then
echo "[sync] 找不到 HF_TOKEN"; exit 1
fi
export HF_TOKEN
git config user.email "${HF_GIT_EMAIL:-agent@huggingface.co}"
git config user.name "${HF_GIT_NAME:-Auto Upload Agent}"
ensure_remote() {
local name="$1" repo="$2"
local url="https://oauth2:${HF_TOKEN}@huggingface.co/${repo}"
if git remote get-url "$name" >/dev/null 2>&1; then
git remote set-url "$name" "$url"
else
git remote add "$name" "$url"
fi
}
ensure_remote origin "$STORAGE_REPO"
case "$MODE" in
status)
echo "── repo ──"; git remote -v
echo "── branch ──"; git status -sb | head -30
echo "── log ──"; git log --oneline -10
exit 0
;;
pull)
git fetch origin
if git rev-parse HEAD >/dev/null 2>&1 && ! git diff --quiet 2>/dev/null; then
echo "[sync] 有未提交的改動,先 stash"; git stash push -u -m "sync-pull $(date -Iseconds)"
fi
git checkout -B main origin/main 2>/dev/null || git reset --hard origin/main
echo "[sync] 已拉到最新:$(git log --oneline -1)"
exit 0
;;
esac
# ── push ──
git add -A
if git diff --cached --quiet; then
echo "[sync] 沒有改動,不用上傳"
else
git commit -q -m "$MSG" || { echo "[sync] commit 失敗"; exit 1; }
fi
# 即使沒有新 commit 也要推 —— 這是「成果已保存」的保險,不能跳過。
# 第一次推送時遠端還沒有 main,要帶 -u。
git push -u origin main 2>&1 | tail -3 \
|| git push -u --force origin main 2>&1 | tail -3
echo "[sync] 完成:$(git log --oneline -1)"
echo "[sync] https://huggingface.co/${STORAGE_REPO}" |