Part 8 in Gates that lie. Earlier parts include what a gate is.
What this is about
Imagine two boxes with the same label on the lid. One holds apples and one holds bricks. If you only check the label, you will say they match.
That is the problem in this article. Software often checks a name, an id or a short summary instead of the real thing. That check can pass while the content is wrong.
The fix is simple to say and takes some care to do: compare the actual output, down to the last byte.
Why it matters
A check that passes on wrong data is worse than no check. It gives you permission to relax.
In our case, the data was a saved conversation. Our language-model engine can save the state of a chat and send it to a second copy of the engine, which then carries on the conversation. If the saved state is wrong, the second engine carries on from the wrong place.
We wanted a gate for this: after transfer, is the state right? We first built it out of the words the model produced next.
How it works
The first gate: look at the ids
A language model writes text as a list of ids, one number for each small piece of text. Our first gate fed the transferred state to the second engine, asked it to continue for 32 ids, and compared those ids with a reference. If they matched, the state must be right.
Testing the gate
Remember the lesson from earlier in this series: break something on purpose. We took five saved states and swapped two of their parts, called K and V, on purpose. A swapped state is wrong, so the continuation ought to be wrong too.
For two of the five, the continuation was still right. The same 32 ids came out.
Why? On a short, easy prompt, the model can be so sure of its next word that a damaged state still gives the same answer for a while. A wrong inside and a right output are different facts, and a check on the output alone cannot tell them apart.
The same pattern showed up in a nearby gate. There, a swapped file was accepted and reused 20 times out of 20 by a second program, and a "was it reused" check passed every time, even though the generated ids were wrong from the very first one. That check measured whether the state was reused. It did not measure whether it was correct.
The second gate: compare the bytes
So we changed what we compared. We had one engine import a state and export it again, and then compared the exported bytes with the imported bytes, one for one. A deliberately swapped state was also sent through, so that only an engine that really kept what it was given could pass.
What the byte compare found
On its first run, the byte check found a real bug that had been there all along.
When the engine saved a state, it chose which saved snapshot to write out using the position in the conversation alone. Two different conversations that happened to be at the same position, 14 words in, got mixed up. One of them was exported with the other's conversation and memory state inside it. That was 52 of the 61 megabytes in the file.
The file had a valid fingerprint and passed every identity check that existed at the time. Anything that trusted the fingerprint would have accepted it.
We fixed it the same day. After the fix, 7 of 7 exports were bit-identical, including the deliberately swapped states.
What we learned
- A label, an id or a count is a summary. Summaries lose information. Wrong data can share a summary with right data.
- If a check can pass on corrupted data, you have not checked the data.
- Use the ids check as a quick signal, but let a byte compare make the final call when correctness matters.
- Do not mix up "was the state reused" with "was the state correct". They are two questions.
What counts as comparing the right thing
Counts:
- Comparing the full output, or a strong fingerprint of all of it.
- Testing the check against a case you know is wrong.
- Naming what the check proves, and what it does not.
Does not count:
- Comparing only the name or id.
- Comparing the first few results of something long.
- A fingerprint taken from the wrong thing. A fingerprint of the wrong file is a perfect check of the wrong file.
Glossary
- Byte: the smallest unit of a file that we usually count. A file is a long list of bytes.
- Bit-identical: exactly the same, bit for bit.
- Id: a number standing for a piece of text.
- State: what a program remembers, here the memory of a conversation.
- Fingerprint (hash): a short code made from a file, used to detect changes.
- Gate: a check that decides whether work may go forward.
Try it
Make a copy of any file. Change one letter in the copy. Compare the file names, and they look fine. Compare the file sizes, and they may also match. Now run cmp on the two files in a terminal. It tells you at once where they differ. That is the idea in one minute.
For a tool that compares real output, look at mojo-port. It runs a Python tool and its Mojo port on the same cases and compares what they print and how they exit, character for character, and not a summary of it.
What to remember
Compare the thing itself, not its name. A name can match when the contents do not.

Kommentare
Noch keine Kommentare.
Anmelden um zu kommentieren.