Module 7 of 18
Model-Specific Prompt Strategies
Master cross-model fluency by understanding how GPT, Claude, Gemini, and open-source models differ in prompt handling
Model Architecture Impact
Not all large language models are created equal. While they share the transformer architecture at their core, differences in training data, alignment techniques, context window sizes, and inference optimizations create distinct "personalities" that affect how each model responds to prompts.
Understanding these architectural differences is what separates a prompt engineer who works with one model from one who can deploy effectively across any model. The same prompt can produce excellent results on one model and mediocre results on another, not because the prompt is bad, but because it wasn't tuned for that model's strengths.
Definition
Model-specific prompt engineering
Training Data Differences
Models trained on different data mixtures excel at different tasks. Code-heavy training improves structured output; conversation-heavy training improves natural dialogue.
Alignment Approaches
RLHF, Constitutional AI, and other alignment methods shape how models interpret instructions, handle ambiguity, and express uncertainty.
Context Window Size
Models with larger context windows can process more information at once, but performance may degrade with very long contexts. Prompt placement matters.
Inference Optimization
Some models are optimized for speed (smaller, distilled) while others prioritize quality (larger, slower). This affects prompt complexity trade-offs.
The best prompt engineers don't have one universal prompt. They have a universal intent that they express differently for each model, much like a translator who conveys the same meaning in different languages.
GPT-4/4o Prompt Patterns
OpenAI's GPT models are among the most widely used LLMs and have established many of the prompting conventions that other models now support. GPT-4o excels at structured output, function calling, and instruction following with minimal prompt overhead.
JSON Mode
GPT-4o supports native JSON mode through the API, guaranteeing valid JSON output. Your prompt should describe the desired JSON structure but doesn't need to enforce format compliance since the API handles that.
Set response_format: { type: "json_object" } in the API call, then describe the schema in your prompt: "Return a JSON object with keys: name, category, score."
Function Calling
GPT models support function calling, allowing you to define structured output schemas that the model will populate. This is ideal for integration workflows where the output must match a specific interface.
Define functions with JSON Schema parameters. The model decides when to call them and populates arguments. Use tool_choice: "required" to force structured output.
System Message Best Practices
GPT models give strong weight to system messages. Place role definitions, behavioral rules, and output constraints in the system message for consistent adherence across conversation turns.
"You are [role]. Rules: 1) [constraint]. 2) [constraint]. Always respond in [format]." Keep system messages concise and rule-oriented.
Claude Prompt Patterns
Anthropic's Claude models are built with Constitutional AI and tend to be thorough, careful, and transparent in their reasoning. Claude responds particularly well to XML-structured prompts and explicit thinking instructions.
XML Tag Structuring
Claude is trained to recognize and follow XML-style tags for structuring input and output. Wrapping different parts of your prompt in descriptive tags significantly improves Claude's ability to parse complex instructions.
<context>Background info here</context> <task>Your instruction here</task> <format>Output format here</format>
Thinking Blocks
Claude supports extended thinking, where it reasons through complex problems before providing a final answer. You can prompt this behavior explicitly or use the API's thinking feature.
"Think through this step by step inside <thinking> tags before giving your final answer. Show your reasoning process."
Detailed Instruction Following
Claude excels at following detailed, multi-part instructions. Unlike some models where verbose prompts can cause confusion, Claude typically benefits from more explicit and thorough instructions.
Provide numbered requirements, explicit constraints, and examples of desired output. Claude will address each point systematically.
Gemini Prompt Patterns
Google's Gemini models offer unique capabilities including native grounding with Google Search, code execution, and strong multimodal performance. Gemini prompts benefit from leveraging these built-in tools rather than trying to achieve everything through text alone.
Search Grounding
Gemini can ground its responses in real-time Google Search results, making it particularly powerful for tasks requiring current information. Enable this through the API's grounding configuration.
Ask factual questions with the grounding tool enabled. "Using current data, what is the market share of [product] in [region]?"
Code Execution
Gemini can execute code as part of its response, making it excellent for mathematical calculations, data transformations, and algorithmic tasks where you need verified computational results.
"Calculate [mathematical task]. Use code execution to verify your answer. Show the code and its output."
Concise Instruction Style
Gemini tends to respond best to clear, concise instructions rather than highly verbose prompts. Focus on what you want rather than extensive context, and let Gemini's tools fill in gaps.
Lead with the task, follow with constraints. "Summarize this article in 3 bullet points. Focus on financial impact. Use simple language."
Open-Source Model Strategies
Open-source models like Llama, Mistral, and Qwen offer deployment flexibility and cost advantages but require different prompting approaches. These models are typically more sensitive to prompt format and may need more explicit instructions to achieve comparable output quality.
Chat Template Compliance
Each open-source model family has its own chat template format. Using the correct template (ChatML, Llama format, Mistral format) is critical for instruction following.
Few-Shot Is Essential
Include 2-3 examples of desired input-output pairs. Open-source models rely more heavily on in-context learning than proprietary models fine-tuned for instruction following.
Output Format Enforcement
Use constrained decoding or grammar-based generation to enforce output formats. Tools like Outlines or llama.cpp grammar support guarantee valid JSON or other structured outputs.
Prompt Length Sensitivity
Smaller models degrade faster with long prompts. Keep prompts focused and avoid redundant instructions. Place the most important instructions at the beginning and end.
Cross-Model Prompt Portability
In production environments, depending on a single model provider is a risk. Cross-model portability, the ability to deploy the same prompt logic across multiple models with minimal changes, is a critical skill for building resilient AI systems.
The "prompt contract" pattern provides a structured approach to achieving this portability. A prompt contract defines the input schema, output schema, and behavioral expectations independently of any specific model, with thin adapter layers that handle model-specific formatting.
Definition
Prompt contract
The Prompt Contract Pattern
Separate your prompt into three layers: the universal intent (what you want), the model-specific format (how to ask), and the output validation (how to verify). This separation allows you to swap models without rewriting the core logic.
Adapter Layer Design
Each model gets a thin adapter that translates the universal prompt into model-specific formatting. For GPT, this might add JSON mode. For Claude, it wraps sections in XML tags. For open-source models, it adds few-shot examples.
Output Normalization
Regardless of model, validate and normalize the output against your contract's schema. This catches model-specific quirks (extra whitespace, different casing, nested vs. flat structures) before they reach your application.
Building model-portable prompts isn't about finding the lowest common denominator. It's about defining clear contracts and using thin adapter layers that let each model perform at its best while delivering consistent results to your application.
Activities
Activity 1
35-45 min · Intermediate
Cross-Model Adaptation
Take a complex prompt from Module 3 and adapt it for three different models. Document what changed and why.
Activity 2
40-50 min · Advanced
Output Divergence Analysis
Run the same evaluation task across two models and analyze where outputs diverge. Identify the architectural reason.
Activity 3
35-45 min · Advanced
Prompt Contract Design
Design a 'prompt contract' for a real business task that can be deployed across any model with minimal changes.
Real-World Applications
Multi-Model Deployment
Deploy the same AI feature across multiple model providers, routing traffic based on cost, latency, and availability while maintaining consistent output quality.
Model Migration Planning
Plan and execute migrations between model providers when pricing, capabilities, or strategic needs change, minimizing disruption to production systems.
Cost Optimization
Route simple tasks to smaller, cheaper models and complex tasks to more capable ones. Model-aware prompting ensures quality at each tier.
Provider Fallback Systems
Build resilient systems that automatically fall back to alternative models during outages, with prompt adapters that maintain output consistency.
Cross-Platform Libraries
Create prompt libraries that work across model providers, enabling teams to share and reuse prompt engineering work without model lock-in.
Benchmark-Driven Selection
Use structured evaluation frameworks to compare model performance on your specific tasks, making data-driven provider selection decisions.