Live data from Hacker News

Understand how transformers work by demystifying the math behind them

osanseviero.github.io

131–139 of 139 posts

Re: Understand how transformers work by demystifying the math behind them

#131

Earlier quoted context omitted.

I think some earlier NLP applications have something called "Unknown token", which they will replace any unseen word. But for recent implementations, I don't think they are being used anymore. It still baffles me why such stochastic parrot / next token predictor, will recognize these "Unseen combinations of tokens" and reuse them in response.

This helped me understand but not well enough to explain it yet: https://transformer-circuits.pub/2022/in-context-learning-an...

Thanks. "In-context learning" was the phrase I was looking for.

Also, I found these 2 links pretty good too. 1. http://ai.stanford.edu/blog/understanding-incontext/ 2. http://ai.stanford.edu/blog/in-context-learning/

I'm still not completely convinced. Probably need to dwell on the topic longer.

Re: Understand how transformers work by demystifying the math behind them

#132

Not completely related. Does anyone know where I can find articles / papers that discuss why transformers, while acting as merely "next token predictor" can handle questions with: 1. Unknown words (or subwords/tokens) that are not seen in the training dataset. Example: Create a table with "sdsfs_ff", "fsdf_value" as columns in pandas. 2. Create examples(unseen in training dataset) and tell the LLM to provide similar…

P(X_1=x_1, X_2=x_2, X_3=x_3) = P(X_3=x_3 | X_1=X_1, X_2=x_2) • P(X_1=x_1, X_2=x_2) = P(X_3=x_3 | X_1=X_1, X_2=x_2) • P(X_2=x_2 | X_1=x_1) • P(X_1=x_1)

That is to say: Having a correct conditional probability distribution over the next token conditional on the previous tokens, produces a correct probability distribution over sequences of tokens.

And, “correct probability distribution over sequences of tokens” (or, “correct conditional probability distribution over sequences of tokens, conditional on whatever)”, can be... well, you can describe pretty much any kind of input/output behavior in those terms.

So, “it works by predicting the next token” is, at least in principle, not much of a constraint on what kinds of input/output behavior it can have?

So, whatever impressive thing it does, is not really in conflict with its output being produced from the probability distribution P(X_{n+1}=x_{n+1} | X_1=x_1, ..., X_n=x_n) (“predicting the next token”)

Re: Understand how transformers work by demystifying the math behind them

#133
post #21

Earlier quoted context omitted.

Transformers can be considered a kind of neural network. It’s mainly fancy math. With tools like PyTorch or tensorflow, you use python to describe a graph of computations which gets compiled down into optimized instructions. There are some examples of people making transformers and other NN architectures in about 100 lines of code. I’d google for those to see what these things look like in code. The training loop, da…

> The code is disappointingly simple. I absolutely adore this sentence, it made me laugh to imagine coders or other folks looking at the code and thinking "That's it?!? But that's simple!" Although it feels a little similar to some of the basic reactions that go to make up DNA: start with simple units that work together to form something much more complex. (apologies for poor metaphors, I'm still trying to grasp some…

I spent a solid month very confused after reading up on how to implement some basic neural networks.

I was sure I missed something, so I didn’t even try to implement it since I was so sure I missed the complicated bit.

But no, all the complexity is in the mathematical implications

Re: Understand how transformers work by demystifying the math behind them

#134

For a dryer, more formal and succinct approach, see "The Transformer Model in Equations" [0], by John Thickstun. The whole thing fits in a single page, using standard mathematical notation. [0] https://johnthickstun.com/docs/transformers.pdf

Finally, thank you so much! Was it so difficult? Isn't 7 lines of mathematical notation way better than pages of qualitative pub talking? I don't really understand these ML researchers, it always looks like they have never studied mathematics at all.

Re: Understand how transformers work by demystifying the math behind them

#135
post #89

Earlier quoted context omitted.

I seen an LLM, or maybe another variant of “AI” [0] a while back that could aid design of electronic circuits by having a pool of data sheets added for referencing. As you were querying specs for a board at component level it could give you a schematic, I think, with citations to the actual data sheets. I suppose the same scale up could be used for systems that needed a varying number of specific power supplies. [0]…

Actually, in my experience chatgpt knows quite a lot about electronic components so I wouldn't be surprised if it was fed datasheets.

I think for me it was due to hearing about made up citations being used, I think for legal stuff.

So being able to load a boatload of official datasheets and have them referenced in the design was what caught my eye as being useful.

Re: Understand how transformers work by demystifying the math behind them

#136
post #66

Earlier quoted context omitted.

We have made progress in efficiency, not functionality. Instead of searching google or stack overflow or any particular documentation, we just go to Chatgpt. Information compression is cool, but I want actual AI.

Fascinating. What’s “actual AI”?

It is a tool that has the ability to craft a prompt that will break current state of the art model.

It is a tool that can be given a project in language X and produce an idomatic port in language Y.

It is a tool that given a 20 pages paper spec will ask the questions needed to clarify the specs.

Re: Understand how transformers work by demystifying the math behind them

#137

> The complexity comes from the number of steps and the number of parameters. Yes, it seems like a transformer model simple enough for us to understand isn't able to do anything interesting, and a transformer complex enough to do something interesting is too complex for us to understand. I would love to study something in the middle, a model that is both simple enough to understand and complex enough to do something…

I would assume that the boundaries of those ranges are such that the middle in between those extremes is something that is already too complex for a human to properly understand while still too small to be able to do anything interesting.

Re: Understand how transformers work by demystifying the math behind them

#138

Earlier quoted context omitted.

Thanks for your reply, you raise a very good point, transformer models are a lot more complex. I'd argue conceptually they're the same, just the data and process is more abstracted. Autoencoded data implies using efficient representations, basically semantically abstracted data and opting for measures like back propagation through time.

So like in my sister reply, I don't see the Backprop, but maybe I'm missing it. This article does use the word, but in a generic way "For example, when doing the backpropagation (the technique through which the models learn), the gradients can become too large" But I think this is more of a borrowing and it's not used again in description and may just be a misconception. There's no use of the Backprop term in the ori…

Yes, if the below perhaps helps. Over my head but...

https://courses.grainger.illinois.edu/ece448/sp2023/slides/l...

From another source:

Backpropagation Through Time (BPTT) is an adaptation of backpropagation used for training recurrent neural networks (RNNs), which are designed to process sequences of data and have internal memory. Because the output at a given time step might depend on inputs from previous time steps, the forward pass involves unfolding the RNN through time, which essentially converts it into a deep feedforward neural network with shared weights across the time steps. The error for each time step is computed, and then BPTT is used to calculate the gradients across the entire unfolded sequence, propagating the error not just backward through the layers but also backward through the time steps. Updates are then made to the network weights in a way that should minimize errors for all time steps. This is computationally more involved than standard backpropagation and has its own challenges such as exploding or vanishing gradients"

Re: Understand how transformers work by demystifying the math behind them

#139
post #12

Earlier quoted context omitted.

Just give it a computer? Even a virtual machine. It can output assembly code or high level code that gets compiled.

The issue is not having access to the cpu, the issue is that the model being able to be trained in such a way that it has representative structures for applicable problem solving. Furthermore, the structures itself should Philosophically, you can start ad hoc-ing functionalities on top of LLMs and expect major progress. Sure, you can make them better, but you will never get to the state where AI is massively useful.…

From what you've written, I don't see why any of this would require the LLM to "be trained to the point where a subset of the graph represents all the nand gates necessary for a cpu and ram" - you'd just be emulating a CPU, but slower.

Tool usage is better, because the LLM can access the relevant computing/simulation at the highest fidelity and as fast as they can run on a real or virtual computer, rather than emulated poorly in a giant pyramid of matrix multiplications.

Am I missing the point?

Post reply on HN