Prompt Engineering for Local LLMs: What Works, What Doesn't
Prompting techniques that work brilliantly with GPT-4 often fail with smaller local models. The gap isn't just capability — it's that local models have different training data, instruction formats, and context handling behaviors. This guide covers what actually works when you're running 7B-13B models locally.
Use the Correct Chat Template
Every instruction-tuned model expects a specific token format. Llama 3 uses <|begin_of_text|><|start_header_id|>system<|end_header_id|>. Mistral uses [INST]...[/INST]. Using the wrong template is the single most common reason local models produce repetitive or incoherent output. Tools like llama.cpp, Ollama, and LM Studio handle this automatically — but if you're calling models directly, always check the model card.
Techniques That Work Well Locally
Chain-of-thought prompting ("think step by step") improves reasoning quality on 7B+ models noticeably. Few-shot examples are more effective than long instructions for local models. Clear, explicit formatting requests ("respond in bullet points", "use markdown headers") improve output structure. Keep system prompts under 200 tokens — local models struggle with very long system contexts.
What to Avoid
Avoid overly complex role-play personas for task-focused work — they consume context without improving performance. Don't assume the model remembers earlier in a very long conversation (most GGUF-based inference truncates context). Negative instructions ("don't do X") are less reliable than positive ones ("always do Y instead"). For creative tasks, higher temperature (0.8-1.1) and lower top_p (0.85) produces better variety than default settings.
Comments
Post a Comment