Tokens are not free (notes from an AI workshop)

Share
Tokens are not free (notes from an AI workshop)
Is it worth to shoot a cannonball on a sparrow? From a papership? On a complex pipeline?

Not exactly homelab this time, more like work-ish stuff.

Yesterday I joined a workshop about AI agents and what they cost. So basically a day about AI, made for humans who pay the AI's bills. Funny situation, because I also used an AI to help me with these notes. Very meta, I know.

I will not name the platform they showed us, because this is not an ad. The ideas are what I care about, and most of them work with any tool.

The main question

The whole day was about one question: what did I get for the tokens I spent?

Not 'how few tokens can I use'. A cheap agent that gives wrong answers is not cheap, it is just wrong. And a super accurate agent that loops around and costs a fortune cannot scale. You need both sides of the story.

The provider bill alone cannot tell you this. It says how much you spent, but not if it was worth it.

Three ways to waste tokens

1. Wrong model for the job

The demo was an AI shopping assistant for a webshop. It gets two kinds of questions:

  • Policy questions (returns, refunds, and so on)
  • Product questions (is it in stock, what size, how much)

They ran the same set of questions on a cheap model and on an expensive one, and compared the answers with the known correct ones. The result was interesting:

  • For policy questions the cheap model was almost as good, and it was around 3x faster and a lot cheaper.
  • For product questions the cheap model gave vague answers and made things up. The expensive one was something like 8x slower, but it actually answered the question.

So the answer is not 'always use the big model' and also not 'always use the small one'. You send each task to the model that is good enough for it. The trick they used is called an experiment: same questions, change one thing at a time, otherwise you cannot explain the results. Like a unit test, but for your model choice.

2. Over-engineered workflows

The right model can still sit in a bad workflow. In one example the agent visited the knowledge base multiple times for a single question. Every visit adds latency, and more (not so relevant) text in the prompt can also make the model hallucinate.

Other usual suspects:

  • sending the full chat history when only the last few messages matter
  • long tool descriptions repeated in every call
  • retries that do exactly the same thing again
  • too many search results, or wrongly sized chunks

My favorite part: the automated judge said the agent completed the task and also that it was efficient, even with all the extra calls. It noticed the redundancy, but decided it is a small thing. So you have to give feedback to the judge, and teach it what you consider wasteful. Successful is not the same as efficient.

A router or judge LLM tries to choose among LLMs: which will be most cost effective to use?

3. Spend without outcomes

Tokens are only interesting next to the results. Did the user get what they wanted? Did the answer meet the quality bar? A few simple rules of thumb I took with me:

  • Cost went up and traffic also went up? Maybe it is just good news.
  • Cost went up but traffic stayed the same? Something changed per request. Go and look at the models, prompts and versions.
  • Tokens are growing while the 'task completed' rate is falling? Your agent is working harder for less.

The part where checking costs more than working

This one surprised me. If you use an LLM as a judge, a check can cost around $0.05. Let's say 5 checks per conversation and 1000 conversations per hour. That is about $6k per day, only for the checking. Not for the agent itself.

So what can you do?

  1. Do no checks at all. Flying blind, and AI fails silently.
  2. Check a 5-10% sample. Flying almost blind.
  3. Run your own big model locally. Slow, and heavy to scale.
  4. Train a small model that does only the judging. Much cheaper and faster, but you need good labeled data and humans to review it.

The vendor says the small-model way can be up to 98% cheaper. I take that number with a grain of salt, but the idea makes sense to me. Also, important: this only makes the checking cheaper, the agent itself costs the same.

The big picture

The last part was about AI coding assistants inside a company. Token prices are expected to go down, but usage is expected to grow much faster. Cheaper tokens do not mean cheaper AI, they mean more AI in more places. There are already stories about teams burning their yearly AI budget in a few months. Well, that was a bad idea anyway, in my opinion at least.

The same three questions work here too: where is the money going, what is wasted (idle seats, expensive model for a simple job), and what is actually working.

What I take home to my small world

I don't run a giant chatbot, but I do have an ollama on my server - well it's shut down at the moment due to some memory issues (oh, what a surprise), but I want to make it work. I already have some ideas, but that will be another post.
So my notes to self:

  1. Measure first. If I don't know what a call costs, I cannot optimize it.
  2. Watch for loops and retries. The silent ones are the most expensive.
  3. Define what success means before I look at the cost.
  4. Small model for the easy stuff, big model only where it really matters. Judge & route accordingly in enterprise environment; or at least it seems waaay too overkill to use more LLM in a homelab. It's hard to meet the memory needs for just one at the moment. But, judge it for yourself. Or Christopher Judge will do it for you.

One more thing, to be fair: this was a vendor workshop, so some claims were a bit marketing-ish. The general ideas are good, but test everything on your own data.