Harnessing Large Language Models as Post-hoc Correctors (2024)

Abstract: As Machine Learning (ML) models grow in size and demand higher-quality training data, the expenses associated with re-training and fine-tuning these models are escalating rapidly. Inspired by recent impressive achievements of Large Language Models (LLMs) in different fields, this paper delves into the question: can LLMs efficiently improve an ML’s performance at a minimal cost? We show that, through our proposed training-free framework LLMCORR, an LLM can work as a post-hoc corrector to propose corrections for the predictions of an arbitrary ML model. In particular, we form a contextual knowledge database by incorporating the dataset’s label information and the ML model’s predictions on the validation dataset. Leveraging the in-context learning capability of LLMs, we ask the LLM to summarise the instances in which the ML model makes mistakes and the correlation between primary predictions and true labels. Following this, the LLM can transfer its acquired knowledge to suggest corrections for the ML model’s predictions. Our experimental results on text analysis and the challenging molecular predictions show that LLMCORR improves the performance of a number of models by up to 39% 1.

heading: 1 Introduction
text: In recent decades, Machine Learning (ML) models have become increasingly prevalent in various real-world applications (Dixon et al., 2020; Zhong et al., 2023). As ML models grow in size and demand higher-quality training data, the expenses associated with pre-training and fine-tuning these models to achieve superior performances are escalating rapidly (Devlin et al., 2018; He et al., 2021). Hence, there is an urgent need to develop effective, lightweight and practical solutions for users to improve their ML model’s predictions.
1The code and models are available at https://github. com/zhiqiangzhongddu/LLMCorr.
Large Language Models (LLMs) exhibit unprecedented capabilities in understanding and generating human-like text, making them invaluable across a wide range of Natural Language Processing (NLP) tasks, including machine translation (Hendy et al., 2023), commonsense reasoning (Krishna et al., 2023) and coding tasks (Bubeck et al., 2023). While LLMs have showcased their effectiveness across an array of NLP applications, the full extent of their potential in broader fields remains largely unexplored (Zhang et al., 2024). This paper delves into the essential research question: can LLMs effectively improve an ML’s performance at a minimal cost?
To answer the research question, we propose a groundbreaking framework, LLMCORR, which extends the application scope of LLMs by positioning them as training-free post-hoc correctors (illustrated in Figure 1). A fixed LLM is leveraged to propose corrections to an arbitrary ML model’s predictions without introducing additional training or the need for additional datasets.
At its core, LLMCORR consists of three main steps: (1) After completing the training of the ML model, we collect the dataset’s available label information, along with the primary predictions made by the ML model on the validation set, to construct a contextual knowledge database. We anticipate
14559
that the established database records the contextual knowledge about the types of instances for which the ML models produce accurate or inaccurate predictions, as well as the correlation between the primary predictions and the true labels. A recent breakthrough known as In-Context Learning (ICL) (Liu et al., 2023) has enhanced the adaptability of LLMs by enabling them to acquire contextual knowledge during inference, eliminating the need for extensive fine-tuning (Clark et al., 2020). (2) Consequently, given the target data with a primary prediction generated by the ML model, we extract the relevant contextual knowledge from the knowledge database to form a prompt. Given the input token constraints of current LLMs, transmitting all contextual information to one prompt for querying becomes impractical (Touvron et al., 2023; Achiam et al., 2023). To address this limitation, we introduce an embedding-based information retrieval approach, which can efficiently locate similar data likely to offer relevant insights with the target data. (3) Finally, we query the LLM using the created prompts for suggestions to refine the target data’s primary prediction. To mitigate the knowledge hallucination (Huang et al., 2023), we implement a self-correction mechanism when the LLM demonstrates a tendency to make substantial modifications to the ML model’s prediction.
The training-free nature of LLMCORR carries several natural advantages: (i) LLMCORR facilitates the straightforward application of LLMs, eliminating the necessity for expensive re-training and fine-tuning for an arbitrary ML model. (ii) One of the most obvious limitations of LLMs is their reliance on unstructured text (Guo et al., 2023), but LLMCORR can be adapted to arbitrary scenarios by incorporating different ML models.
To validate the effectiveness of LLMCORR, we mainly deploy it in the face of structured molecule graph data within the domain of biology, e.g., predicting the functionality of molecules. Through extensive experiments conducted on six real-world benchmark datasets covering diverse subjects, we empirically demonstrate that LLMCORR significantly elevates the quality of predictions across diverse ML models, achieving notable improvements, up to 39%. Besides, we demonstrate LLMCORR’s effectiveness on general text analysis tasks. Furthermore, we conduct comprehensive follow-up ablation studies and analyses to validate the efficacy of LLMCORR’s designs and elucidate the impact of key factors.

heading: 2 Related Work
text: Large Language Models. Traditional language models are typically trained on sequences of tokens, learning the likelihood of the next token dependent on the previous tokens (Vaswani et al., 2017). Recently, Brown et al. (2020) demonstrated that increasing the size of language models and the amount of training data can result in new capabilities, such as zero-shot generalisation, where models can perform text-based tasks without specific task-oriented training data. Consequently, Large Language Models (LLMs) have experienced exponential growth in both size and capability in recent years (Brown et al., 2020; Touvron et al., 2023; Achiam et al., 2023). A wide range of NLP applications have been reshaped by LLMs, including machine translation (Hendy et al., 2023), commonsense reasoning (Krishna et al., 2023) and coding tasks (Bubeck et al., 2023). In this work, we innovatively harness LLMs as post-hoc correctors, further extending the application scope of LLMs.
In-Context Learning. While the impressive performance and generalisation capabilities of language models have rendered them highly effective across various tasks (Wei et al., 2022a), they have also resulted in larger model parameters and increased computational costs for additional finetuning on new downstream tasks (Hu et al., 2021a). To address this challenge, recent research has introduced In-Context Learning (ICL), enabling LLMs to excel at new tasks by incorporating a few task samples directly into the prompt (Liu et al., 2023). Despite the success of these methods in improving LLM performance, their potential for correcting predictions made by ML models has not been thoroughly explored. This work investigates the utility of LLMs as post-hoc correctors to rectify incorrect predictions by leveraging their ICL abilities.
Post-hoc Corrector for Machine Learning Models. Driven by the increasing prevalence of ML models in diverse real-world applications (Butler et al., 2018; Dixon et al., 2020; Zhong et al., 2023), academia and industry have invested significant efforts in enhancing ML effectiveness. However, the majority of existing research focuses on refining the design of the ML module. Meanwhile, as ML models grow in size and demand higherquality training data, the expenses associated with re-training and fine-tuning these models are escalating rapidly (Devlin et al., 2018; He et al., 2021). Hence, there is an urgent need to develop effec-
tive, lightweight and practical solutions for users to improve their ML model’s predictions adaptively. While some studies (Huang et al., 2021; Zhong et al., 2022) propose post-processing techniques to adjust ML model predictions on node-wise tasks of graph-structured data, their solutions often lack scalability across different types of data. This work introduces a novel and versatile post-hoc corrector framework applicable to an arbitrary ML model.

heading: 3 Preliminary and Problem
text: This paper aims to leverage LLMs as post-hoc correctors to enhance predictions made by an arbitrary ML model. Specifically, we showcase our framework on challenging prediction tasks on structured molecule graph data in biology. We further demonstrate the generality of our framework on sentiment analysis and text classification in Section in the Appendix. For instance, consider the supervised molecule property prediction task, where molecules can be represented using various formats such as SMILES string (Weininger, 1988) and geometry structures (Zhang et al., 2024) (as shown in Figure 8). However, a notable limitation of existing LLMs is their reliance on unstructured text, rendering them unable to incorporate essential geometry structures as input (Li et al., 2023; Guo et al., 2023). To overcome this limitation, Fatemi et al. (2023) propose encoding the graph structure into text descriptions. In this paper, as depicted in Figure 8, we extend this concept by encoding both the molecule’s atom features and graph structure into textual descriptions.
Notion. Given a molecule, we formally represent it as a graph G = (S,G,D), where S, G and D denote the SMILES string, geometry structures and generated atom feature and graph structure descriptions of G. y ∈ Y stands for the label for G. Problem Setup. Given a set of molecules M = {G1,G2, . . . ,Gm}, where MT ⊂ M contains molecules with known labels yv for all Gv ∈ MT . Our objective is to predict the unknown labels yu for all Gu ∈ Mtest, where Mtest = M\MT . In addition, MT is split into two subsets: Mtrain and Mval, where Mtrain is the training set and Mval works as the validation set.
ML Models. The conventional approach to tackle molecule property prediction tasks is employing ML models. Take the supervised molecule property prediction task as an example. The goal is to learn a mapping function fML : M → Ŷ , by minimising
loss function value minΘ ∑n
i=1 L(Ŷ itrain,Y itrain), where Θ represents the set of trainable parameters of fML. Subsequently, fML can be employed on test dataset Mtest to generate predictions Ŷtest. Leveraging LLMs as Post-hoc Correctors. In recent decades, significant efforts have been devoted to enhancing the effectiveness, robustness, and generalisation of advanced ML models (fML). However, the potential for improving the quality of ML model predictions after completing the training process remains largely unexplored. With the trend of ML models increasing in size and requiring higher-quality training data, the costs associated with re-training and fine-tuning ML models are rapidly escalating. This paper intends to explore the possibility of positioning LLMs (fLLM ) as posthoc correctors to refine predictions of an arbitrary fML. Compared with re-training and fine-tuning a model, this work has outstanding advantages in terms of cost and versatility.

heading: 4 Methodology
text: In this section, we outline the workflow of LLMCORR, designed as a post-hoc corrector to refine predictions generated by any ML model. As illustrated in Figure 2, the key idea is to leverage the LLM’s ICL ability to summarise the types of data in which the ML model makes mistakes and the correlation between primary predictions and true labels, thereby refining the ML’s prediction on the test dataset. To achieve this goal, LLMCORR comprises three main steps: (1) Contextual knowledge database construction; (2) Contextual knowledge retrieval; (3) Prompt engineering and query.

heading: 4.1 Contextual Knowledge Database Construction
text: After completing the training of the ML model (fML) on the training set Mtrain, we collect data from both the training set Mtrain and the validation set Mval, along with the primary predictions Ŷval made by fML on the validation set. Subsequently, we construct a contextual knowledge database D based on the collected data. Notably, the knowledge database D not only contains information regarding the original training and validation datasets but also provides insights into the types of molecules for which the ML models generate accurate or inaccurate predictions. Additionally, it captures the relationship between the initial prediction Ŷval and the true label Yval. We anticipate
that this essential contextual knowledge will empower the LLM (fLLM ) to refine the predictions Ŷtest made by fML on the test dataset Mtest.

heading: 4.2 Contextual Knowledge Retrieval
text: The effectiveness of the LLMCORR heavily relies on the richness and relevance of the information received by the LLM, as it determines the task-specific contextual knowledge available to the LLM. However, due to the input token constraints of existing LLMs, transmitting all contextual knowledge into the LLM is impractical (Touvron et al., 2023; Achiam et al., 2023). After constructing the contextual knowledge database D, the next challenge is to retrieve relevant contextual knowledge for a given query data Qu = (Gu, ŷu) from either the validation set Mval or the test set Mtest. To address this limitation, we propose an Embedding-based Information Retrieval (EIR) approach. The EIR technique comprises two primary steps: (1) Utilising a text encoder (fEmb) on available textual descriptions of molecule Gu, we generate embedding vectors fEmb : (S,D) → Z for molecules from the knowledge database D and the query data Qu. (2) Calculating the similarity between the query data Zu and molecules in the knowledge database based on the obtained embeddings Zv,∀Gv ∈ D. Different selection strategies can be employed to retrieve various contextual knowledge based on the ranking. In this study, we retrieve the top-k similar data as the contextual
knowledge. We delve into the influence of different retrieval selection strategies in Section 5.2. Addressing Data Leakage Concerns. It is important to recognise that when the query data Qu comes from the validation dataset Mval, precautions are taken to prevent retrieving information about Qu to avoid data leakage. Then, LLMCORR’s performance on Mval can be assessed in a manner consistent with traditional ML pipeline, e.g., hyper-parameters selection.

heading: 4.3 LLMCORR Prompt Engineering
text: The goal in prompt engineering is to find the correct way to formulate a question Q in such a way that an LLM (fLLM ) will return the corresponding answer A essentially represented as A = fLLM (Q). In this work, our goal is to provide the LLM with helpful and comprehensive contextual knowledge regarding molecules and the ML model’s behaviours on the validation set so that it can make precise corrections to the ML model’s predictions on the test dataset. A variety of approaches exist for modifying the fLLM so that it could better perform downstream tasks such as fine-tuning (Clark et al., 2020) and LoRA (Hu et al., 2021a). However, these methods typically require access to the internals of the model and heavy computation capability, which can limit their applicability in many real-world scenarios. In this work, we are instead interested in the case where fLLM and its parameters are fixed, and the system is available only for users in a black box
setup where fLLM only consumes and produces text. We believe this setting to be particularly valuable as the number of proprietary models available and their hardware demands increase. LLMCORR Prompting. To this end, we propose a novel prompt that serves to position LLMs as post-hoc correctors, refining predictions made by an arbitrary ML model. Different from existing prompts that often work as predictors (Fatemi et al., 2023) or explainers (He et al., 2023), leveraging LLMs as correctors combining the strengths of LLMs’ in context-based question answering with the ML model’s proficiency in learning from specific datasets. Specifically, the proposed LLMCORR prompt template is illustrated in Figure 3, which mainly consists of following components:
1. Instruction: Provides general guidance to the LLM, clarifying its role in the conversation.
2. Contextual knowledge from the training dataset: Includes SMILES string and molecule label in-
formation of the training dataset.

heading: 3. Contextual knowledge from the validation
text: dataset: Includes SMILES string, molecule label information and the ML model’s predictions of the validation dataset. This equips the LLM with insights into the ML model’s error patterns, enhancing its ability to refine predictions on the test dataset.
4. Question: Tasks the LLM to refine the ML model’s predictions for the query data, drawing on the provided contextual knowledge.
It’s worth noting that by expanding the template’s sections on contextual knowledge from the training and validation datasets, multiple instances of contextual knowledge from the knowledge database D can be included. Subsequently, we query the LLM with generated prompts to obtain an initial response concerning the refined prediction of the query data, along with probability values and explanations, offering significant interpretability.
Self-correction Prompting. An inherent limitation of existing LLMs is their tendency to generate hallucinations producing content that deviates from real-world facts or user inputs (Ganguli et al., 2023; Huang et al., 2023). One promising solution is known as self-correction, where the LLM is prompted or guided to rectify errors in its own output (Pan et al., 2023). In this work, after obtaining corrected prediction ỹu from the LLM, we introduce a self-correction mechanism (prompt template is shown in Figure 4) if the LLM makes significant modifications on the primary prediction generated by the ML (for classification tasks - reversing the prediction label; for regression tasks - modifying the prediction value range by more than 20%). As demonstrated empirically in our experiments (see Section 5.2), this approach can prevent LLM from hallucinating incorrect corrections in many cases. Extensibility. LLMCORR is designed as a posthoc corrector framework that leverages the ICL
capability of LLMs. As illustrated in Figure 2, LLMCORR is adaptable to an arbitrary ML model, showcasing its remarkable extensibility. With the trend of ML models increasing in size and requiring higher-quality training data, the costs associated with enhancing ML models by re-training and finetuning are rapidly escalating. LLMCORR emerges as a promising, general-purpose practical solution in the LLM era. LLMCORR is summarised in Algorithm 1 in Appendix C.

heading: 5 Are LLMs Post-hoc Correctors?
text: In this section, we evaluate the effectiveness of LLMs as post-hoc correctors. Our experimental analysis mainly focuses on the challenging structured molecular graph property prediction tasks. The additional experiments on general text analysis tasks are presented in Appendix G.
Dataset. We consider six widely used molecule datasets from the OGB benchmark (Hu et al., 2021b), including ogbg-molbace, ogbg-molbbbp, ogbg-molhiv, ogbg-molesol, ogbg-molfreesolv and ogbg-mollipo. Detailed descriptions are summarised in Appendix D.
ML Models. To investigate whether LLMCORR can effectively improve predictions across various types of ML models. We consider ML models of three different categories: (1) Language Model (LM) that only takes text information as inputs, i.e., DeBERTa (He et al., 2021). (2) Graph Neural Networks (GNNs) that capture the molecule’s geometry structure information. We consider two classic GNN variants, i.e., GCN (Kipf and Welling, 2017) and GIN (Xu et al., 2019), and two SOTA GNN variants collected from the OGB leaderboards (Hu et al., 2021b), i.e., HIG and PAS (Wei et al., 2021). (3) And we consider one recently released hybrid framework, TAPE (He et al., 2023), in our experiments. TAPE leverages LM and LLMs to capture textual information as features, which can be used to boost GNN performance. The implementation details are discussed in Appendix E.
LLMs. In this work, we are interested in where the LLM’s parameters are fixed, and the system is available for users in a black box setup where the LLM only consumes and produces text. We believe this setting to be particularly valuable as most users would practically have access to LLMs. In this case, we consider GPT-3.5 and GPT-4 (Achiam et al., 2023) as LLMs in this work, and GPT-3.5 is the major LLM for most experiments. Besides,
open-source LLMs are also of great interest since they are easier to deploy privately, so we adopt Llama2 (Touvron et al., 2023) as another LLM. Because the generated descriptions following (Fatemi et al., 2023) have tons of tokens, easily over the LLM’s input token constraints, hence we do not include descriptions in the LLMCORR prompt in this study. Including the description information is a promising future work to explore with LLMs of more input tokens.

heading: 5.1 Main Results
text: Observation 1: LLMCORR is a potent post-hoc corrector. Examining the molecule graph property prediction performance across six datasets in Table 1, it’s evident that LLMCORR consistently delivers substantial enhancements over various ML models, with improvements reaching up to 39% in terms of RMSE. This consistent and notable performance underscores the effectiveness of LLMs within our framework LLMCORR, serving as proficient post-hoc correctors to refine the primary predictions generated by ML models.
Observation 2: The significance of geometric structure. Table 1 underscores the superiority of models incorporating geometric structure over others. This highlights the crucial role of geometric structure in accurately predicting a molecule’s property. However, LLMCORR currently cannot directly incorporate geometric structure in the prompt due to limitations in the token count of generated descriptions over the LLM’s constraints. Addressing this limitation is identified as a promising avenue for future exploration.
Observation 3: Enhanced assistance for lowerperforming ML models. Furthermore, we observe that LLMCORR provides more substantial assistance when the performance of ML models is lower. This trend is noticeable across various datasets; for instance, LLMCORR boosts LM performance from 0.6163 to 0.6915 with a 12.2% improvement on the test dataset of ogbg-molbace. Even though the ultimate performance still falls short compared to GNN models, the magnitude of improvement is most significant.
Observation 4: GPT-4 and Llama2 underperform compared to GPT-3.5. Table 2 displays the molecule graph property prediction performance and execution time for three datasets, comparing Llama2, GPT-3.5 and GPT-4. Llama2 has fewer parameters than GPT-3.5 and GPT-4, but Llama2 can
still improve the predictions within the framework of LLMCORR on some datasets. Interestingly, we find that despite its larger training data and more complex fine-tuning process, GPT-4 exhibits inferior performance compared to GPT-3.5 in this study. We hypothesise that this discrepancy may be attributed to interventions such as reinforcement learning through human feedback.
Observation 5: LLMs exhibit limited competitiveness as predictors. Given LLMCORR’s remarkable performance as correctors, another intriguing question arises: can LLM generate accurate predictions directly? To investigate, we conduct additional experiments where the LLM is tasked with directly predicting the molecule’s property. For detailed findings, please refer to Appendix F due to space constraints. As shown in the results of Table 3, LLMs do not demonstrate competitive performance as predictors. This obser-
vation reinforces the efficacy of LLMCORR, which leverages LLMs as post-hoc correctors.

heading: 5.2 Ablation Study
text: Variants of contextual knowledge retrieval. Within the EIR of LLMCORR, the selection of topk data from the knowledge database following similarity calculations is a critical step. This ablation study explores alternative approaches such as Jump and Random. In Random, k data are randomly selected from the knowledge database, disregarding similarity rankings. On the other hand, Jump selects k evenly spaced indices, ensuring diversity in the selected data. Results from Table 4 suggest that selecting top-k data yields optimal results, with Jump outperforming Random. We posit that LLMs benefit from closely relevant knowledge to generate effective corrections.
Impact of k. In the EIR, the parameter k dictates
the number of knowledge instances sampled from the database to construct LLMCORR’s prompt, thus influencing the knowledge presented to the LLM. It is observed (Figure 5) that larger k values correlate with improved performance, underscoring the significance of comprehensive knowledge to guide LLMs for enhanced performance.
Effect of fEmb. Another ablation study concerning
the EIR process examines the influence of different fEmb functions. Figure 6 suggests that larger fEmb values yield superior performance on benchmark testing, aiding LLMCORR in achieving better results. This is attributed to accurate semantic embeddings facilitating the identification of relevant instances during the EIR process, reinforcing the importance of selecting top-k relevant knowledge instances.
Impact of self-correction. Upon completion of LLMCORR’s inference process, the LLM is tasked with self-correction if major modifications to primary predictions are made. Figure 7 illustrates LLMCORR’s performance on the test dataset across six datasets, revealing instances where the selfcorrection component leads to uncertain impacts. This phenomenon is attributed to the LLM becoming hesitant and cautious after the questioning. Designing a more effective self-correction prompt emerges as an intriguing area for future investigation.

heading: 6 Concluding Discussion
text: We have introduced a novel framework, LLMCORR, a training-free, lightweight, yet effective approach, harnessing the in-context learning capabilities of LLMs to improve the predictions of arbitrary ML models. Through this simple and versatile ap-
proach, we have demonstrated significant improvements over a number of ML models on different challenging tasks. As LLMs continue to improve in performance and in-context learning capabilities, LLMCORR stands to directly benefit from these advancements.

heading: 7 Limitations and Ethic Statement
text: Limitations. While LLMCORR demonstrates simplicity and effectiveness in improving the predictions of an arbitrary ML model, our verification was mainly confined to structured molecular graph property prediction tasks and several text analysis tasks. Further extensive empirical investigations across diverse domains are warranted to establish its generalisability. Additionally, considering the purported enhanced ICL capabilities of GPT-4 on various benchmark tasks (OpenAI, 2023), it is noteworthy that our findings (as discussed in Section 5.1 and illustrated in Table 2) reveal GPT-4’s underperformance compared to the GPT-3.5 model. This discrepancy merits further exploration to elucidate the underlying reasons. Moreover, while LLMCORR’s prompt template could accommodate the insertion of molecule atom features and geometry structure descriptions, similar to prompt templates shown in Appendix F, limitations stemming from the LLM’s input token constraints prevented their inclusion in the prompt in this paper. We believe that with the rapid development of LLMs, some LLMs that allow much longer inputs will soon be available. It would be interesting to investigate LLMCORR’s effectiveness while including descriptions in the prompt. Lastly, while our approach incorporates contextual knowledge into the prompt, its utility is constrained by several factors, including limited flexibility. For example, further leveraging different techniques, e.g., RAG (Lewis et al., 2020) to involve more contextual knowledge into the LLM and advanced contextual knowledge retrieval (Zhang et al., 2022) are also fruitful directions. Further enhancements in this regard are warranted to maximise LLMCORR’s effectiveness.
Ethic Statement. Our proposed framework, LLMCORR, is designed as a post-hoc corrector aims at improving the prediction of an arbitrary ML model. However, given the emergent in-context learning ability within LLMs, which typically consist of billions of parameters, the accessibility of computational resources may inadvertently introduce disparities in the utilisation of these methods. Re-
search groups with limited access to computational resources will be handicapped, while resourceful groups will be able to investigate and advance the future directions of this research. Throughout our work, we did not utilise any private or sensitive information. However, it’s essential to note that if any private information were to be inadvertently exposed to an LLM during internal pre-training and fine-tuning stages, LLMCORR does not offer any privacy filtration mechanism. Therefore, there exists the potential for privacy concerns associated with the underlying model to manifest through the output provided by LLMCORR.

heading: Acknowledgments
text: This work is supported by the Horizon Europe and Innovation Fund Denmark under the Eureka, Eurostar grant no E115712 - AAVanguard.

heading: B LLMCORR Prompt Templates for Regression Tasks
text: Due to the page space limit, we only provide LLMCORR prompt templates in Section 4. This section illustrates our LLMCORR prompt templates for regression tasks. Particularly, the proposed LLMCORR prompt template for regression tasks is illustrated in Figure 9, which contains similar components as LLMCORR prompt template for classification tasks as discussed in Section 4.3. The self-construction prompt for regression tasks is illustrated in Figure 10.

heading: C Algorithm
text: We outline the process of LLMCORR in Algorithm 1. Given a dataset M, an ML model fML, a LLM fLLM . After completing the training of the ML model (fML) on the training set Mtrain (line 1), we construct a contextual knowledge database D by incorporating the dataset’s label information and the ML model’s prediction on the validation dataset Mval (line 2). Given a query data Gu, we
create a prompt Pu using its primary prediction generated by fML and relevant contextual knowledge Du (line 3-6). Finally, we query the LLM (fLLM ) to obtain the refined prediction ỹu (line 7).

heading: D Dataset Description
text: We consider six benchmark molecule property prediction datasets that are common within ML research, which are summarised in Table 5.
1. ogbg-molbace. The ogbg-molbace dataset provides quantitative (IC50) and qualitative (binary label) binding results for a set of inhibitors of human b-secretase 1 (BACE-1). All data are experimental values reported in the scientific literature over the past decade, some with
Algorithm 1: LLMCORR Input: Dataset M = {G1,G2, . . . ,Gm},
ML model fML, LLM fLLM Output: Refined predictions Ỹ
1 Complete training of fML : M → Ŷ by minΘ ∑n i=1 L(Ŷ itrain,Y itrain) ; 2 Construct a contextual knowledge database D = {Mtrain,Mval, Ŷval} ; 3 for Gu ∈ {Mval ∪Mtest} do 4 ŷu = fML(Gu) 5 Qu = (Gu, ŷu) 6 Create a prompt Pu using Qu and
retrieved contextual knowledge Du ⊂ D
7 Query the LLM and contain the refined prediction ỹu = fLLM (Pu) 8 end
detailed crystal structures available. MoleculeNet (Wu et al., 2018) merged a collection of 1,522 compounds with their 2D structures and binary labels, built as a classification task.
2. ogbg-molbbbp. The Blood–Brain Barrier Penetration (BBBP) dataset comes from scientific studies on the modelling and prediction of barrier permeability. As a membrane separating circulating blood and brain extracellular fluid, the blood–brain barrier blocks most drugs, hormones and neurotransmitters. Thus penetration of the barrier forms a long-standing issue in the development of drugs targeting the central nervous system. This dataset includes binary labels for over 2,039 compounds on their permeability properties. Scaffold splitting is also recommended for this well-defined target.
3. ogbg-molhiv. The HIV dataset was introduced by the Drug Therapeutics Program (DTP) AIDS Antiviral Screen, which tested the ability to inhibit HIV replication for 41,127 compounds. Screening results were evaluated and placed into three categories: confirmed inactive (CI), confirmed active (CA) and confirmed moderately active (CM). We further combine the latter two labels, making it a classification task between inactive (CI) and active (CA and CM). As we are more interested in discovering new categories of HIV inhibitors, scaffold splitting is recommended for this dataset.
4. ogbg-molesol. ESOL is a small dataset con-
sisting of water solubility data for 1,128 compounds. The dataset has been used to train models that estimate solubility directly from chemical structures (as encoded in SMILES strings). Note that these structures don’t include 3D coordinates, since solubility is a property of a molecule and not of its particular conformers.
5. ogbg-molfreesolv. The Free Solvation Database (FreeSolv) provides experimental and calculated hydration-free energy of small molecules in water. A subset of the compounds in the dataset is also used in the SAMPL blind prediction challenge. The calculated values are derived from alchemical free energy calculations using molecular dynamics simulations. We include the experimental values in the benchmark collection and use calculated values for comparison.
6. ogbg-mollipo. Lipophilicity is an important feature of drug molecules that affects both membrane permeability and solubility. This dataset, curated from the ChEMBL database (Mendez et al., 2019), provides experimental results of the octanol/water distribution coefficient (log D at pH 7.4) of 4200 compounds.
E Implementation
Implementation. We implement ML predictive models following their available official implementations. For instance, we adopt the available code of variant GNN models on the OGB benchmark leaderboards, e.g., GCN2, GIN3, HIG 4 and PAS 5. About DeBERTa, we adopt its official implementation 6 and incorporate it within the pipeline of TAPE 7. For the GPT-3.5 and GPT-4, we simply call the API provided by OpenAI with default hyper-parameter settings. For the Llama2, we adopt the Llama-2-13b version and call their official implementation on https://huggingface. co. We empirically tried with some combinations of recommended important hyper-parameters, e.g., temperature and top_P, yet did not observe signifi-
2https://github.com/snap-stanford/ogb/tree/ master/examples/graphproppred/mol
3https://github.com/snap-stanford/ogb/tree/ master/examples/graphproppred/mol
4https://github.com/TencentYoutuResearch/ HIG-GraphClassification
5https://github.com/LARS-research/PAS-OGB 6https://huggingface.co/microsoft/
deberta-v3-base 7https://github.com/XiaoxinHe/TAPE
cant improvement. To realise the embedding-based information retrieval for LLMCORR, we adopt two capable embedding models (fEmb) provided by OpenAI 8, e.g., text-embedding-3-large and textembedding-3-small. In this work, we mainly adopt text-embedding-3-large for better empirical performance. We perform careful discussions about the influence of different variants in Section 5.2.

heading: F Are LLMs Predictors?
text: Following the thorough demonstration of LLMCORR’s efficacy as a post-hoc corrector in Section 5.1, a fundamental question emerged: does LLMCORR’s remarkable performance stem from the LLM’s ability to comprehend and rectify the ML model’s predictions, or does it possess an inherent capability to predict molecule properties? To answer this question, undertake another series of empirical investigations. Specifically, we devise predictor prompts that task LLMs with directly predicting molecule properties, devoid of any information regarding the predictions made by the ML model. In the following sections, we will present our designed prompts and demonstrate the experimental results.
8https://platform.openai.com/docs/models/ embeddings
Figure 12: Zero-shot prompt templates for regression tasks.
Figure 13: Few-shot prompt template for classification tasks. Multiple contextual knowledge can be included by expanding the template.
F.1 Predictor Prompt Engineering
Zero-shot Prompting. The first set of prompts (IP, IE) simply provides the LLM with molecule and task descriptions and asks it to generate the desired output with a desired format without any prior training or knowledge on the task, as illustrated in Figure 11 and Figure 12. The only guidance we provide to the LLM is instruction, which tells about
a little background context. Particularly, IP only asks the LLM to provide predictions, while IE further asks for explanations, which may ask the LLM to clarify the thought process in explanation generation and provide helpful evidence to help users understand the given prediction. In addition, if we fill out the description of IP and IE, which derives IPD and IED prompts. Few-shot Prompting. The second kind of prompt (FS) that we propose provides the LLM with a small number of examples of the task, along with the desired outputs (Brown et al., 2020). The model then learns from these examples to perform the task on new inputs. This approach can be categorised as a simple in-context learning (ICL) technique, An example prompt template is shown in Figure 13 and Figure 14. FS-k indicates k contextual knowledge instances are included in the prompt. In this work, we do not discuss the FSD prompts since the generated descriptions have tons of tokens, which will easily go over the LLM’s input constraints.
We note there are also some popular recent ICL techniques, e.g., Chain-of-thought (CoT) (Wei et al., 2022b), Tree-of-thought (ToT) (Yao et al., 2023), Graph-of-thought (GoT) (Besta et al., 2023) and Retrieval Augmented Generation (RaG) (Lewis et al., 2020), which are theoretically available to support complicated tasks and include large knowledge context. However, our initial experiments showed that methods, e.g., CoT, ToT and GoT, perform much worse for molecule property prediction tasks due to the significant difficulties in designing proper chain thoughts without solid expertise. RaG implementations that we tested are unstable and
slow with query, and they fall short of the relatively simpler FS’s performance. We argue the unqualified information retrieval system causes it, and we will discuss it in the future work discussion section.
F.2 Results - LLMs work as Predictors From the results of Table 3, we can observe that the LLM can generate predictions about the molecule’s property. However, LLM’s performances are not significantly competitive compared with the ML models’ performance. Hence, we argue existing LLMs are not competitive predictors and employing LLMs as effective predictors is still an open challenge.

heading: G LLMCORR for Other NLP Tasks
text: In Section 5, we have illustrated the effectiveness of LLMCORR on various challenging molecular property prediction tasks. Our experimental results show that LLMCORR can consistently improve the performance of a number of models. In order to demonstrate the usability of LLMCORR in broader applications, we further conduct additional experiments on some NLP tasks. Dataset. Particularly, we introduce two datasets:
1. Twitter. The Twitter sentiment analysis dataset contains 6,940 tweets obtained by querying the Twitter API (Dong et al., 2014). Each tweet was manually annotated a sentiment labels (negative, neutral, positive). The task is to predict the tweet’s sentiment label based on its text. We split datasets into training/validation/test (70%, 10%, 20%) subsets for the experiments.
2. Cora. The Cora dataset contains 2,708 academic publications (He et al., 2023), which belong to one of seven categories (case-based, genetic algorithms, neural networks, probabilistic methods, reinforcement learning, rule learning, theory). The task is to predict which category the publication belongs to based on its title and abstract. We split datasets into training/validation/test (60%, 20%, 20%) subsets for the experiments.
We evaluate the model performance on these two datasets in terms of classification accuracy. Methods. This section investigates the effectiveness of LLMCORR on NLP tasks, so we adopt NLP models of three categories: (1) one Language Model (LM), i.e., DeBERTa (He et al., 2021). (2) One Large Language Model (LLM), i.e., GPT-3.5,
which takes IP and FS prompts similar to the one shown in Figure 11 and Figure 13. (3) Our LLMCORR, that improves the predictions of DeBERTa. LLMCORR utilises a prompt similar to the one shown in Figure 3, by replacing {SMILES} and {task} with corresponding information. We adopt k = 10 for FS and LLMCORR in this experiment. Other settings are the same as the main experiments, discussed in Section 5.
Results. Examining the experimental results on two datasets in Table 6, it’s evident that LLMCORR can consistently improve the LM’s performance. It confirms the good usability of LLMCORR on various application tasks. Meanwhile, we observe LLM exhibit competitive performance compared to the LM which fine-tune on the datasets. It is attributed to the LLM’s qualified large-scale training datasets, which empower the LLM with an outstanding ability to understand different texts. Yet, compared to LLMCORR, our proposed framework still demonstrates significant priority over using LLMs as predictors.

heading: Future Work