/powertools:domain-specific-slmsfrom powertools
Design, adapt, optimize, and ship small, domain-specific language models (SLMs) — the practitioner's playbook from Guglielmo Iozzia's *Domain-Specific Small Language Models* (Manning). Use whenever someone is working with SLMs or trying to make an LLM run cheaply, privately, or on constrained hardware. Triggers: "should I fine-tune or use RAG?", "which quantization should I use?", "run an LLM on a laptop / CPU / phone / edge device", "shrink / speed up / reduce the cost of a model", LoRA / PEFT, ONNX / ONNX Runtime, INT8 / INT4 / GPTQ / ggml / gguf / AWQ / SmoothQuant / BitNet / FlexGen, vLLM, Ollama / LM Studio / Jan / Cortex / llama.cpp, MLC LLM, DeepSpeed, model profiling, "deploy an LLM with FastAPI / vLLM", domain-specific fine-tuning (code, chemistry, proteins, legal, medical, finance), RAG pipelines, vector databases, GraphRAG, agentic RAG, LLM agents, long/short-term memory, test-time compute, reasoning models, OptiLLM, or building a private/on-prem generative AI system in a regulated industry. Also trigger on "generalist LLM vs domain-specific model", "reduce inference cost", "quantize", or "which small model for my domain".
Trending skills
7-day visitors to each skill page
Ships in powertools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill is a practitioner's decision-and-technique reference for building small language models (SLMs) that are adapted to one domain, optimized to run cheaply, and deployed close to the data — including on-prem clusters, laptops, CPUs, and mobile/edge devices. It distills Guglielmo Iozzia's Domain-Specific Small Language Models.
Use it to answer questions like: Do I fine-tune or use RAG? Which quantization? How do I get this onto a CPU or a phone? How do I serve it? How do I turn a small model into an accurate, reasoning, RAG-grounded agent for my domain?
The book's thesis: you rarely need a frontier model. A carefully chosen, well-tuned model in the ~100M–10B parameter range, pushed as close as possible to where data is generated and decisions are made, delivers outsized business value — lower latency, lower cost, data privacy, regulatory fit, and no vendor lock-in.
Every SLM project moves through four stages. Most questions map to one of them.
1. CHOOSE & ADAPT Pick a base model in your domain → adapt it
(prompting → RAG → PEFT/LoRA → full fine-tune)
│
2. OPTIMIZE Make it small and fast enough for your target
(precision/quantization → ONNX → profiling → advanced quant)
│
3. DEPLOY & SERVE Put it where the data is
(vLLM / FastAPI server → laptop runner → Android/edge)
│
4. COMPOSE Make it capable and grounded
(RAG → vector DB → agents → GraphRAG → memory → test-time compute)
The stages are a pipeline, not a waterfall — optimization choices (e.g. INT4 for a phone) constrain adaptation choices, and composition (RAG) can substitute for adaptation (fine-tuning).
Load the reference file that matches the task. Read only what you need.
| Topic | Reference file | Read when |
|---|---|---|
| What SLMs are, generalist-vs-domain decision, open-source ecosystem, data prep, fine-tuning, LoRA/PEFT, RAG-vs-fine-tune, end-to-end tuning + evaluation | references/01-fundamentals-and-adaptation.md | Choosing a base model; deciding how to adapt; preparing data; running a fine-tune; evaluating a tuned model |
| Generation/decoding params, inference cost math, GPU utilization, batching, DeepSpeed, ONNX format + Runtime + providers, exporting to ONNX, precision formats, INT8/INT4, LLM.int8(), GPTQ, ggml/gguf | references/02-inference-onnx-quantization.md | Tuning generation quality; cutting inference cost; converting to ONNX; picking a quantization method |
| Domain playbook: code generation, chemistry/proteins/materials; advanced quantization (FlexGen, SmoothQuant, BitNet 1.58-bit) | references/03-domain-usecases-advanced-quant.md | Adapting an SLM to a specialized/scientific domain; squeezing a model past INT4 |
| Profiling ONNX graphs, deployment & serving (vLLM, FastAPI, MLC LLM, Android), local runners (Ollama, LM Studio, Jan, Cortex) | references/04-profiling-deployment-serving.md | Finding bottlenecks; choosing how/where to serve; running locally or on-device |
| RAG pipelines, vector DBs, agents, GraphRAG, agentic RAG, memory, test-time compute, reasoning SLMs, OptiLLM | references/05-llm-applications-and-test-time-compute.md | Building a real application around the model; grounding, agents, or reasoning |
These are the high-frequency calls. Deeper criteria live in the reference files.
Prefer a domain-specific SLM when any of these hold:
Prefer a generalist (often hosted) LLM when: the task is broad/open-ended, volume is low, you have no training data, or time-to-first-prototype dominates cost. Common pattern: prototype on a generalist, then distill/fine-tune a small model for production.
| Use RAG when… | Use fine-tuning / PEFT when… |
|---|---|
| Knowledge changes often (docs, tickets, policies) | The behavior/format/style must change (tone, schema, code dialect) |
| You need source citations / auditability | You need a new skill or domain language, not just facts |
| Facts are large and enumerable | Latency/prompt-length budget is tight (no room for retrieved context) |
| You must add/remove knowledge without retraining | The domain vocabulary/tokens are alien to the base model |
| Hallucination on facts is the main risk | You need the capability offline with no retrieval store |
They compose. The book's headline application pattern is a fine-tuned (or PEFT-adapted) domain SLM + RAG: fine-tune for the domain's language and behavior, use RAG for current, citable facts. Default to RAG first (cheaper, faster to iterate); add PEFT/LoRA when RAG can't fix behavior; reserve full fine-tuning for when PEFT plateaus.
Order of preference — stop at the first that meets your accuracy + hardware budget:
Rule of thumb: quantize as little as you can get away with. More bits = more accuracy. Pick the coarsest precision that still passes your domain evaluation, not the coarsest that runs.
| Target | Reach for | Why |
|---|---|---|
| High-throughput GPU serving | vLLM (offline batch or OpenAI-compatible online server) | PagedAttention + continuous batching → best tokens/sec |
| Simple custom API / microservice | FastAPI wrapping the model | Full control, easy to embed in an app |
| Developer laptop, quick local use | Ollama (Modelfile), LM Studio (GUI + Python SDK), Jan, Cortex | Zero-infra, private, gguf-based |
| CPU-only / pure C++ | llama.cpp / ggml/gguf | No GPU, portable |
| Phone / Android / cross-platform edge | MLC LLM (compiles models per-target) | On-device, offline, private |
| CPU/GPU-portable optimized runtime | ONNX Runtime | One graph, many execution providers |
references/01-fundamentals-and-adaptation.md (opens in a new tab)references/02-inference-onnx-quantization.md (opens in a new tab)references/03-domain-usecases-advanced-quant.md (opens in a new tab)references/04-profiling-deployment-serving.md (opens in a new tab)references/05-llm-applications-and-test-time-compute.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jordangaston/claude-plugins --plugin powertools79 skills in this plugin
/ai-camera-movementsLibrary of 46 camera movement prompt blocks for AI video generation (Seedance, Kling, Veo, Runway, Higgsfield). Use this skill EVERY time the user needs a camera move for a video prompt, asks "what camera movement should I use", wants a dolly/pan/orbit/zoom/crane/drone/tracking/handheld/whip-pan/FPV/snorricam/tilt-shift/earth-zoom prompt, asks to add camera motion to a shot, wants to compare camera moves for a scene, or says "Run Camera" / "camera move for this shot". Also trigger when building shot lists or video prompts with other skills (ai-filmmaking, seedance-prompt-structure, genhq-seedance-2-prompt-builder) and a camera instruction is needed — this skill supplies the camera block./ai-image-promptsTurn a seed idea into a polished AI image-generation prompt using a 6-part structure: [medium], [subject], [action/pose], [environment], [style/vibe], [technical specs]. Use this skill whenever the user wants a prompt for generating an image with any model — Midjourney, DALL-E, Imagen, Nano Banana, Flux, Stable Diffusion, Freepik, or unnamed — or asks to 'write an image prompt,' 'make a prompt for this idea,' 'improve my image prompt,' or gives a rough visual idea ('a red panda barista,' 'cyberpunk samurai in the rain') and wants it image-ready. Also trigger when the user asks why their image prompts produce weak or inconsistent results. Covers any visual medium: photorealistic, digital painting, 3D render, anime, illustration, pixel art, watercolor, concept art, and more./ai-videoTurn a seed idea into a polished AI video-generation prompt. Picks the right mode — T2V (text-to-video), I2V (image-to-video), or V2V (video-to-video) — then builds the prompt: for T2V, an 8-part structure [medium] + [shot] + [angle] + [movement] + [focus] + [subject] + [lighting] + [color]; for I2V, a shorter motion-first structure. Use whenever the user wants a prompt for generating video with any model — Sora, Veo, Runway, Kling, Pika, Luma/Dream Machine, Hailuo/MiniMax, Wan, Seedance, or unnamed — or asks to 'write a video prompt,' 'make a prompt for this clip,' 'animate this image,' 'improve my video prompt,' or gives a rough motion idea ('a samurai on a neon rooftop,' 'my logo forming from smoke') and wants it video-ready. Also trigger when the user asks why their generated video looks static, frozen, or like a moving JPEG, or how to describe camera moves./apple-designApple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces./autonomous-sprintRun a full feature sprint from user stories to verified, demoed, shipped code with minimal supervision. Use when the user hands over a set of user stories / acceptance criteria and wants them built end-to-end overnight (or unattended): analyze reference material, ask ONE batch of clarifying questions, (optionally, on request, hold one design review), write per-story specs, run a pre-mortem, implement without stopping (decide-and-log every blocker), demo each story, and write a sprint report. Trigger on "run this sprint", "build these stories overnight", "complete this sprint autonomously", "/autonomous-sprint", or any hand-off of a story list with an expectation of unattended completion.
/binstackRun a Binstack decision-making analysis. Binstack chooses between competing options by checking each against stack-ranked priorities using binary materiality (does this option materially move the needle -- yes or no?) rather than weighted scoring. Best for: (1) Prioritizing a backlog of features, projects, or initiatives where you need one winner, (2) Choosing between alternatives that seem 'close' on paper but differ in strategic impact, (3) Decisions where defensibility matters -- explaining 'why this and not that' to stakeholders. Not ideal for: cost/effort tradeoff analysis (use ROI), exploring a problem space (use HEAD), or decisions with a single dominant criterion that needs no framework. Trigger on: 'binstack', 'prioritize these options', 'which should we build next', 'rank these features', or when the user has multiple options and needs a clear, defensible pick.Other plugins' skills for the same job