Sub topic 4
Mentions: detecting a brand in an answer
Assume you understand basic SEO terms such as keywords and rankings, and that you can read simple ratios. Optional Python knowledge helps with the example. This chapter focuses on mentions, not citations. A mention is a reference to a brand in an AI-generated answer. A citation is a source URL linked from that answer.
What counts as a mention?
A tracking system records a mention when an answer identifies the brand or one of its approved aliases. The system usually checks the answer text after collecting it from an AI answer engine.
For example, these answers mention Acme:
- “Acme is a popular choice for small teams.”
- “Consider Acme CRM if you need simple reporting.”
- “Acme’s platform integrates with Slack.”
This answer does not mention Acme:
- “Look for a CRM with reporting and workflow automation.”
A mention is a binary observation for one run: the brand appeared, or it did not. If Acme appears in 12 of 40 runs, its mention rate is:
12 / 40 = 0.30, or 30%.
The rate describes the selected prompts and runs. It does not describe every possible question that a user might ask.
The working model
A visibility tracker follows this sequence:
The tracker should store the original answer as well as the parsed result. This makes the result auditable when a matching rule produces an error.
Detecting names safely
A basic matcher should handle:
- Case differences, such as
Acmeandacme. - Approved aliases, such as
Acme CRM. - Punctuation next to a name, such as
Acme,. - Word boundaries, so
acmedoes not matchAcmePlus. - Entity ambiguity, where a common word might refer to something other than the brand.
This example uses regular expressions. A regular expression is a pattern for finding text.
import re
brands = {
"Acme": ["acme", "acme crm"],
"Globex": ["globex"],
}
answers = [
"Acme is a good CRM for small teams.",
"AcmePlus is a different product.",
"GLOBEX offers a free plan.",
]
def mentions_brand(answer, aliases):
return any(
re.search(rf"\b{re.escape(alias)}\b", answer, re.IGNORECASE)
for alias in aliases
)
for answer in answers:
found = [
brand for brand, aliases in brands.items()
if mentions_brand(answer, aliases)
]
print(found)The output is:
['Acme']
['Globex']The first answer matches Acme. The second does not match acme inside AcmePlus. The third matches Globex despite different capitalization.
Common matching errors
| Error | Why it causes trouble | Better practice |
|---|---|---|
| Substring matching | Matches `acme` inside `AcmePlus` | Use word boundaries |
| Case-sensitive matching | Misses `ACME` or `acme` | Compare without case |
| Incomplete aliases | Misses legal or product names | Maintain a reviewed alias list |
| Blind alias expansion | Matches unrelated entities | Approve aliases and inspect samples |
| Counting citations as mentions | A linked page may not name the brand in the answer | Store text mentions and URLs separately |
| Counting every occurrence | A long answer can inflate the result | Usually record whether the brand appeared at least once |
Do not treat an automated match as proof of correct entity recognition. “Apple” may refer to the company, fruit, or a product name. Ambiguous brands need contextual rules or manual review.
From mentions to useful measurements
For each run, record one Boolean value per brand: 1 for mentioned and 0 for not mentioned. Then calculate the mention rate across all runs for a prompt set. Keep prompt-level results too. An overall rate can hide the fact that a brand appears often for pricing questions but rarely for comparison questions.
Repeated runs can produce different answers. Report the number of runs beside the percentage, and inspect borderline changes rather than treating every change as a trend.
Exercise
An answer says, “Acme and Acme CRM are both options.” If both strings are aliases for the same brand, should this count as one mention or two?
Show answer
Count one brand mention for that run. A run-level mention metric records whether the entity appeared, while a separate occurrence count can record how many times its names appeared.