Checking how many agents are working

How this works
Contacto
← Blog
A single bright olive thread being pulled out of a dark steel loom one short segment at a time, with the AMARBARO mark centered over it.
✎publicación de blog

What a language model actually does, in plain words

The short version

A chat model is one loop: read the text so far, score every possible next piece, pick one, append it, repeat.

What this is about

A language model does one job. You give it some text, and it guesses what small piece of text should come next. Then it adds that piece to the text and guesses again. It keeps going until it decides to stop.

That is all. A chat answer, a poem, a bit of code and a summary all come out of this same loop. This article walks through the loop slowly, so the rest of the series has something solid to stand on.

Why it matters

When you know the loop, a lot of odd behavior makes sense. A model can sound sure and still be wrong, because it picks likely text, not checked facts. A long answer takes longer than a short one, because each piece costs one trip around the loop. And two models can give different answers to the same question, because they scored the next piece differently.

It also tells you where the speed comes from. If the whole product is one loop that runs once per piece of text, then making that loop fast is most of the work. That is the work we do on our own engine.

How it works

Think of a very well-read friend who plays one game: "finish my sentence." You say "The capital of France is" and they say " Paris". They are not looking it up. They have read so much that "Paris" is simply the most likely next word.

A model does this in four steps.

  1. Cut the text into pieces. The model does not read letters or whole words. It reads small chunks called tokens. The next article in this series covers them.
  2. Score every possible next piece. The model holds a long list of every piece it knows. For your text, it gives each one a score for how well it fits as the next piece.
  3. Pick one. The simplest way is to take the top score. This is called greedy decoding. Other ways pick among the top few at random, which makes answers vary from run to run.
  4. Add it and go again. The chosen piece joins the text, and the model scores the whole thing again for the piece after that.

Chat works the same way. A chat program wraps your message in a fixed layout, a "chat template", that marks who is speaking. The model then continues the text where the assistant's turn begins. There is no separate "answer mode". It is the same guessing game, played on a page that looks like a conversation.

Here is a real example from our own work. Our engine is called mojo-baro. It reads a model file and serves a chat over HTTP on one AMD RX 7900 XTX graphics card. In one test we ran plain greedy decoding, with no tricks, on twenty prompts. The engine produced 130.7 tokens per second as the median. llama.cpp, a well-known open program, produced 110.0 on the same model file and the same twenty prompts. That is a ratio of 1.19. It is one card and one setup, so it says nothing about other machines.

A token per second is one trip around the loop per second. So the engine goes around about 131 times every second.

One shortcut worth knowing

Going around the loop one token at a time is slow, because each trip must wait for the one before it. There is a trick called speculative decoding. A small helper guesses a few tokens ahead, and the big model checks all of them in one pass. If the guesses were right, you saved trips. If not, you throw them away.

In our engine, the answer with this trick is identical to the answer without it. The trick changes speed, not the text. It did not always help us. In one Q4_0 test, our version with the trick reached 129.3 tokens per second, a hair under our plain 130.7, while llama.cpp's version reached 169.5 on the same prompts. Our post on that comparison has the details.

What the model does not do

It does not look things up while it writes, unless a program around it gives it a search tool. It does not "know" it is right. It does not remember your last chat unless the text of that chat is pasted back into the page it reads. Each trip around the loop sees only the text in front of it.

This is also why we are careful with claims. A model that scores well on one prompt may do badly on the next. Later articles in this series show how we test that.

Words you may not know

  • Model: a very large file of numbers that, together, score what text should come next.
  • Token: one small piece of text, a few letters or a short word, that the model reads and writes.
  • Greedy decoding: always picking the top-scored next token.
  • Decode: the writing phase, one token at a time. The reading phase is called prefill, and gets its own article.
  • Speculative decoding: a small helper guesses ahead and the big model checks the guesses.
  • Chat template: the fixed layout that marks who is speaking, so a text-continuing model can act like a chat partner.
  • GGUF: a file format that holds a model. We cover it in a later article.

Try it

You can watch the loop run on your own machine if you have a supported card.

  • Read how our engine works, and see the measured results, on the mojo-baro project page. The page lists its limits too, for example that only one card has been measured.
  • The step-by-step run is in a later article of this series.
  • Talk to other people running models, and ask what you are stuck on, at gllm.forum.

A simple first experiment, once any chat model is running: ask the same question three times and compare. If the answers differ, that is step three of the loop, the pick, showing itself.

  • Beating llama.cpp at Decode, Without Speculating, the full story of the 110.0 against 130.7 test, with every table and the honest list of what it does not show.
  • Next in this series: what a token is, and why it changes speed, cost and how much fits in one question.

Comentarios

Aún no hay comentarios.

Iniciar sesión para comentar.