Sub topic 10
Privacy, bias, fake reviews and hallucination
This chapter assumes you can read basic Python and JSON. It also assumes you have met the text preparation and LLM extraction steps from earlier chapters. Review analysis can fail in four ways even when the code runs: it can expose personal data, it can reflect a skewed sample, it can count fake reviews as real, and it can report claims the reviews never made. This chapter covers how to spot and reduce each one.
Privacy: remove personal data early
Reviews and support messages often contain names, emails, phone numbers, order numbers and health or financial details. Customers did not write them for your analysis pipeline.
- Redact before anything else. Run the redaction from the text preparation chapter before data reaches a third-party LLM API, a shared notebook or a log file.
- Collect only what you need. If the goal is themes, you do not need the author's name or address. Drop those fields.
- Keep an access boundary. Store raw text in one place with restricted access. Let the analysis work on the redacted copy.
- Check your provider's terms. Find out whether submitted text is retained or used for training, and whether your legal basis for processing covers this use. Rules such as GDPR may apply.
Regular expressions miss things, such as a name in free text or an email written as "john at example dot com". Treat redaction as a filter that reduces risk. It does not remove the risk.
Bias: your sample is not your customers
The data sources chapter showed that feedback is self-selected. Three further biases affect the analysis itself.
- Sampling bias. Angry and delighted customers write more than satisfied, quiet ones. Percentages from reviews describe reviewers, not all customers.
- Language and dialect bias. Sentiment tools trained mostly on standard English can misread slang, sarcasm, other languages and non-native phrasing. Check accuracy per language and per group before trusting an overall score.
- Model bias. An LLM may treat the same complaint differently depending on tone or wording. Compare labels on matched examples, using the human-labelled sample from the evaluation chapter split by language or channel.
A simple mitigation is to report counts with the caveat about who wrote them, and to show per-segment accuracy next to per-segment results.
Fake and manipulated reviews
Fake reviews can be paid praise, competitor attacks or bot-generated text. No single signal proves a review is fake, so combine weak signals and send flagged reviews to a person.
from collections import Counter
def flag_suspicious(reviews):
per_day = Counter(r["date"] for r in reviews)
counts = sorted(per_day.values())
median = counts[len(counts) // 2]
same_text = Counter((r["author"], r["text"].lower()) for r in reviews)
flagged = []
for r in reviews:
reasons = []
if per_day[r["date"]] > 3 * median:
reasons.append("burst")
if len(r["text"].split()) < 4:
reasons.append("very short")
if same_text[(r["author"], r["text"].lower())] > 1:
reasons.append("repeated by author")
if reasons:
flagged.append((r["author"], reasons))
return flagged
reviews = [
{"author": "ana", "date": "2026-11-01", "text": "Works fine after a month of use."},
{"author": "ben", "date": "2026-11-02", "text": "Battery died in a week, support was slow."},
{"author": "cy", "date": "2026-11-03", "text": "Arrived late but the screen is great."},
{"author": "x1", "date": "2026-11-04", "text": "Best product ever buy now!"},
{"author": "x1", "date": "2026-11-04", "text": "Best product ever buy now!"},
{"author": "x2", "date": "2026-11-04", "text": "Best product ever buy now!"},
{"author": "x3", "date": "2026-11-04", "text": "Amazing"},
{"author": "x4", "date": "2026-11-04", "text": "Five stars"},
]
for author, reasons in flag_suspicious(reviews):
print(author, reasons)The three genuine reviews pass. All five reviews from 4 November are flagged as a burst, and the other signals add reasons for some of them. Thresholds like 3 * median are starting points, so tune them on your own data. Flagged reviews should be excluded from headline numbers, or reported separately, only after review.
Hallucination: claims the reviews never made
An LLM can invent a quote, attribute a complaint to the wrong product, or state a trend that is not in the data. The structured extraction chapter already showed three defences, and they apply to every LLM step:
- Fixed label sets. Reject any label outside the allowed list.
- Evidence quotes. Require a quote copied from the review, then check it is actually a substring of the review text.
- Traceability. Every sentence in a summary should point to review IDs a person can open.
Add a human spot check. Read a random sample of LLM outputs against their sources each time you change the prompt or model.
Summary table
| Risk | Typical sign | Main mitigation |
|---|---|---|
| Privacy | Emails or names in LLM inputs | Redact first, restrict raw data |
| Bias | Accuracy differs by language or channel | Per-segment evaluation, caveats |
| Fake reviews | Bursts, repeats, very short text | Combine signals, human review |
| Hallucination | Quote not found in review | Validate output, cite review IDs |
Exercise
An LLM returns the evidence quote "the charger overheated twice" for a review, but that phrase does not appear in the review text. Which check from this chapter catches it, and what should the pipeline do with the quote?
Show answer
The check that the evidence is a substring of the review catches it. The pipeline should discard the quote (set it to None) and count the case as a hallucination when you measure quality. The label can then be sent for human review rather than trusted.
Exercise
Your overall sentiment accuracy is 90 percent, but you have never measured it by language. Why is that a problem, and what would you do?
Show answer
The overall figure can hide poor accuracy on a smaller group, such as non-English or slang-heavy reviews. Split your human-labelled sample by language or channel, compute precision and recall for each part, and report the weaker results next to the overall score.