All benchmarks

  Preprint

Fine-tuned RoBERTa-base beat Claude Sonnet 4.5 and GPT-4o at sorting news by topic

Made by Alberto Andres Valdes Gonzalez

arXiv preprint

The result

  • Quality

    Macro F1 on the AG News test split (3,800 articles). Small model: RoBERTa-base, fine-tuned (mean of 3 seeds). Large model: Claude Sonnet 4.5, zero-shot, temperature 0 (its best AG News setting; mean of 3 runs).

    94.63%vs 91.35%

    Ahead by 3.28 points

    RoBERTa-base, fine-tuned94.63%
    Claude Sonnet 4.591.35%

    Macro F1, AG News · higher is better

  • Cost per call

    The paper’s own estimate (Table 4 and Appendix A), given per 1M requests and divided by 1M here; not a bill. Encoder: p50 latency (0.1887 s) x (2 vCPU x US$24 + 2 GiB x US$2.50 per 1M seconds) for the Cloud Run service. Claude: average tokens per request (121.86 in, 5.00 out) x list prices (US$3 and US$15 per 1M tokens). Price snapshot of 22 Jan 2026. Training cost, discounts and batching are left out. As reported: US$10.00 per 1M requests for RoBERTa vs US$440.58 for Claude Sonnet 4.5 zero-shot (Claude few-shot US$1,271.58; GPT-4o zero-shot US$276.00, few-shot US$903.50)

    44×cheaper

    RoBERTa-base, fine-tunedUS$0.00001on Google Cloud Run, 2 vCPU, no GPU
    Claude Sonnet 4.5US$0.00044via Anthropic’s API

    US$ per call · lower is better

  • Latency

    Median (p50) time per request after 10 warm-up requests, measured the same way for both from the client in Google Colab: to the encoder’s Cloud Run service (2 vCPU, 2 GiB, no GPU) and to Anthropic’s API (released notebooks). At p95: 279.20 ms vs 2,298.01 ms; at p99: 485.33 ms vs 4,551.21 ms.

    7.6×faster

    RoBERTa-base, fine-tuned188.7 mson Google Cloud Run, 2 vCPU, no GPU
    Claude Sonnet 4.51,434.82 msvia Anthropic’s API

    ms · lower is better

The story

Is an API the right tool for sorting text?

When a text only has to be sorted into a fixed set of labels, large language model APIs are often picked because they work without any training. Alberto Andres Valdes Gonzalez, at the Pontifical Catholic University of Chile, measured that choice against the older route: a small encoder fine-tuned for the task and served on your own infrastructure. He compared the two on accuracy, response time and cost across four public datasets.

The clearest of the four is AG News: put each news article into one of four topics, World, Sports, Business or Sci/Tech. The author trained on 120,000 articles and kept 3,800 for validation and 3,800 for the test, with stratified splits.

Data

AG News

120,000 training, 3,800 validation and 3,800 test articles

Training 120,000Validation 3,800Test 3,800

Public news-topic benchmark (Zhang et al., 2015), split by the author with stratified sampling

Four classes. The split notebook, the prompts and the training and inference notebooks are on GitHub.

The small model

Small model

RoBERTa-base

124.7M (Hugging Face card) · Meta (FacebookAI)

Fully fine-tuned by the author on the 120,000 AG News training articles

Base
Roberta-base (FacebookAI), with a new 4-class classification head
FacebookAI/roberta-base

Three encoders were fine-tuned end to end: BERT, DistilBERT and RoBERTa. In the released notebook, RoBERTa is roberta-base, trained with AdamW at a learning rate of 2e-5 and a batch size of 16 on one NVIDIA A100 in Google Colab, about ten minutes per epoch. After each of up to four epochs the author scored the validation set with a rule that penalizes the gap between training and validation F1; epoch 1 won every time. Each encoder was trained with three seeds.

Training

Full fine-tune with a classification head

AdamW, learning rate 2e-5, batch 16, up to 4 epochs, 3 seeds; checkpoint chosen on validation (epoch 1 every time)

1x NVIDIA A100-SXM4-80GB on Google Colab
Time
About 10 minutes per epoch (9 min 51 s at epoch 1, mean of 3 seeds)
Cost
Not reported; the paper leaves training cost out

The large models

Large model

Claude Sonnet 4.5

Size not disclosed · Anthropic

Used as released through Anthropic’s API at temperature 0, answer capped at 16 tokens; zero-shot with the label list, or with one example per class

Base
General model; API ID claude-sonnet-4-5-20250929

On the other side, Claude Sonnet 4.5 and GPT-4o were called through their APIs at temperature 0, with the answer limited to a single class digit. Each got two prompts: zero-shot, with only the label list, and few-shot, with one example article per class. Every configuration ran three times over the whole test set.

Evaluation

3,800 test items

Test set
AG News test split, 3,800 articles
Metric
Macro F1 (class-balanced) on the held-out test split
How it was compared
Same articles and scoring for all seven setups. The LLMs got the label list, or one example per class, at temperature 0; Claude ran without extended thinking (released code). Encoders are means of 3 seeds, LLMs means of 3 runs.

RoBERTa reached 94.63 macro F1 on the 3,800 test articles (BERT 94.43, DistilBERT 94.11). The best LLM setting was Claude zero-shot at 91.35; with examples Claude reached 90.56, and GPT-4o 87.93 zero-shot and 89.65 with examples.

Timed and priced the same way

Every request was timed from the same client in Colab, either to the encoder running as a Google Cloud Run service with 2 vCPUs, 2 GiB of memory and no GPU, or to the provider’s API. After 10 warm-up requests, RoBERTa’s median response took 188.7 ms against 1,434.8 ms for Claude zero-shot; at the 95th percentile, 279.2 ms against 2,298.0 ms.

Cost is the author’s estimate, not a bill. For the encoder it is median latency times Cloud Run’s prices for that machine; for the LLMs, average tokens per request times list prices on 22 January 2026. Per million requests that comes to US$10.00 for RoBERTa, US$440.58 for Claude zero-shot and US$276.00 for GPT-4o zero-shot. Training cost is left out.

AG News is the paper’s clearest result, not a universal one. On IMDB movie reviews both LLMs beat every encoder (Claude with examples 96.48 against RoBERTa’s 94.84), and on SST-2 the best encoder and Claude with examples tied (94.42 and 94.41).

All the numbers

Show all numbersHide all numbersEvery model · Cost, latency and energy · 4 more results

Every model on the headline test

Cost, latency and energy, as reported

Cost · US$ per 1M requests (estimated)
RoBERTa-base, fine-tuned10
Claude Sonnet 4.5440.58
RoBERTa served on Google Cloud Run, 2 vCPU and 2 GiB memory (CPU only); fine-tuned on NVIDIA A100 (Google Colab). Claude Sonnet 4.5: Anthropic API, hardware not disclosed.
Estimated by the author. Encoder: p50 latency x Cloud Run price for 2 vCPU and 2 GiB (US$24 per 1M vCPU-seconds, US$2.50 per 1M GiB-seconds). LLM: average input/output tokens x list price (Claude Sonnet 4.5: US$3 input, US$15 output per 1M tokens), price snapshot 22 Jan 2026. Training cost excluded. GPT-4o on AG News: US$276.00 zero-shot, US$903.50 few-shot.
Latency · ms, p50 end-to-end
RoBERTa-base, fine-tuned188.7
Claude Sonnet 4.51434.82
Encoder latency is measured end to end, from client request to label, through Cloud Run; LLM latency is the total response latency as provided by the APIs (Section 3.6). The paper says LLM response time is largely dominated by network/API overhead.
Energy
Not reported

More from the source

  • AG News macro F1, others: BERT 94.43, DistilBERT 94.11; GPT-4o few-shot 89.65, GPT-4o zero-shot 87.93, Claude 4.5 few-shot 90.56

    Table 4

  • AG News p50 latency: RoBERTa 188.70 ms vs Claude 4.5 ZS 1,434.82 ms (GPT-4o FS 332.31 ms)

    Small model 188.7Large model 1434.82 ms

    Table 4

  • AG News p95 latency: RoBERTa 279.20 ms vs Claude 4.5 ZS 2,298.01 ms

    Small model 279.2Large model 2298.01 ms

    Table 4

  • Where the LLM wins or ties

    IMDB macro F1Claude 4.5 few-shot 96.48 vs best encoder RoBERTa 94.84 (LLM wins)
    SST-2 macro F1BERT 94.42 vs Claude 4.5 few-shot 94.41 (tie)
    DBPedia macro F1BERT and DistilBERT 99.40 vs Claude 4.5 zero-shot 98.83

    Tables 2, 3, 5

Worth knowing

  • Single-author preprint, not peer-reviewed.
  • Public benchmarks; the LLMs are not fine-tuned and get no chain-of-thought.
  • Costs are the author’s estimates from list prices and one Cloud Run configuration, not billed invoices; training cost is excluded.
  • Not a universal win: Claude is more accurate on IMDB and ties on SST-2.
1 more caveat
  • The paper doesn’t name the encoder checkpoint; the size comes from the released code plus the Hugging Face card.

Weights on Hugging Face

Base model on Hugging Face

Base model, verified 03 Oct 2026; ‘roberta-base’ confirmed in the released notebook 02.Finetunning_Encoders/AG_News/RoBERTa/seed=1. The fine-tuned weights are not on Hugging Face.

Sources

  1. Valdes Gonzalez, “Cost-Aware Model Selection for Text Classification: Multi-Objective Trade-offs Between Fine-Tuned Encoders and LLM Prompting in Production”, arXiv 2602.06370
  2. Author’s code, prompts and notebooks (GitHub)
  3. Author’s Cloud Run deployment configs (GitHub)
  4. arXiv v1 6 Feb 2026 (2602.06370). Prices are snapshots from 22 Jan 2026.
5 more sources behind this page
  1. arXiv 2602.06370v1
  2. github.com/anvaldes/Finetuned-encoders-LLM-Prompting/…/Inference_AG_News_RoBERTa_seed_1_part_1.ipynb
  3. github.com/anvaldes/Finetuned-encoders-LLM-Prompting/…/Inference_AG_News_Claude_Zero_seed_1_part_1.ipynb
  4. github.com/anvaldes/Finetuned-encoders-LLM-Prompting/…/RoBERTa_AG_News_Seed_1.ipynb
  5. github.com/anvaldes/bert-family-deploy/.github/workflows/deploy.yml
Share this benchmark

Drawing the image…

Post text