Sub topic 7
Position and Sentiment Within an Answer
A mention is not a single kind of event. A brand named first in a recommendation, with a clear endorsement, is worth more than a brand named last in a list with a caveat. Mention rate and share of voice treat both as one count. This chapter covers two measures that separate them: position and sentiment.
Prerequisites
This chapter assumes you can already:
- Detect a brand in an answer with word-boundary matching (the mentions chapter).
- Compute mention rate and share of voice from a set of recorded runs.
- Read a simple ratio or average.
- Read basic Python. The code is optional but runs as shown.
Why presence is not enough
Suppose two brands each appear in 40% of runs. Brand A is usually the first option listed and is described as "a strong choice". Brand B is usually the last option and is described as "cheaper, but with limited support". Their mention rates are identical. Their value to a reader is not.
Position and sentiment add two questions to the count:
- Position: where in the answer does the brand appear?
- Sentiment: how does the answer describe the brand?
Both are properties of a single mention inside a single answer. You compute them per run and then aggregate across runs.
Measuring position
Position has several definitions. Pick one, write it down, and keep it fixed, because changing the definition changes the trend line.
| Definition | What it measures | Weakness |
|---|---|---|
| Character offset of first mention | How early the brand appears in the text | Long intros push every brand down |
| Rank among brands mentioned | Order of brands relative to each other | Ignores how many brands there are |
| List index | Number in an explicit numbered or bulleted list | Undefined when the answer is prose |
| First-mentioned flag | Whether the brand is named before all competitors | Loses all information below first place |
Rank among brands is the most common choice because it is easy to explain and is not distorted by answer length. The rest of this chapter uses it.
Position is not a ranking
A numbered list in an AI answer looks like a search results page. It is not one. The order often reflects the model's phrasing habits, the order in which sources were retrieved, or the prompt's wording. Treat position as a soft signal. A brand listed first in 70% of runs is probably well associated with the topic. A brand listed first in one run tells you almost nothing.
Edge cases for position
- Same sentence. "Acme and Globex are popular" names two brands in one sentence. Rank by character offset, and accept that the tie is arbitrary.
- Repeated mentions. Use the first mention for rank. Count repeats separately if you want to measure emphasis.
- Mention in a comparison. "Unlike Globex, Acme supports..." names Globex first, but Acme is the subject. Offset-based rank misreads this. You can flag it for review or accept the error and document it.
- Brand in a citation only. If the brand appears only in a source title or URL and not in the answer text, it is a citation, not a mention. Do not assign it a position.
- Absent brands. A brand with no mention has no position. Exclude it from average-position calculations, and report mention rate beside it.
Computing position
The code below extracts brand order from an answer using the first match offset, then computes average rank and first-place rate for one brand across runs.
import re
BRANDS = {"Acme": ["acme"], "Globex": ["globex"], "Initech": ["initech"]}
def first_offset(answer, aliases):
offsets = [
m.start()
for a in aliases
for m in [re.search(rf"\b{re.escape(a)}\b", answer, re.IGNORECASE)]
if m
]
return min(offsets) if offsets else None
def brand_ranks(answer):
found = {}
for brand, aliases in BRANDS.items():
offset = first_offset(answer, aliases)
if offset is not None:
found[brand] = offset
ordered = sorted(found, key=found.get)
return {brand: i + 1 for i, brand in enumerate(ordered)}
answers = [
"Popular options include Globex and Acme.",
"Initech and Globex both offer free plans.",
"Acme is a solid pick. Globex is cheaper.",
"Look at pricing, integrations and support.",
]
ranks = [brand_ranks(a).get("Acme") for a in answers]
present = [r for r in ranks if r is not None]
print(ranks) # [2, None, 1, None]
print(sum(present) / len(present)) # 1.5
print(sum(r == 1 for r in present) / len(answers)) # 0.25Note the denominators. Average rank divides by runs where the brand appeared. First-place rate here divides by all runs, so it is comparable to mention rate. Choose the denominator on purpose and label it, because "first in 50% of runs" and "first in 50% of the runs that mentioned us" are different claims.
Measuring sentiment
Sentiment records the tone of the language around a mention. The usual scale is three values: positive, neutral, negative. Some tools add a "mixed" label for answers that praise and criticize in the same passage.
There are three common ways to assign it.
- Lexicon rules. Count positive and negative words near the brand, such as "reliable" or "expensive". This is cheap and transparent. It fails on negation ("not reliable") and on domain terms where "cheap" is praise in one context and a criticism in another.
- A trained classifier. A model scores the sentence. It handles negation better but can be unreliable on short or unusual text.
- An LLM judge. A language model reads the passage and returns a label. It handles context well, but its labels can change between calls and between model versions.
For all three, extract the text that is about the brand, not the whole answer. An answer that praises Globex in one sentence and criticizes Acme in the next should not receive one shared label.
A minimal lexicon scorer
This sketch scores the sentence containing the brand. It is deliberately simple, to show the mechanics and the failure points.
import re
POSITIVE = {"best", "reliable", "strong", "solid", "popular", "recommended"}
NEGATIVE = {"expensive", "limited", "slow", "lacks", "poor", "complaints"}
NEGATORS = {"not", "no", "never", "isn't"}
def sentences(text):
return [s.strip() for s in re.split(r"(?<=[.!?])\s+", text) if s.strip()]
def sentiment_for(answer, alias):
pattern = rf"\b{re.escape(alias)}\b"
scores = []
for sentence in sentences(answer):
if not re.search(pattern, sentence, re.IGNORECASE):
continue
words = re.findall(r"[a-z']+", sentence.lower())
score = 0
for i, w in enumerate(words):
sign = 1 if w in POSITIVE else -1 if w in NEGATIVE else 0
if sign and i > 0 and words[i - 1] in NEGATORS:
sign = -sign
score += sign
scores.append(score)
if not scores:
return None
total = sum(scores)
return "positive" if total > 0 else "negative" if total < 0 else "neutral"
print(sentiment_for("Acme is a solid pick. Globex is cheaper.", "acme")) # positive
print(sentiment_for("Acme is expensive and support is limited.", "acme")) # negative
print(sentiment_for("Acme is not reliable.", "acme")) # negative
print(sentiment_for("Look at pricing and support.", "acme")) # NoneReturn None when the brand is absent, not "neutral". Neutral means the brand was mentioned without a stance. Mixing the two understates both mention rate effects and sentiment effects.
Where sentiment breaks
- Sarcasm and hedging. "Acme is fine, I guess" reads as neutral to a lexicon and mildly negative to a person.
- Comparative praise. "Globex is better than Acme" is positive for Globex and negative for Acme. Sentence-level scoring needs to know which brand is the subject.
- Sentence boundaries. A criticism in the sentence after the brand name is attributed to no one. Some tools score a window of one or two sentences instead.
- Recommendation versus description. "Acme offers a free plan" is neutral in tone but is a factual claim a reader may treat as positive. Decide whether you track tone or endorsement and name the metric accordingly.
- Label drift. If an LLM judge is upgraded, labels can shift without any change in the engines you track. Keep the judge version in your records and re-score a sample when it changes.
Aggregating position and sentiment
Report distributions, not single averages, wherever you can.
| Metric | Formula | Denominator |
|---|---|---|
| Average position | Mean rank across runs with a mention | Runs with a mention |
| First-place rate | Runs where rank is 1, divided by total runs | All runs |
| Positive share | Positive mentions divided by all mentions | Mentions with a label |
| Net sentiment | Positive share minus negative share | Mentions with a label |
Because these come from repeated, variable runs, they carry noise. A brand with four mentions in a month cannot support a claim about its sentiment. The Wilson interval from the variability chapter applies to any of these proportions, using the count of mentions as the number of trials. Report the count next to every percentage.
Using the two measures together
Cross-reading position and sentiment shows patterns that neither shows alone.
- High mention rate, late position, mixed sentiment. The engine knows your brand but treats it as an alternative. Look at which attributes it cites as weaknesses.
- Low mention rate, first position, positive sentiment. The brand is recommended when it appears but is not triggered by many prompts. The prompt set or your topical coverage may be the cause.
- High mention rate, first position, negative sentiment. The brand is the default example, possibly in a cautionary role. Read the answers before acting.
Always read a sample of the underlying answers. Metrics tell you where to look, and the text tells you why.
Common misreadings
- Treating average position as a ranking that can be improved by a fixed number of places.
- Comparing sentiment scores between tools that use different scales or judges.
- Ignoring that sentiment is conditional on a mention, so a brand with a handful of mentions can show 100% positive.
- Averaging rank across prompts of very different types, such as "best" queries and "how to" queries, without segmenting.
- Reading a position change as a result of your work when run-to-run variation is enough to explain it.
Exercise
Over 20 runs, your brand is mentioned in 8. In those 8 mentions its ranks are 1, 1, 2, 3, 1, 2, 4, 1. Compute the average position, the first-place rate over all runs, and the first-place rate among runs that mentioned the brand. Then say which figure you would put beside mention rate in a report, and why.
Show answer
Average position is (1+1+2+3+1+2+4+1) / 8 = 15 / 8 = 1.875. The brand ranked first in 4 runs. Over all runs the first-place rate is 4 / 20 = 20%. Among runs with a mention it is 4 / 8 = 50%. Use the 20% figure beside mention rate (8 / 20 = 40%), because both share the same denominator and can be read together. If you report the 50% figure, label it as conditional on a mention and show the count of 8, because 8 mentions is a small sample.
Exercise
A lexicon scorer labels this sentence about Acme as positive: "Globex is not as reliable as Acme is popular, but Globex is recommended." Name two reasons the label may be wrong and one change that would reduce the error.
Show answer
First, the sentence has several sentiment words that belong to different brands ("reliable", "popular", "recommended"), so a sentence-level score cannot tell which words describe Acme. Second, negation ("not as reliable") and comparison change the polarity of nearby words in ways a simple previous-word check does not capture. Using an LLM judge or classifier that is told which brand to evaluate, and checking a sample of its labels by hand, would reduce the error. Splitting on clauses instead of sentences would also help.