## Appendix B Synthetic Sample Generation for Instability Detection Model Training  
Given a sequence of volatility values and returns, we discretize according to some rule that allows us to differentiate between unusually high volatility values and unusually low return values. As we indicated in Section 3.2, we make the discretized volatility value \(v_{i}^{v}=1\) if the volatility value is above the 80 th percentile of volatility. Similarly, the discretized returns value \(v_{i}^{r}=0\) if the return value is below the 20 th percentile of returns. We have also seen that the magnetization just after the critical moment is close to 1 for volatility and 0 in return, indicating a highly volatile system state and negative index variations. Based on this observation, we can simulate an independent chain of binary values for volatility and returns before and after the critical moment for a desired number of days. To avoid misunderstandings regarding the decision to binarize volatility and return sequences using percentile thresholds (80 th for volatility and 20 th for returns), we wish to clarify that this transformation is not intended to model raw financial dynamics in their continuous or autocorrelated form. Instead, it is a deliberate abstraction to identify extreme configurations indicative of instability. The choice of the 80 th and 20 th percentiles is rooted in two empirical observations: (a) extreme volatility and extreme negative returns frequently co-occur in proximity to financial stress events, and (b) the behavior of the magnetization metric, which we use as a proxy for the collective behavior of agents, exhibits a strong signal when these thresholds are crossed--aligning well with observed post-critical dynamics. This binary encoding is applied as a preprocessing step to feed our model sequences that are more interpretable in the context of phase transitions. It does not aim to fully preserve stylized facts such as volatility clustering or return autocorrelation, which are more relevant in modeling the pathwise dynamics of financial markets. Our complementary bubble detector explicitly addresses these dynamics, which analyzes long-run structures and retains temporal correlations. However, exploring adaptive thresholds or soft binarization schemes (e.g., probabilistic mappings) may be interesting, particularly in datasets exhibiting regime shifts or non-stationarities. For the present study, however, the percentile thresholds serve as an effective and interpretable tool for training the instability detector in a robust and focused manner. To obtain binary values, we simulate values obtained from an \(m\)-day Binomial distribution, independent of each other, with the probability of the value being equal to 1 with probability \(p\). This is carried out separately for \(m\) trials before the critical time and for \(m\) trials after the critical time, which is equivalent to obtaining non-unstable and unstable samples, respectively. To simulate unstable samples, the value of \(p\) equals the probability of obtaining a high volatility (1) and a probability \(p\) of obtaining a very low return (0). To simulate non-stable samples, the opposite is true, i.e., \(1-p\) probability of obtaining a high volatility (1), and \(1-p\) for a very low return (0). In this way, we can simulate binary sequence strips representing unstable and non-stable samples, which will be the inputs to the BBRBM. The value of \(p\) is obtained empirically by testing different values for both volatilities and returns. We realized that at the same value of \(p=0.67\) for volatility and returns, we obtain magnetization diagrams that well reflect the empirical diagrams and the desired behavior. By increasing the value of \(p\), we obtain unrealistic diagrams because we observe sequences of binary values only at 1 or 0. In contrast, if we decrease the value of \(p\), the opposite happens, and we destroy the desired behavior (remember that in areas of instability, volatility is extreme, and returns are very low).