Notes on Large Language Models as General Pattern Machines
This is a summary of an important research paper that provides a 16:1 time savings. It was made interactively by a human and several AI's. The goal is to save time and curate good ideas.
Link to paper: https://arxiv.org/abs/2307.04721
Paper published on: 2023-07-10
Paper's authors: Suvir Mirchandani, Fei Xia, Pete Florence, Brian Ichter, Danny Driess, Montserrat Gonzalez Arenas, Kanishka Rao, Dorsa Sadigh, Andy Zeng
GPT3 API Cost: $0.04
GPT4 API Cost: $0.13
Total Cost To Write This: $0.17
Time Savings: 16:1
The Power of Large Language Models (LLMs) in Sequence Transformation and Robotics
This research reveals that Large Language Models (LLMs) can autoregressively complete complex token sequences, including spatial patterns found in the Abstract Reasoning Corpus (ARC). This capability remains even when sequences are expressed using randomly sampled tokens from the vocabulary, indicating token mapping invariance. This means that LLMs can recognize patterns regardless of the specific tokens used.
Moreover, LLMs have shown promise as general sequence modelers without the need for additional training. This is driven by in-context learning, a method of sequence modeling that represents sequences autoregressively. This ability to learn in context improves out-of-distribution generalization and can learn simple function classes.
For instance, imagine a robotic arm trained to wipe a table in a specific pattern. Using LLMs, we can provide the robot with a sequence representing this wiping motion. Now, if we change the tokens representing this sequence randomly, the LLM can still recognize the pattern and complete it. This is token mapping invariance in action.
LLMs in Robotics: Pattern Recognition and Sequence Completion
LLMs have been successfully applied in robotics for tasks such as instruction following, program synthesis, reward function design, and user preference generalization. They can recognize and complete sequences of numeric or arbitrary tokens expressing abstract problems in robotics and sequential decision-making.
LLMs can directly influence control in a zero-shot manner, extending or optimizing low-level action sequences. This means LLMs can improve sequences by providing reward-labeled trajectories as context, enabling learning to navigate, discover controllers, and optimize trajectories.
For example, consider a robotic arm trained to place a marker in a cup. The arm's movements can be represented as a sequence of actions. By providing reward-labeled trajectories, the LLM can learn to optimize this sequence, resulting in more successful attempts at placing the marker in the cup.
LLMs and In-Context Learning: A Powerful Combination
In-context learning with LLMs has shown promising results in solving sequence transformation problems. This method can be used for sequence transformation, sequence completion, and sequence improvement. In-context learning represents sequences autoregressively, which means it takes into account the sequence's history when making predictions.
For instance, if a robot is trained to navigate a maze, its movements can be represented as a sequence. Using in-context learning, the LLM can learn from the robot's past movements and improve its future ones, enabling the robot to navigate the maze more efficiently.
Consistent Tokenization: A Key to Pattern Recognition
Consistent tokenization is important for LLMs to accurately represent patterns in the input. Despite this, LLMs can still solve ARC problems even with randomly sampled alphabets, indicating token mapping invariance. This suggests that LLMs can recognize patterns regardless of the specific tokens used.
In other words, the LLM doesn't care about the specific tokens used to represent a sequence. It can still recognize the underlying pattern. This has positive implications for new modalities or symbolic representations in robotics.
The PCFG Benchmark: A New Standard for Evaluating LLMs
The researchers introduce a new benchmark called Procedurally Generated Context-Free Grammar (PCFG) for evaluating pattern reasoning capabilities in language models. PCFG transformations include a collection of lexical rules that can be composed over input sequences to generate output sequences. The complexity of PCFG transformations can be controlled by varying the number of tokens and lexical rules used.
For example, a PCFG rule might state that every occurrence of the token "A" should be replaced with the sequence "B C". An LLM trained on this rule would then be able to transform the sequence "A A A" into "B C B C B C".
LLMs in Action: Experiments and Applications
The research demonstrates the application of LLMs in sequence completion tasks such as table sweeping and whiteboard drawing. They also introduce the Marker in Cup task, where LLMs are used to generate improved trajectories based on a reward metric.
In the CartPole environment, observations are two-dimensional (pole angle and velocity) and the maximum time horizon is 200. The CartPole agent receives a reward of +1 for every time step that the pole is kept upright. The action space consists of two possible actions: left (1) and right (2). The context format for CartPole includes a trajectory history (reward, observation, action, observation, action...) followed by an encoding of the current trajectory.
In the clicker training example, the observation consists of the end-effector position and the approximate object position. Actions correspond to movements of the end-effector. The context format for clicker training includes (reward, observation, action) tuples ordered by reward, with an equal number of reward 0 and reward 1 transitions represented in the context.
These experiments demonstrate the potential of LLMs in various sequence-related tasks, opening up new possibilities for LLMs' application in robotics and other domains.
Future Directions and Limitations
While the capabilities of LLMs are impressive, the research also highlights some limitations. The inference costs of using LLMs in the control loop are currently high, and LLM-based control is not suitable for application outside of constrained lab settings. Future work could focus on improving LLM quantization and inference efficiency.
Despite these limitations, the research underscores the potential of LLMs as powerful tools for sequence modeling and transformation, especially in the field of robotics. By leveraging the capabilities of LLMs, we can build more robust, adaptable, and efficient robotic systems.




