Sub topic 3
Benchmarking Against Competitors
This chapter assumes you have a prompt set and a test log from the earlier chapters, that you can read simple JSON, and that you know what a mention rate is. Each run sends one prompt to one assistant under the same settings.
Benchmarking against competitors
A brand's mention rate means little alone. Compare it with the same measure for each named competitor, using the same prompts, assistant, and run count. Share of voice is one brand's mentions divided by all mentions of the brands you track. Report both figures, because a brand can have a high mention rate while competitors dominate the recommendations.
from collections import Counter
def share_of_voice(records, brands):
"""Each brand's mentions as a fraction of all tracked-brand mentions."""
counts = Counter()
for r in records:
for brand in r["mentions"]:
if brand in brands:
counts[brand] += 1
total = sum(counts.values())
if total == 0:
return {b: 0.0 for b in brands}
return {b: counts[b] / total for b in brands}
records = [
{"prompt_id": "cmp-01", "run": 1, "mentions": ["Acme Analytics", "Example BI"]},
{"prompt_id": "cmp-01", "run": 2, "mentions": ["Example BI"]},
]
print(share_of_voice(records, ["Acme Analytics", "Example BI"]))
# {'Acme Analytics': 0.333..., 'Example BI': 0.666...}Finding which sources assistants cite
Some assistants list sources beside their answers. Record each cited URL in every run, then group the URLs by domain. If review sites or comparison pages appear often, they probably shape what the assistant says. Changing your own pages may then have little effect until those sources change.
from collections import Counter
from urllib.parse import urlparse
def cited_domains(records):
"""Count how often each domain is cited across all runs."""
counts = Counter()
for r in records:
for url in r["citations"]:
counts[urlparse(url).netloc] += 1
return counts.most_common()
records = [
{"citations": ["https://www.example-review.com/bi-tools"]},
{"citations": ["https://www.example-review.com/bi-tools", "https://acme.example/pricing"]},
]
print(cited_domains(records))
# [('www.example-review.com', 2), ('acme.example', 1)]Scripting repeated runs and scoring
Put the test in a loop so each prompt runs the same number of times. Store every raw answer before you score anything. Fix your scoring rules before you look at results, so you do not adjust the rules to suit the data.
Reading results carefully: sampling limits and what tests cannot show
Three runs per prompt give only a rough estimate. A rate of 2 of 3 could be 1 of 3 on another day. Results describe the dates, settings, and prompts you tested. They do not describe every user's experience, and assistants change without notice.
Acting on findings and re-testing over time
Choose one or two gaps to fix, such as a missing comparison page or an outdated pricing page that an assistant cites. Re-run the same prompt set on a fixed schedule, such as monthly, and compare the new rates with your earlier log.
Exercise
Brand A is mentioned in 4 of 10 answers to one prompt. Brand B is mentioned in 2 of 10 answers to the same prompt. What is each brand's share of voice between the two?
Show answer
The total is 6 mentions. Brand A has 4/6, about 0.67. Brand B has 2/6, about 0.33.