---
title: "My Journey to a serverless transformers pipeline on Google Cloud"
description: "The post documents Maxence Dominici’s effort to deploy a Transformers sentiment-analysis pipeline on Google Cloud for classifying customer reviews from Discord. After considering AI Platform Prediction and App Engine, he chose Cloud Run with a Docker image because custom checkpoint handling, dependencies, and resource requirements made the other options unsuitable. The implementation uses a PyTorch DistilBERT model fine-tuned on SST-2, Flask, Gunicorn, and a GET request protected by an optional API key; the shown handler retrieves a review but passes the hard-coded text “that was great” to the classifier. Cloud Run is configured with 4 GB of memory, one worker, and one thread to limit memory pressure and billing. Requests take under five seconds including model loading, while cold starts may add about ten seconds, and the author reports that the pretrained model’s accuracy was already impressive."
---

# My Journey to a serverless transformers pipeline on Google Cloud

[Hugging Face](https://yomu.fyi/company/hugging-face) · Dominici · Mar 18, 2021

**Type:** Tutorial

## Summary

The post documents Maxence Dominici’s effort to deploy a Transformers sentiment-analysis pipeline on Google Cloud for classifying customer reviews from Discord. After considering AI Platform Prediction and App Engine, he chose Cloud Run with a Docker image because custom checkpoint handling, dependencies, and resource requirements made the other options unsuitable. The implementation uses a PyTorch DistilBERT model fine-tuned on SST-2, Flask, Gunicorn, and a GET request protected by an optional API key; the shown handler retrieves a review but passes the hard-coded text “that was great” to the classifier. Cloud Run is configured with 4 GB of memory, one worker, and one thread to limit memory pressure and billing. Requests take under five seconds including model loading, while cold starts may add about ten seconds, and the author reports that the pretrained model’s accuracy was already impressive.

## Context

The goal was to create a microservice that detects whether customer reviews left in Discord are positive or negative, enabling different follow-up actions for dissatisfied customers. Expected usage was low—up to 2,000 requests per month—so the author did not impose performance or scalability constraints.

## Approach / What changed

The implementation packages a PyTorch DistilBERT sentiment model, its configuration and vocabulary, Flask application code, and pinned dependencies in a Docker image. The image runs on Cloud Run with Gunicorn, one worker, one thread, and 4 GB of memory. The service accepts review and API-key query parameters and uses the Transformers sentiment-analysis pipeline; deployment uses Google Cloud Build and Cloud Run commands.

## Takeaways

- Cloud Run was selected after AI Platform Prediction encountered beta-service issues and App Engine had TensorFlow installation problems and limited PyTorch concurrency.
- The container uses PyTorch DistilBERT fine-tuned on SST-2, with 4 GB of memory and a single worker and thread to accommodate model memory usage and limit billing exposure.
- Measured request handling took less than five seconds including pipeline loading and prediction, while cold starts could add roughly ten seconds; loading the model at startup was identified as a possible improvement.

**Tags:** [Docker](https://yomu.fyi/topic/docker), [Google Cloud](https://yomu.fyi/topic/gcp), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Performance](https://yomu.fyi/topic/performance), [Serverless](https://yomu.fyi/topic/serverless)

- Source: [Hugging Face](https://huggingface.co/blog/how-to-deploy-a-pipeline-to-google-clouds)
- Source URL: https://huggingface.co/blog/how-to-deploy-a-pipeline-to-google-clouds
- Ingested by Yomu: 2026-08-27T15:06:11.517Z

[Read original post](https://huggingface.co/blog/how-to-deploy-a-pipeline-to-google-clouds)
