## 2 Materials and Methods
### Building the Database
#### 2.4.2 Modeling the Bayesian Network  
To model the diagnostic process, we constructed a Bayesian network that captures the relationships between symptoms and conditions. This network is designed to refine the diagnosis obtained from the language model by validating or refuting the identified symptoms. The network comprises two types of nodes: symptom nodes \(S\) and disease nodes \(D\). The symptom nodes represent the presence or absence of a symptom, while the disease nodes represent the presence or absence of a disease. The edges between the nodes denote the conditional dependencies between symptoms and, in each edge, a Conditional Probability Table (CPT) is defined.  
Our network is based on the Quick Medical Reference (QMR) [66; 67] network, which is a Bayesian network specifically designed for medical diagnosis. It represents diseases' and symptoms' relationships by using a two-layer structure: the top layer consists of disease nodes and the lower layer consists of finding nodes (symptoms or exam results), with arcs from diseases to findings. The graph representation of the network is shown in Figure 3.  
The probability distribution represented by the QMR network is typically a joint probability distribution over all diseases and symptoms.  
\[P(S,D)=P(S|D)P(D)=\left[\prod_{i=1}^{n}P(s_{i}|d)\right]\left[\prod_{j=1}^{m}P( d_{j})\right] \tag{1}\]  
where \(D=\{d_{1},d_{2},\ldots,d_{m}\}\) and \(S=\{d_{1},d_{2},\ldots,d_{n}\}\) variables are binary and model the presence or absence of certain a symptom or disease.  
Consider a symptom \(s\) that can arise from m conditions \(\{d_{1},\ldots,d_{m}\}\). To establish this conditional probability distribution, \(2^{m}\) parameters are required. This introduces a  
Figure 3: A diagram for a QMR network of symptoms and diseases.  
significant challenge that complicates the task of experts to define probabilities, since an expert would need to consider every potential combination of the activation of parent variables for each symptom.  
A more intuitive approach for experts is to determine the sensitivity and specificity values for each symptom and condition. For a given condition \(d_{j}\) and a symptom \(s_{i}\), sensitivity is the probability that the symptom appears when the condition \(d_{j}\) is present:  
\[Se_{ij}:=P(s_{i}=1|d_{j}=1) \tag{2}\]  
In contrast, specificity is the probability that symptom \(d_{i}\) does not manifest when the condition \(d_{j}\) is absent:  
\[Sp_{ij}:=P(s_{i}=0|d_{j}=0) \tag{3}\]  
To model these probabilities, [PERSON] (1972) introduced the Noisy-OR model. This model presupposes that each condition can independently cause the symptom \(s\), and the probability of the symptom being _on_ is the cumulative effect of these independent probabilities. Mathematically, it is assumed that there are \(m\) relationships between the parent conditions \(\{d_{i},\dots,d_{m}\}\) and the symptom \(s\), merged in an OR gate. To add stochasticity to the model, each link between a parent and the symptom may fail with a probability of \(1-p_{i}\). Under these assumptions, the probability of the symptom being \"on\" is given by  
\[P(s_{i}=1|d)=1-\prod_{j=1}^{m}(1-p_{ij}) \tag{4}\]  
Here, \(p_{ij}\) represents the likelihood that the condition \(d_{j}\), if present, could independently activate the symptom \(s_{i}\).  
The network is then constructed by defining the relationships between symptoms and conditions using the Noisy-OR model. The network structure is shown in Figure 4.  
In the following section, we describe how we combine the predictions from the language model with the Bayesian network to refine the diagnosis.