Extracting human interpretable structure-property relationships in chemistry using XAI and large language models

Geemi P. Wellawatte, Philippe Schwaller · DOI

Abstract

Machine learning (ML) models have become highly effective at predicting chemical properties from molecular structures, yet they often function as "black boxes," lacking human-interpretable reasoning. This paper introduces XpertAI, a framework that bridges the gap between opaque ML predictions and chemical intuition. By synergizing Explainable AI (XAI) with Large Language Models (LLMs) and automated literature retrieval, XpertAI transforms raw data into cited, natural language explanations. Evaluation across diverse case studies, including metal-organic frameworks and small molecule toxicity, demonstrates that XpertAI provides more accurate and accessible scientific justifications than standard XAI tools or LLMs alone.

Introduction: The Interpretability Gap in Chemical ML

In chemistry, the fundamental principle is that "structure determines property." While modern ML models excel at mapping these relationships, they rarely provide the "why" behind their predictions. Existing Explainable AI (XAI) tools like SHAP or LIME identify influential features (e.g., atom counts or pore size), but their output is often too technical for experimental chemists. Conversely, standard LLMs like GPT-4 can explain general concepts but frequently hallucinate or lack grounding in specific datasets. XpertAI aims to unify the data-driven precision of XAI with the communicative power of LLMs to provide targeted, scientifically justified explanations.

The XpertAI Framework

The XpertAI pipeline automates the transition from raw data to human-readable insights through four primary stages:

  1. Surrogate Modeling: A standard ML model (e.g., XGBoost, Random Forest, or Neural Networks) is trained on chemical data to map structures to target properties.
  2. Feature Extraction: XAI methods (SHAP and LIME) identify the molecular descriptors most impactful to the model's decisions.
  3. Literature Retrieval: Utilizing the LangChain framework and a Chroma vector database, the system retrieves relevant excerpts from scientific literature (e.g., user-provided PDFs or arXiv) that explain the underlying chemistry of the identified features.
  4. Natural Language Generation: An LLM (GPT-4 or Claude) uses Chain-of-Thought prompting to synthesize XAI findings and literature evidence into a coherent, cited explanation.
Figure 1: Overview of the XpertAI framework, illustrating the integration of user data, ML models, XAI tools, and LLMs to produce interpretable structure-function relationships.

Case Studies and Datasets

The framework was validated across five distinct chemical domains:

  • Metal-Organic Frameworks (MOFs): Predicting open metal sites and pore-limiting diameters using the CoRE MOF 2019 database.
  • Small Molecule Toxicity: Analyzing the Tox21 database featurized with MACCS descriptors.
  • Aqueous Solubility: Utilizing the AqSolDB dataset of nearly 10,000 molecules.
  • Compound Flammability: Predicting upper flammability limits (UFL) using a specialized dataset of organic compounds.

Key Results and Expert Evaluation

To assess the quality of the generated natural language explanations (NLEs), the authors conducted a "Turing Test" involving three expert chemists.

Figure 5: Expert consensus on the attributes and accuracy of explanations generated by XpertAI compared to ChatGPT and raw XAI plots.

The results highlighted several key advantages:

  • Superior Interpretability: XpertAI’s explanations were rated significantly easier to understand and more "scientific" than raw XAI plots.
  • Enhanced Accuracy: In 4 out of 5 case studies, XpertAI outperformed GPT-4 alone in terms of accuracy and grounding.
  • Actionable Insights: In the toxicity study, the system not only identified toxic features but also suggested structural modifications (e.g., removing an aminomethyl group) to mitigate toxicity, demonstrating its utility in molecular design.

Discussion: Synergy and Integrity

The core innovation of XpertAI is the synergy between XAI and LLMs: XAI identifies what is important in the data, while the LLM explains why based on established science. Furthermore, the system maintains scientific integrity through its "garbage in, garbage out" guardrail. In cases where the underlying ML model performed poorly (e.g., the flammability study with limited data), XpertAI accurately reflected the model's uncertainty rather than generating a confident but false explanation.

Limitations and Future Directions

Despite its success, XpertAI faces several challenges:

  • Surrogate Dependency: The quality of the explanation is tethered to the initial ML model's performance.
  • Proprietary Bottlenecks: Current reliance on GPT-4 limits accessibility and data privacy. Future work aims to transition to open-source LLMs.
  • Model Agnosticism: The authors plan to allow users to integrate their own pre-trained models, increasing the framework's flexibility for power users.

Summary updated

BibTeX
@inproceedings{wellawatte2023extracting,
  author = {Geemi P. Wellawatte and Philippe Schwaller},
  title = {{Extracting human interpretable structure-property relationships in chemistry using XAI and large language models}},
  booktitle = {XAIA @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=cBXiaGUcK8},
}
Figure