---
title: "1 Billion Classifications"
description: "Processing 1B classifications or embeddings on a single-GPU baseline costs about $254 for DistilBERT sentiment classification and $409 for ModernBERT-based gte embeddings on an NVIDIA L4 ($0.8/hr), but roughly $44,500 for ColQwen2 vision embeddings."
url: "https://swe.quest/articles/1-billion-classifications-90168b62de6ffa1b"
canonical: "https://huggingface.co/blog/billion-classifications"
source: "Hugging Face"
published: "2025-02-13"
difficulty: "medium"
kind: "Research"
reading_minutes: 17
tags: ["inference","cost-optimization","performance","machine-learning"]
---

# 1 Billion Classifications

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-02-13, 17 min read, Research. Original: [https://huggingface.co/blog/billion-classifications](https://huggingface.co/blog/billion-classifications)

## Summary

Processing 1B classifications or embeddings on a single-GPU baseline costs about $254 for DistilBERT sentiment classification and $409 for ModernBERT-based gte embeddings on an NVIDIA L4 ($0.8/hr), but roughly $44,500 for ColQwen2 vision embeddings. The method serves models with Infinity on Hugging Face Inference Endpoints and load-tests them with k6's shared-iterations executor. It sweeps batch size and virtual users using an exponential-then-binary search with a 2% improvement threshold, then scales cost horizontally by adding replicas. The best configurations were batch 64 / 448 VUs for classification, 32 / 256 for embedding and 4 / 4 for vision. The cheap T4 lost to the L4, partly because Flash Attention 2 requires newer GPUs.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)

## Prerequisites

- transformer encoder models
- GPU inference basics ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- load testing concepts ([easy posts on Testing](https://swe.quest/tags/testing.md?difficulty=easy))

## Keywords

Infinity, k6, Hugging Face Inference Endpoints, DistilBERT, ModernBERT, ColQwen2, NVIDIA L4

## Related posts

- [Rocket Money x Hugging Face: Scaling Volatile ML Models in Production​](https://swe.quest/articles/rocket-money-x-hugging-face-scaling-volatile-ml-models-in-production-acc7e904259d3114.md): Hugging Face · 2023-09-19 · Easy · 8 min read · Inference & serving, ML platforms, Machine learning, Caching, Payments & fintech
  Rocket Money replaced a regex-and-decision-table merchant detector with a BERT-family transformer classifier spanning 4000+ classes, served through Hugging Face's hosted Inference API rather than an in-house MLOps stack.
- [My Journey to a serverless transformers pipeline on Google Cloud](https://swe.quest/articles/my-journey-to-a-serverless-transformers-pipeline-on-google-cloud-202ccbc112026927.md): Hugging Face · 2021-03-18 · Medium · 8 min read · Serverless, Inference & serving, Cloud platforms, Python, Containers
  A Hugging Face transformers sentiment-analysis pipeline (DistilBERT fine-tuned on SST-2) was deployed as a low-traffic microservice on Google Cloud Run after AI Platform Prediction (beta instability, checkpoint not a pure TensorFlow model) and App Engine (TensorFlow install failure, PyTorch handling only 2 requests per instance) fell short.
- [Deploy Embedding Models with Hugging Face Inference Endpoints](https://swe.quest/articles/deploy-embedding-models-with-hugging-face-inference-endpoints-e85e7e272a9c97bc.md): Hugging Face · 2023-10-24 · Medium · 5 min read · Inference & serving, RAG & retrieval, ML platforms
  Open-source embedding models such as BAAI/bge-base-en-v1.5 can be deployed on Hugging Face Inference Endpoints using Text Embeddings Inference (TEI), which offers token-based dynamic batching, Flash Attention, Candle and cuBLASLt kernels, safetensors loading, small images for fast boot, and OpenTelemetry/Prometheus support.
- [Why we’re switching to Hugging Face Inference Endpoints, and maybe you should too](https://swe.quest/articles/why-we-re-switching-to-hugging-face-inference-endpoints-and-maybe-you-should-too-bfdcddeceab350fa.md): Hugging Face · 2023-02-15 · Medium · 6 min read · Inference & serving, ML platforms, Cost optimization, Cloud platforms
  A team moved CPU-based transformer inference off a self-built FastAPI + Docker + AWS ECS/Fargate stack onto Hugging Face Inference Endpoints, collapsing deployment to train, push to Hub, deploy.
- [Accelerate BERT inference with Hugging Face Transformers and AWS Inferentia](https://swe.quest/articles/accelerate-bert-inference-with-hugging-face-transformers-and-aws-inferentia-a06f31ecbe8356b6.md): Hugging Face · 2022-03-16 · Medium · 8 min read · Inference & serving, Hardware, Cloud platforms, Python
  DistilBERT can be compiled to AWS Neuron with torch.neuron.trace and served on an Inferentia-backed SageMaker real-time endpoint, using a custom inference.py that pins one Neuron core per HTTP worker.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
