Graduate Course: Teaching with Generative AI
After this activity, you'll be able to:
A token is the basic unit of text that LLMs process
Examples:
For today's activity: 1 token ≈ 0.75 words
Or: Tokens ≈ Word Count × 1.33
Note: Real tokenization is more complex, but this approximation works for our exercise
Model | Input Cost | Output Cost |
---|---|---|
Model A (Balanced) | $0.50 / Million tokens | $1.50 / Million tokens |
Model B (High-Performance) | $10.00 / Million tokens | $30.00 / Million tokens |
These rates are simplified for our exercise. Real rates vary by provider and model.
As conversations get longer, input costs grow non-linearly!
Turn 1: User sends message (50 tokens) → Input: 50 tokens → Assistant responds (75 tokens) Turn 2: User sends new message (40 tokens) → Input: 50 + 75 + 40 = 165 tokens → Assistant responds (80 tokens) Turn 3: User sends new message (30 tokens) → Input: 50 + 75 + 40 + 80 + 30 = 275 tokens → Assistant responds (70 tokens)
This is why we need to track cumulative input tokens!
## AI Tutoring Session: Solving Quadratic Equations **User (Turn 1):** Hi! I need help understanding how to solve quadratic equations like x^2 + 5x + 6 = 0. **Assistant (Turn 1):** Hello! I can definitely help with that. Quadratic equations are typically in the form ax^2 + bx + c = 0. Yours fits this perfectly! There are a few common methods to solve them: factoring, completing the square, or using the quadratic formula. Which method would you like to start with, or would you like an overview of factoring first? **User (Turn 2):** Factoring sounds easiest. How does that work for x^2 + 5x + 6 = 0? **Assistant (Turn 2):** Great choice! For factoring x^2 + 5x + 6 = 0, we're looking for two numbers that MULTIPLY to 'c' (which is 6) and ADD up to 'b' (which is 5). Can you think of two numbers that do that? ...
Time: 30-40 minutes
Turn # | Who | Word Count | Est. Tokens (This Message) | Cumulative Input Tokens | Output Tokens |
---|---|---|---|---|---|
1 | User | T_u1 | T_u1 | 0 | |
1 | Assistant | T_a1 | T_u1 | T_a1 | |
2 | User | T_u2 | T_u1 + T_a1 + T_u2 | 0 | |
2 | Assistant | T_a2 | T_u1 + T_a1 + T_u2 | T_a2 | |
... | ... | ... | |||
Totals | Sum of column | Sum of column |
Key insight: The "Cumulative Input Tokens" represents everything sent to the API for each turn
Input Cost = (Total Input Tokens ÷ 1,000,000) × Input Rate
Output Cost = (Total Output Tokens ÷ 1,000,000) × Output Rate
Total Cost = Input Cost + Output Cost
Time: 15-20 minutes
Questions?