mona
MONA

Prompt Engineering Knowledge Cards

foxgem

The Google Prompt Engineering Whitepaper is excellent, so I created a set of knowledge cards with ChatGPT, 😄.

🛠️ Best Practices for Effective Prompting

PrincipleKey IdeaExample / Tip
Provide ExamplesUse one-shot or few-shot examples to show the model what good output looks like.✅ Include 3-5 varied examples in classification prompts.
Design with SimplicityClear, concise, and structured prompts work better than vague or verbose ones.❌ “What should we do in NY?” -> ✅ “List 3 family attractions in Manhattan.”
Be Specific About OutputExplicitly define output length, format, tone, or constraints.”Write a 3-paragraph summary in JSON format.”
Instructions > ConstraintsTell the model what to do, not what not to do.✅ “List top consoles and their makers.” vs ❌ “Don’t mention video game names.”
Control Token LengthUse model config or prompt phrasing to limit response length.”Explain in 1 sentence” or set token limit.
Use VariablesTemplate prompts for reuse by inserting dynamic values.Tell me a fact about {city}
Experiment with Input StyleTry different formats: questions, statements, instructions.🔄 Compare: “What is X?”, “Explain X.”, “Write a blog about X.”
Shuffle Classes (Few-Shot)Mix up response class order to avoid overfitting to prompt pattern.✅ Randomize class label order in few-shot tasks.
Adapt to Model UpdatesLLMs evolve; regularly test and adjust prompts.🔄 Re-tune for new Gemini / GPT / Claude versions.
Experiment with Output FormatFor structured tasks, ask for output in JSON/XML to reduce ambiguity.”Return response as valid JSON.”
Document Prompt IterationsKeep track of changes and tests for each prompt.📝 Use a table or versioning system.

🎯 Core Prompting Techniques

TechniqueDescriptionExample Summary
Zero-ShotAsk the model directly without any example.🧠 “Classify this review as positive/neutral/negative.”
One-ShotProvide one example to show expected format/output.🖋️ Input + Example -> New input
Few-ShotProvide multiple examples to show a pattern.🎓 Use 3-5 varied examples. Helps with parsing, classification, etc.
System PromptingSet high-level task goals and output instructions.🛠️ “Return the answer as JSON. Only use uppercase for labels.”
Role PromptingAssign a persona or identity to the model.🎭 “Act as a travel guide. I’m in Tokyo.”
Contextual PromptingProvide relevant background info to guide output.📜 “You’re writing for a retro games blog.”
Step-Back PromptingAsk a general question first, then solve the specific one.🔄 Extract relevant themes -> Use as context -> Ask final question
Chain of Thought (CoT)Ask the model to think step-by-step. Improves reasoning.🤔 “Let’s think step by step.”
Self-ConsistencyGenerate multiple CoTs and pick the most common answer.🗳️ Run same CoT prompt multiple times, use majority vote
Tree of Thoughts (ToT)Explore multiple reasoning paths in parallel for more complex problems.🌳 LLM explores different paths like a decision tree
ReAct (Reason & Act)Mix reasoning + action. Model decides, acts (e.g. via tool/API), observes, and iterates.🤖 Thought -> Action -> Observation -> Thought
Automatic PromptingUse LLM to generate prompt variants automatically, then evaluate best ones.💡 “Generate 10 ways to say ‘Order a small Metallica t-shirt.’”

⚙️ LLM Output Configuration Essentials

Config OptionWhat It DoesBest Use Cases
Max Token LengthLimits response size by number of tokens.📦 Prevent runaway generations, control cost/speed.
TemperatureControls randomness of token selection (0 = deterministic).🎯 0 for precise answers (e.g., math/code), 0.7+ for creativity.
Top-K SamplingPicks next token from top K probable tokens.🎨 Higher K = more diverse output. K=1 = greedy decoding.
Top-P SamplingPicks from smallest set of tokens with cumulative probability ≥ P.💡 Top-P ~0.9-0.95 gives quality + diversity.

🔁 How These Settings Interact

If You Set…Then…
temperature = 0Top-K/Top-P are ignored. Most probable token is always chosen.
top-k = 1Like greedy decoding. Temperature/Top-P become irrelevant.
top-p = 0Only most probable token considered.
high temperature (e.g. >1)Makes Top-K/Top-P dominant. Token sampling becomes more random.

✅ Starting Config Cheat Sheet

GoalTempTop-PTop-KNotes
🧠 Precise Answer0AnyAnyFor logic/math problems, deterministic output
🛠️ Semi-Creative0.20.9530Balanced, informative output
🎨 Highly Creative0.90.9940For stories, ideas, writing