Generative AI Learns When You Use It
DISCOUNTING PAST INFORMATION FOR FUTURE PREDICTION
Some of our readers expressed shock at our recent analysis of prompting generative AI to “think like Buffett”. After we published on May 4th, researchers from the Max Planck Institute hit upon the same approach in their May 24th paper, “In-Context Impersonation Reveals Large Language Models' Strengths and Biases”. Why would such a simple method be powerful and what’s the mechanism that explains why this isn’t a slight of hand? Researchers from Stanford University explain mechanisms in their paper “An Explanation of In-context Learning as Implicit Bayesian Inference” for LLMs. What is Bayesian inference and why is prompting as Bayesian inference a powerful concept? We’ll understand why generative AI requires our intelligence as the value investor to take it to the required performance level.
The figure that started the investigation
Bayesian inference is a statistical method that combines prior beliefs with observed data to produce updated beliefs. Named after Thomas Bayes, an 18th-century mathematician and theologian, the core idea behind Bayesian inference is Bayes' theorem, a fundamental theorem in probability theory and statistics. The theorem describes how to update the probability for a hypothesis as more evidence becomes available. While this general description seems like how human learning and decision works, the power comes in the mechanisms of the prior, the posterior, and the marginal probability distributions in Bayes’ theorem.
To explain, imagine you're a detective investigating a case, and you have a suspect in mind. Bayes' theorem is like your thought process during the investigation. The "prior" is your initial suspicion of the suspect being guilty before you've looked at any evidence. Maybe this is based on their criminal record, their relationship to the victim, or other circumstances that you're aware of. It's essentially your best guess given the limited information you have.
Now, you find a piece of evidence - say, a fingerprint at the crime scene. The "likelihood" is how much this evidence makes sense if your suspect was indeed guilty. If it's the suspect's fingerprint, that would strongly point towards their guilt, but if it's someone else's, it would suggest they're probably innocent.
The "posterior" is your updated belief about the suspect's guilt after taking this evidence into account. If the evidence was highly suggestive, it might strongly increase your belief in their guilt. But if the evidence didn't fit, it would reduce your belief. You'd then go forward and use this updated belief as your new "prior" when you encountered the next piece of evidence.
The denominator in Bayes' theorem, the "marginal likelihood", is a bit trickier, but in our detective analogy, it's akin to considering all the other possible suspects who could have left a fingerprint at the crime scene. This factor 'normalizes' your suspicions, ensuring they are not wholly tied to one suspect without considering other possibilities, much like how probabilities should add up to 1 in a well-calibrated thought process.
So, in essence, Bayes' theorem is a systematic way of updating your beliefs in light of new evidence. It balances how strongly you believed something initially (the prior) with how much the new evidence supports it (the likelihood), to arrive at a new, updated belief (the posterior).
Bayesian inference is used in various fields, such as science, engineering, and economics, to make sense of data and draw conclusions from it. It has gained popularity in recent years due to its flexibility in modeling complex scenarios and its ability to incorporate uncertainty explicitly. It can handle everything from simple parameter estimation to complex hierarchical models and ML tasks. We trade-off Bayesian inference versus simple frequentist (one-off accuracy) estimation when there’s an expectation of longitudinal evidence, like a long-term investment. Stanford researchers deduced that asking LLMs to take on roles imparts a prior distribution onto outputs.
Figure credit: https://arxiv.org/abs/2305.14930
According to Stanford researchers, LLMs are using Bayesian inference to perform in-context learning. They're given a bunch of examples, and they infer the underlying concept or pattern from these examples. The more examples they're given, the better they can "guess" the right answer. The paper suggests in-context learning is updating the probability for a correct response as more the context (the user prompt) becomes available.
Now there’s a wrinkle in out of distribution prediction, crucial to the investing setting. Take the longitudinal study predicting what your friend will order at a restaurant. Investing, like say predicting your friend's order at a new restaurant, involves making forecasts based on past data. But just as the cuisine of the new restaurant might differ from those you've visited before, market conditions can change, and past performance may not predict future results. However, like a good friend who knows their dining companion's preferences, an experienced investor can draw upon their understanding of fundamental principles and strategies to make educated guesses about future market behavior. You've been to many different restaurants with this friend, and each time, you've noted what they ordered. Over time, you start to see patterns and can make educated guesses about what they might order next time based on their past choices. The researchers acknowledge this challenge - the prompts given to the model (like "predict what my friend will order at a new restaurant") come from a different distribution than the data the model was trained on (the past orders at different restaurants). It's like trying to predict your friend's order at a Mexican restaurant when all your previous experiences were in Italian restaurants.
They offer a mathematical proof showing that, despite lacking out of domain information, the model's predictions can still be optimal, as long as each prompt gives enough information about the underlying concept.
To validate their theory, the researchers created a synthetic dataset called GINC with two main components - entities (eg. Einstein) and properties (eg. nationality) for studying in-context learning. They observed that larger models and longer examples improved the accuracy of in-context learning (seeing a few examples and then predicting what comes next), providing more evidence that these models are indeed learning through a process like Bayesian inference. In-context learning is when a model learns a downstream task just by conditioning on a prompt that contains input-output examples, without any explicit pre-training. The authors aim to understand how this type of learning can occur, especially when pre-training documents demonstrate long-range coherence.
The authors hypothesize that the LLM infers a latent document-level concept, which helps to generate coherent next tokens during pre-training. Then, during the testing phase, the LLM infers a shared latent concept between the examples in a prompt, facilitating in-context learning. This process can occur despite a mismatch between the distributions of prompts and pre-training data.
However, they also found open questions and phenomena that aren't yet explained by their theory, suggesting more research is needed in this fascinating field. This brings us to our current topic, the surprising practice of asking LLMs to impersonate roles, like Buffett. Researchers from Max Planck wanted to know if LLMs could pretend to be different roles effectively and if these roles could change how the models approach different problems. To do this, they used a range of different tasks, like the multi-armed bandit problem and reasoning tasks.
Let's unpack the multi-armed bandit problem first. Picture a game where you have multiple slot machines (also known as one-armed bandits), and you can choose to play any one of them on each turn. Each machine gives different rewards, but you don't know which one is best. You need to decide whether to stick with the machine you're currently playing (exploiting) or try a different machine (exploring) in the hopes of getting more rewards. The researchers asked the language models to pretend they were people of different ages playing this game. They found out that models pretending to be children explored more, while those pretending to be adults exploited more. It's like children being more curious and trying different things, while adults use their experience to make the best choice.
Now, onto the reasoning tasks. Let's imagine a quiz show. You've got some multiple-choice questions about different topics. Some are about STEM topics, others about Humanities and Social Sciences. The experimenters asked the generative AI to answer questions while pretending to be experts in different fields. They found out that models pretending to be experts in a specific domain did better than those pretending not to be experts.
The researchers also used different models, including Vicuna and GPT-3.5-Turbo in the ChatGPT series. They wanted to check if different models performed differently in these tasks, and indeed they did.
Finally, they found that when LLMs pretend to be different characters, they can bring out some biases encoded in them. For instance, when pretending to be different races or genders, the models performed differently in some tasks, revealing some societal biases they had learned.
In conclusion, these experiments show that language models can effectively pretend to be different personas and that these personas can influence their performance and behavior in different tasks. It's like people at the fancy dress party not only dressing like different characters but also thinking and behaving like them. The research helps us understand more about how these models learn and behave, and it opens up new directions for future studies.
Yet still the robustness of in-context learning presents a significant challenge. This is because the performance of in-context learning can be highly unstable and sensitive to a variety of factors. This instability means that its performance can vary dramatically, sometimes performing at state-of-the-art levels, and at other times performing no better than random guessing. This is exactly what we explored in our series of analyses of ChatGPT for value investing.
These performance fluctuations can be affected by several factors. For instance:
1. Demonstration Permutation: The order in which demonstration examples are provided can influence the performance.
2. Demonstration Format: The specific format or style of the demonstration examples can also affect the results.
3. Instructions Sensitivity: In-context learning performance can vary based on slight changes or perturbations in the instructions given to the model.
Consistent Conceptual Frameworks
From a top level, we well know generative AI performs fairly well out of distribution. Conceptual models have powerful effects and the study “Out-of-context Meta-learning in Large Language Models” investigated OOD performance. The paper found LLMs internalize consistent definitions more than inconsistent ones. After fine-tuning on a specific data set, the neural network arrives at a point in parameter space where gradient updates on consistent definitions result in more internalization than updates on inconsistent ones. This is described as "out-of-context meta-learning", where the network anticipates that consistent definitions will be more beneficial for reducing future training loss, so it internalizes them more.
The authors perform an entity attribution experiment, asking models questions about a variable's name, its meaning, what it stands for, or who it represents. They evaluate the model on these questions after every epoch of a 2-stage fine-tuning setup, finding that consistent entities are internalized stronger than inconsistent ones.
The Pythia model, with 2.8 billion parameters, and the smaller Pythia-410M model exhibit similar behaviors. However, the smaller model has less strong internalization with the more challenging T-REx dataset. Jointly fine-tuning on two datasets also results in weak and strong internalization.
When running experiments with the sequence-to-sequence transformer model T5-3B, there is weak and strong internalization with one dataset (CVDB), but none with the harder T-REx dataset. Since the T5 model had minimal accuracy across entity attribution question types, a complex learning dependence was expected.
The paper discusses potential mechanisms responsible for weak and strong internalization. One hypothesis suggests that LLMs store factual information in their parameters and retrieve these definitions to answer questions. Another hypothesis proposes that gradient-descent-based methods favor gradient alignment across minibatches.
The paper also provides a discussion on the implications of these findings, such as the possibility of LLMs acquiring situational awareness and the potential of reinforcement learning agents seeking power. The authors suggest that these scenarios need better understanding for proactive measures against potentially harmful consequences. LLMs are capable of out-of-context meta-learning, which could have significant implications for our understanding of foundational models.
Outlook
At Amicus, we had explored generative AI in our empirical studies ahead of general studies that arrived later. Our position is that investing AI, while powerful, should be used in a copilot function– that is with you as the pilot in charge of steering. In forthcoming articles, we cover the future of generative AI for investing. First, in the short term, how to incorporate AI in investing via the well-trodden path of model ensembling. Second, in the medium term, how to register your decision output in a format compatible with generative AI training recipes for the goal of higher performance. Generative AI, even with internet scale datasets, doesn’t yet reproduce top tier investing analysis. High performance investment analysis is not sufficiently represented and identified in internet discourse. Your investing analysis output is the most precious resource in your daily work and now with generative AI, it could secure your future legacy.
References
Salewski, Leonard, et al. "In-Context Impersonation Reveals Large Language Models' Strengths and Biases." arXiv preprint arXiv:2305.14930 (2023). https://arxiv.org/abs/2305.14930
Xie, Sang Michael, et al. "An explanation of in-context learning as implicit Bayesian inference." arXiv preprint arXiv:2111.02080 (2021). https://arxiv.org/abs/2111.02080
Krasheninnikov, Dmitrii, Egor Krasheninnikov, and David Krueger. "Out-of-context Meta-learning in Large Language Models." ICLR 2023 Workshop on Mathematical and Empirical Understanding of Foundation Models. 2023. https://openreview.net/forum?id=X3JFgY4gvf
DISCLAIMER: This Paper is not intended to provide any investment, financial, legal, regulatory, accounting, tax or similar advice, and nothing on this Paper should be construed as a recommendation, by Amicus AI, its affiliates or any third party, to acquire or dispose of any investment or security, or to engage in any investment strategy or transaction. You should consult your own investment, legal, tax and/or similar professionals regarding your specific situation and any specific decisions.