Showing posts with label Bayesian. Show all posts
Showing posts with label Bayesian. Show all posts

Google Researchers Propose Bayesian Teaching Method for Large Language Models

Mike's Notes

This is a rather cool idea.

Resources

References

  • Reference

Repository

  • Home > Ajabbi Research > Library > Subscriptions > InfoQ
  • Home > Handbook > 

Last Updated

10/04/2026

Google Researchers Propose Bayesian Teaching Method for Large Language Models

By: Daniel Dominguez
InfoQ: 14/03/2026

Daniel is the Managing Partner at SamXLabs an AWS Partner Network company. He has over 13 years of experience in software product development for startups and Fortune 500 companies. Daniel holds a degree in Engineering and a Machine Learning specialisation from the University of Washington. He is passionate about leveraging AI and cloud computing to create innovative solutions. As an AWS Community Builder in the Machine Learning tier, Daniel is committed to sharing knowledge and driving innovation in software products.

Google Researchers have proposed a training method that teaches large language models to approximate Bayesian reasoning by learning from the predictions of an optimal Bayesian system. The approach focuses on improving how models update beliefs as they receive new information during multi-step interactions.

The study examines how language models update beliefs when interacting with users over time. In many real-world applications, such as recommendation systems, models need to infer user preferences gradually based on new information. Bayesian inference provides a mathematical framework for updating probabilities as new evidence becomes available. The researchers investigated whether language models behave in ways consistent with Bayesian belief updates and explored training methods to improve that behavior.

To evaluate this, the team created a simulated flight recommendation task. In the experiment, a model interacted with a simulated user for five rounds. In each round, the assistant and user were shown three flight options defined by departure time, duration, number of stops, and price. Each simulated user had hidden preferences for these attributes. After each recommendation, the user indicated whether the assistant selected the correct option and revealed the preferred flight. The assistant was expected to use this feedback to improve future recommendations.

The researchers compared several language models with a Bayesian assistant that maintains a probability distribution over possible user preferences and updates it using Bayes’ rule after each interaction. In the experiment, the Bayesian assistant reached about 81% accuracy in selecting the correct option. Language models performed worse and often showed limited improvement after the first interaction, suggesting that they did not effectively update their internal estimates of user preferences.

The study then tested a training approach called Bayesian teaching. Instead of learning only from correct answers, models were trained to imitate the predictions of the Bayesian assistant during simulated interactions. In early rounds, the Bayesian assistant sometimes made incorrect recommendations due to uncertainty about the user’s preferences, but its decisions reflected probabilistic reasoning based on the available evidence.

The image below shows the recommendation accuracy of Gemma and Qwen after fine-tuning on user interactions with the Bayesian assistant or with an oracle.

The training data for supervised fine-tuning consisted of simulated conversations between users and the Bayesian assistant. For comparison, the researchers tested a method in which the model learned from an assistant that always selected the correct option because it had perfect knowledge of the user’s preferences.

Both fine-tuning approaches improved model performance, but Bayesian teaching produced better results. Models trained with this method made predictions that more closely matched those of the Bayesian assistant and demonstrated stronger improvement across multiple interaction rounds. The trained models also showed higher agreement with the Bayesian system when evaluating user choices.

Community reactions to the Google Research post were largely positive, with commenters highlighting improved probabilistic reasoning and multi-turn adaptation in LLMs. 

Software developer Yann Kronberg commented:

People talk about reasoning benchmarks, but this is basically about belief updates. We know that most LLMs don’t revise their internal assumptions well after new information arrives, so @GoogleResearch teaching them to approximate Bayesian inference could matter a lot for long-running agents.

Some also questioned the use of supervised fine-tuning rather than reinforcement learning to approximate Bayesian inference.

Researcher Aidan Li quoted:

Why did the authors use SFT instead of RL to train the model to approximate probabilistic inference? There is a wealth of work relating RL and probabilistic inference, even for LLMs. Maybe I'm missing something but RL seems like the obvious choice.

The researchers describe the method as a form of model distillation in which a neural network learns to approximate the behaviour of a symbolic system implementing Bayesian inference. The results suggest that language models can acquire probabilistic reasoning skills through post-training that demonstrate optimal decision strategies during sequential interactions.

Bayesian Statistics

Mike's Notes

A great introduction to Bayesian Statistics. With example workbooks. All free, including an Excel Resource Pack. The Real Statistics website by Charles Zaiontz is a fantastic resource.

Update

The YouTube lesson by Vivek Vinushanth Christopher is superb.

Resources

References

  • Reference

Repository

  • Home > Ajabbi Research > Library >
  • Home > Handbook > 

Last Updated

24/01/2026

Bayesian Statistics

By: Charles Zaiontz
Real Statistics: 01/05/2021

Dr. Charles Zaiontz has a PhD in mathematics from Purdue University and has taught as an Assistant Professor at the University of South Florida as well as at Cattolica University (Milan and Piacenza) and St. Xavier College (Milan).

Bayesian statistics uses an approach whereby beliefs are updated based on data that has been collected. This can be an iterative process, whereby a prior belief is replaced by a posterior belief based on additional data, after which the posterior belief becomes a new prior belief to be refined based on even more data. The initial prior belief in this series may be based on intuition, previous studies, experience, etc.

In inferential statistics, we commonly test hypotheses, estimate parameters, and make predictions. In the traditional approach to statistics, commonly called the frequentist approach, parameters are constants whose values we aim to discern. Bayesian statistics uses a different approach: we treat these parameters as variables that have a probability distribution.

Topics

References

  1. Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., Rubin, D. B. (2014) Bayesian data analysis, 3rd Ed. CRC Press
    https://statisticalsupportandresearch.files.wordpress.com/2017/11/bayesian_data_analysis.pdf
  2. Marin, J-M and Robert, C. R.  (2014) Bayesian essentials with R. 2nd Ed. Springer
    https://www.springer.com/gp/book/9781461486862
  3. Jordan, M. (2010) Bayesian modeling and inference. Course notes
    https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/lectures/index.html
  4. Lee, P. M. (2012) Bayesian statistics an introduction. 4th Ed. Wiley
    https://www.wiley.com/en-us/Bayesian+Statistics%3A+An+Introduction%2C+4th+Edition-p-9781118332573

Markov Blankets

Mike's Notes

Pipi uses Markov chains, which can form a Markov Blanket. Blankets can be aggregated and nested. The Royal Society paper "The Markov Blankets of Life: autonomy, Active Inference and the Free Energy Principle" is excellent.

A Markov blanket statistically defines a system's boundaries (e.g., a cell or a multicellular organism). It is a statistical partitioning of a system into internal and external states, and the blanket itself consists of the states that separate the two.

Resources

References

  • Reference

Repository

  • Home > Ajabbi Research > Library >
  • Home > Handbook > 

Last Updated

12/10/2025

A Markov Chain Theory of Self Organization

By: Jacob Calvert, Georgia Tech University 

YouTube: 14/11/2024


Fundamentals of statistical mechanics explain that systems in thermal equilibrium spend more time in states with greater order because these states have lesser energy. This explanation is remarkable, and powerful, because energy is a "local" property of states. Nonequilibrium systems, like living systems, can also exhibit order, but there is no property analogous to energy that generally explains why states with greater order tend to emerge. However, recent experiments suggest that a local property called rattling predicts which states are favored, at least for a broad class of nonequilibrium systems. In this seminar, I will present a simple theory of rattling that explains when and why it works, and I will demonstrate its application to systems across scientific domains. Surprisingly, the core idea of rattling is so general as to apply to equilibrium and nonequilibrium systems alike. (Joint work with Dana Randall.)

Markov Blanket

"In statistics and machine learning, when one wants to infer a random variable with a set of variables, usually a subset is enough, and other variables are useless. Such a subset that contains all the useful information is called a Markov blanket. If a Markov blanket is minimal, meaning that it cannot drop any variable without losing information, it is called a Markov boundary. Identifying a Markov blanket or a Markov boundary helps to extract useful features. The terms of Markov blanket and Markov boundary were coined by Judea Pearl in 1988. A Markov blanket can be constituted by a set of Markov chains." - Wikipedia.


Eruption Forecasting using Bayesian Networks

Mike's Notes

I don't know enough to describe Pipi technically. I know that I built Fuzzy Logic and Markov into its design. I suspect Bayesian Networks and some kind of Monte Carlo are also involved. But I don't have any formal training in Mathematics apart from High School, to be sure.

Part of the problem is that I accidentally stumbled across an architecture that worked to solve a problem I wanted to solve.

I will ask my friends Alex and Chris ( both retired computer scientists) to help determine what is happening.

I may also find a friendly mathematician lurking around Wolfram.

Here is an article from the GNS publication "Beneath the Waves" that makes me think Bayesian probably is happening because of the first figure. It looks like what I have done anyway.

"Bayesian networks are a type of Probabilistic Graphical Model that can be used to build models from data and/or expert opinion. They can be used for a wide range of tasks including diagnostics, reasoning, causal modeling, decision making under uncertainty, anomaly detection, automated insight and prediction." ... Bayes Server

"A Bayesian network (also known as a Bayes network, Bayes net, belief network, or decision network) is a probabilistic graphical model that represents a set of variables and their conditional dependencies via a directed acyclic graph (DAG).[1] While it is one of several forms of causal notation, causal networks are special cases of Bayesian networks. Bayesian networks are ideal for taking an event that occurred and predicting the likelihood that any one of several possible known causes was the contributing factor. For example, a Bayesian network could represent the probabilistic relationships between diseases and symptoms. Given symptoms, the network can be used to compute the probabilities of the presence of various diseases." ... Wikipedia

Resources

References

  • Reference

Repository

  • Home > Ajabbi Research > Library >
  • Home > Handbook > 

Last Updated

17/05/2025

Eruption Forecasting using Bayesian Networks

GNS Science: 04/12/2024

A novel method of eruption forecasting has been developed using Bayesian Networks. This innovation allows for data-based forecasts of activity without reliance on a single monitoring dataset.

What is a Bayesian Network?

A Bayesian Network is a simple model and statistical tool that can be used to determine the probability of an event happening, based on:

  • a set of variables (nodes) that influence the event occurring,
  • the relationships and dependencies between the variables,
  • prior information about the event, and
  • prior information about the variables.

Bayesian networks can combine different sources of information by defining a system of conditional probabilities between sources. An event is then simply a certain constellation of that system for which the Bayesian Network will give us a probability of occurrence.

A Bayesian network (e.g. see Figure 1) has two main components:

  • the causal relationships between the variables in the system, and
  • the actual probabilities for the variable (node) that are used to make predictions.



Figure 1: A Bayesian Network showing the relationship between nodes for a volcanic eruption and the variables that can be measured (e.g. gas monitoring (CO2, H2S, SO2), volcanic tremors (RSAM)).

A Bayesian network is learned from data and previous patterns. Having knowledge of a previous event can help the model to predict the probability of a future event. Because Bayesian Networks also include prior information, they  are resilient to gaps in information (such as missing sensors).

Eruption Forecasting at Whakaari | White Island

Since the 2019 eruption, destruction of monitoring equipment on island means that Whakaari (White Island) has reduced real-time monitoring data. Yet, eruption forecasting is still possible through the ongoing monitoring of volcanic activity (e.g. remote sensing, monthly gas plume monitoring). Using Bayesian Networks, we have developed and tested a novel method of eruption forecasting that does not solely rely on on-island data streams.

The Bayesian Network was trained on most of the Whakaari monitoring data available since 2009. Figure 2 shows the timing of past eruptions on Whakaari. Group A data (2009-2012) was the initial training set used to model the 2013 eruption, Group A & B were used to predict the 2016 eruption, and so forth. In this manner, the error margins of the network were greatly improved, and the model was found to be effective even when not all data streams are available, such as the current day situation. Results from this network showed increases in eruption likelihood prior to the 2012-2019 sequences, even when using airborne gas measurements only.


Figure 2: Past monitoring data was used to train the Whakaari Bayesian Network.

Once this new method has gone through the scientific peer-review process, it will become an important part in setting life safety parameters around the volcano. Forecasts will be updated automatically as new monitoring data becomes available and provided to geohazard response staff. This information will help GNS Science to perform it’s monitoring and advisory requirements to advise external stakeholders of increases in eruption likelihood.

Forecasts from our BN are easy to understand and interpret by volcanologists, which adds to its usefulness for decision support and expert advice. Expert judgment can also be easily integrated and potentially help to improve forecasts in the absence of data.

Plan for SPAM FAQ

Mike's Notes

Paul Graham wrote this neat article about dealing with SPAM and introduces the use of Bayesian Filtering.

Resources

References

  • Reference

Repository

  • Home > Ajabbi Research > Library >
  • Home > Handbook > 

Last Updated

18/05/2025

Article

By: Paul Graham
PaulGraham.com: 13/09/2024

"Paul Graham (/ɡræm/; born November 13, 1964) is an English-American computer scientist, writer, entrepreneur and investor. His work has included the programming language Arc, the startup Viaweb (later renamed Yahoo! Store), co-founding the startup accelerator and seed capital firm Y Combinator, his essays, and Hacker News.

He is the author of the computer programming books On Lisp, ANSI Common Lisp,and Hackers & Painters. Technology journalist Steven Levy has described Graham as a "hacker philosopher".

Graham was born in England, where he and his family have maintained a permanent residence since 2016. He is also a citizen of the United States, where he attended all of his schooling and lived for 48 years prior to returning to England." - Wikipedia

Plan for SPAM FAQ

Is this code available anywhere?

No; it's written in Arc, which is itself not released yet.

Is there a Bayesian filter for Outlook?

I know of nine so far: Spammunition, SpamBayes, Spam Bully, InboxShield, Junk-Out, Outclass, Disruptor OL, SpamTiger, and JunkChief.

Is there anything that can protect my company's server?

The best commercial server-level Bayesian filter is probably Death2Spam. SpamProbe, one of the best open-source Bayesian filters, can also be run on the server.

Most commercial server-level spam filters are still rule-based. But there are starting to be some that use Bayesian filtering. The way to find them is probably to search in Google.

The question to ask the salesman is, does the filter learn to recognize spam based on the spam and nonspam mail we receive? If it doesn't learn, it isn't Bayesian.

Does Arc/Lisp have some advantage for writing this kind of software?

Lisp's symbol type is useful in manipulating databases of words, because it lets you test for equality by just comparing pointers. (If you find yourself using checksums to identify words, it's symbols you mean to be using.) Prolog, Erlang, and Ruby also support symbols. So does Python, to a degree, though I don't think it has any syntax for them yet.

More generally, Lisp was designed for rapid prototyping, and this application involved a lot of that. I probably spent 95% of the development time typing expressions into the toplevel, trying variously tweaked algorithms on individual emails.

Do you mind if I write filters based on this algorithm?

Of course not. I don't claim to have invented anything new here. Bayesian text classification is an old and established field. If there is anything new in this article (at least, it was news to me) it is that such a simple variant of it is so effective at filtering spam.

So by all means go write spam filters. It is a very rewarding hack. If you end up creating something other people can use, let me know and I'll make a link to it.

I don't know Lisp; can you explain the algorithm to me?

It's expressed in math notation in Hackers & Painters.

Could you use Bayesian filtering to make Web content filters?

I've never tried it, but yes, I think it would work well.

Will this algorithm filter out 99.5% of my spam with no false positives?

It does filter out 99.5% of my spam. I got similar results for the one other spam collection I've tested it on so far. (I couldn't measure false positives, because I only had the spams.)

I do worry a bit that my email might just be especially easy to filter. A lot of my spam comes from "opt-in" spammers like Qves and Virtumundo, and that stuff is really easy to detect. Plus my own mail is full of references to programming that make it easy to distinguish from spam (though not "programming" itself, ironically, which often occurs in spams selling satellite dishes).

So if you do try implementing this filter for yourself, I'd appreciate it if you could let me know how well it works for you. My gut feel is that it will work pretty effectively for almost everyone, but it would be reassuring to hear numbers.

Could spammers fool Bayesian filters by filling their spams with random words?

They would have to get rid of the bad words as well as adding neutral ones. Only the most interesting fifteen words contribute to the probability, and neutral words like "onion", no matter how many there are of them, can't compete with the incriminating "viagra" for statistical significance.

To outweigh incriminating words, the spammers would need to dilute their emails with especially innocent words, i.e. those that are not merely neutral but occur disproportionately often in the user's legitimate email. But these words (e.g. the nicknames of one's friends, terms one uses in one's work) are different for each recipient, and the spammers have no way of figuring out what they are.

Once this software was available, couldn't spammers just tune their spams to get through it?

They couldn't necessarily tune their emails and still say what they wanted to say. If they wanted to send you to a url that is known to the filters, for example, they would find it hard to tune their way around that.

Second, tune using what? Each user's filters will be different, and the innocent words will vary especially. At most, spammers will be able to dilute their mails with merely neutral words, and those will not tend to be much use because they won't be among the fifteen most interesting.

If the spammers did try to get most of the incriminating words out of their messages, they would all have to use different euphemisms, because if they all started saying "adolescents" instead of "teens", then "adolescents" would start to have a high spam probability.

Finally, even if spammers worked to get all the incriminating words out of the message body, that wouldn't be enough, because in a typical spam a lot of the incriminating words are in the headers.

What if spammers sent their messages as images?

They already do sometimes, and we are able to catch them. Such emails include a lot of damning content, actually. The headers, to start with, will be as bad as ever. And remember that we scan html as well as text. Within the message body there will probably be a link as well as the image, both containing urls, which would probably score high. "Href" and "img" themselves both have spam probabilities approaching pornographic words. Within the url, the image has to have some kind of name, and these are usually far from random.

Can your program deal with the spam trick of inserting html comments in the middle of words?

Yes, I ignore html comments down at the level of scanning tokens, not even considering them as separators.

Spammers sometimes use randomly generated tags to break up tokens, since html rendering software will usually ignore meaningless tags. I do allow these to separate tokens, and it works fine. Broken bits of words simply get high spam probabilities.

Would this article itself be filtered out by your filters?

No. Someone sent it to me as a test, and it wasn't. Although the article contains a lot of spam words, it also contains a lot of even more provably innocent words (like "spammers" ironically, which occurs in a lot of my real email, and never in my spam). Since only the most interesting words count, the innocent words crowded out the spam words in the rankings, and this mail ended up with the minimum possible probability.

That makes sense, because an article someone writes is more likely to resemble the content of their own email than it would a spam, even if the article happens to be about spam.

How well can your software filter out mail that's about spam?

This is a problem for anyone who works on spam filtering. In the extreme case, if someone you've never heard from merely forwards you a spam with no additional comment, it's going to be hard to filter out. There it will all come down to the headers.

But after all, if someone could forward you spam with impunity, then spammers could forward you spam too. So for these situations we may have to have a special password that people could include in mail to get it by the filters, and also (I have one already) a special trash folder for metaspam so that it doesn't contribute to the probabilities.

If there is a good side to this, it's that if we can create filters that work acceptably well for us, they'll work even better for everyone else.

Will this software filter out good automated email like order receipts and newsgroup faqs?

Mostly not. That kind of mail may be automated, but the text usually has a very different character from spam.

The only automated responses that tend to get filtered out are the ones that contain a lot of additional advertising. In effect, these emails consist of an automated response with a spam appended to the end, so it is not surprising filters catch them.

Will the kind of people who would respond to a spam use filters?

I think so. I'm guessing here, but I suspect that people stupid enough to respond to a spam will often get email through one of the free services like Yahoo Mail or Hotmail, or through big ISPs like AOL or Earthlink. Once word spreads that it is possible to filter out most spam, they'll be forced to offer effective filters.

If filters catch most spam, won't spammers just send more to compensate?

Spammers already operate at capacity.

How do you feel about blacklists?

As ISPs use them now, they're equivalent to very bad filters. But the information they supply could be incorporated into Bayesian filtering.

Doesn't Bayes' Rule assume the predictors are independent?

Yes, strictly speaking it is only valid assuming the probabilitiy of e.g. "sex" occurring in an email is unrelated to the probability of "sexy" occurring in it. Obviously that is not the case.

On the other hand, there is a long tradition of violating this requirement. When you do that it's called a "naive Bayesian" algorithm and in practice it works pretty well, just as in practice (if you stay away from the edges of precision) it works pretty well to treat floating point numbers as if they were reals.

Does this algorithm consider the prior probability of a mail being a spam?

No. It assumes it's equally likely for a mail to be a spam or not. So accuracy could be slightly improved by taking into account the actual proportion of spam received by each user. You would have to do this by hour though, because the proportion varies so much depending on the time of the day that the overall prior probability is useless as a predictor.

Why do you consider 15 words? What's special about 15?

Actually, in the latest version of the filter I use 20, because marking tokens by context means the software now sees more distinct tokens per mail.

Nearly all spams tend to have that many fairly incriminating words in them. If you look at more than that, you'll start to include neutral words, which are noise at best. But you want to look at as many words as you can, because legitimate emails may well contain two or three words with high spam probabilities-- if you used only the top 5 words, for example, you'd start to get false positives.

Will this work for languages other than English?

As long as they use whitespace to separate tokens, it should.