Skip to content
Journai
Go back

Hugging Face pipelines powering moderation of customer reviews

Customer reviews are essential for e-commerce platforms. However, moderating them is often tedious, especially when the majority are positive or benign. Manual moderation of every review is inefficient, so the main challenge is how to concentrate human effort where it truly matters: on potentially harmful, inappropriate content or feedback that may be valuable to fix products issues and create a better customer experience.

Demos

User submitting a positive review

Positive review metaobject

Positive review metaobject

User submitting a negative review

Negative review metaobject

Negative review metaobject

From constraints to solution

Thinking about this customer review moderation feature, several requirements and constraints stood out:

My solution puts AI in a supporting role as a filter rather than a final judge of content. I centralized the AI moderation into a dedicated FastAPI service that runs multiple Hugging Face pipelines, each specializing in a different classification task related to review quality and safety.

Shopify review moderation architecture using Hugging Face pipelines

Why use Hugging Face Pipelines for moderation?

Hugging Face Pipelines provide a straightforward interface for deploying various pretrained models to handle tasks like sentiment analysis, toxicity detection, and spam classification. They abstract away model loading, tokenization, and output parsing, simplifying integration.

The advantages in this context include:

Given the wide availability of relevant pretrained models from Hugging Face’s model hub, pipelines are a good fit for the requirements of review moderation.

High-level process overview

The system’s flow follows this sequence:

  1. The user enters a review in a form on the Shopify product detail page.
  2. The review data is sent to a backend middleware service (here powered by Brush) via Shopify’s front-end and App Proxy mechanisms.
  3. Brush acts as a centralized API gateway and integration platform, forwarding the review content to the AI FastAPI moderation service.
  4. The FastAPI service runs Hugging Face Pipelines with models specialized in toxicity, sentiment, and spam classification. The output includes flags like toxicity, negative_review, spam, or advertisement.
  5. Based on these flags, FastAPI determines an action field: whether the review must_review (require human approval) or can_publish immediately.
  6. The FastAPI service responds to Brush with this enriched moderation result.
  7. Brush uses the moderation outcome to create review metaobjects in Shopify Admin via its APIs, setting review states like “Draft” for reviews requiring human moderation or “Active” for approved content.
  8. The product detail page reviews section and listing show only reviews with status “Active”, thus preventing problematic reviews from displaying prematurely.

This process ensures that human moderators focus attention only where needed, reducing workload and improving trust in the review system.

The role of Brush as middleware

Brush is the bridge between Shopify’s front-end and the AI service. I used it to:

Brush receives POST requests at /customer-reviews (the user-submitted reviews) and triggers the call to /customer-review/moderate on the FastAPI service.

FastAPI moderation API

The dedicated FastAPI service:

This separation keeps AI model concerns isolated, enabling easier scalability or model swapping.

Shopify integration with metaobjects

Shopify’s Admin API supports dealing with metaobjects, which I used to represent reviews as entries with fields for rating, review text, and moderation flags.

The system filters to display only “Active” reviews publicly, preventing premature or unsafe content exposure.

This integration provides a native way to store enriched metadata alongside reviews.

Designing for change

By separating concerns with Brush acting as middleware and FastAPI as the AI inference layer, the system offers flexibility:

In this project, I tried to enforce the principle that AI should assist human moderation, not replace it, focusing effort on problematic content while automating the straightforward majority.

Automated moderation with Hugging Face Pipelines strikes a practical balance between operational complexity, accuracy and cost efficiency, serving the real-world constraints of e-commerce businesses.

The architecture described is therefore not a black-box but a pragmatic tool to lighten the human workload and uphold review quality at scale.


Share this post:

Previous Post
Automated weekly Shopify dev changelog with open-source LLM
Next Post
An AI chatbot in Shopify Admin