Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cost estimation for use of closed source models #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fraboniface
Copy link
Collaborator

Work done
Very simple analysis:

  • take official API pricing for leading small models GPT-4o-mini and Claude 3.5 Haiku;
  • take MediaTree dataset from https://drive.google.com/drive/folders/1d0idkOmMIXabj7ajYhvkitMMHnH_woSN and compute average number of tokens per sample: ~500
  • calculate total number of tokens if we have instead 19 channels for 800 h each : ~200M
  • write a cost function accounting for input tokens, output tokens, and cached prompt tokens
  • run this function on a range of numbers of output tokens, assuming a rather long example prompt

Results: it could cost as little as $60, and a few hundreds USD for more output tokens (max is $600 for 1000 ot using Claude).

Related issue: #11

@fraboniface fraboniface requested a review from ycrouin October 29, 2024 19:48
Copy link
Collaborator

@ycrouin ycrouin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I think one interesting result is that it will cost at the very least 60$ for one run. The good thing is that it's acceptable and manageable but we probably won't be able to run our pipeline again and again carelessely. The other result is that larger models like gpt-4o or sonnet-3.5 are probably too expensive for this scale.

Maybe we can rerun this later when we'll have the final dataset and prompts to have a more accurate cost estimation before running it on the entire data history.

Copy link
Collaborator

@ycrouin ycrouin Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prompt_cost = prompt_tokens * prices['input'] * prices['cache_discount'] / 1e6

The caching is only possible starting from 1024/2048 tokens, see OpenAI & Anthropic docs so it's a bit optimistic with this prompt that contains only 636 tokens. Maybe we'll include few shots & more and eventually reach this limit though. I guess if we use structured outputs that counts as extra tokens too. But this is really a detail 😛, I just wasn't sure if you were aware of this lower limit of 1024/2048.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants