LLM-based Inappropriate Language Detection in User-Generated Reviews

yelp · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Trust and safety content moderation

Yelp needed to proactively detect egregious inappropriate language in reviews while maintaining high precision so legitimate reviews were not unnecessarily delayed or blocked.

Constraints:

Architecture

Yelp built an LLM-based binary classification pipeline for egregious inappropriate review detection. The team curated high-quality examples with User Operations, scored severity, augmented data with embedding similarity, used zero-shot and few-shot LLMs to label subcategories for sampling balance, fine-tuned HuggingFace LLMs, evaluated class separation with embeddings and t-SNE, calibrated thresholds with mock traffic at different spam prevalences, and deployed the model through Redshift, S3, MLFlow, MLeap, and a service container.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  Historical_review_corpus["Historical review corpus"] --> User_Operations_annotation["User Operations annotation"]
  Historical_review_corpus --> Similarity_augmentation["Similarity augmentation"]
  User_Operations_annotation --> Curated_dataset["Curated dataset"]
  Similarity_augmentation --> Curated_dataset
  Subcategory_sampler["Subcategory sampler"] --> Curated_dataset
  Curated_dataset --> S3_bucket["S3 bucket"]
  S3_bucket --> Fine_tuned_LLM_classifier["Fine-tuned LLM classifier"]
  Fine_tuned_LLM_classifier --> MLFlow_registry["MLFlow registry"]
  MLFlow_registry --> Model_server["Model server"]
  Threshold_calibration["Threshold calibration"] --> Model_server
  Model_server --> User_Operations_review_queue["User Operations review queue"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Historical review corpus Past reported and pre-filtered reviews used as the basis for training and evaluation. User Operations annotation, Similarity augmentation, Redshift
User Operations annotation Human moderation expertise used to curate high-quality labels and severity signals. Historical review corpus, Curated dataset
Similarity augmentation Uses sentence embeddings from LLMs to identify reviews similar to high-quality annotated samples. Historical review corpus, Curated dataset
Subcategory sampler Uses zero-shot and few-shot classification to identify inappropriate-content categories and rebalance training data. Curated dataset
Curated dataset High-quality balanced training/evaluation dataset for binary inappropriate-language classification. S3 bucket, Fine-tuned LLM classifier
Fine-tuned LLM classifier HuggingFace LLM fine-tuned for classifying reviews as appropriate or inappropriate. Curated dataset, MLFlow registry, S3 bucket
Threshold calibration Mock-traffic analysis used to set a production threshold for accepted confidence and high precision. Fine-tuned LLM classifier, Model server
Model server MLeap-backed service container serving predictions in live traffic. MLFlow registry, User Operations review queue
User Operations review queue Manual review stage for flagged reviews before final moderation decisions. Model server

Data flow

Historical and reported reviews are selected from Redshift for moderator curation, severity scoring, similarity expansion, and subcategory balancing. Curated training data is stored in S3 and used by a batch training script to fine-tune an LLM classifier. The trained model is registered in MLFlow, loaded into MLeap, served in a model-server container, and used to flag egregious reviews for User Operations review before final action.

3 supporting quotes
“Historical reviews stored in Redshift were selected for labeling and similarity matching (as described in the data curation section).”article, stated
“The curated dataset is stored into an S3 bucket and fed into the model training batch script.”article, stated
“The model generated from the batch is registered in MLFlow from which it is loaded into MLeap for serving predictions inside a service container”article, stated

Why this architecture

Yelp used LLMs because inappropriate-language detection requires contextual understanding beyond prior approaches, but it wrapped them in human curation, class balancing, threshold calibration, and manual review to protect high-precision moderation.

3 supporting quotes
“The tradeoffs in precision-recall drove us to adopt LLMs, which have been largely successful in the field of natural language processing.”article, stated
“it was necessary to more precisely define the task of inappropriate language detection to the LLM.”article, stated
“we needed to be extremely careful in our assessment of the model’s performance in real-time and choose a threshold that helps generate high precision.”article, stated

Models used: Large Language Models · HuggingFace LLMs · sentence embeddings · zero-shot classification · few-shot classification · fine-tuned binary classifier · t-SNE · MLeap

Scale

Alternatives considered (roads not taken)

Traditional ML or previous automated moderation approaches alone

Rejected because: Prior approaches did not provide the precision-recall balance Yelp wanted, prompting LLM adoption.

“we have iterated through several approaches to achieve higher precision and recall in the detection of inappropriate content.”article, stated
“The tradeoffs in precision-recall drove us to adopt LLMs”article, stated

Train only on raw historical inappropriate-review labels

Rejected because: Raw labels lacked enough precision and subcategory coverage, so Yelp added moderator curation, severity scoring, similarity augmentation, and sampling.

“raw volume alone was insufficient. The team recognized that language complexity—including metaphors, sarcasm, and other figures of speech—required precise task definition”summary, stated
“we collaborated with Yelp’s User Operations team to curate a high-quality dataset comprising the most egregious instances”article, stated

Ship from balanced-test metrics without real-traffic prevalence simulation

Rejected because: The team needed to assess false positives under low-prevalence real traffic and choose a high-precision threshold.

“Although the metrics were promising, we still needed to assess the false positive rate generated by the model in real-time traffic.”article, stated
“the spam prevalence in actual traffic is very low, so we needed to be extremely careful”article, stated

Patterns

fine-tuning-adaptation (model-adaptation)

Yelp fine-tuned a HuggingFace LLM on a curated binary classification dataset for inappropriate-review detection.

“we minimally fine-tuned the same model on the dataset for the given classification task and saw successful results”article, stated
“The model generated from the batch is registered in MLFlow from which it is loaded into MLeap for serving predictions”article, stated

human-in-the-loop-gate (safety)

Human moderators helped curate labels and reviewed model-flagged content before final moderation decisions.

“we collaborated with Yelp’s User Operations team to curate a high-quality dataset”article, stated
“The flagged reviews are manually reviewed by our User Operations team”article, stated

confidence-thresholding (routing)

Yelp simulated real-time traffic at different spam prevalences to choose a threshold that identifies inappropriate reviews within an accepted confidence range.

“determine the model threshold at which we can identify inappropriate reviews with an accepted range of confidence.”article, stated

Tradeoffs

Adopt LLM classification for egregious moderation cases.

Chose Fine-tuned LLMs over Continuing only with prior non-LLM moderation approaches.

Rationale: The team needed better precision-recall behavior for contextual language categories.

“The tradeoffs in precision-recall drove us to adopt LLMs”article, stated
“explored the efficacy of LLMs to identify egregious content”article, stated

Favor high precision in production moderation.

Chose Threshold calibration for high precision over A less stringent recall-maximizing threshold.

Rationale: False positives can delay legitimate reviews, while low prevalence makes threshold choice sensitive.

“In the absence of high precision, such a tool can have significant consequences, including delays in evaluating reviews”article, stated
“choose a threshold that helps generate high precision.”article, stated

Keep human review after automated flagging.

Chose Model-assisted moderation with User Operations review over Fully automated removal decisions.

Rationale: The article positions the model as a proactive surfacing system while final decisions remain with moderators.

“The flagged reviews are manually reviewed by our User Operations team”article, stated
“Yelp allows both consumers and business owners to report reviews they believe violate our content policies”article, stated

Gotchas (what bit them)

Balanced-test performance was not enough to ship safely.

Root cause: In real traffic, inappropriate-review prevalence is low, so false positives can dominate if thresholds are set from balanced data alone.

Resolution: Simulate mock traffic at different spam prevalence levels and choose a high-precision confidence threshold.

“Although the metrics were promising, we still needed to assess the false positive rate generated by the model in real-time traffic.”article, stated
“the spam prevalence in actual traffic is very low, so we needed to be extremely careful”article, stated

Historical inappropriate-review data lacked enough category coverage.

Root cause: Many curated reviews did not include subcategory information for the forms of inappropriate content.

Resolution: Use zero-shot and few-shot LLM classification to label subcategories, then under-sample or over-sample where needed.

“a large number of reviews that we curated did not contain this information.”article, stated
“we leveraged zero shot and few shot classification capabilities of LLMs to identify the sub-category of inappropriate content”article, stated

Language complexity made generic labels insufficient.

Root cause: Metaphors, sarcasm, and figures of speech complicate inappropriate-language detection.

Resolution: Collaborate with User Operations to curate severe examples and define the task precisely.

“given the inherent complexity of language, especially in the presence of metaphors, sarcasm and other figures of speech”article, stated
“it was necessary to more precisely define the task of inappropriate language detection to the LLM.”article, stated

Evaluation

Yelp evaluated embedding separation with silhouette score and t-SNE, fine-tuned on curated data, checked class-balanced test metrics, and simulated real-time traffic with different spam prevalence levels to choose a confidence threshold.

Metrics: silhouette score · t-SNE separation · balanced test data metrics · false positive rate in simulated real-time traffic · confidence threshold

3 supporting quotes
“we determined the separation between appropriate and inappropriate samples by evaluating the silhouette score between the two groups”article, stated
“as well as by plotting them on a two-dimensional space upon dimension reduction with t-SNE.”article, stated
“The result of this analysis allowed us to determine the model threshold”article, stated

Outcomes

The source gives concrete moderation volumes: 26,500+ reported reviews removed in 2022 and 23,600+ reviews prevented from publishing in 2023.

3 supporting quotes
“Now we were ready to push the model’s deployment to actual traffic on Yelp.”article, stated
“it enabled our moderators to proactively prevent 23,600+ reviews from ever publishing to Yelp in 2023.”article, stated
“Based on the decisions made by moderators and subsequent retraining of the model, we anticipate further improvements in the model’s recall in the future.”article, stated