Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- token-prediction
|
| 5 |
+
- gpt-4o
|
| 6 |
+
- cost-estimation
|
| 7 |
+
- distilbert
|
| 8 |
+
datasets:
|
| 9 |
+
- ShareGPT-X
|
| 10 |
+
language:
|
| 11 |
+
- en
|
| 12 |
+
metrics:
|
| 13 |
+
- mae
|
| 14 |
+
pipeline_tag: text-classification
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# GPT-4o Output Token Predictor
|
| 18 |
+
|
| 19 |
+
Predicts the number of output tokens GPT-4o will generate for a given prompt, enabling accurate cost estimation before API calls.
|
| 20 |
+
|
| 21 |
+
## Model Details
|
| 22 |
+
|
| 23 |
+
- **Architecture**: DistilBERT encoder + 3-layer MLP prediction head
|
| 24 |
+
- **Training Data**: 30,000 ShareGPT-X conversations
|
| 25 |
+
- **Performance**: MAE 268 tokens | MAPE 15.2%
|
| 26 |
+
- **Inference**: ~5ms on CPU
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from huggingface_hub import hf_hub_download
|
| 32 |
+
import torch
|
| 33 |
+
|
| 34 |
+
# Download model
|
| 35 |
+
model_path = hf_hub_download(
|
| 36 |
+
repo_id="gurpreets64/gpt4o-output-token-predictor",
|
| 37 |
+
filename="best_model.pt"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
# Load and use
|
| 41 |
+
checkpoint = torch.load(model_path, map_location="cpu")
|
| 42 |
+
# See full code at: github.com/gurpreeet-singh/llm-output-token-prediction
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Links
|
| 46 |
+
|
| 47 |
+
- **GitHub**: [gurpreeet-singh/llm-output-token-prediction](https://github.com/gurpreeet-singh/llm-output-token-prediction)
|
| 48 |
+
- **Documentation**: See GitHub repo for full training and inference code
|
| 49 |
+
|
| 50 |
+
## Citation
|
| 51 |
+
|
| 52 |
+
```bibtex
|
| 53 |
+
@software{gpt4o_token_predictor,
|
| 54 |
+
author = {Gurpreet Singh},
|
| 55 |
+
title = {GPT-4o Output Token Predictor},
|
| 56 |
+
year = {2025},
|
| 57 |
+
url = {https://github.com/gurpreeet-singh/llm-output-token-prediction}
|
| 58 |
+
}
|
| 59 |
+
```
|