DeepSeek Prompting 101: Few-Shot Examples That Drive Output
When you want a model to output in a specific format, ten sentences of instruction work worse than one or two examples. That's the core of few-shot prompting: put several input-output pairs in your prompt, and the model will mimic their style, structure, and level of detail. This works especially well with DeepSeek — the V-series conversational models follow instructions faithfully, and pairing them with well-structured examples noticeably stabilizes the output. Here are copy-paste-ready templates plus some pitfalls to avoid.
Why Examples Beat Adjectives
Many people write prompts full of adjectives: "be concise and professional," "make it vivid." These are too vague for a model. When you say "concise," do you mean one sentence or three lines? When you say "professional," academic-paper tone or technical-doc tone?
One example beats ten adjectives. Give the model one complete example and it instantly knows the length, punctuation, numbering, and how to handle terminology. An example makes your implicit expectations explicit — more precise than any description.
DeepSeek handles Chinese well, so Chinese phrasing habits in your examples get inherited faithfully. Write examples in the real Chinese of your target scenario, not translated prose.
When to Use Few-Shot
Not every task needs examples. The test is simple:
- Use them: when output format matters (JSON, tables, fixed fields), when you need a specific voice (rewriting, summarizing in a particular tone), or when task boundaries are fuzzy (what counts as "important information" is best defined by example).
- Skip them: factual Q&A, code generation, math — just state the requirement clearly. Math and code are already DeepSeek's strengths; examples may distract it.
- Be careful with deep-thinking mode: when R-series thinking is on, the model reasons through steps itself. Examples should then only constrain the format of the final answer — don't provide examples of intermediate reasoning, which could interfere with its own chain of thought. For simple tasks, just use the V-series; there's no need to trigger deep thinking.
Template 1: Structured Extraction
For extracting fixed fields from text into JSON:
You are an information extraction assistant. From the product review provided by the user, extract these fields and output JSON:
product (product name), sentiment (positive/negative/neutral), issue (problem mentioned, null if none).
Example 1:
Input: Bought this thermos, but it doesn't hold heat — lukewarm after half a day. Build quality is nice though.
Output: {"product": "thermos", "sentiment": "negative", "issue": "poor heat retention"}
Example 2:
Input: Fast shipping, packaging intact, the mug looks great, family all say it's pretty.
Output: {"product": "mug", "sentiment": "positive", "issue": null}
Now process the following review. Output JSON only, no explanations:
Input: {paste review text here}
Key point: the examples cover different situations (with and without an issue), so the model knows how to handle edge cases. Defining null via example works better than ten lines of rules.
Template 2: Style Mimicking and Rewriting
For rewriting content into a specific voice:
Rewrite the product description below into a casual social-media post style.
Example 1:
Original: This lotion contains niacinamide, which improves dull skin tone. The texture is light and non-greasy.
Rewrite: Late-night skin, saved!! I've repurchased this lotion THREE times🙌 The niacinamide brightening actually works, absorbs in seconds, never breaks me out — dull-skin girlies, run!
Example 2:
Original: This keyboard features hot-swappable switches and full N-key rollover, suitable for programmers' daily use.
Rewrite: Programmer friends, look at this keyboard⌨️ You can swap the switches yourself — one bad key doesn't mean a new board! The typing feel is unreal, hands don't tire even after a full day of coding, office procrastination just got happier hahaha
Now rewrite the following original. Keep the same style, emoji density, and paragraph length:
Original: {paste original text here}
Writing style can't be captured by rules, but with two examples in place, the model picks it up fast and accurately. The examples deliberately keep a rough, colloquial feel — the model follows suit.
Common Pitfalls
1. Don't overdo examples: two to four usually suffice. Too many lengthen the prompt, add cost, and yield diminishing returns. DeepSeek's API pricing is low, but on complex tasks context length itself can affect quality. 2. Cover edge cases: if all your examples are positive reviews, the model may stumble on negative ones. The most important example is often the extreme case you least want to see. 3. Keep examples consistent with instructions: if the instruction says "no explanations" but an example contains explanation text, the model wavers. Keep both aligned. 4. Lock format with examples, not pleas: rather than repeating "please output JSON," make every example end in valid JSON — the model imitates more faithfully than you'd expect.
A Bonus for Open-Weights Users
DeepSeek's open weights allow local deployment, and few-shot has an extra benefit there: bake examples directly into the system prompt, effectively hard-coding your format requirements into the service. Anyone on the team calling it gets consistent output without restating rules each conversation.
Apply this to the most repetitive task on your plate: find two outputs you've hand-polished to satisfaction, reverse-engineer them into examples, drop them into the prompt, and let the model handle the rest. With examples done right, you nail it on the first try.
大模型网摘