For fixed-label text classification, fine-tuned encoders give near-equal accuracy with 10–100× lower cost and much lower tail latency than L

February 6, 20269 min

Overview

Decision SnapshotReady For Pilot

The study uses reproducible code, repeated runs, and production-like deployments; results directly map to operational choices and show consistent large cost/latency gaps favoring encoders.

Citations0

Evidence Strength0.90

Confidence0.88

Risk Signals10

Trust Signals

Findings with numeric evidence: 5/5

Findings with evidence refs: 5/5

Results with explicit delta: 6/6

Reproducibility

Status: Code + data available

Open source: Yes

At A Glance

Cost impact: 92%

Production readiness: 88%

Novelty: 30%

Authors

Alberto Andres Valdes Gonzalez

Links

Abstract / PDF / Code / Data

Why It Matters For Business

Choosing LLM prompting for routine fixed-label classification often increases operating cost by 10–100× and raises tail latency risk; using fine-tuned encoders saves money, stabilizes SLAs, and eases governance.

Who Should Care

Summary TLDR

This paper benchmarks fine-tuned BERT-family encoders against zero- and few-shot LLM prompting (GPT-4o, Claude Sonnet 4.5) on IMDB, SST-2, AG News, and DBPedia. It measures macro-F1, end-to-end latency (p50/p95/p99), TTFT, and per-request cost. Result: encoders match or exceed LLM accuracy on these fixed-label tasks while delivering one to two orders of magnitude lower inference cost and much tighter tail latency. DistilBERT often wins the utility ranking (best trade-off). The authors release code and configs to reproduce cost/latency estimates.

Problem Statement

Model choice for fixed-label text classification is usually driven by accuracy alone. In production, latency, tail behavior, recurring inference cost, and governance (reproducibility, versioning) matter just as much. The paper asks: when does LLM prompting justify its higher operational overhead compared to fine-tuned encoders?

Main Contribution

A reproducible benchmark comparing fine-tuned BERT-family encoders and zero/few-shot LLM prompting on four standard datasets, reporting macro-F1, latency percentiles, TTFT, and per-request cost.

A decision framework: Pareto-front analysis plus a parameterized utility function that ranks models under different latency tolerances.

Key Findings

Fine-tuned encoders match or exceed LLM prompting on structured fixed-label tasks while running far cheaper and faster.

NumbersExamples: DistilBERT cost $5.73$12.44 vs GPT-4o/Claude $276$2,701 per 1M req (datasets AG News, IMDB, DBPedia).

Practical UsePrefer fine-tuned encoders for high-throughput fixed-label classification to save money and meet latency SLAs.

Evidence RefTables 2-5; Tables 4,2,5 cost rows

Tail latency and TTFT for LLM APIs are much higher and more variable than for encoders.

NumbersLLM p95 latencies often ≥1.72.0s; encoder p50 latencies typically 98622 ms with tighter tails.

Practical UseIf your SLA needs predictable tails (p95/p99), avoid API LLM prompting for per-request inference.

Evidence RefSections 4.2 and Tables 2-5 (p95/p50 latency rows)

Results

MetricValueBaselineDeltaSplit / DatasetEvidenceEvidence Ref
IMDB macro-F1RoBERTa 94.84% ±0.12 vs Claude 4.5 FS 96.48% ±0.01RoBERTa encoderLLM +1.64 F1 pointsIMDB testTable 2 F1 rowsTable 2
IMDB estimated cost (USD / 1M req)DistilBERT $12.44 vs GPT-4o ZS $842.78DistilBERT encoderLLM ~67.7× higher costIMDB cost estimateTable 2 cost rowsTable 2

What To Try In 7 Days

Run this paper's repo to measure your p50/p95 latency and cost using your pricing snapshot.

Fine-tune DistilBERT on your label set as a baseline and measure macro-F1 vs latency and cost.

Compute the provided utility function with your τ (latency tolerance) to pick a deployment candidate.

Optimization Features

Token Efficiency
few-shot prompting substantially increases input tokens and token cost
Infra Optimization

measure end-to-end latency on realistic serverless infra (Cloud Run) rather than raw hardware timing

Model Optimization
fine-tuning encoder weights for task specializationpick compact models (DistilBERT) to reduce latency/cost
System Optimization
use utility + Pareto analysis to choose models under SLA constraints
Training Optimization
select checkpoint by a gap-penalized generalization score to avoid overfitting
Inference Optimization
deploy encoders as stateless services to minimize end-to-end latencyavoid few-shot prompting when throughput and cost matter

Reproducibility

Code AvailableYes
Data AvailableYes
Open Source StatusYes
LicenseUnknown

Data URLs

IMDBSST-2AG NewsDBPedia

Risks & Boundaries

Limitations

Benchmarks limited to four English fixed-label datasets; results may differ for open-ended, high-ambiguity tasks.

Latency and cost estimates tied to specific Cloud Run config and January 22, 2026 pricing snapshot.

When Not To Use

When the task requires open-ended generation, schema discovery, or evolving taxonomies where LLM reasoning adds unique value.

Low-volume prototypes where per-request cost is negligible and developer convenience matters more than operating cost.

Failure Modes

Adopting few-shot LLM prompting at scale causes high token bills and unpredictable tail latencies.

Relying on API LLMs creates vendor-lock and silent behavior changes from provider updates.

Core Entities

Models

BERTRoBERTaDistilBERTGPT-4oClaude Sonnet 4.5

Metrics

macro F1precisionrecallAccuracyinference latency p50/p95/p99time-to-first-token (TTFT)avg input/output tokensestimated cost per 1M requestsutility score (F1/cost with latency decay)Pareto dominance in (F1, latency, cost)

Datasets

IMDBSST-2AG NewsDBPedia

Benchmarks

fixed-label text classification benchmark (this work)