ChinaWHAPI
Global Gateway
← Back to Knowledge Center
Prompt EngineeringFew-shotCoTAdvanced

Advanced Prompt Engineering: Few-shot, CoT, and Structured Prompt Techniques

Master Few-shot examples, Chain of Thought reasoning, and structured prompt design for more stable and accurate AI output.

Few-shot Examples

Provide the model 2-3 examples to help it understand your expected output format and style. More accurate than pure text descriptions.

{"model":"qwen3.6-plus","messages":[{"role":"user","content":"Classify the following:

Example 1: 'How do I get a refund' → refund
Example 2: 'When will it ship' → logistics
Example 3: '{user_input}' → "}]}

Chain of Thought (CoT)

Ask the model to show reasoning steps first, then give the answer. For complex problems, CoT can significantly improve accuracy.

{"model":"qwen3.6-plus","messages":[{"role":"user","content":"Please reason step by step and then give the answer: if an item's original price is 100 yuan, gets 20% off, then 10 yuan off, what's the final price?"}]}

Structured Prompts

Use clear sections and tags to organize prompts, making it easier for the model to understand instruction structure.

# Role
You are a professional technical support engineer.

# Task
Extract issue type and key information from user descriptions, output JSON.

# Output Format
{"type": "refund|logistics|product|other", "urgency": "high|medium|low", "summary": "one-sentence summary"}

# User Input
{user_input}

Temperature and Top-P

Temperature controls randomness (0.7-0.9 for creative tasks, 0.1-0.3 for accuracy tasks); top_p controls sampling range (typically 0.9-1.0). Don't tune both high simultaneously.