Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -2,134 +2,89 @@
|
|
| 2 |
license: mit
|
| 3 |
library_name: xgboost
|
| 4 |
tags:
|
| 5 |
-
- agent-cost-optimizer
|
| 6 |
-
- model-router
|
| 7 |
-
- cost-aware-inference
|
| 8 |
-
- cascade-routing
|
| 9 |
-
- execution-feedback
|
| 10 |
-
-
|
| 11 |
---
|
| 12 |
|
| 13 |
-
# ACO: Agent Cost Optimizer
|
| 14 |
|
| 15 |
-
A universal control layer that reduces the cost of autonomous agent runs while preserving task quality.
|
| 16 |
|
| 17 |
-
## What
|
| 18 |
|
| 19 |
-
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
- Whether to verify outputs
|
| 25 |
-
- When to stop failing runs
|
| 26 |
-
- How to recover from errors
|
| 27 |
|
| 28 |
-
##
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
### Synthetic Benchmark (3K traces)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
Key: 64.6% of SWE-bench tasks are solvable by the cheapest model. v9 achieves higher success than always-frontier by escalating when cheap fails.
|
| 60 |
-
|
| 61 |
-
### BFCL v3 Function-Calling (82K traces, 108 models)
|
| 62 |
-
|
| 63 |
-
- **84.1% of tasks solvable by cheaper models** — validates routing thesis
|
| 64 |
-
- **82.5% need only tier 1** — massive savings potential
|
| 65 |
-
- **Top error: state mismatch** — validates tool-use cost gate
|
| 66 |
-
|
| 67 |
-
## The 11 Modules
|
| 68 |
-
|
| 69 |
-
1. **Cost Telemetry Collector** - Normalized JSON trace schema
|
| 70 |
-
2. **Task Cost Classifier** - 9 task types, dynamic difficulty
|
| 71 |
-
3. **Model Cascade Router (v8)** - Dynamic difficulty + XGBoost + safety floors
|
| 72 |
-
4. **Execution-Feedback Router (v9)** - Token-level uncertainty + cascade
|
| 73 |
-
5. **Context Budgeter** - Adaptive context allocation
|
| 74 |
-
6. **Cache-Aware Prompt Layout** - Prefix-cache optimization
|
| 75 |
-
7. **Tool-Use Cost Gate** - Skip/batch/cache tool calls
|
| 76 |
-
8. **Verifier Budgeter** - Risk-weighted selective verification
|
| 77 |
-
9. **Retry/Recovery Optimizer** - Failure-specific recovery actions
|
| 78 |
-
10. **Meta-Tool Miner** - Repeated workflow compression
|
| 79 |
-
11. **Doom Detector** - Early termination for failing runs
|
| 80 |
|
| 81 |
## Quick Start
|
| 82 |
|
| 83 |
```python
|
| 84 |
-
from aco.
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
| 88 |
|
| 89 |
-
#
|
| 90 |
-
result = opt.start_run("Debug this critical production bug")
|
| 91 |
-
print(result["routing"]) # tier, model_id, confidence, cost_estimate
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
| 97 |
```
|
| 98 |
|
| 99 |
-
##
|
| 100 |
|
| 101 |
-
|
| 102 |
-
aco route "Fix a typo in the README" # → tier 2
|
| 103 |
-
aco route "Debug critical prod bug NOW" # → tier 5
|
| 104 |
-
aco version # ACO v8.0
|
| 105 |
-
```
|
| 106 |
|
| 107 |
## Links
|
| 108 |
|
| 109 |
- **Model**: [narcolepticchicken/agent-cost-optimizer](https://huggingface.co/narcolepticchicken/agent-cost-optimizer)
|
| 110 |
- **Dataset**: [narcolepticchicken/agent-cost-traces](https://huggingface.co/datasets/narcolepticchicken/agent-cost-traces)
|
| 111 |
- **Dashboard**: [narcolepticchicken/aco-dashboard](https://huggingface.co/spaces/narcolepticchicken/aco-dashboard)
|
|
|
|
| 112 |
|
| 113 |
## License
|
| 114 |
|
| 115 |
MIT
|
| 116 |
-
|
| 117 |
-
<!-- ml-intern-provenance -->
|
| 118 |
-
## Generated by ML Intern
|
| 119 |
-
|
| 120 |
-
This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
|
| 121 |
-
|
| 122 |
-
- Try ML Intern: https://smolagents-ml-intern.hf.space
|
| 123 |
-
- Source code: https://github.com/huggingface/ml-intern
|
| 124 |
-
|
| 125 |
-
## Usage
|
| 126 |
-
|
| 127 |
-
```python
|
| 128 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 129 |
-
|
| 130 |
-
model_id = 'narcolepticchicken/agent-cost-optimizer'
|
| 131 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 132 |
-
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 133 |
-
```
|
| 134 |
-
|
| 135 |
-
For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
|
|
|
|
| 2 |
license: mit
|
| 3 |
library_name: xgboost
|
| 4 |
tags:
|
| 5 |
+
- agent-cost-optimizer
|
| 6 |
+
- model-router
|
| 7 |
+
- cost-aware-inference
|
| 8 |
+
- cascade-routing
|
| 9 |
+
- execution-feedback
|
| 10 |
+
- swebench
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# ACO v10: Agent Cost Optimizer
|
| 14 |
|
| 15 |
+
A universal control layer that reduces the cost of autonomous agent runs while preserving task quality. **Trained on real execution data from 8 models across 500 SWE-bench tasks.**
|
| 16 |
|
| 17 |
+
## What's New in v10
|
| 18 |
|
| 19 |
+
- **Real-data training**: XGBoost models trained on SWE-Router traces (500 tasks × 8 models = 4,000 real outcomes)
|
| 20 |
+
- **v10 cascade**: 49.5% cost reduction at 67.8% success
|
| 21 |
+
- **v10 + feedback**: 23.3% cost reduction at 73.8% success (only 4.4pp below frontier)
|
| 22 |
+
- **Per-step routing**: Routes each agent step independently (search→cheap, edit→stronger)
|
| 23 |
+
- **Execution feedback**: Uses cheap model output confidence to decide escalation
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
## Real-World Results
|
| 26 |
|
| 27 |
+
### SWE-bench (500 coding tasks, 8 models)
|
| 28 |
|
| 29 |
+
| Policy | Success | Cost | CostRed |
|
| 30 |
+
|--------|---------|------|---------|
|
| 31 |
+
| Oracle | 87.0% | $0.06 | 80.3% |
|
| 32 |
+
| **v10 feedback** | **73.8%** | **$0.24** | **23.3%** |
|
| 33 |
+
| v10 cascade | 67.8% | $0.16 | 49.5% |
|
| 34 |
+
| Always frontier | 78.2% | $0.32 | baseline |
|
| 35 |
+
| v8 (synthetic) | 65.8% | $0.35 | -11.6% |
|
| 36 |
|
| 37 |
+
### BFCL v3 (82K traces, 108 models)
|
| 38 |
+
- 84.1% of tasks solvable by cheaper models
|
| 39 |
+
- 82.5% need only tier 1
|
| 40 |
|
| 41 |
### Synthetic Benchmark (3K traces)
|
| 42 |
+
- v9 feedback: 90.0% success at 2.1% cost reduction (matches frontier)
|
| 43 |
+
- v8 router: 83.7% success at 8.5% cost reduction
|
| 44 |
+
|
| 45 |
+
## 11 Modules
|
| 46 |
+
|
| 47 |
+
1. Cost Telemetry Collector
|
| 48 |
+
2. Task Cost Classifier
|
| 49 |
+
3. Model Cascade Router (v10: real-data trained)
|
| 50 |
+
4. Execution-Feedback Router (v9: output confidence cascade)
|
| 51 |
+
5. Context Budgeter
|
| 52 |
+
6. Cache-Aware Prompt Layout
|
| 53 |
+
7. Tool-Use Cost Gate
|
| 54 |
+
8. Verifier Budgeter
|
| 55 |
+
9. Retry/Recovery Optimizer
|
| 56 |
+
10. Meta-Tool Miner
|
| 57 |
+
11. Doom Detector
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
## Quick Start
|
| 60 |
|
| 61 |
```python
|
| 62 |
+
from aco.router_v10 import V10Router
|
| 63 |
+
v10 = V10Router(model_path="router_models/router_bundle_v10_fixed.pkl", success_threshold=0.70)
|
| 64 |
+
decision = v10.route_cascade("Fix the auth bug in production")
|
| 65 |
+
print(f"Tier: {decision.tier}, Model: {decision.model}, Cost: ${decision.cost_estimate:.2f}")
|
| 66 |
+
```
|
| 67 |
|
| 68 |
+
## Per-Step Routing
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
```python
|
| 71 |
+
from aco.per_step_router import PerStepRouter
|
| 72 |
+
ps = PerStepRouter(max_budget=2.0)
|
| 73 |
+
d = ps.route_step("Search for the bug", step_num=1, task_risk="medium")
|
| 74 |
+
print(f"Step type: {d.step_type.value}, Tier: {d.adjusted_tier}, Cost: ${d.cost_estimate:.2f}")
|
| 75 |
```
|
| 76 |
|
| 77 |
+
## Key Insight
|
| 78 |
|
| 79 |
+
**Training on real execution data matters enormously.** The v8 router trained on synthetic data achieved -11.6% cost reduction on SWE-bench (it actually cost MORE than always-frontier). The v10 router trained on real SWE-Router data achieves 23.3% cost reduction at comparable quality. The gap: 34.9 percentage points.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
## Links
|
| 82 |
|
| 83 |
- **Model**: [narcolepticchicken/agent-cost-optimizer](https://huggingface.co/narcolepticchicken/agent-cost-optimizer)
|
| 84 |
- **Dataset**: [narcolepticchicken/agent-cost-traces](https://huggingface.co/datasets/narcolepticchicken/agent-cost-traces)
|
| 85 |
- **Dashboard**: [narcolepticchicken/aco-dashboard](https://huggingface.co/spaces/narcolepticchicken/aco-dashboard)
|
| 86 |
+
- **SWE-Router data**: [SWE-Router/swebench-verified-*](https://huggingface.co/SWE-Router)
|
| 87 |
|
| 88 |
## License
|
| 89 |
|
| 90 |
MIT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|