Lesson 12.3 · 3 of 4 · 4 min read · Reviewed 24 Nov 2026
Avoiding examples the model copies too literally
By the end, you can
- Spot when the model copies examples too literally.
- Vary examples so the model learns the pattern, not the words.
Examples are powerful, and that cuts both ways. If every example opens with “Introducing”, every output will too. If every example is about shoes, a description of a lamp may mention comfort.
Signs of over-copying
- Repeated phrases or sentence shapes in every output.
- Values carried over from examples, such as the same dates or names.
- Output lengths that match the examples whatever the input.
Fixes
- Vary everything you don’t want copied: openings, length, topic, names.
- Say what the examples are for: “These examples show the format and tone. Don’t reuse their wording.”
- Use realistic, varied inputs, not three near-identical ones.
Then check the outputs over a varied test set, not just one or two runs.
Key points
- Models can copy surface details from examples: the same phrases, lengths or even values.
- Vary wording, length and content so only the intended pattern is shared.
- Say explicitly that examples show the format and aren't templates to copy.
Detect phrases copied from examples
Find the surface phrases every example shares and check whether outputs copied them.
You will have: An n-gram checker that lists shared phrases, flags copied outputs, and confirms a varied example set shares none.
Steps
- Fill in ngrams: every run of 3 consecutive words in a text.
- Run it and read which phrases all three examples share.
- See which outputs copied those phrases.
- Rewrite the examples in VARIED so they share no 3-word phrase.
- Rerun and confirm nothing is shared.
Done when
- The shared phrases include the all new.
- Two of three outputs are flagged as copied.
- The varied set prints none.
Open in the Playground No API key needed.
Starter code (Python)
import re
EXAMPLES = [
"Introducing the all new Trailblazer boots: tough soles for muddy paths.",
"Introducing the all new Summit jacket: warm, light and fully waterproof.",
"Introducing the all new Ridge backpack: 30 litres with a padded back.",
]
OUTPUTS = [
"Introducing the all new Nova desk lamp: warm light for late nights.",
"A slim steel kettle that boils a litre in under three minutes.",
"Introducing the all new Cloud pillow: soft support, washable cover.",
]
def ngrams(text, n=3):
words = re.findall(r"[a-z']+", text.lower())
# TODO: return the set of every run of n consecutive words, joined by spaces.
return set()
def shared_by_all(texts, n=3):
sets = [ngrams(t, n) for t in texts]
return set.intersection(*sets) if sets else set()
cue = shared_by_all(EXAMPLES)
print("phrases in every example:", sorted(cue))
copied = [o for o in OUTPUTS if ngrams(o) & cue]
print(f"outputs copying them: {len(copied)}/{len(OUTPUTS)}")
for o in copied:
print(" copied:", o)
# TODO: rewrite the three examples so they share no 3-word phrase, keeping the same products.
VARIED = list(EXAMPLES)
print("phrases shared after varying the examples:", sorted(shared_by_all(VARIED)) or "none")
Show a solution
import re
EXAMPLES = [
"Introducing the all new Trailblazer boots: tough soles for muddy paths.",
"Introducing the all new Summit jacket: warm, light and fully waterproof.",
"Introducing the all new Ridge backpack: 30 litres with a padded back.",
]
OUTPUTS = [
"Introducing the all new Nova desk lamp: warm light for late nights.",
"A slim steel kettle that boils a litre in under three minutes.",
"Introducing the all new Cloud pillow: soft support, washable cover.",
]
def ngrams(text, n=3):
words = re.findall(r"[a-z']+", text.lower())
return {" ".join(words[i:i + n]) for i in range(len(words) - n + 1)}
def shared_by_all(texts, n=3):
sets = [ngrams(t, n) for t in texts]
return set.intersection(*sets) if sets else set()
cue = shared_by_all(EXAMPLES)
print("phrases in every example:", sorted(cue))
copied = [o for o in OUTPUTS if ngrams(o) & cue]
print(f"outputs copying them: {len(copied)}/{len(OUTPUTS)}")
for o in copied:
print(" copied:", o)
VARIED = [
"Tough soles for muddy paths: meet the Trailblazer boots.",
"Warm, light and fully waterproof, the Summit jacket packs into its own pocket.",
"Thirty litres, a padded back and room for a laptop: the Ridge backpack.",
]
print("phrases shared after varying the examples:", sorted(shared_by_all(VARIED)) or "none")