Sub topic 8
Adding persona and context variants deliberately
The earlier chapters produced base prompts: real customer questions, cleaned, labelled by intent, grouped into clusters and phrased in customer wording. This chapter covers the next step, which is adding variants of those prompts. A variant is a copy of a base prompt with one extra piece of information about who is asking or what situation they are in. This chapter assumes you have a base prompt set with ids, clusters and intent labels, and that you can read short Python scripts.
Variants are optional, and they are easy to overuse. A set where most prompts are invented variants stops reflecting real customer questions. That is the problem the whole tutorial is meant to avoid. The goal here is to add variants only where they answer a specific question, and to keep them traceable to a real base question.
Why variants exist at all
AI assistants and AI search features often answer differently depending on what they know about the asker. "Can I move my subscription to a different email address?" may get one answer from someone who says they are a new customer and another from someone who says they manage a team account. If your customers actually phrase questions both ways, a set with only the bare wording can miss that difference.
Variants help in three situations:
- Real questions already contain persona or context cues. Customers write "as a small business owner, how do I..." or "I'm on my phone and can't find...". Your base prompts may have stripped these out during normalisation, or you may have kept only the most common phrasing.
- You need to know whether answers change with the asker. You are testing sensitivity: does the assistant mention your product, give correct steps or add warnings differently for different askers?
- A rare but important segment is under-represented. For example, enterprise buyers send few support tickets but matter commercially. A few variants can cover them, as long as you label them as added for coverage.
If none of these applies, skip variants. A smaller set of real prompts is more trustworthy than a larger set padded with invented ones.
Persona versus context
The two terms are easy to blur, so use one definition for each.
- A persona is a fact about the person asking. Examples are their role, experience level, company size or how long they have been a customer. Personas change who is asking.
- A context is a fact about the situation. Examples are the device, the time pressure, a recent event such as a failed payment, or a stage in the customer journey. Contexts change when and why they are asking.
Keeping the two separate lets you change one at a time and see which one moves the answer. A variant that adds both a persona and a context cannot tell you which caused a difference.
| Factor | Answers the question | Example text added to the base prompt |
|---|---|---|
| Persona: experience | Does the answer change for beginners? | "I just signed up last week." |
| Persona: role | Does it change for decision makers? | "I run a small shop with two employees." |
| Context: device | Does it assume a desktop? | "I'm on my phone right now." |
| Context: urgency | Does it change when time is short? | "My renewal date is next week." |
Rules for deliberate variants
Follow these rules so that variants remain evidence and do not become noise.
- Start from a real base prompt. Every variant points back to a base question by id. A variant with no base question is a synthetic prompt, and you should label it as one.
- Change one factor at a time. One persona or one context per variant. Combinations are allowed only when you have seen that combination in real questions.
- Keep the customer wording intact. Add a short sentence before or after the original text. Do not rephrase the question itself, because that destroys the wording you worked to keep.
- Take the added text from real data. Look at how customers describe themselves in tickets and reviews, and reuse that style. If customers say "I'm new to this", do not write "As a novice user of this platform".
- Cap the number per base prompt. Two or three variants per base prompt is usually enough. Without a cap, a set of 200 base prompts grows to 2,000 prompts that mostly repeat each other.
- Label everything. Store the factor type, the value and the base id on each record. You will need them to compare results and to exclude variants from frequency counts.
- Do not let variants count as demand. Frequency came from real questions. A variant inherits the base prompt's weight and does not add to it.
Recording variants
Extend the prompt record from earlier chapters with fields that identify the variant. A base prompt has factor and value set to null.
{"id":"q-0042-v1","text":"I just signed up last week. Can I move my subscription to a different email address?","source":"support_tickets","intent":"how_to","cluster":"account_management","count":37,"variant_of":"q-0042","factor":"persona","value":"new_customer"}The count field is copied from the base record. When you later report coverage by frequency, you use variant_of to count each real question once.
Generating variants in code
The script below generates up to a fixed number of variants per base prompt. It picks the factors with a random generator seeded from the base id, so the same base prompt always gets the same variants and a rerun reproduces the set. Each variant changes exactly one factor and keeps the original text unchanged after the added sentence.
import json
import random
PERSONAS = {
"new_customer": "I just signed up last week.",
"long_term_customer": "I've been a customer for about three years.",
"small_business_owner": "I run a small shop with two employees.",
}
CONTEXTS = {
"mobile": "I'm on my phone right now.",
"renewal_soon": "My renewal date is next week.",
}
def make_variants(base, max_variants=2, seed=7):
rng = random.Random(f"{seed}-{base['id']}")
options = [("persona", name, sentence) for name, sentence in PERSONAS.items()]
options += [("context", name, sentence) for name, sentence in CONTEXTS.items()]
picked = rng.sample(options, min(max_variants, len(options)))
records = [dict(base, variant_of=None, factor=None, value=None)]
for n, (factor, name, sentence) in enumerate(picked, start=1):
records.append(
dict(
base,
id=f"{base['id']}-v{n}",
text=f"{sentence} {base['text']}",
variant_of=base["id"],
factor=factor,
value=name,
)
)
return records
if __name__ == "__main__":
base = {
"id": "q-0042",
"text": "Can I move my subscription to a different email address?",
"source": "support_tickets",
"intent": "how_to",
"cluster": "account_management",
"count": 37,
}
for record in make_variants(base):
print(json.dumps(record))Running it prints the base record followed by two variants, each with one factor. The base record is always included, which matters for the comparison described below.
Note that the generator picks from all factors at random. In a real project you would usually restrict each cluster to the factors that make sense for it. A question about changing an email address has little to do with device type, so a mobile variant would be a weak test there. Keep a small mapping from cluster to allowed factors, and review it with someone who knows the customers.
Where variants fit in the pipeline
Variants are created after phrasing and before sampling, because the sampling step must know which prompts are base prompts and which are variants.
Using variants in analysis
Because every variant has a base prompt and a single changed factor, you can compare results in pairs: the answer to the base prompt against the answer to each variant. Differences that appear across many pairs for the same factor are worth investigating. A difference that appears for one pair is probably ordinary variation between runs.
Some practical points:
- Run each prompt more than once. AI assistants can give different answers to the same prompt, so a single pair says little.
- Report results by factor value, for example "new_customer" against the base, not as one pooled number for all variants.
- Keep base-only results as the headline measure. Variant results are a secondary analysis of sensitivity.
Common errors
- Inventing personas the business has never met. If no customer has ever described themselves as a "chief data officer", a variant using that persona tests a customer you do not have.
- Stereotyped or leading personas. Adding "I'm not very good with technology" to prompts may push the answer toward simplified or patronising text. Keep persona sentences factual and neutral, and avoid traits that assume ability, age or background.
- Brand leakage. Do not mention your brand or competitors in the added sentence unless real customers did in that question. Mentioning a brand changes what the assistant is likely to talk about.
- Variants that change the question. "I want to cancel soon" added to a how-to question shifts the intent from how-to to cancellation. Check that the intent label of the variant still matches the base prompt.
- Counting variants as demand. If variants enter the frequency calculation, the clusters with the most variants look more common than they are.
- Too many variants. If variants make up more than a minority of the set, review the cap. A common starting point is that variants are no more than about a quarter to a third of all prompts, and you can adjust it once you see how much they add.
Checklist before moving on
- Each variant has
variant_of,factorandvalue. - Each variant changes one factor only.
- The base question text is unchanged inside the variant.
- Each added sentence appears in, or closely follows, wording seen in real data.
- The intent label of each variant matches its base prompt.
- The cap per base prompt is documented, and the generator is seeded.
- Frequency counts use base prompts only.
The next chapters use these records for sampling and validation. Both steps depend on being able to tell a real question from a derived one.
Exercise
A teammate generates five persona variants for each of your 300 base prompts and adds them all to the set. The share of the set in the "billing" cluster rises from 12% to 31%, although billing tickets are still about 12% of real questions. What went wrong, and how do you fix it?
Show answer
The variants were counted as separate questions, and billing prompts happened to receive more variants (or billing had more base prompts with allowed factors). The set no longer reflects real demand. Fix it by capping variants per base prompt (two or three), restricting factors to those that fit each cluster, and calculating frequency and cluster share from base prompts only, using variant_of to group each variant with its base. Variants then inherit the base prompt's weight instead of adding to it.
Exercise
You want to know whether an assistant answers differently for "small business owner" than for a prompt with no persona. Why should the variant keep the base wording unchanged and add only one sentence, and why should you also run the base prompt?
Show answer
With only one changed factor and identical question wording, any difference in the answer can be attributed to the persona sentence and not to rephrasing or to a second factor. The base prompt is the control. Without its answer you have nothing to compare the variant against, and you cannot separate a persona effect from normal run-to-run variation, which is why each prompt should also be run more than once.