Ask HN: Has anyone considered using rich tokens for LLMs?

1 points by jiggawatts ↗ HN
The tokens used by LLMs are the rough equivalent of the tokens produced during programming language parsing, but LLM tokens can only represent fixed character sequences. In programming language parsing, literals are parsed into tokens that have the literal value as extra baggage that they carry around.

Current LLMs map words to token IDs, such as "apple" -> '1', "the" -> '2', etc...

Why not have them map numeric literals to special token IDs that also has the numeric values associated with them?

E.g.: token IDs 0..1000 could be assigned to the first 1K distinct numeric literals being processed.

Subsets of the matrices at each layer could be special-purposed to do arithmetic on those tokens. E.g.:, if a "maths operator neuron" is activated with inputs that are IDs 533 and 712, then it'll "multiply" those two numeric values.

This could allow LLM-like systems to be built that can do arithmetic in the same way as a calculator instead of trying to do long-form multiplication like a human with pencil and paper.

10 comments

[ 5.8 ms ] story [ 30.8 ms ] thread
I think the trend is away from semantic tokens, and away anything that is remotely like 'feature engineering'. Maybe even they will just use character level or byte level encoding in the future. They have used it before, and probably something like it will be used again if the Rich Sutton 'bitter lesson' continues to be true.
Have you seen how many steps an AI would have to go through to do something as simple as division or square root of “just” a single number? This is an operation a calculator from the 1970s can do instantly but an AI running on a computer worth half a million and sucking down ten kilowatts of juice struggles with!

PS: I just asked GPT 4 to use long form division to calculate 73732/64. It took over ten seconds and the result was wrong.

They are making machines that think basically like people. People suck at mental math for whatever reason and it looks like the machines are sucking at it too, probably for the same reason. As someone else said here, these thinking machines can just use a calculator themselves or write a small python code or use wolfram alpha plugin.
I’m saying instead of emulating the AI pressing buttons on a calculator, just a plug a calculator into its brain.

Make a cyborg without surgery.

OK I see what you mean. I don't think using your suggestion of semantic tokens is a good way to do it. They will do it by wrapping the raw text completion with more steps that are hidden from you, which will make it do the math right, and then it won't make such obvious math mistakes anymore.
The problem with that is that the AI can’t reason over the results of computations it can’t see.
Why have the LLM do arithmetic at all though? Just have it generate python if you need a calculation.
Symbolic maths that involves constants.

Processing tabular data such as spreadsheets.

Efficiency — invoking Python would be very inefficient for scenarios such as a math tutor AI checking a student’s arithmetic.

Generally I like to think of a useful AI as a hybrid between biological networks and computers. Give an LLM the ability to compute directly so it’s not emulating a human with a calculator, but working more like a human with a calculator neural implant.

One problem is that the current LLMs generate code without actually running and testing it. "Here is Python syntax I dreamed up using language manipulation, but never actually ran (since I have no way of doing that without your help); it should work for you!".

If the LLM is trained on arithmetic, its arithmetic results could be more accurate than its untested code, due to that being a simpler task with simple rules over a small number of symbols with a fixed meaning.

Situations in which the LLM produces code requires the operator to be a programmer, in order to understand, and test the code, possibly fixing it, and give feedback about it. Someone who just wanted the AI to check some arithmetic doesn't want to be checking the AI's buggy code and may not even know how.

I have my local chatbot set up to automatically run shell commands that start with "$." It wouldn't be too hard to check the status and have the LLM try to debug it if something goes wrong.

This to me seems much more flexible and likely to work than training a neural network to do arithmetic.