Skip to content

Commit 7549f40

Browse files
Add Anthropic Sonnet 5 parse pipeline (run-llama#64)
Registers anthropic_sonnet_5_parse_with_layout_file, a raw-PDF parse-with-layout pipeline backed by claude-sonnet-5 with adaptive thinking enabled. Adds Sonnet 5 pricing to the Anthropic provider, using the introductory rate through 2026-08-31 and the standard rate afterward, with tests covering the pricing transition. Also adds the extended-benchmark leaderboard row.
1 parent 0eb315e commit 7549f40

5 files changed

Lines changed: 63 additions & 1 deletion

File tree

docs/pipelines.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ These pipelines use hosted APIs. You only need an API key in your `.env` file.
6565
| `anthropic_opus_4_6_parse_file` | Claude Opus 4.6, PDF file mode | `ANTHROPIC_API_KEY` |
6666
| **`anthropic_opus_4_6_parse_with_layout_file`** | Claude Opus 4.6, parse + layout, file mode (In paper: *Anthropic Opus 4.6*) | `ANTHROPIC_API_KEY` |
6767
| **`anthropic_opus_4_8_parse_with_layout_file`** | Claude Opus 4.8, parse + layout, file mode (In paper: *Anthropic Opus 4.8*) | `ANTHROPIC_API_KEY` |
68+
| `anthropic_sonnet_5_parse_with_layout_file` | Claude Sonnet 5, adaptive thinking + layout, file mode | `ANTHROPIC_API_KEY` |
6869
| `anthropic_fable_5_parse_with_layout_file` | Claude Fable 5, parse + layout, file mode | `ANTHROPIC_API_KEY` |
6970

7071
### Google Gemini

leaderboard.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Anthropic Opus 4.6,VLM - Proprietary,54.07,86.52,13.49,89.70,64.19,16.47,5.78,4.
1313
Anthropic Opus 4.7,VLM - Proprietary,63.34,87.17,55.84,90.26,69.42,13.99,7.14,5.69,8.63,6.07,8.17,
1414
Anthropic Opus 4.8,VLM - Proprietary,63.70,89.65,49.75,89.02,71.38,18.69,7.30,5.82,8.78,6.24,8.36,
1515
Anthropic Fable 5,VLM - Proprietary,70.78,89.79,52.21,90.02,72.62,49.24,15.60,13.04,19.36,13.03,16.99,
16+
Anthropic Sonnet 5,VLM - Proprietary,62.13,86.65,60.53,86.51,64.93,12.03,3.18,2.79,3.82,2.60,3.52,
1617
Google Gemini 3.1 Pro,VLM - Proprietary,69.14,91.00,41.13,90.16,52.43,70.99,8.49,6.69,9.69,7.73,10.54,
1718
Google Gemini 3.1 Flash Lite,VLM - Proprietary,58.32,85.48,9.92,89.46,58.38,48.38,0.29,0.19,0.37,0.27,0.31,
1819
OpenAI GPT-5.4 (Reasoning None),VLM - Proprietary,62.23,83.89,65.22,85.57,59.52,16.95,2.90,2.55,4.04,2.13,3.00,

src/parse_bench/inference/pipelines/parse.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,21 @@ def register_parse_pipelines(register_fn) -> None: # type: ignore[no-untyped-de
18301830
)
18311831
)
18321832

1833+
# Anthropic Sonnet 5 - Parse with Layout File - Adaptive Thinking
1834+
register_fn(
1835+
PipelineSpec(
1836+
pipeline_name="anthropic_sonnet_5_parse_with_layout_file",
1837+
provider_name="anthropic",
1838+
product_type=ProductType.PARSE,
1839+
config={
1840+
"model": "claude-sonnet-5",
1841+
"max_tokens": 32768,
1842+
"mode": "parse_with_layout_file",
1843+
"thinking": {"type": "adaptive"},
1844+
},
1845+
)
1846+
)
1847+
18331848
# Anthropic Fable 5 - Parse with Layout File
18341849
register_fn(
18351850
PipelineSpec(

src/parse_bench/inference/providers/parse/anthropic.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import base64
44
import io
55
import os
6-
from datetime import datetime
6+
from datetime import date, datetime
77
from pathlib import Path
88
from typing import Any
99

@@ -73,6 +73,9 @@
7373
_ANTHROPIC_PRICING_PER_M: dict[str, tuple[float, float]] = {
7474
# model-prefix: (input_per_M, output_per_M)
7575
"claude-fable-5": (10.00, 50.00),
76+
# Sonnet 5 has introductory pricing through 2026-08-31; handled in
77+
# _get_pricing so benchmark costs switch to standard pricing on time.
78+
"claude-sonnet-5": (3.00, 15.00),
7679
"claude-haiku-4-5": (1.00, 5.00),
7780
"claude-haiku-3-5": (0.80, 4.00),
7881
"claude-haiku-3": (0.25, 1.25),
@@ -153,6 +156,9 @@ def _get_pricing(self) -> tuple[float, float]:
153156
Uses longest-prefix matching to avoid ambiguity when one model
154157
prefix is a substring of another.
155158
"""
159+
if self._model.startswith("claude-sonnet-5") and date.today() <= date(2026, 8, 31):
160+
return (2.00, 10.00)
161+
156162
matches = [(p, r) for p, r in _ANTHROPIC_PRICING_PER_M.items() if self._model.startswith(p)]
157163
return max(matches, key=lambda x: len(x[0]))[1] if matches else (0.0, 0.0)
158164

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Unit tests for Anthropic provider pricing, including the Sonnet 5
2+
introductory-rate transition."""
3+
4+
from __future__ import annotations
5+
6+
from datetime import date
7+
8+
import pytest
9+
10+
from parse_bench.inference.providers.parse import anthropic
11+
from parse_bench.inference.providers.parse.anthropic import AnthropicProvider
12+
13+
14+
def _provider_for_model(model: str) -> AnthropicProvider:
15+
provider = object.__new__(AnthropicProvider)
16+
provider._model = model
17+
return provider
18+
19+
20+
def test_sonnet_5_uses_introductory_pricing_through_august_2026(monkeypatch: pytest.MonkeyPatch) -> None:
21+
class IntroDate(date):
22+
@classmethod
23+
def today(cls) -> date:
24+
return cls(2026, 8, 31)
25+
26+
monkeypatch.setattr(anthropic, "date", IntroDate)
27+
28+
assert _provider_for_model("claude-sonnet-5")._get_pricing() == (2.00, 10.00)
29+
30+
31+
def test_sonnet_5_uses_standard_pricing_after_intro_period(monkeypatch: pytest.MonkeyPatch) -> None:
32+
class StandardDate(date):
33+
@classmethod
34+
def today(cls) -> date:
35+
return cls(2026, 9, 1)
36+
37+
monkeypatch.setattr(anthropic, "date", StandardDate)
38+
39+
assert _provider_for_model("claude-sonnet-5")._get_pricing() == (3.00, 15.00)

0 commit comments

Comments
 (0)