Question Rephrasing for Quantifying Uncertainty in Large Language Models: Applications in Molecular Chemistry Tasks

Zizhang Chen, Pengyu Hong, Sandeep MadireddyarXiv 2024

Abstract

Uncertainty quantification enables users to assess the reliability of responses generated by large language models (LLMs). We present a novel Question Rephrasing technique to evaluate the input uncertainty of LLMs, which refers to the uncertainty arising from equivalent variations of the inputs provided to LLMs. This technique is integrated with sampling methods that measure the output uncertainty of LLMs, thereby offering a more comprehensive uncertainty assessment. We validated our approach on property prediction and reaction prediction for molecular chemistry tasks.

Introduction

As Large Language Models (LLMs) like GPT-4 are increasingly integrated into scientific discovery, understanding their reliability is paramount. Commercial LLMs are essentially "black boxes"—users lack access to internal confidence levels or logit probabilities. In molecular chemistry, this challenge is compounded by the flexibility of chemical notation. A single molecule can be represented by numerous valid SMILES (Simplified Molecular Input Line Entry System) strings. If an LLM's prediction changes based solely on which valid string is used, it indicates a lack of robust chemical understanding. This study introduces a "Question Rephrasing" technique to quantify this input-driven uncertainty.

Methodology

The researchers propose a dual-pronged approach to Uncertainty Quantification (UQ):

Input Uncertainty (Question Rephrasing)

Inspired by clinical psychological assessments that use varied questioning to test consistency, the authors generate multiple equivalent SMILES variants for a single molecule using the RDKit library. By querying the model with these different but chemically identical representations, they can measure the model's sensitivity to syntactic variation.

Example of a SMILES representation for acetylsalicylic acid.
An alternative, chemically equivalent SMILES representation for the same molecule.

Output Uncertainty (Sampling)

To complement input uncertainty, the model is queried multiple times with the same prompt. This "self-consistency" check measures the inherent stochasticity of the model's output.

Metrics and Clustering

To quantify uncertainty, the authors employ Shannon entropy. For generative tasks like reaction prediction, they use Tanimoto Similarity to cluster chemically similar outputs. This prevents the model from being penalized for generating different but valid string representations of the same product molecule.

Experimental Evaluation

The approach was validated using two primary task types:

  1. Property Prediction: Five classification datasets from the MoleculeNet benchmark (BBBP, HIV, BACE, Tox21, and ClinTox).
  2. Reaction Prediction: The USPTO-MIT dataset, where the model predicts the product of a chemical reaction.

Key Insights

Syntactic Brittleness

The study reveals that LLMs are surprisingly sensitive to chemical notation. Changing the starting atom or the traversal order in a SMILES string can lead the model to entirely different conclusions about a molecule's properties.

Uncertainty as a Reliability Proxy

A strong correlation was observed between high entropy (uncertainty) and incorrect predictions. In reaction prediction tasks, the Area Under the ROC Curve (AUC) for predicting correctness reached between 0.86 and 0.99. This suggests that uncertainty metrics can effectively serve as an automated "warning light" for researchers.

The Canonical Bias

Models performed significantly better on "canonical" SMILES—the standardized versions likely overrepresented in training data. Performance dropped sharply when using "rephrased" or non-standard SMILES. For instance, GPT-4's accuracy in reaction prediction fell from 25% to 7% when moving from canonical to rephrased inputs.

Conclusion and Future Work

While the Question Rephrasing technique provides a robust way to measure LLM reliability in chemistry, it is currently limited by the computational cost of multiple API calls and a focus on SMILES notation. Future research will explore multi-modal rephrasing (e.g., combining IUPAC names with structural descriptions) and scaling the evaluation to larger chemical spaces. Ultimately, quantifying uncertainty is a critical step toward the safe and effective use of AI in scientific discovery.

Summary updated

BibTeX
@misc{chen2024question,
  author = {Zizhang Chen and Pengyu Hong and Sandeep Madireddy},
  title = {{Question Rephrasing for Quantifying Uncertainty in Large Language Models: Applications in Molecular Chemistry Tasks}},
  year = {2024},
  eprint = {2408.03732},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.03732},
}
Figure