Summary: Background: Post-hepatectomy liver failure (PHLF), defined as acute liver failure following hepatectomy, remains a major complicati
Summary: Background: Post-hepatectomy liver failure (PHLF), defined as acute liver failure following hepatectomy, remains a major complication for postoperative mortality lacking early detection approaches. This study aimed to leverage cutting-edge artificial intelligence (AI) techniques for extensive temporal feature analysis using perioperative data, to advance the detection of PHLF to the first 24 h after surgery. Methods: This nationwide multicenter retrospective study was conducted with a total of 1832 patients across six geographically diverse hospitals in China. This China cohort was divided into 681 cases for training the deep-learning model and 1151 cases for validation. Perioperative electronic health record (EHR) data were collected for each patient, including the basic characteristics and preoperative, intraoperative, and early postoperative factors within the first 24 h after surgery. 242 cases from the Medical Information Mart for Intensive Care (MIMIC)-IV database, predominantly comprising Caucasian patients with limited perioperative EHR data, were included to assess robustness in Western populations. PHLF was diagnosed by concurrent elevated prothrombin time/INR and hyperbilirubinemia on or after postoperative day 5 and graded according to the International Study Group of Liver Surgery criteria. The proposed algorithm employed a powerful foundation model (Bio-Clinical Bidirectional Encoder Representation from Transformers) and a context-aware transformer module to perform in-depth temporal feature investigation of perioperative data to enable early detection of PHLF. Our approach was compared with state-of-the-art machine learning and deep learning methods. T-distributed stochastic neighbor embedding and Shapley additive explanation analysis were conducted for model interpretability. The versatility of our model for routine clinical practice was systematically evaluated. This study is registered with ClinicalTrials.gov (NCT06532214). Findings: Our model demonstrated high accuracy in detecting PHLF within the first 24 h after surgery, achieving an AUC of 0.952 in internal validation and 0.884 in external validation of the China cohort, outperforming other competing algorithms. In the MIMIC-IV cohort with challenging incomplete EHR data, our model had an AUC of 0.654, which was still superior to alternative algorithms, indicating generalization potential for the Western population. Interpretability analysis showed that our model could effectively encode all perioperative factors into discriminative high-dimensional feature embeddings with temporal correlations into consideration. Importantly, our model holds clinically acceptable interpretability that the patients with model-detected PHLF are likely experiencing the onset of liver failure comprehensively driven by reduced liver volume, extensive surgical injury, and underlying liver disease. Further evaluation demonstrated that our model is of superior versatility to support perioperative phase-agnostic PHLF prediction, risk stratification for PHLF, and incomplete variable inputs. Importantly, our model demonstrates a high capacity for predicting clinically relevant PHLF. The clinicians' prediction assisted by our model was substantially improved over the clinician-only predictions (AUC = 0.778 vs. 0.637, P = 0.009). Interpretation: Our model achieved state-of-the-art performance in accuracy, generalizability, interpretability, and versatility for early detection of PHLF within the first 24 h after surgery. This approach holds promise for transforming perioperative management of hepatectomy and improving the rescue of life-threatening PHLF. Funding: The work was partially supported by a grant from the Research Grants Council of the Hong Kong Special Administrative Region, China (Project Reference Number: T45-401/22-N), in part by grants from the National Natural Science Foundation of China (82170647, 82270661, and 62372441), in part by grants from the Basic and Applied Basic Research Foundation of Guangdong Province (2023A1515010088, 2024A1515013204, and 2023A1515030268) and in part by grant from Shenzhen Science and Technology Program (Grant No. RCYX20231211090127030).