Skills von blackbook: software-development/local-llm-mac
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
---
|
||||
name: local-llm-mac
|
||||
description: Use when running or wiring local LLMs on blackbook.
|
||||
version: 1.0.0
|
||||
author: Robert Rapp
|
||||
license: MIT
|
||||
platforms: [macos]
|
||||
metadata:
|
||||
hermes:
|
||||
tags: [llm, ollama, llama.cpp, mlx, strata, fallback, benchmark]
|
||||
related_skills: [hermes-agent, hermes-a2a]
|
||||
---
|
||||
|
||||
# Lokale LLMs auf blackbook (M3 Pro, 36 GB)
|
||||
|
||||
## When to Use
|
||||
For installing, checking, benchmarking, or using a local model on Robby's Mac as a fallback for when Claude is unavailable. This also covers adjusting the Hermes fallback and goal scripts that drive the local model. Requests often come relayed from the `android` peer on Robby's behalf.
|
||||
|
||||
## Gates (always)
|
||||
- Default is **read-only**. Install, download, change config, or activate services/launchd/cron only after Robby explicitly says yes, and only for exactly the scope he approved (e.g. "one model at a time, nothing new to download").
|
||||
- Ask before any multi-GB download, administrator password, or system setting. Send the exact question back with size, the remaining free disk space, and the exact command. Never guess.
|
||||
- Only one model in RAM at a time: 36 GB does not fit two 20-GB models plus the system, and macOS then swaps.
|
||||
- Use free disk space as a planning number (`df -h ~`). The disk is ~90% full.
|
||||
|
||||
## Procedure
|
||||
1. **Inventory first** (read-only, batch it):
|
||||
- `command -v ollama llama-server llama-cli mlx_lm.generate lms`
|
||||
- `ollama list`
|
||||
- list the model folders `~/models` and `~/.cache/huggingface/hub`
|
||||
- `ps -axo pid,rss,command` filtered for llama-server, mlx_lm, ollama
|
||||
- `lsof -nP -iTCP -sTCP:LISTEN`
|
||||
- `GET /v1/models` for every listening server
|
||||
- Real speed values are in `~/hermes/llama-server.log` (lines containing `eval time`): prompt eval = time to first token, eval = generation tok/s. Report measured numbers and label estimates as estimates.
|
||||
2. **Before a third-party install script runs:** download it to scratch, read it completely, and check for elevated rights, writes outside its own directory, foreign downloads, and checksum/signature checks. Run it only if all is clean, and report what it does.
|
||||
3. **Probing sizes without loading:** use the tool's plan/dry-run mode (e.g. `strata launch --plan --model X --no-tui`). Cross-check its claims against the source/docs. Details are in `references/strata.md`.
|
||||
4. **Fallback in Hermes:** see the section below.
|
||||
5. **Benchmark:** plan in `references/benchmark-plan.md`. Run it only with approval for each model.
|
||||
|
||||
## Changing the Hermes fallback config
|
||||
- The `custom_providers` entry and the entry in `fallback_providers` must point to a server that actually serves the model. Read the model ID from `GET /v1/models` (llama-server: `--alias`) and set it identically in both places.
|
||||
- The Hermes config is protected: the agent's write tools refuse it. Respect the guard and do not work around it with shell tricks. Instead:
|
||||
1. Make a timestamped backup copy next to it (`config.yaml.bak-YYYYMMDD-HHMMSS`).
|
||||
2. Write the new version via Python string replacement to `~/.hermes/cache/scratch/config-fallback/config.yaml.neu`. Assert that each old snippet occurs exactly once.
|
||||
3. Save the diff (`diff -u`) and validate the YAML with a Python that has PyYAML. The system python3 may lack it; Strata's bundled Python under `~/.local/share/strata/terminal/*/python/bin/` has it.
|
||||
4. Give Robby the diff and the one copy command, or tell him to use `hermes config edit`. The change takes effect from the next session.
|
||||
- Test the server with a chat-completions request (the model ID plus `max_tokens:50`), which works regardless of the config.
|
||||
|
||||
## Idle goal script
|
||||
`~/bin/idle-goal.sh` (not activated) sends `~/goals/next.md` to the local llama-server (:8081), but only when HIDIdleTime is above 15 min and no other model is loaded. Results go to `~/goals/done/`, there is a lockfile, timeout handling, `--dry-run`, and `--tts` (off by default). It only produces text and writes only under `~/goals`. After changing it, always run `bash -n` and `--dry-run`, plus a cross-check with a dummy process: start `exec -a llama-cli sleep 25` in the background; the dry run must then yield exit code 3.
|
||||
|
||||
## Pitfalls
|
||||
- When detecting "another model running", match the **program name** (first word of the command, its basename via `${exe##*/}`, and for Python the first argument), not the full command line. Otherwise `tee …llama-server.log` and similar processes count as models.
|
||||
- Do not use `basename` on arbitrary ps lines: process names like `-zsh` are parsed as options. Use parameter expansion instead.
|
||||
- Server processes without a loaded model (`ollama serve`, `mlx_lm.server`, which here serves only Whisper/TTS on :8080) are allowed. Treat them as a model only when RSS > ~1 GB or `ollama ps` shows something.
|
||||
- Strata and other tools default to port 8080, which is already used by `mlx_lm.server`. Always set `--port` explicitly.
|
||||
- macOS has no `timeout` and no `pgrep -E`. Use curl `--max-time` and ps with grep instead.
|
||||
Reference in New Issue
Block a user