Human interpretable structure-property relationships in chemistry using explainable machine learning and large language models

Geemi P. Wellawatte, Philippe SchwallerCommunications 2025

Abstract

Explainable Artificial Intelligence (XAI) is an emerging field in AI that aims to address the opaque nature of machine learning models. Furthermore, it has been shown that XAI can be used to extract input-output relationships, making them a useful tool in chemistry to understand structure-property relationships. However, one of the main limitations of XAI methods is that they are developed for technically oriented users. We propose the XpertAI framework that integrates XAI methods with large language models (LLMs) accessing scientific literature to generate accessible natural language explanations of raw chemical data automatically. We conducted 5 case studies to evaluate the performance of XpertAI. Our results show that XpertAI combines the strengths of LLMs and XAI tools in generating specific, scientific, and interpretable explanations.

Introduction

Machine learning (ML) has revolutionized the prediction of structure-property relationships in chemistry, enabling rapid assessments of molecular toxicity, solubility, and other critical properties. Despite their predictive power, these models often function as "black boxes," providing little insight into the underlying chemical logic. While technical tools like SHAP (SHapley Additive exPlanations) and LIME (Local Interpretable Model-agnostic Explanations) offer a glimpse into model decision-making, their outputs—often complex plots—require significant expertise to interpret. Furthermore, general-purpose Large Language Models (LLMs) frequently struggle with specificity or "hallucinate" facts when queried about niche chemical datasets. There is a pressing need for tools that can bridge the gap between technical XAI outputs and human chemical intuition by grounding explanations in peer-reviewed literature.

The XpertAI Framework

To address these challenges, we developed XpertAI, a framework that transforms raw chemical data into natural language explanations (NLEs) that are scientifically grounded and easy for chemists to interpret.

The XpertAI framework integrates user inputs, machine learning models, XAI tools, and LLMs to generate interpretable structure-function relationships.

The framework follows a multi-step pipeline:

  1. Surrogate Modeling: A standard ML model (e.g., XGBoost or Random Forest) is trained on a chemical dataset to map molecular structures to specific properties.
  2. Feature Extraction: XAI methods like SHAP and LIME identify the most impactful molecular features, such as specific functional groups or structural motifs.
  3. Retrieval-Augmented Generation (RAG): To ensure scientific accuracy, XpertAI uses a retriever to search a curated library of peer-reviewed papers for the identified features.
  4. Natural Language Explanation: An LLM (such as GPT-4o or open-source alternatives like Llama 3.1) synthesizes the XAI findings and retrieved literature into a cohesive explanation with formal citations.

Experimental Validation

The framework was validated across five diverse chemical case studies to test its versatility:

  • Metal-Organic Frameworks (MOFs): Predicting open metal sites and pore-limiting diameters using the CoRE MOF 2019 database.
  • Small Molecule Toxicity: Utilizing the Tox21 database.
  • Aqueous Solubility: Leveraging the AqSolDB dataset.
  • Compound Flammability: A "negative case study" using a small dataset (79 compounds) to evaluate system performance under data scarcity and potential spurious correlations.

Results and Discussion

Evaluation by five graduate-level chemists revealed that XpertAI consistently outperformed raw XAI plots and generic LLM responses in terms of interpretability, reliability, and specificity.

Precision and Reliability

XpertAI demonstrated higher precision in identifying correct feature-property correlations compared to baseline LLMs because its responses were strictly grounded in the provided dataset and literature. In solubility, toxicity, and flammability studies, the system achieved 100% citation accuracy. By utilizing RAG, the framework significantly reduced the risk of hallucinations; if no literature support was found for a correlation, the system was prompted to state this explicitly rather than inventing a rationale.

Open-Source Viability

While GPT-4o served as the primary model, tests with open-source models like Llama 3.1:8b and Mixtral showed promising results. This suggests that XpertAI can be deployed locally, ensuring data privacy for sensitive research.

Hypothesis Generation

Beyond mere explanation, XpertAI mimics scientific workflow. It observes data correlations, searches for precedents in existing literature, and proposes hypotheses for why a specific property exists, effectively acting as an automated research assistant.

Conclusion

XpertAI represents a significant step toward making AI-driven chemistry more transparent and intuitive. By combining the specificity of XAI with the reasoning capabilities of LLMs and the authority of scientific literature, the framework provides a robust tool for understanding structure-property relationships.

However, limitations remain. The quality of explanations is inherently tied to the performance of the surrogate ML model—a phenomenon described as "Garbage In, Garbage Out." Additionally, the system currently requires human-interpretable feature names and relies on the quality of the provided PDF library. Future work will focus on automated hyperparameter optimization for surrogate models and more sophisticated automated literature scraping to further enhance the depth and accuracy of the generated explanations.

Summary updated

BibTeX
@inproceedings{wellawatte2025human,
  author = {Geemi P. Wellawatte and Philippe Schwaller},
  title = {{Human interpretable structure-property relationships in chemistry using explainable machine learning and large language models}},
  booktitle = {Communications},
  year = {2025},
  doi = {10.1038/s42004-024-01393-y},
}
Figure