Well, it’s really terribly simple, […] it works any way you want it to. You see, the computer that runs it is a rather advanced one. In fact it is more powerful than the sum total of all the computers on this planet including—and this is the tricky part—including itself.
— Douglas Adams, Dirk Gently’s Holistic Detective Agency
Transformers are big self-attention networks with some extra tricks — self attention, and a query, key, value mechanism, and usually a positional encoding as well.
I am no expert. Here are some good blog posts explaining everything, for my reference, but I will not write yet another one. This is a fast-moving area and I am not keeping track of it, so if you are on this page looking for guidance you are already in trouble.
Phuong and Hutter (2022)
Transformers are deep feed-forward artificial neural networks with a (self)attention mechanism. They have been tremendously successful in natural language processing tasks and other domains. Since their inception 5 years ago, many variants have been suggested. Descriptions are usually graphical, verbal, partial, or incremental. Despite their popularity, it seems no pseudocode has ever been published for any variant. […] This report intends to rectify the situation for Transformers. It aims to be a self-contained, complete, precise and compact overview of transformer architectures and formal algorithms (but not results)
These networks are massive (heh) in natural language processing right now.
A key point about these networks seems to be that they can be made extremely large but still remain trainable. This leads to interesting scaling laws.
Introductions
- Understanding einsum for Deep learning: implement a transformer with multi-head self-attention from scratch | AI Summer
- Jay Alammar’s Illustrated Transformer
- Lilian Weng, Large Transformer Model Inference Optimization
- Lilian Weng, The Transformer Family Version 2.0
- The AlphaFold2 Method Paper: A Fount of Good Ideas
- Xavier Amatriain, Transformer models: an introduction and catalog — 2023 Edition
- nostalgebraist, An exciting new paper on neural language models
- This guide to pruning multihead attention NN should probably go somewhere useful if I actually end up doing NLP like all the recruiters seem to want.
- 1A - Scaled Dot Product Attention explained
A good paper read is Yannic Kilcher’s.
Power of
Transformers are pretty good at weird stuff, e.g. automata — see Unveiling Transformers with LEGO (Zhang et al. 2022).
How about Bayesian inference? (Müller et al. 2022)
Can they be an engine of intelligence? What do they do in society? etc. Controversial — see the Stochastic Parrots paper (Bender et al. 2021), and the entire internet commentariat from November 2022 onwards.
Image by Anthrupad
As set functions
Transformers are neural set functions (!).
RWKV
State-space, i.e. recurrent transformers, without (classic) attention. Suggestive connection to S4 models.
RWKV is inspired by Apple's Attention Free Transformer.(@ Zhai et al. 2021). …
How to combine the best of transformers and RNNs? The main drawback of transformer-based models is that it can become challenging to run a model with a context window that is larger than a certain value, as the attention scores are computed simultaneously for the entire sequence.
RNNs natively support very long context lengths - only limited by the context length seen in training, but this can be extended to millions of tokens with careful coding. Currently, there are RWKV models trained on a context length of 8192 (
ctx8192
) and they are as fast asctx1024
models and require the same amount of RAM.The major drawbacks of traditional RNN models and how RWKV is different:
- Traditional RNN models are unable to utilize very long contexts (LSTM can only manage ~100 tokens when used as a LM). However, RWKV can utilize thousands of tokens and beyond…
- Traditional RNN models cannot be parallelized when training. RWKV is similar to a "linearized GPT" and it trains faster than GPT.
By combining both advantages into a single architecture, the hope is that RWKV can grow to become more than the sum of its parts.
- Introducing RWKV - An RNN with the advantages of a transformer
- How the RWKV language model works
- The RWKV language model: An RNN with the advantages of a transformer
- BlinkDL/ChatRWKV: ChatRWKV is like ChatGPT but powered by RWKV (100% RNN) language model, and open source.
Tokens as recurrent state
See also RecurrentGPT (Zhou et al. 2023)
GitHub - aiwaves-cn/RecurrentGPT
RecurrentGPT replaces the vectorized elements (i.e., cell state, hidden state, input, and output) in a Long-short Term Memory RNN (LSTM) with natural language (i.e., paragraphs of texts), and simulates the recurrence mechanism with prompt engineering.
At each timestep t, RecurrentGPT receives a paragraph of text and a brief plan of the next paragraph, which are both generated in step t − 1. It then attends to the long-term memory, which contains the summaries of all previously generated paragraphs and can be stored on hard drives, and relevant paragraphs can be retrieved with semantic search.
RecurrentGPT also maintains a short-term memory that summarizes key information within recent timesteps in natural language and is updated at each time step. RecurrentGPT combines all aforementioned inputs in a prompt and asks the backbone LLM to generate a new paragraph, a short plan for the next paragraph, and updates the long-short term memory by rewriting the short-term memory and appending the summary of the output paragraph to the long-term memory.
Practicalities
Democratizing the hardware side of large language models seems to be an advertisement for some new hardware, but there is interesting background in there.
HuggingFace distributes and documents and implements a lot of Transformer/attention NLP models and seem to be the most active neural NLP project. Certainly too active to explain what they are up to in between pumping out all the code.
Embedding vector databases
See embedding vector databases.
LMQL: Programming Large Language Models: “LMQL is a programming language for language model interaction.” (Beurer-Kellner, Fischer, and Vechev 2022)
LMQL generalizes natural language prompting, making it more expressive while remaining accessible. For this, LMQL builds on top of Python, allowing users to express natural language prompts that also contain code. The resulting queries can be directly executed on language models like OpenAI's GPT models. Fixed answer templates and intermediate instructions allow the user to steer the LLM's reasoning process.
No comments yet. Why not leave one?