Claude Token Counter, now with model comparisons

Simon Willison's Weblog

View Original ↗
AI 導讀 technology AI 重要性 3/5

Opus 4.7 採用全新分詞器,實測顯示純文字 Token 消耗達前代的 1.46 倍。

  • 新版分詞器使純文字 Token 消耗達前代 1.46 倍,成本大增。
  • 影像解析度上限升級,高畫質圖片 Token 消耗飆升 3.01 倍。
  • 處理 30 頁密集文字 PDF,Token 消耗僅微增 1.08 倍。

Anthropic 釋出的 Claude Opus 4.7 在維持每百萬輸入 Token 5 美元定價的表象下,實際文本處理成本可能上升高達 40%。獨立開發者 Simon Willison 實測發現,由於採用全新的底層分詞器,同一組純文字系統提示詞在 Opus 4.7 消耗的 Token 數量達到了前一代的 1.46 倍。這項基礎架構的改變直接影響了 API 的真實預算消耗。

Claude 計數工具更新支援 4.7 模型對比

知名開發者 Simon Willison 近期升級了他專屬的 Claude Token 計算工具,正式加入針對不同模型版本進行交叉比對的核心功能。這項系統更新的主要驅動力來自於近期釋出的 Opus 4.7,這是 Claude 家族中第一個針對底層 Tokenizer(將文本切分為模型可處理最小單位的分詞器)進行重大調整的版本。由於早期版本的處理架構相對統一,過往進行這類跨版本數據對比的意義不大。現在透過全面升級的計數介面,開發者能夠直接載入相同的測試資料,並同步檢視 Opus 4.7、Opus 4.6、Sonnet 4.6 以及 Haiku 4.5 之間精確的運算消耗差異。這項工具不僅支援文字輸入,也串接了完整的 Claude API(應用程式介面),確保回報的數據與實際扣款邏輯完全一致。

Anthropic 聲明與純文字 1.46 倍成本膨脹

檢視 Anthropic 在發布 Opus 4.7 時發布的官方技術聲明,原廠明確指出新版模型採用了經過大幅更新的 Tokenizer,目的是為了整體提升模型處理特定文本的精確度與效率。研發團隊同時提出警告,表示這種架構上的權衡將導致相同的輸入內容映射出更多的 Token,官方預估的增長倍率落在 1.0 至 1.35 倍之間,具體數字取決於資料的類型與結構。為了驗證這項說法,Willison 直接將一段 Opus 4.7 專用的系統提示詞輸入測試工具中。實測結果顯示,新版分詞器實際生成的 Token 數量是 Opus 4.6 的 1.46 倍,這個數字甚至突破了官方技術聲明中所預測的增長上限。儘管 Anthropic 在帳面上維持了每百萬輸入 Token 5 美元、輸出 Token 25 美元的原始定價結構,但這種底層的通貨膨脹效應,意味著開發者在處理純文字任務時需面臨約 40% 的實質成本增幅。

3.75 百萬畫素圖片升級引發 3 倍消耗

除了一般文本格式,新版計數工具也完整支援圖片輸入的預算評估,藉此測試多模態模型的處理極限。Anthropic 在更新日誌中特別強調了 Opus 4.7 在高解析度視覺處理能力的顯著提升。根據官方規格,該模型現在能夠接收長邊達 2,576 像素的高畫質影像,總畫素容量高達約 3.75 百萬畫素(megapixels),這項處理上限是先前所有 Claude 模型規格的 三倍以上。為了檢驗這項視覺運算能力的成本代價,測試者上傳了一張解析度為 3456x2234 像素、檔案大小 3.7MB 的 PNG 圖片進行深度分析。終端回報的實測數據呈現出比純文字更驚人的增幅,Opus 4.7 針對這張高解析度圖片所計算出的 Token 數量,達到了前一代 Opus 4.6 的 3.01 倍

682 像素低解析圖片與 30 頁 PDF 實測差異

針對影像 Token 數據暴增的現象,後續的交叉比對測試進一步釐清了背後的底層運作邏輯。高達三倍的消耗增長,實際上完全歸因於 Opus 4.7 具備處理並保留更高原始解析度的能力,而非基礎計價演算法遭到全面調漲。當測試環境切換至一張僅 682x318 像素的低解析度圖片時,Opus 4.7 消耗了 314 個 Token,而 Opus 4.6 則為 310 個 Token,這證明兩者在低解析度區間的處理成本幾乎完全相同。另一方面,在處理長篇文字文件的極端場景中,測試者載入了一份高達 15MB、總計 30 頁的文字密集型 PDF 檔案。在這種以排版文本為主的複雜輸入格式下,Opus 4.7 回報的消耗量為 60,934 個 Token,對比 Opus 4.6 的 56,482 個 Token,其增幅倍率僅微幅上漲至 1.08 倍。這項測試數據遠低於純文字提示詞測試中觀察到的倍數,顯示新版模型架構對於不同資料結構的切割與壓縮策略有著極大差異。

Tokenizer 變更對 API 開發預算的影響

語言模型底層架構的更新,直接決定了字元、像素與雲端機器運算單位之間的基礎轉換匯率。從 Opus 4.6 跨越到 Opus 4.7 的進展過程,不僅僅是模型參數與推論能力的常規升級,更是基礎資料處理邏輯的全面重構。開發團隊在評估是否將生產環境中的核心系統升級至最新版本時,必須針對自身的專屬資料集重新建立一套精確的成本預測模型。從目前的各項實測數據來看,如果應用場景高度集中於簡短且密集的系統提示詞,成本增幅的影響將會極度顯著。相對地,若核心業務依賴解析度極高的多模態圖像分析,開發者就必須善用模型拓展的新視覺上限,並同時承擔相應的預算花費。對於那些處理大量標準化 PDF 商業文件的後台系統而言,升級至新版架構所帶來的財務衝擊則被有效壓縮在一個相對平緩的個位數百分比區間內。

升級至 Opus 4.7 雖維持原定價,但新版分詞器將依據輸入格式帶來最高 40% 至 3 倍不等的隱藏預算增長。

補充數據視覺化

Claude Opus 4.7 vs 4.6 Token 消耗實測對比
測試項目Opus 4.6 消耗量Opus 4.7 消耗量增幅倍率
系統提示詞 (純文字)--1.46x
高解析度圖片 (3456x2234)--3.01x
低解析度圖片 (682x318)310 tokens314 tokens~1.01x
文字密集型 PDF (30頁)56,482 tokens60,934 tokens1.08x

Abstract

Claude Token Counter, now with model comparisons I upgraded my Claude Token Counter tool to add the ability to run the same count against different models in order to compare them. As far as I can tell Claude Opus 4.7 is the first model to change the tokenizer, so it's only worth running comparisons between 4.7 and 4.6. The Claude token counting API accepts any Claude model ID though so I've included options for all four of the notable current models (Opus 4.7 and 4.6, Sonnet 4.6, and Haiku 4.5). In the Opus 4.7 announcement Anthropic said: Opus 4.7 uses an updated tokenizer that improves how the model processes text. The tradeoff is that the same input can map to more tokens—roughly 1.0–1.35× depending on the content type. I pasted the Opus 4.7 system prompt into the token counting tool and found that the Opus 4.7 tokenizer used 1.46x the number of tokens as Opus 4.6. Opus 4.7 uses the same pricing is Opus 4.6 - $5 per million input tokens and $25 per million output tokens - but this token inflation means we can expect it to be around 40% more expensive. The token counter tool also accepts images. Opus 4.7 has improved image support, described like this: Opus 4.7 has better vision for high-resolution images: it can accept images up to 2,576 pixels on the long edge (~3.75 megapixels), more than three times as many as prior Claude models. I tried counting tokens for a 3456x2234 pixel 3.7MB PNG and got an even bigger increase in token counts - 3.01x times the number of tokens for 4.7 compared to 4.6: Update: That 3x increase for images is entirely due to Opus 4.7 being able to handle higher resolutions. I tried that again with a 682x318 pixel image and it took 314 tokens with Opus 4.7 and 310 with Opus 4.6, so effectively the same cost. Update 2: I tried a 15MB, 30 page text-heavy PDF and Opus 4.7 reported 60,934 tokens while 4.6 reported 56,482 - that's a 1.08x multiplier, significantly lower than the multiplier I got for raw text. Tags: ai, generative-ai, llms, anthropic, claude, llm-pricing, tokenization