A Medical Multimodal Large Language Model for Pediatric Pneumonia
Weiwei Tian Xinyu Huang Tianhao Cheng Wen He Jinwu Fang Rui Feng Daoying Geng Xiaobo Zhang








A Medical Multimodal Large Language Model for Pediatric Pneumonia
    Weiwei Tian, Xinyu Huang, Tianhao Cheng, Wen He, Jinwu Fang, Rui Feng, Daoying Geng, Xiaobo Zhang


Manuscript received September 4, 2024. This work was supported in part by the National Natural Science Foundation of China (No.62172101), and in part by the Science and Technology Commission of Shanghai Municipality (No.22511106003, No.23511100602) and Municipal Hospital Frontier Joint Research Project (No.SHDC12024136), which studies on Evaluation Indicator Construction and Clinical Application Management for Diagnostic and Treatment Assistant Large-scale Model for Pediatric Severe Pneumonia. (Xinyu Huang and Tianhao Cheng contributed equally. Corresponding author: Xiaobo Zhang.)
Weiwei Tian, Rui Feng, and Daoying Geng are with the Academy for Engineering and Technology, Fudan University, No. 220 Handan Road, Shanghai 200433, China (e-mail: {wwtian20, fengrui}@fudan.edu.cn, gengdy@163.com).
Xinyu Huang, Tianhao Cheng, and Rui Feng are with the School of Computer Science, Shanghai Key Laboratory of Intelligent Information Processing, Fudan University, No. 2005 Songhu Road, Shanghai 200438, China (e-mail: xinyuhuang20@fudan.edu.cn, thcheng23@m.fudan.edu.cn).
Wen He, Rui Feng, and Xiaobo Zhang are with the Department of Respiratory Medicine, Children’s Hospital of Fudan University, No. 399 Wanyuan Road, Shanghai 201102, China (e-mail: hewen@fudan.edu.cn, zhangxiaobo0307@163.com).
Jinwu Fang is with the School of Public Health, Fudan University, No. 130 Dongan Road, Shanghai 200032, China (e-mail: fangjinwu007@126.com).
Daoying Geng is also with the Department of Radiology, Huashan Hospital, Fudan University, No. 12 Wulumuqi Rd. Middle, Shanghai 200040, China.

    September 9, 2024
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================



§ ABSTRACT 
Pediatric pneumonia is the leading cause of death among children under five years worldwide, imposing a substantial burden on affected families. Currently, there are three significant hurdles in diagnosing and treating pediatric pneumonia. Firstly, pediatric pneumonia shares similar symptoms with other respiratory diseases, making rapid and accurate differential diagnosis challenging. Secondly, primary hospitals often lack sufficient medical resources and experienced doctors. Lastly, providing personalized diagnostic reports and treatment recommendations is labor-intensive and time-consuming. To tackle these challenges, we proposed a Medical Multimodal Large Language Model for Pediatric Pneumonia (P2Med-MLLM). This was the first foundation model tailored for patients primarily diagnosed with pediatric pneumonia, capable of handling diverse clinical tasks—such as generating free-text radiology reports and medical records—within a unified framework. Specifically, P2Med-MLLM can process both pure text and image-text data, trained on an extensive and large-scale dataset (P2Med-MD), including real clinical information from 163,999 outpatient and 8,684 inpatient cases. This dataset comprised 2D chest X-ray images, 3D chest Computed Tomography (CT) images, corresponding radiology reports, and outpatient and inpatient records. P2Med-MLLM combined a Large Language Model (LLM) with a vision encoder, fine-tuning them together to handle multiple temporally sequenced and interleaved 2D or 3D images with corresponding radiology reports using a perceiver module. We designed a three-stage training strategy to enable P2Med-MLLM to comprehend medical knowledge and follow instructions for various clinical tasks. To rigorously evaluate P2Med-MLLM’s performance, we developed P2Med-MBench, a benchmark consisting of 642 meticulously verified samples by pediatric pulmonology specialists, covering six clinical decision-support tasks and a balanced variety of diseases. The automated scoring results demonstrated the superiority of P2Med-MLLM. This work plays a crucial role in assisting primary care doctors with prompt disease diagnosis and treatment planning, alleviating patient disease burden, reducing severe symptom mortality rates, and optimizing the allocation of medical resources.



§ INTRODUCTION




In 2021 alone, more than 0.5 million children under the age of five died from Lower Respiratory Infections (LRI) worldwide, accounting for 12% of total deaths <cit.>. Among LRI, pediatric pneumonia, especially when accompanied by severe symptoms and complications, has the highest morbidity and mortality, particularly in developing countries <cit.>. Pediatric pneumonia, bronchitis, and asthma share similar symptoms like coughing and wheezing, making prompt diagnosis upon admission very challenging <cit.>. Limited healthcare resources and a lack of experienced doctors in primary hospitals exacerbate this situation, leading to misdiagnoses and inappropriate treatments.

To meet the growing demands of precision medicine, deep learning-based technologies have emerged for identifying pediatric respiratory diseases <cit.>, early triage <cit.>, and predicting clinical outcomes <cit.>. Despite achieving or nearing human expert levels, these models primarily treated clinical tasks as simple classification or regression problems, falling short of providing detailed and reliable diagnostic bases and treatment recommendations.

Recently, Multimodal Large Language Models (MLLMs) have experienced exponential growth in general domains <cit.>, but they were still not fully capable of effectively supporting real-world clinical applications <cit.>. The essential reason was that, to protect patient privacy, these models were mainly trained on medical textbooks and literature from the internet, without exposure to real and comprehensive medical data. Aligning with human doctors has significantly improved MLLMs' performance across various specialties (e.g., radiology, pathology, ophthalmology, and dermatology) and tasks (e.g., disease diagnosis, medical image generation, medical image caption, medical report generation, medical report summarization, rationale diagnosis, survival prediction, medical image-text retrieval, medical report quality assessment, medical question answering, and medical visual question answering) <cit.> in the healthcare field. Inspired by the aforementioned work, we aim to explore the feasibility of MLLMs using real clinical data on pediatric pneumonia. Given the complexity of pediatric pneumonia, we mainly face challenges from three aspects:



  * Lack of a large-scale and high-quality multimodal dataset for training: Due to the rapid physical development of children, their medical imaging, laboratory tests, and demographic data significantly differ from those of adults. Currently, there is a shortage of a large-scale pediatric pneumonia dataset that reflects real clinical scenarios. Moreover, real-world data tend to be noisy and have a long-tailed distribution, which can severely impact model training effectiveness.


  * Lack of a unified and compatible model architecture: Addressing the diverse clinical needs in the full process of diagnosing and treating pediatric pneumonia requires a model architecture that can efficiently handle different modalities, sequences, and time-series data inputs, and produce outputs for various tasks in a unified manner. Currently, such a compatible model structure is lacking.


  * Lack of a comprehensive and objective evaluation benchmark: A comprehensive and objective benchmark is crucial for supervising model training and assessing performance. There is a lack of a high-quality evaluation benchmark that covers a wide range of clinical tasks and disease categories.



To address the obstacles of applying MLLMs to pediatric pneumonia, we developed a Medical Multimodal Large Language Model tailored for Pediatric Pneumonia (P2Med-MLLM, Fig. <ref>), which was trained and deployed on a local server within the hospital environment to ensure data security and privacy.

To effectively train P2Med-MLLM, we constructed the first large-scale Chinese Medical Multimodal Dataset for Pediatric Pneumonia (P2Med-MD), covering real clinical information from 163,999 outpatients and 8,684 inpatients. Specifically, we collected comprehensive medical data for patients with a primary diagnosis of pediatric pneumonia, including 2D chest X-ray and 3D chest Computed Tomography (CT) images, corresponding radiology reports, outpatient records, and three-level inpatient records reflecting disease progression <cit.> (Fig. <ref>). During the three training stages, we ensured data quality by deduplication, task type-based balanced sampling, and disease category-based balanced sampling (Fig. <ref>).

As for the architecture of P2Med-MLLM, it consisted of three core components: a Large Language Model (LLM, Chinese-LLaMA-2 <cit.>), a CLIP-pretrained vision encoder <cit.>, and a perceiver module <cit.>. This design enabled P2Med-MLLM to retain its original capabilities in understanding and generating pure text (outpatient and inpatient records), while also allowing it to interleave multiple 2D chest X-rays or 3D chest CT images with corresponding radiology reports. This facilitated comparative analysis of a patient's radiological examinations over different time points, aligning more closely with clinical practice.

For evaluation, we initialized a Medical Multimodal Benchmark for Pediatric Pneumonia, termed P2Med-MBench. This benchmark covered various disease categories and valuable clinical tasks, including radiology report generation (X-ray), radiology report generation (CT), outpatient medical record generation, first disease course record generation, attending physician's first ward round record generation, and chief physician's first ward round record generation (Fig. <ref>). All real-world data have been meticulously verified by professional pediatric pulmonology specialists to ensure quality and representativeness. Automatic scoring of results generated by P2Med-MLLM and other open-source LLMs on P2Med-MBench, along with a series of ablation studies, demonstrated the superiority of our approach.

Overall, the main contributions of our work are summarized as follows:



  * Construct a large-scale and high-quality multimodal dataset (P2Med-MD): Based on real clinical scenarios, we developed the first Chinese medical multimodal dataset for patients with a primary diagnosis of pediatric pneumonia. This dataset covered various diseases and clinical tasks. 


  * Propose a unified and compatible multimodal model architecture (P2Med-MLLM): For different clinical tasks, we introduced the first model capable of handling both pure text data (outpatient and inpatient records) and temporally sequenced, interleaved image-text pairs (2D X-rays and 3D CT images, along with corresponding radiology reports).


  * Establish a comprehensive and objective multimodal evaluation benchmark (P2Med-MBench): To supervise the training process and objectively evaluate different models, we meticulously designed a multimodal benchmark with balanced distributions of diseases and clinical tasks. Extensive quantitative and qualitative experimental results demonstrated the effectiveness of our approach.




§ RESULTS


In this section, we conducted experiments on various tasks, including radiology report generation (X-ray), radiology report generation (Computed Tomography, CT), outpatient medical record generation, first disease course record generation, attending physician's first ward round record generation, and chief physician's first ward round record generation. We began by describing the evaluation metrics used for the experiments. Then, we presented the quantitative and qualitative results of our framework on the Medical Multimodal Benchmark for Pediatric Pneumonia (P2Med-MBench).



 §.§ Evaluation Metrics


To evaluate the professional performance of various Medical Multimodal Large Language Model variants for Pediatric Pneumonia (P2Med-MLLM) and baseline models, we utilized 13B Chinese-LLaMA-2 <cit.> with a one-shot in-context example to automatically score the generated open-ended responses and provide reasons for the given scores. Our pediatric pulmonology specialists meticulously curated a set of examples across tasks and evaluation components based on their clinical expertise. For the most critical evaluation components in a range of tasks, such as impression or diagnosis results, we employed accuracy and comprehensiveness metrics. For other evaluation components, we used accuracy alone. We assessed the quality of the generated answers using a 5-point scale, as depicted in Fig. <ref>. The original Chinese version can be found in Fig. <ref>. The 95% confidence interval for each metric was calculated using the t-distribution.









 §.§ Radiology Report Generation (X-ray)

As shown in Table <ref>, Large Language Models (LLMs) such as Baichuan 2 <cit.> and Chinese-LLaMA-2 <cit.> can only process pure texts. In clinical practice, X-ray images were crucial for screening and diagnosing pediatric pneumonia. By incorporating a perceiver with an LLM, P2Med-MLLM can handle sequential 2D X-ray images and generate corresponding radiology reports. Fig. <ref> demonstrated that P2Med-MLLM was capable of processing X-ray images taken at different times from the same patient in two conversation turns. The model generated different impressions: “bronchopneumonia" (October 29, 2022) and “bronchopneumonia resolved" (November 11, 2022), effectively reflecting the patient's disease progression. The original Chinese results were detailed in Fig. <ref>.



 §.§ Radiology Report Generation (CT)

In addition to 2D X-ray images, P2Med-MLLM can also generate radiology reports for 3D CT images. As shown in Fig. <ref> and Fig. <ref>, the model successfully identified critical radiological features in the images and recognized underlying diseases.



 §.§ Outpatient Medical Record Generation

Generating outpatient medical records was a challenging and open-ended task that required comprehensive analysis of the outpatient's chief complaint, history of present illness, and physical examination. As indicated in Table <ref>, the 8B P2Med-MLLM demonstrated significant improvements compared to other LLMs (such as the 7B or 13B Baichuan 2 or Chinese-LLaMA-2). For example, P2Med-MLLM increased the accuracy of preliminary diagnosis from 2.96 to 3.37 and improved the comprehensiveness from 3.26 to 4.17. These results indicated that P2Med-MLLM can generate radiology reports without compromising the language model's capabilities. Fig. <ref> and Fig. <ref> showed that P2Med-MLLM can make accurate diagnoses in free-text format and provide highly relevant treatment recommendations and plans, despite missing information “follow-up appointments as necessary".



 §.§ First Disease Course Record Generation

Generating resident physician's first disease course records for inpatients was more challenging because it required comprehensive analysis of various information, including the history of present illness, physical examination, auxiliary examinations, and clinical history features. As depicted in Table <ref>, compared to the suboptimal models, the 7B or 13B Baichuan 2, P2Med-MLLM showed an improvement in the accuracy and comprehensiveness of admission diagnosis by 0.25 and 0.35, respectively. Qualitatively, as shown in Fig. <ref> and Fig. <ref>, P2Med-MLLM can understand the provided patient information and questions, generating a relatively accurate diagnostic basis, admission diagnosis, and diagnostic and treatment plan in a standardized format. However, some details still needed improvement. For instance, the chest X-ray on October 1, 2023, showed “bronchitis", while the chest X-ray on October 8, 2023, showed “minor inflammation in both lungs and right upper and lower pulmonary emphysema". The most recent examination results should be prioritized. Additionally, there were some errors in the nursing level recommendations and medication guidelines that needed to be addressed.



 §.§ Attending Physician's First Ward Round Record Generation

Generating attending physician's first ward round records for inpatients was also a crucial and meaningful task for generative medical foundation models. This task involved using input clinical history features and additional clinical history and signs to produce the patient's diagnostic basis, current diagnosis, and diagnostic and treatment plan. In Table <ref>, the 8B P2Med-MLLM outperformed the 13B Baichuan 2 by 0.07 in accuracy and 0.12 in comprehensiveness for the current diagnosis, highlighting the advantages of our model. Fig. <ref> and Fig. <ref> demonstrated the effectiveness of P2Med-MLLM in generating the three components for this task. However, the generated record still had some shortcomings, such as omitting critical information like abnormal findings in the “physical examination" section of the diagnostic basis and the “neonatal nutritional risk assessment" in the diagnostic and treatment plan.



 §.§ Chief Physician's First Ward Round Record Generation

The task of generating chief physician's first ward round records for inpatients was similar to that of generating attending physician's first ward round records. As shown in Table <ref>, although the 8B P2Med-MLLM maintained advantages in most tasks, components, and metrics, it fell behind the 13B Baichuan 2 by 0.08 in accuracy for the current diagnosis in this specific task. This was remarkable especially considering that, for the baseline LLMs, namely Baichuan 2 and Chinese-LLaMA-2, the 13B models significantly outperformed the 7B models. It not only demonstrated that more model parameters can lead to further performance improvements, but also indicated the potential of LLMs that can be further simulated by scaling up the models. Due to computational resource constraints, we opted for the largest model size of 8B to balance performance. Fig. <ref> and Fig. <ref> showed that our model provided correct answers in most components, except for the incorrect addition of “congenital" in the diagnosis of hemangioma and the omission of the “nasal cannula oxygen" keyword in the components of the diagnostic basis and diagnostic and treatment plan.



§ DISCUSSION




 §.§ Impact of Different Stages and Modalities in P2Med-MLLM







To investigate the impact of different stages and modalities, we provided a thorough ablation study of the Medical Multimodal Large Language Model for Pediatric Pneumonia (P2Med-MLLM) by removing single stage or modality. The results were shown in Table <ref> and Fig. <ref>. 

First, we investigated the impact of different training stages on the most critical evaluation components of each task, specifically impression or diagnosis results (columns Full and A-C in Table <ref>). We found that each stage contributed to performance improvement, demonstrating the significance of medical knowledge infusion pre-training, task type-based balanced instruction tuning, and disease category-based balanced instruction tuning in multi-task clinical decision supports. Specifically, the importance of the three stages, in descending order, were: stage 1, stage 2, and stage 3, respectively.

In addition to the three-stage training strategy, we also evaluated the impact of different modalities, that is, plain text and image-text data. By comparing column Full with columns D and E in Table <ref>, respectively, we observed that removing either modality adversely affected the performance of the other (at least 0.6 on average). These results suggested that tasks involving both modalities were mutually beneficial to some extent. Notably, image-text tasks had a more significant influence on plain text tasks.

Next, as shown in Fig. <ref>, we explored the performance of P2Med-MLLM across different stages and modalities for all evaluation components of each task. Compared to incomplete stages and modalities, P2Med-MLLM demonstrated significant advantages. Specifically, P2Med-MLLM outperformed others in 4 out of the 6 most crucial evaluation components and in 9 out of 16 evaluation components overall. These observations suggested that while P2Med-MLLM achieved the best results, some evaluation components, such as diagnostic basis and treatment plan, still showed room for improvement. We believed the reason behind this was that the ground truth for these open-ended evaluation components was inherently diverse, making automatic scoring with language models more challenging. Therefore, we focused primarily on the most crucial and standardized evaluation components of each task.



 §.§ Impact of Different Tasks in P2Med-MLLM

Traditional methods typically involved training a network on a subset for a specific medical task. While intuitive, such a training strategy significantly increased computational complexity. To demonstrate the effectiveness of P2Med-MLLM trained jointly on multiple tasks, we compared it with multiple single-task dedicated networks on the most crucial evaluation components using accuracy and comprehensiveness metrics. As shown in Fig. <ref>, joint training by P2Med-MLLM yielded substantial performance improvements, particularly in tasks such as radiology report generation (Computed Tomography, CT), outpatient medical record generation, and chief physician’s first ward round record generation. We utilized a generative network to unify all tasks, and this flexible structure ensured performance while easily extending to new tasks. It was valuable in the real world for assisting clinicians in completing multiple tasks.





 §.§ Impact of Different Conversation Forms in P2Med-MLLM

We found that during a single outpatient or inpatient visit for each patient, there may be multiple scans for the same imaging modality, reflecting changes in the patient's condition. Thus, for the radiology report generation task, we constructed a multi-round conversation using all scans of the same imaging modality from a single visit, arranged in chronological order. Using X-ray scans as an example, we compared the performance of models with and without multi-round conversations. As shown in Table <ref>, “w/o MRC" indicated treating each scan as an independent single-round conversation. Although P2Med-MLLM and “w/o MRC" achieved comparable results in the evaluation component of findings, adopting multi-round conversations showed a notable advantage in the most crucial evaluation component of impression, exceeding in both accuracy and comprehensiveness metrics by at least 0.37. This demonstrated that the temporal information was critical to perform radiological diagnosis.






 §.§ Impact of Different Large Language Models in P2Med-MLLM

In this subsection, we explored different Large Language Models (LLMs) in P2Med-MLLM using the Medical Multimodal Benchmark for Pediatric Pneumonia (P2Med-MBench). Specifically, we compared models based on Baichuan 2 <cit.> and Chinese-LLAMA-2 <cit.>. The results in Table <ref> showed that the Chinese-LLAMA-2-based model significantly outperformed Baichuan 2-based model on average and most tasks, except for the outpatient medical record generation task. Therefore, we chose Chinese-LLAMA-2 as the Large Language Model (LLM) for P2Med-MLLM.




§ OUTLOOK


Multimodal Large Language Models (MLLMs) have brought substantial advancements in the healthcare field. In this study, we preliminarily explored and demonstrated the feasibility of securely and effectively training and deploying a MLLM on private hospital data, specifically focusing on real clinical scenarios involving patients with a primary diagnosis of pediatric pneumonia. Our work encompassed the entire process, from data collection and cleaning to model construction and evaluation, offering a valuable reference for researchers in the interdiscipline of artificial intelligence for medicine. We built the largest Chinese Medical Multimodal Dataset for Pediatric Pneumonia (P2Med-MD) so far. Different from previous efforts, the Medical Multimodal Large Language Model for Pediatric Pneumonia (P2Med-MLLM) employed a unified framework that supported both pure text data (outpatient and inpatient records) and temporally sequenced, interleaved 2D or 3D medical images alongside radiology reports, aligning more closely with clinical practice. P2Med-MLLM could potentially serve as a clinical assistant, helping doctors enhance diagnostic and treatment efficiency, providing personalized recommendations for pediatric pneumonia patients, and optimizing clinical workflows.

Despite the progress achieved in our research, there are several limitations. Firstly, for complicated and open-ended clinical tasks, such as generating diagnostic bases and treatment plans in medical records, the performance of P2Med-MLLM still falls short of real clinical applications. Additionally, the automatic scoring system lacks robustness, highlighting the need for more objective evaluation metrics. Secondly, this study only includes patients primarily diagnosed with pediatric pneumonia. Future work could extend the objects to cover all respiratory diseases, or even the entire spectrum of general medicine across all age groups. Thirdly, the study is limited to a single-center cohort, and data collection from multiple healthcare institutions and countries would enhance diversity and generalizability. Lastly, as this is a retrospective study, future research could explore prospective studies.


§ METHODS


In this section, we provided a detailed description of our self-built dataset, the medical multimodal Large Language Model (LLM), and the implementation details.



 §.§ Medical Multimodal Dataset for Pediatric Pneumonia (P2Med-MD)

Currently, the medical domain faces a significant shortfall in multimodal datasets that accurately reflect real-world clinical scenarios, a crucial element for training a practical medical multimodal LLM. To bridge this gap, we constructed a high-quality, large-scale Chinese Medical Multimodal Dataset for Pediatric Pneumonia (P2Med-MD), through human-machine interaction. P2Med-MD focused on pediatric patients with a primary diagnosis of pneumonia. Here, we started by providing an overview of P2Med-MD in Sec <ref>. It consisted of three sets, medical knowledge infusion, task type-based balanced sampling, and disease category-based balanced sampling, corresponding to Sec <ref>,  <ref>, and  <ref>, respectively. These parts were utilized for different training stages described in Sec  <ref>. In Sec <ref>, we introduced a new Medical Multimodal Benchmark for Pediatric Pneumonia, termed P2Med-MBench, which encompasses six tasks, e.g., radiology report generation (X-ray), radiology report generation (Computed Tomography, CT), outpatient medical record generation, first disease course record generation, attending physician's first ward round record generation, and chief physician's first ward round record generation. These tasks were designed to monitor the development of the medical multimodal LLM.



  §.§.§ Overview


The study was approved by the Ethics Committee of Children’s Hospital, Fudan University (2022-307A, approved November 22, 2022). For participants admitted before November 22, 2022, informed consent was waived; for those admitted on or after November 22, 2022, informed consent was obtained. In this retrospective study, we collected the outpatient information of 163,999 patients and the inpatient information of 8,684 patients who were admitted to Children’s Hospital of Fudan University between August 26, 2016 to November 1, 2023. Outpatient information included outpatient medical records, and chest X-ray and CT scans along with corresponding radiology reports. Inpatient information comprised three-level round records formed by first disease course records, attending physician's first ward round records, and chief physician's first ward round records, as well as chest X-ray and CT scans with corresponding radiology reports. The built dataset altogether contained 67,616 chest X-ray examinations and 2,321 chest CT examinations along with their respective radiology reports, 684,758 outpatient medical records, 9,180 first disease course records, 9,993 attending physician's first ward round records, and 6,426 chief physician's first ward round records. More details were given in Table <ref>. Fig. <ref> illustrated the distribution of gender, age, and image modalities in P2Med-MD.









  §.§.§ Stage 1: Medical Knowledge Infusion Data

Considering the complexity of inpatient records, stage 1 injected medical knowledge into the general model by learning from all radiology image-report pairs (including X-ray and CT) and simple outpatient medical records. Fig. <ref> depicted the disease categories derived from the impression in X-ray radiology reports, with each category comprising over 100 samples during stage 1. Fig. <ref> displayed the disease categories extracted from the impression in CT radiology reports, each with more than 10 samples. And Fig. <ref> outlined the disease categories identified from the preliminary diagnosis in outpatient medical records, each encompassing over 400 samples.

However, we observed a significant amount of repetitive descriptions within the outpatient records. Prior researches <cit.> have demonstrated that repetition in training data can degrade model performance. Thus, it was crucial to perform deduplication to ensure the quality of outpatient records. The data deduplication scheme employed in previous studies <cit.> typically relied on non-whitespace exact text matching, which was suboptimal due to the diverse writing styles of different doctors. <cit.> indicated that near-deduplication could enhance performance. We followed this pipeline that largely inherited the settings from CodeParrot <cit.>. It involved calculating MinHashes <cit.> of all outpatient records and applying Locally Sensitive Hashing (LSH) to cluster records based on their MinHash fingerprints. During the LSH phase, similar outpatient records were grouped into the same buckets, thereby identifying them as duplicates. From each group of duplicates, only one record was retained. Fig. <ref> illustrated the disease distribution post-deduplication of these outpatient medical records. 



  §.§.§ Stage 2: Task Type-Based Balanced Sampling Data

To ensure the model effectively followed diverse task instructions, we curated a variety of instruction-following data covering six distinct tasks in stage 2. Given the two orders of magnitude difference in sample volumes between outpatient and inpatient medical records, it was essential to balance the number of outpatient and inpatient records, as the generative model was sensitive to data imbalances. By looping through disease categories with sample sizes between 325 and 5,000 in outpatient records of stage 1, a maximum of 500 samples per category were sampled without repetition until the total sample size was balanced with that of inpatient records. Due to the multi-label nature of the preliminary diagnosis in outpatient records, the sampled data included a broader range of disease categories. Fig. <ref>, <ref>, <ref>, <ref>, <ref>, and <ref> depicted the distribution of disease categories for six tasks during stage 2. Specifically, Fig. <ref>, <ref>, and <ref> illustrated the disease categories extracted from the admission diagnosis or current diagnosis in three-level inpatient medical records, each category featuring over 40 samples.



  §.§.§ Stage 3: Disease Category-Based Balanced Sampling Data

We observed considerable differences in the distribution of disease categories per task in stage 2, potentially impairing the performance of the generative model. To mitigate the long-tail problem, it was essential to perform balanced sampling of disease categories in stage 3. For X-ray image-report pairs, we sampled up to 500 samples per category from those with sample sizes ranging from 100 to 2,000. All CT image-report pairs were included due to the relatively smaller sample size. For outpatient medical records, we sampled up to 200 samples per category from those identified in stage 1 with sample sizes between 325 and 5,000. For three-level inpatient medical records, we included all samples from disease categories containing 40 to 500 samples. Fig. <ref>, <ref>, <ref>, <ref>, <ref>, and <ref> illustrated the distribution of disease categories for six tasks in stage 3, which were more balanced compared to stage 2.



  §.§.§ Medical Multimodal Benchmark for Pediatric Pneumonia (P2Med-MBench)


Building upon P2Med-MD, we presented P2Med-MBench, a comprehensive evaluation benchmark for pediatric pneumonia. P2Med-MBench contained six distinct tasks, including radiology report generation (X-ray), radiology report generation (CT), outpatient medical record generation, first disease course record generation, attending physician's first ward round record generation, and chief physician's first ward round record generation. A detailed breakdown of each task, including task description, clinical scenario, modality, image dimension, model input, and model output <cit.>, was shown in Table <ref>.



It was noteworthy that the P2Med-MD was collected over a continuous period. It was diverse and complex, potentially even containing some data with noise. To guarantee the data quality and representativeness for evaluation, two pediatric pulmonology specialists performed meticulous manual verification of the P2Med-MBench samples. Ultimately, we obtained 121 samples for radiology report generation (X-ray), 121 samples for radiology report generation (CT), 100 samples for outpatient medical record generation, 100 samples for first disease course record generation, 100 samples for attending physician's first ward round record generation, and 100 samples for chief physician's first ward round record generation. These samples were dismissed in the whole training set. Detailed descriptions of the six evaluation tasks were provided in the following.

Radiology report generation (X-ray).
This task primarily focused on the automatic generation of radiology reports for X-ray images, encompassing two key sections: findings and impression. The former provided a detailed description of crucial aspects observed in the 2D X-ray images, while the latter summarized the most relevant findings. Given that an outpatient or inpatient might have one or more X-ray images taken from various views and different times, we incorporated time, modality, and corresponding multi-view images in the input to facilitate correlation and comparison with prior radiological data of the same patient, thereby enabling the generation of more objective and comprehensive radiology reports. For a given set of X-ray images, we employed prompt sentences similar to the following as input: “Current radiological data is as follows: \n [Examination time] December 31, 2022 \n [Examination modality] X-ray \n [Image] image...image \n Based on the above information, combined with professional radiological knowledge, generate a report in the format: \n [Findings] {Your findings based on the images} \n [Impression] {Your impression based on the images} \n". The number of image tokens corresponded to the number of views, with one for the anteroposterior view and two for the anteroposterior and lateral views. The impression, as the most critical component, was assessed using two metrics: accuracy and comprehensiveness, while the findings were evaluated solely on accuracy. To ensure the reliability of our evaluation, we have selected 100 sets of X-ray image-report pairs at unique time points and 10 sets at multiple times from the same patient, altogether comprising 121 samples and covering more than 47 distinct diseases.

Radiology report generation (CT).
This task was similar to the radiology report generation (X-ray) task but was specifically designed for 3D CT images, thereby the examination modality was CT. The number of image tokens denoted the number of series, with one representing a non-contrast series, and two indicating both non-contrast and contrast-enhanced series. The final selection of 121 samples encompassed more than eight types of diseases.

Outpatient medical record generation.
This task imitated the clinical process of a physician's outpatient visit, utilizing textual information such as the chief complaint, history of present illness, and physical examination to formulate a preliminary diagnosis, a treatment recommendation for the patient, and a treatment plan for the doctor. Here, we simulated this task as a prompt-based generative dialogue task. For example, we used the following as input: “Current outpatient pediatric information is as follows: \n [Chief complaint] The pediatric patient presented with cough and fever for 4 days ... \n [History of present illness] Maximum temperature of 40^∘C ... \n [Physical examination] The pediatric patient is conscious and responsive ... \n Based on the above information, combined with professional medical knowledge, make a diagnosis in the format: \n [Preliminary diagnosis] {Your preliminary diagnosis} \n [Treatment recommendation] {Your treatment recommendation}\n [Treatment plan] {Your treatment plan} \n". The output was then matched with the ground truth. The preliminary diagnosis, the most crucial element, was assessed on both accuracy and comprehensiveness, while the treatment recommendation and treatment plan were evaluated only on accuracy. We have selected 100 samples covering more than 55 disease types for preliminary diagnosis.

First disease course record generation.
This task simulated the process by which a resident physician recorded the first disease course for a patient within 24 hours of hospitalization, synthesizing textual information such as history of present illness, physical examination, auxiliary examination, and clinical history features to predict the diagnostic basis, admission diagnosis, and diagnostic and treatment plan. The diagnostic basis explained the causes related to the admission diagnosis, reflecting the model's capacity for logical reasoning. We employed prompt sentences like “Current inpatient pediatric information is as follows: \n [History of present illness] The pediatric patient had a fever without obvious inducement five days ago (October 9, 2023) ... \n [Physical examination] The pediatric patient is conscious and responsive ... \n [Auxiliary examination] October 9, 2023: outpatient blood test ... \n [Clinical history features] Male, 13 years old ... \n Based on the above information, combined with professional medical knowledge, make a diagnosis in the format: \n [Diagnostic basis] {Your diagnostic basis} \n [Admission diagnosis] {Your admission diagnosis} \n [Diagnostic and treatment plan] {Your diagnostic and treatment plan} \n" as input. We focused primarily on the admission diagnosis, evaluating it for both accuracy and comprehensiveness, while the diagnostic basis and diagnostic and treatment plan were assessed only for accuracy. Similarly, we have selected 100 samples that include more than 47 types of diseases for admission diagnosis.

Attending physician's first ward round record generation.
This task simulated how an attending physician performed the first ward round within 72 hours of a patient's hospitalization, analyzing textual data such as clinical history features and additional clinical history and signs to predict the diagnostic basis, current diagnosis, and diagnostic and treatment plan. We utilized the following prompt as input: “Current inpatient pediatric information is as follows: \n [Clinical history features] Male, 13 years old ... \n [Additional clinical history and signs] The pediatric patient continues to experience recurrent fever, peaking at 39.7^∘C ... \n Based on the above information, combined with professional medical knowledge, make a diagnosis in the format: \n [Diagnostic basis] {Your diagnostic basis} \n [Current diagnosis] {Your current diagnosis} \n [Diagnostic and treatment plan] {Your diagnostic and treatment plan} \n". Our primary focus was on the current diagnosis, thus we evaluated the prediction using accuracy and comprehensiveness, while the diagnostic basis and the diagnostic and treatment plan were assessed solely on accuracy. Similarly, we have selected 100 samples, covering over 79 types of diseases for current diagnosis.

Chief physician's first ward round record generation.
This task was similar to the attending physician's first ward round record generation task; however, it specifically simulated the chief physician's first ward round record within one week of a patient's hospitalization. The selected 100 samples encompassed more than 74 types of diseases for current diagnosis.





 §.§ Medical Multimodal Large Language Model for Pediatric Pneumonia (P2Med-MLLM)

As illustrated in Fig. <ref>, the architecture of the Medical Multimodal Large Language Model for Pediatric Pneumonia (P2Med-MLLM) primarily consisted of three modules: a pre-trained LLM (e.g., Chinese-LLaMA-2 <cit.>) serving as the foundational model, a pre-trained vision encoder (e.g., CLIP <cit.>) responsible for encoding medical images into image embeddings, and an attention-based perceiver <cit.> that transformed these image embeddings into image tokens compatible with the LLM.

For P2Med-MLLM training, we considered a three-stage procedure, shown in Fig. <ref>. During the first stage of medical knowledge fusion pre-training, only the perceiver module was trainable, facilitating the alignment of multimodal features. Subsequently, during the second and third stages of instruction-tuning, the LLM employed Low-Rank Adaptation (LoRA) <cit.> for efficient parameter tuning. All medical data were formatted as either a single-round conversation (plain text and image-text paired data) or multi-round conversations (interleaved image-text data) for model training. Next, we would provide a detailed introduction to the P2Med-MLLM.



  §.§.§ Efficient Large Language Model Finetuning
 
The LLM pre-trained on web datasets lacked the vertical domain knowledge required for pediatric pneumonia, leading to suboptimal performance for corresponding medical tasks. It was essential to update the LLM parameters using medical data. Due to constraints in computational resources, finetuning the full parameters of the LLM, which consisted of 7B parameters, was unfeasible. To address these challenges, we adopted LoRA for efficient parameter tuning.

LoRA introduced low-rank matrices, denoted as A and B, which had a significantly smaller number of parameters than the original model weights. The adaptation was formulated as:
 

    W' = W + Δ W

where W was the original weight matrix, and Δ W was the low-rank update defined as:

    Δ W = A B^T

where A ∈ℝ^d × r and B ∈ℝ^d × r, with r being the rank which was much smaller than d, the dimension of W. T represented the transpose operation.

By training only the low-rank matrices A and B while keeping the original LLM parameters frozen, we achieved efficient optimization with significantly reduced computational overhead. The lightweight nature of these low-rank matrices ensured that there was almost no additional inference latency introduced during the inference stage. Ultimately, we efficiently incorporated critical medical knowledge into the LLM, enhancing its performance in this specialized field without the need for extensive computational resources.



  §.§.§ 2D/3D Medical Image Perception

Traditional approaches typically employed a linear projection <cit.> or a Multi-Layer Perceptron (MLP) <cit.> as the cross-modal connector to convert medical image embeddings into visual tokens for being integrated into LLM. However, these conventional methods encountered significant challenges when processing 3D CT images, which typically consisted of more than 30 slices. The conversion of these images resulted in an excessively large number of visual tokens, far exceeding the LLM's maximum token limit. For instance, a 2D image was encoded as 576 visual tokens, whereas a 3D image with 30 slices was encoded as 30 × 576 = 17,280 visual tokens, which far exceeded the typical LLM maximum length of 4,096 tokens.

To address this challenge, we utilized a lightweight Transformer decoder-only <cit.> structure based on the attention mechanism, named as the perceiver module <cit.>, to simultaneously process 2D/3D medical images embeddings into a fixed number of visual tokens. Specifically, the perceiver first incorporated learnable temporal and positional embeddings into the image embeddings, which were then flattened for injecting into the attention layer. The attention layer operates were as follows:


    Q = W^Q h,  K = W^K x, V = W^V x

where h represented the learnable latent array, while x corresponded to the flattened visual features. Q, K, and V denoted the query, key, and value vectors used in cross-attention interactions. W^Q, W^K, and W^V were learned weight matrices.

The attention mechanism then computed:

    Attention(Q, K, V) = softmax(QK^T/√(d_k))V

where d_k was the dimension of the key vector.

Ultimately, through this unified architecture, the perceiver module efficiently processed the perception of both 2D and 3D medical images, ensuring that the resulting visual tokens were compatible in length with the LLM. This approach optimized the integration of complex medical imaging data with the LLM, making it suitable for advanced medical tasks.



  §.§.§ Multimodal Medical Data Formats

The medical data collected for training were categorized into plain text data and multimodal data. Each data instance input X_i and output X_o were reformatted into an instruction-following structure: 
 
    𝑋_p  𝑋_i^1 ⟨⟩  𝑋_o^1 ⟨⟩

where X_p referred predefined instructional prompts for different tasks. Please see Sec <ref> for the illustrations of different prompts. The model was designed to predict the assistant's responses and where to stop. Therefore, only green tokens were used to calculate the training loss.

For the plain text data, which primarily concerned record generation, X_i referred to patient-specific information, while X_o consisted of the resultant medical records. In the context of multimodal medical image-report data, the input X_i referred to visual data such as X-ray or CT images, and X_o consisted of the findings and impressions, interpreting and summarizing the visual observations. Qualitative examples illustrating our data formats were shown in Fig. <ref>. For the original Chinese version, please refer to Fig. <ref>.

The analysis of the collected data revealed that a patient sometimes underwent multiple radiological examinations, resulting in correlated medical image-report pairs. For instance, sequential reports may contain comparisons such as “Compared to the scan from October 29, 2022, both lungs show ...". Treating each medical image-report pair as an independent instruction instance can hinder the model's ability to recognize relationships across a patient's sequential image-report data. To mitigate this limitation, we converted multiple related image-report pairs of a patient into an interleaved data format:

    𝑋_p  𝑋_i^1 ⟨⟩  𝑋_o^1 ⟨⟩, 
        𝑋_p  𝑋_i^2 ⟨⟩  𝑋_o^2 ⟨⟩…


This approach enabled our model to consider all previously associated image-report data when generating new reports.



 §.§ Training Details




  §.§.§ Data Preprocessing

In the analysis of medical imaging and textual data for pediatric pneumonia, we initially de-identified all patient-related information. For the preprocessing of 2D chest X-ray images, each chest X-ray examination retained either an anteroposterior view or both anteroposterior and lateral views, and the x-axis and y-axis were resized to 336 pixels. For the preprocessing of 3D chest CT images, we selected lung reconstruction series with a slice thickness of 5.0 mm and normalized them based on a window level of -500 HU and a window width of 1,200 HU. Each chest CT examination retained either a non-contrast series or both non-contrast and contrast-enhanced series, and the x-axis and y-axis were resized to 336 pixels. When the z-axis dimensions of non-contrast and contrast-enhanced series differed, the shorter one was padded with zeros to match. For the preprocessing of textual data including medical reports, outpatient, and inpatient records, we removed records with any missing element in the model's ground truth output. Additionally, we excluded records containing over 4,000 tokens, as their excessive lengths hindered the effective learning of the LLM. Specifically, for deduplication of outpatient records, we utilized 5-grams with a Jaccard similarity threshold of 0.85, 16 rows, and 256 bands. Meanwhile, we filtered out outpatient records with n-grams less than 5.



  §.§.§ Implementation

We utilized a 24-layer, 2D ViT-L/14 with 1,024 embedding dimensions as the vision encoder, initialized with CLIP weights. The perceiver was a 6-layer transformer decoder with a learnable latent array of 32 × 4,096 dimensions. For the LLM, we employed the 32-layer, 7B Chinese-LLaMA-2. Our final model comprised 8B parameters. During the three training stages, we froze the vision encoder and LLM, updating only the perceiver and LoRA parameters. All models were implemented in PyTorch and trained on 8 NVIDIA A6000 GPUs with 48 GB memory each. To prevent gradient errors during backpropagation, each batch during training samples was either image-text pairs or plain text data. For optimization, we used the Adam optimizer with a cosine decay scheduler and a warmup ratio of 0.03. Detailed hyperparameters were provided in Table <ref>.



IEEEtran







§ SUPPLEMENTARY MATERIALS






