lchen001/pricing-reversal
GitHub: lchen001/pricing-reversal
该项目通过大规模基准实验揭示了LLM推理模型中「价格反转」现象——标价更低的模型因隐藏思考token反而花费更高,并提供了交互式成本分析工具和预测方法。
Stars: 4 | Forks: 0
# 价格反转现象:当更便宜的推理模型最终花费更多时
[](https://arxiv.org/abs/2603.23971)
[](LICENSE)
[](https://price-reversal.streamlit.app)
本仓库包含我们论文的数据和代码:
## 核心发现
- **价格反转现象非常普遍**:标价较低的 API 模型在实际使用中往往花费*更多*。例如,Gemini 3 Flash 的标价仅为 GPT-5.2 的 1/5,但在各项任务中的平均花费却高出 22%。
- **思考 token 是根本原因**:隐藏的推理 token 在不同模型之间差异巨大(对于相同的查询,思考 token 数量差异高达 860%),并且它们在实际成本中占主导地位。
- **预测实际成本很困难**:即使使用基于 KNN 的成本估算器,准确预测单次查询的费用仍然是一个尚未解决的挑战。
## 模型与定价
我们评估了来自 5 个提供商的 8 种模型配置:
| 模型 | 提供商 | 输入 ($/MTok) | 输出 ($/MTok) |
|-------|----------|:--------------:|:---------------:|
| GPT-5.2 | OpenAI | 1.75 | 14.00 |
| GPT-5 Mini | OpenAI | 0.25 | 2.00 |
| Gemini 3.1 Pro | Google | 2.00 | 12.00 |
| Gemini 3 Flash | Google | 0.50 | 3.00 |
| Claude Opus 4.6 | Anthropic | 5.00 | 25.00 |
| Claude Haiku 4.5 | Anthropic | 1.00 | 5.00 |
| Kimi K2.5 | Moonshot AI | 0.60 | 3.00 |
| MiniMax-M2.5 | MiniMax | 0.30 | 1.20 |
## 数据集
我们在 9 项不同的任务上进行了基准测试(9 个数据集 × 8 个模型 = 72 个评估文件):
| 数据集 | 类别 | 查询数量 |
|---------|----------|:---------:|
| AIME | 数学 | 60 |
| ARC-AGI-v1 | 推理 | 400 |
| ArenaHard | 通用 | 750 |
| GPQA | 科学 | 198 |
| HLE | 通用 | 2,056 |
| LiveCodeBench | 代码 | 1,054 |
| LiveMathBench | 数学 | 121 |
| MMLU-Pro | 知识 | 3,000 |
| SimpleQA | 问答 | 4,326 |
## 仓库结构
```
├── asset/
│ └── logo.png # Project logo
├── data/
│ ├── consolidated/ # 72 JSON files (9 datasets × 8 models)
│ │ # Each contains per-query tokens, costs, scores
│ └── repeated_trial/ # Repeated trial data (5 runs × 3 models)
│ └── aime/{model}/run{0-4}.json
├── constant/
│ ├── model_info.json # Model pricing information
│ └── experiment_config.json # Dataset & model configurations
├── method/
│ ├── absolute_cost_estimator.py # KNN-based absolute cost predictor (§6)
│ └── relative_cost_estimator.py # KNN-based relative cost predictor (§6)
├── analysis/ # Jupyter notebooks reproducing paper figures/tables
│ ├── price_expense_mismatch.ipynb # Figure 1: price vs expense
│ ├── cost_token_breakdown.ipynb # Cost & token breakdown charts
│ ├── difficulty_variance.ipynb # Query difficulty vs thinking variance
│ ├── absolute_cost_evaluation.ipynb # Absolute cost estimator evaluation
│ ├── relative_cost_evaluation.ipynb # Relative cost estimator evaluation
│ └── scatter_plot.ipynb # Predicted vs actual cost scatter
├── app.py # Interactive Cost Explorer (Streamlit)
├── scripts/
│ ├── ablation_thinking_tokens.py # §5 Ablation: cost without thinking tokens
│ ├── analyze_prevalence.py # §4 Pricing reversal prevalence analysis
│ ├── analyze_perquery_variance.py # Per-query cost variance analysis
│ ├── generate_ablation_figure.py # Generate ablation figure
│ └── generate_repeated_trial_figure.py # Generate repeated trial figure
└── figure/ # Pre-generated paper figures (PNG + PDF)
```
## 数据格式
`data/consolidated/` 中的每个文件都是一个 JSON 对象,包含:
**顶层字段:**
| 字段 | 描述 |
|-------|-------------|
| `model_name` | 模型标识符 |
| `dataset_name` | 数据集标识符 |
| `performance` | 整体准确率/得分 |
| `cost` | 总费用(美元) |
| `prompt_tokens` | 总 prompt token 数 |
| `completion_tokens` | 总 completion token 数 |
| `time_taken` | 总耗时(秒) |
| `records` | 单次查询结果数组 |
**单次查询记录字段:**
| 字段 | 描述 |
|-------|-------------|
| `index` | 查询索引 |
| `prompt` | 输入 prompt 文本 |
| `prompt_tokens` | 输入 token 数量 |
| `completion_tokens` | 输出 token 数量(包含思考 token) |
| `thinking_tokens` | 推理/思考 token 数量 |
| `cost` | 本次查询的费用(美元) |
| `score` | 正确性得分(0.0 或 1.0) |
| `prediction` | 模型的答案 |
| `ground_truth` | 预期答案 |
| `raw_output` | 完整的模型输出文本 |
## 快速开始
### 安装
需要 **Python 3.9+**。
```
git clone https://github.com/lchen001/pricing-reversal
cd pricing-reversal
conda create -n price-reversal python=3.12
conda activate price-reversal
pip install -r requirements.txt
```
### 交互式成本分析器
**[在线启动应用](https://price-reversal.streamlit.app)** — 无需安装。
或在本地运行:
```
streamlit run app.py
```
然后在浏览器中打开 [http://localhost:8501](http://localhost:8501)。该应用提供五个视图:
| 视图 | 展示内容 |
|------|---------------|
| **💰 定价反转** | 每个数据集×模型组合的标价与实际花费对比。突出显示“更便宜”的模型反而花费更多的情况。 |
| **📊 成本分解** | 跨数据集的各模型 token 和成本分解(prompt / 思考 / completion)。 |
| **🔍 单次查询深度分析** | 选择一个数据集 + 查询索引,以并排查看每个模型的思考 token、成本、得分以及**完整响应文本**。 |
| **⚔️ 查询级别比较** | 选择两个模型进行逐个查询的比较——散点图、反转检测,以及包含并排响应和 token 详情的深入分析。 |
| **🎲 重复试验方差** | 可视化将相同查询向同一模型发送 5 次时,如何产生极其不同的思考 token 数量和成本(AIME 数据集)。 |
### 复现主要结果
**定价反转分析(§4):**
```
python scripts/analyze_prevalence.py
```
**思考 token 消融实验(§5):**
```
python scripts/ablation_thinking_tokens.py
```
**生成图表:**
```
# 从 repo 根目录运行
python scripts/generate_ablation_figure.py
python scripts/generate_repeated_trial_figure.py
```
**分析笔记:** 使用 Jupyter 打开 `analysis/` 中的笔记,以交互方式复现论文中的图表和表格。
## 引用
```
@article{thinkingtax2026,
title={The Price Reversal Phenomenon: When Cheaper Reasoning Models End Up Costing More},
author={Lingjiao Chen, Chi Zhang, Yeye He, Ion Stoica, Matei Zaharia, James Zou},
journal={arXiv preprint arXiv:2603.23971},
year={2026}
}
```
## 许可证
本项目基于 MIT 许可证授权 — 详见 [LICENSE](LICENSE)。
标签:AIME, Anthropic Claude, Apex, API定价, ARC-AGI, DLL 劫持, DNS解析, GPQA, Homebrew安装, KNN, Kubernetes, LLM, NLP, NoSQL, OpenAI, Streamlit, Token计费, TruffleHog, Unmanaged PE, 人工智能, 代码示例, 价格逆转, 内存规避, 大语言模型, 学术论文, 开源项目, 思维链, 性价比, 成本分析, 推理模型, 数据分析, 机器学习, 模型评估, 深度学习, 用户模式Hook绕过, 算法, 访问控制, 逆向工具, 隐藏Token