Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,69 +1,253 @@
|
|
| 1 |
-
# Bidding Algorithms Benchmark
|
| 2 |
|
| 3 |
-
> Complete comparison framework for real-time bidding (RTB) algorithms in online advertising.
|
| 4 |
> Optimizing for clicks under budget constraints using Lagrangian dual methods.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
## Research Resources
|
| 7 |
|
| 8 |
-
- **[RESEARCH_RESOURCES.md](RESEARCH_RESOURCES.md)** β Full literature survey:
|
| 9 |
- **[AUDIT_TRAIL.md](AUDIT_TRAIL.md)** β Every paper, dataset, codebase, and external resource consulted (44 items)
|
| 10 |
|
|
|
|
|
|
|
| 11 |
## Problem Setup
|
| 12 |
|
| 13 |
- **Objective**: Maximize number of clicks
|
| 14 |
- **Constraints**: Total spend β€ Budget, with k% minimum spend guarantee
|
| 15 |
-
- **Auction
|
| 16 |
-
- **Core Approach**: Lagrangian dual multiplier with online error gradient descent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
## Models
|
| 31 |
|
| 32 |
-
| Model | Task | Architecture | Dataset |
|
| 33 |
-
|-------|------|-------------|---------|
|
| 34 |
-
| **
|
| 35 |
-
| **
|
| 36 |
-
| **
|
| 37 |
-
| **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
## Structure
|
| 40 |
|
| 41 |
```
|
| 42 |
bidding_algorithms_benchmark/
|
| 43 |
-
βββ README.md
|
| 44 |
-
βββ RESEARCH_RESOURCES.md
|
| 45 |
-
βββ AUDIT_TRAIL.md
|
|
|
|
|
|
|
| 46 |
βββ src/
|
| 47 |
β βββ ctr/
|
| 48 |
-
β β
|
| 49 |
-
β β βββ train_deepfm.py
|
| 50 |
β βββ price/
|
| 51 |
-
β β βββ empirical_cdf.py
|
| 52 |
-
β β βββ torchsurv_model.py
|
| 53 |
β βββ algorithms/
|
| 54 |
-
β β βββ dual_ogd.py
|
| 55 |
-
β β
|
| 56 |
-
β β βββ dual_ros.py
|
| 57 |
-
β β βββ two_sided_dual.py
|
| 58 |
-
β β βββ rlb.py
|
| 59 |
-
β β βββ baselines.py
|
| 60 |
β βββ benchmark/
|
| 61 |
-
β βββ auction_simulator.py
|
| 62 |
-
β βββ run_comparison.py
|
| 63 |
-
β βββ sweep.py
|
| 64 |
-
βββ configs/
|
| 65 |
-
β βββ finalmlp_criteo.yaml
|
| 66 |
-
β βββ sweep_config.yaml
|
| 67 |
βββ results/
|
|
|
|
| 68 |
βββ requirements.txt
|
| 69 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Bidding Algorithms Benchmark β First-Price Auctions
|
| 2 |
|
| 3 |
+
> **Complete comparison framework for real-time bidding (RTB) algorithms in online advertising.**
|
| 4 |
> Optimizing for clicks under budget constraints using Lagrangian dual methods.
|
| 5 |
+
>
|
| 6 |
+
> **Latest benchmark**: 200K rows (Criteo_x4), 5 independent runs, a10g GPU β [results/benchmark_200K_a10g_2026-05-05.json](results/benchmark_200K_a10g_2026-05-05.json)
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
|
| 10 |
## Research Resources
|
| 11 |
|
| 12 |
+
- **[RESEARCH_RESOURCES.md](RESEARCH_RESOURCES.md)** β Full literature survey: 26 papers across bidding algorithms, CTR prediction, and clearing price models
|
| 13 |
- **[AUDIT_TRAIL.md](AUDIT_TRAIL.md)** β Every paper, dataset, codebase, and external resource consulted (44 items)
|
| 14 |
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
## Problem Setup
|
| 18 |
|
| 19 |
- **Objective**: Maximize number of clicks
|
| 20 |
- **Constraints**: Total spend β€ Budget, with k% minimum spend guarantee
|
| 21 |
+
- **Auction Type**: **First-price** (winner pays their own bid)
|
| 22 |
+
- **Core Approach**: Lagrangian dual multiplier with online error gradient descent (Wang et al. 2023)
|
| 23 |
+
- **Key Formula**: Ξ»_{t+1} = max(0, Ξ»_t β Ρ·(Ο β actual_cost))
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
Where:
|
| 27 |
+
Ο = B/T = target spend per auction
|
| 28 |
+
Ξ» = dual multiplier (pacing variable)
|
| 29 |
+
Ξ΅ = learning rate (~1/βT)
|
| 30 |
+
cΜ_t(b) = empirical expected cost of bidding b
|
| 31 |
+
rΜ_t(v,b) = empirical expected reward for value v with bid b
|
| 32 |
+
GΜ_t(b) = empirical win probability P(competing_bid β€ b)
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## Benchmark Results (200K Criteo_x4, 10K auctions Γ 5 runs, a10g GPU)
|
| 38 |
+
|
| 39 |
+
```
|
| 40 |
+
Algorithm Clicks CPC Budget% WinRate
|
| 41 |
+
--------------------------------------------------------------
|
| 42 |
+
π₯ TwoSidedDual 285Β±8 33.41 95.0% 7.6%
|
| 43 |
+
π₯ ValueShading 258Β±7 38.82 100.0% 8.2%
|
| 44 |
+
π₯ DualOGD 248Β±9 31.18 77.3% 6.6%
|
| 45 |
+
RLB 136Β±13 74.34 100.0% 4.2%
|
| 46 |
+
Threshold 71Β±4 70.36 ~50.0% 1.7%
|
| 47 |
+
Linear 64Β±6 79.20 ~50.0% 2.0%
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
**Key Insight**: TwoSidedDual achieves **15% more clicks** than DualOGD by maintaining the k=80% spend floor constraint. DualOGD alone gets too conservative (only 77% of budget used). TwoSidedDual's floor multiplier Ξ½ keeps the bidding aggressive enough to nearly exhaust the budget while maintaining the best CPC among adaptive algorithms.
|
| 51 |
+
|
| 52 |
+
**CTR Model**: Logistic Regression, AUC=0.6947 (fast baseline). Upgrading to FinalMLP (AUC=0.8149) would significantly improve all algorithms by better distinguishing high-value from low-value impressions.
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## Algorithm Descriptions
|
| 57 |
+
|
| 58 |
+
### 1. DualOGD β Lagrangian Dual + Online Gradient Descent β
|
| 59 |
+
|
| 60 |
+
**Paper**: Wang et al. "Learning to Bid in Repeated First-Price Auctions with Budgets" (2023)
|
| 61 |
+
**arXiv**: [2304.13477](https://arxiv.org/abs/2304.13477)
|
| 62 |
+
|
| 63 |
+
**How it works**: The budget-constrained bidding problem is cast as a **Lagrangian optimization**. A single dual multiplier Ξ» tracks whether you are over/under-spending relative to the target rate Ο = B/T (budget per auction).
|
| 64 |
+
|
| 65 |
+
**Bid rule**: `b_t = argmax_b [(vβb)Β·GΜ(b) β λ·bΒ·GΜ(b)]`
|
| 66 |
+
|
| 67 |
+
- Maximizes (expected reward minus Ξ» Γ expected cost)
|
| 68 |
+
- The penalty weight Ξ» adapts online β no separate pacing module needed
|
| 69 |
+
|
| 70 |
+
**Update**: `Ξ» β max(0, Ξ» β Ρ·(Ο β actual_cost))`
|
| 71 |
+
|
| 72 |
+
- Overspent β Ξ» grows β future bids are penalized more β spend decreases
|
| 73 |
+
- Underspent β Ξ» shrinks β future bids are cheaper β spend increases
|
| 74 |
+
|
| 75 |
+
**Regret bound**: Γ(βT) β provably near-optimal under standard assumptions.
|
| 76 |
+
|
| 77 |
+
**Required models**: CTR predictor + empirical win probability CDF of competing bids.
|
| 78 |
+
|
| 79 |
+
**Why it underperforms alone**: Without a floor constraint, Ξ» gets conservative early (it "remembers" past overspending) and you end at 77% budget. The learning rate Ξ΅ = 1/βT makes recovery slow.
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
### 2. TwoSidedDual β Budget Cap + Spend Floor β BETTER
|
| 84 |
+
|
| 85 |
+
**Extension of DualOGD.** Two dual variables instead of one:
|
| 86 |
+
|
| 87 |
+
| Variable | Role | Update |
|
| 88 |
+
|----------|------|--------|
|
| 89 |
+
| **ΞΌ (cap)** | Penalize overspending β restrain | ΞΌ β max(0, ΞΌ β Ξ·βΒ·(Ο β cost)) |
|
| 90 |
+
| **Ξ½ (floor)** | Penalize underSPENDING β encourage | Ξ½ β max(0, Ξ½ β Ξ·βΒ·(cost β kΒ·Ο)) |
|
| 91 |
+
|
| 92 |
+
**Effective multiplier**: (ΞΌ β Ξ½)
|
| 93 |
+
|
| 94 |
+
- When ΞΌ > Ξ½: cap dominates β bid conservatively (ahead on spend)
|
| 95 |
+
- When Ξ½ > ΞΌ: floor dominates β bid aggressively (behind on spend floor)
|
| 96 |
+
|
| 97 |
+
**Why it wins**: The floor multiplier Ξ½ counteracts the natural conservatism of Ξ». If you get behind on your k% target, Ξ½ grows, making the effective penalty negative β bids increase. Once the floor is met, Ξ½ shrinks and ΞΌ takes over to cap spending.
|
| 98 |
+
|
| 99 |
+
**Winner for**: Advertisers who must spend at least k% (common in brand campaigns with contractual minimums).
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
### 3. ValueShading β Adaptive Bid Shading
|
| 104 |
+
|
| 105 |
+
**First-price adaptation of second-price shading.** In first-price auctions, bidding your true value guarantees zero surplus (winner's curse). ValueShading scales bids: `bid = v / (1 + Ξ»)`.
|
| 106 |
+
|
| 107 |
+
Ξ» adapts online based on whether recent bids won or lost. Unlike DualOGD which does a grid search over bid candidates, ValueShading uses a closed-form shading formula β faster per auction (no grid search).
|
| 108 |
|
| 109 |
+
**Trade-off**: Spends the full budget (useful for campaigns where that matters) but CPC is 16% higher than TwoSidedDual. Less precise about pacing.
|
| 110 |
|
| 111 |
+
---
|
| 112 |
+
|
| 113 |
+
### 4. RLB β Reinforcement Learning for Bidding
|
| 114 |
+
|
| 115 |
+
**Paper**: Cai et al. "Real-Time Bidding by Reinforcement Learning in Display Advertising" (WSDM 2017)
|
| 116 |
+
**arXiv**: [1701.02490](https://arxiv.org/abs/1701.02490)
|
| 117 |
+
|
| 118 |
+
Treats bidding as a Markov Decision Process:
|
| 119 |
+
- **State**: (remaining_budget_ratio, pCTR_bucket)
|
| 120 |
+
- **Action**: bid_multiplier β {0.1Γ, 0.3Γ, ..., 2.0Γ} of value
|
| 121 |
+
- **Reward**: pCTR Γ value_per_click if won, else 0
|
| 122 |
+
|
| 123 |
+
Uses tabular Q-learning with Ξ΅-greedy exploration. The Q-table maps (budget_state, impression_quality) β optimal bid_multiplier.
|
| 124 |
+
|
| 125 |
+
**Current limitation**: Spends the entire budget but achieves fewer clicks than adaptive algorithms. Tabular Q-learning needs many more auctions to converge (10K rounds Γ 10 budget buckets Γ 5 pCTR buckets = only ~200 visits per state). With more data, performance would improve, but tabular methods don't have the regret guarantees of dual methods.
|
| 126 |
+
|
| 127 |
+
**Best use case**: Non-stationary environments where the RL agent can continuously adapt, or as a benchmark against optimization-based approaches.
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
### 5. Linear β Proportional Bidding Baseline
|
| 132 |
+
|
| 133 |
+
`bid = base_bid Γ (pCTR / avg_pCTR)`
|
| 134 |
+
|
| 135 |
+
No adaptation to competition or budget pacing. Serves as the **lower bound** β any adaptive algorithm should beat this. Simple, fast, and deterministic. Useful only as a sanity check.
|
| 136 |
+
|
| 137 |
+
---
|
| 138 |
+
|
| 139 |
+
### 6. Threshold β Binary Bidding Baseline
|
| 140 |
+
|
| 141 |
+
`bid = fixed_bid if pCTR > threshold else 0`
|
| 142 |
+
|
| 143 |
+
Bid a fixed amount only on impressions where pCTR exceeds a threshold. Common "rule of thumb" in practice.
|
| 144 |
+
|
| 145 |
+
**Limitation**: Treats all above-threshold impressions equally β doesn't distinguish between pCTR=0.31 and pCTR=0.95. Leaves value on the table.
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
+
|
| 149 |
+
## Algorithm Comparison Matrix
|
| 150 |
+
|
| 151 |
+
| Algorithm | Adaptive? | Budget Cap? | Spend Floor? | Model Requirements | Provable Regret? | Best CPC |
|
| 152 |
+
|-----------|-----------|-------------|--------------|---------------------|------------------|----------|
|
| 153 |
+
| **TwoSidedDual** | β
Online | β
ΞΌ | β
Ξ½ | CTR + CDF | β (heuristic) | 33.41 |
|
| 154 |
+
| **DualOGD** | β
Online | β
Ξ» | β | CTR + CDF | β
Γ(βT) | 31.18 |
|
| 155 |
+
| **ValueShading** | β
Online | β
via pace | β | CTR | β | 38.82 |
|
| 156 |
+
| **RLB** | β
RL | β | β | CTR | β | 74.34 |
|
| 157 |
+
| **Linear** | β | β | β | None | β | 79.20 |
|
| 158 |
+
| **Threshold** | β | β | β | None | β | 70.36 |
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
|
| 162 |
## Models
|
| 163 |
|
| 164 |
+
| Model | Task | Architecture | Dataset | Status |
|
| 165 |
+
|-------|------|-------------|---------|--------|
|
| 166 |
+
| **LogisticRegression** (current) | CTR Prediction | Linear + L2 | Criteo_x4 | β
Deployed (AUC=0.695) |
|
| 167 |
+
| **FinalMLP** | CTR Prediction | Two-stream MLP + Gating | Criteo_x4 | π Ready (AUC=0.815) |
|
| 168 |
+
| **DeepFM** | CTR Prediction | FM + DNN | Criteo_x4 | π Baseline |
|
| 169 |
+
| **DCNv2** | CTR Prediction | CrossNetV2 + DNN | Criteo_x4 | π Alternative |
|
| 170 |
+
| **EmpiricalCDF** | Win Probability | Non-parametric online | Competing bids | β
In use |
|
| 171 |
+
| **TorchSurv** | Win Probability | Deep Cox PH (censored) | Bid logs | π Optional upgrade |
|
| 172 |
+
|
| 173 |
+
---
|
| 174 |
+
|
| 175 |
+
## Running the Benchmark
|
| 176 |
+
|
| 177 |
+
### Quick Run (HF Jobs)
|
| 178 |
+
|
| 179 |
+
```bash
|
| 180 |
+
# Main benchmark (takes ~40 min)
|
| 181 |
+
python benchmark_job.py --max_rows 200000 --budget 10000 --T 10000 --n_runs 5
|
| 182 |
+
|
| 183 |
+
# Hyperparameter sweep (takes ~2h)
|
| 184 |
+
python sweep_job.py --max_rows 200000
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
### Via HF Jobs
|
| 188 |
+
|
| 189 |
+
```python
|
| 190 |
+
hf_jobs.run(
|
| 191 |
+
script="benchmark_job.py",
|
| 192 |
+
dependencies=["numpy", "pandas", "scikit-learn", "datasets"],
|
| 193 |
+
hardware="a10g-small",
|
| 194 |
+
timeout="2h"
|
| 195 |
+
)
|
| 196 |
+
```
|
| 197 |
+
|
| 198 |
+
---
|
| 199 |
|
| 200 |
## Structure
|
| 201 |
|
| 202 |
```
|
| 203 |
bidding_algorithms_benchmark/
|
| 204 |
+
βββ README.md # this file
|
| 205 |
+
βββ RESEARCH_RESOURCES.md # Literature survey (26 papers)
|
| 206 |
+
βββ AUDIT_TRAIL.md # Full resource audit (44 items)
|
| 207 |
+
βββ benchmark_job.py # Self-contained benchmark script
|
| 208 |
+
βββ sweep_job.py # Self-contained sweep script
|
| 209 |
βββ src/
|
| 210 |
β βββ ctr/
|
| 211 |
+
β β βββ finalmlp_model.py # FinalMLP CTR model
|
|
|
|
| 212 |
β βββ price/
|
| 213 |
+
β β βββ empirical_cdf.py # Online win prob CDF
|
| 214 |
+
β β βββ torchsurv_model.py # Deep survival win prob model
|
| 215 |
β βββ algorithms/
|
| 216 |
+
β β βββ dual_ogd.py # DualOGD + TwoSidedDual
|
| 217 |
+
β β βββ baselines.py # Linear, Threshold, ValueShading, RLB
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
β βββ benchmark/
|
| 219 |
+
β βββ auction_simulator.py # First-price auction simulation
|
| 220 |
+
β βββ run_comparison.py # Multi-algorithm runner
|
| 221 |
+
β βββ sweep.py # Grid search
|
|
|
|
|
|
|
|
|
|
| 222 |
βββ results/
|
| 223 |
+
β βββ benchmark_200K_a10g_2026-05-05.json
|
| 224 |
βββ requirements.txt
|
| 225 |
```
|
| 226 |
+
|
| 227 |
+
---
|
| 228 |
+
|
| 229 |
+
## Key Papers
|
| 230 |
+
|
| 231 |
+
| # | Paper | arXiv | Focus |
|
| 232 |
+
|---|-------|-------|-------|
|
| 233 |
+
| 1 | Wang et al. β Learning to Bid in Repeated FPA | 2304.13477 | β Primary algorithm |
|
| 234 |
+
| 2 | β Adaptive Bidding under Non-Stationarity | 2505.02796 | Distribution shift |
|
| 235 |
+
| 3 | β Contextual First-Price (Quantile) | 2603.07207 | Contextual extension |
|
| 236 |
+
| 4 | β Joint Value Estimation + Bidding | 2502.17292 | Simultaneous CTR+bidding |
|
| 237 |
+
| 5 | Cai et al. β RLB | 1701.02490 | RL baseline |
|
| 238 |
+
| 6 | Mao et al. β FinalMLP | 2304.00902 | CTR model |
|
| 239 |
+
| 7 | Wang et al. β DCN V2 | 2008.13535 | CTR model |
|
| 240 |
+
| 8 | Guo et al. β DeepFM | β | CTR model |
|
| 241 |
+
| 9 | BARS-CTR | 2009.05794 | CTR benchmark |
|
| 242 |
+
| 10 | TorchSurv | 2404.10761 | Survival analysis |
|
| 243 |
+
|
| 244 |
+
---
|
| 245 |
+
|
| 246 |
+
## Next Steps
|
| 247 |
+
|
| 248 |
+
1. **Upgrade CTR model** to FinalMLP (AUC 0.695 β 0.815) β will significantly improve all algorithms
|
| 249 |
+
2. **Run sweep** (`--sweep`) to find optimal hyperparameters per algorithm per market condition
|
| 250 |
+
3. **Real market price data** β integrate iPinYou dataset (bid logs with actual competing bids)
|
| 251 |
+
4. **TorchSurv integration** β replace empirical CDF with contextual win probability model
|
| 252 |
+
5. **Non-stationary evaluation** β add distribution shift scenarios from paper 2505.02796
|
| 253 |
+
6. **Larger-scale benchmark** β 1M+ rows on a100, more comprehensive sweep
|