AI Hints
Home›Fine-Tuning LLMs Tutorial›Fast Inference, Many Adapters and Costs
Fine-Tuning LLMs · Lesson 102 of 120

Costs

Time and money.

⏱ 2 min read▶ Video at 2:36:47🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Before you fine-tune a big model, it helps to know roughly what it will cost. The good news is, LoRA fine-tuning is often surprisingly cheap.

  • What will it cost?
  • Estimate first
  • Often surprisingly cheap

A rough estimate

Here's a rough calculator. Five thousand examples, three hundred tokens each, for three epochs. That's the total number of tokens to process. For each GPU, we guess how many tokens per second it can train, and its price per hour. These are rough guesses, so check current prices. Run it. Every option costs around a dollar. The bigger GPU is faster, so it isn't much more expensive.

app.pypython
# Rough training cost: tokens processed, divided by how fast a GPU can process them.
examples, tokens_each, epochs = 5_000, 300, 3
tokens = examples * tokens_each * epochs

gpus = {  # name: (tokens per second for a 7B model with LoRA, price per hour in $)
    "T4 (Colab)":     (600, 0.35),
    "A10G":           (1_500, 1.00),
    "A100 80GB":      (5_000, 2.50),
}
print(f"Training on {tokens:,} tokens")
for name, (speed, price) in gpus.items():
    hours = tokens / speed / 3600
    print(f"{name:15} {hours:7.1f} hours   ${hours * price:7.2f}")
Output
Training on 4,500,000 tokens
T4 (Colab)          2.1 hours   $   0.73
A10G                0.8 hours   $   0.83
A100 80GB           0.2 hours   $   0.62

Where the money goes

Training is usually the smallest cost. Preparing good data takes the most people time. Evaluation takes time too. And serving the model costs money every single day it runs. So plan for all four.

CostUsually
data preparationthe most people time
trainingsmall with LoRA
evaluationpeople and compute time
servingevery day it runs

Summary

Let's recap. Estimate tokens, divided by speed, times price. LoRA training is often cheap. Data and serving usually cost more. Next, our final project begins.

Key takeaways
  • tokens ÷ speed × price
  • Training is cheap
  • Data and serving cost more
Next up: Project: Plan — a better ticket model