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%.

## introduction in recent decades, machine learning (ml) models have become increasingly prevalent in various real-world applications @xcite . 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 @xcite . hence, there is an urgent need to develop effective, lightweight and practical solutions for users to improve their ml model's predictions. 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 @xcite , commonsense reasoning @xcite and coding tasks @xcite . while llms have showcased their effectiveness across an array of nlp applications, the full extent of their potential in broader fields remains largely unexplored @xcite . 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 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) @xcite has enhanced the adaptability of llms by enabling them to acquire contextual knowledge during inference, eliminating the need for extensive fine-tuning @xcite . (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 @xcite . 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. 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 @xcite , 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. ## preliminary and problem 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 @xcite and geometry structures @xcite (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 @xcite . to overcome this limitation, @xcite 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 @xmath0, g, d), where s, g and d denote the smiles string, geometry structures and generated atom feature and graph structure descriptions of g. @xmath1. problem setup. given a set of molecules @xmath2, g 2 , . . . , g m }, where m t ⊂ m contains molecules with known labels y v for all g @xmath3. our objective is to predict the unknown labels y u for all g @xmath4, where m @xmath5. in addition, m t is split into two subsets: m train and m val , where m train is the training set and m val 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 f m l : @xmath6, by minimising loss function value min θ n @xmath7, y i train ), where θ represents the set of trainable parameters of f m l . subsequently, f m l can be employed on test dataset m test to generate predictions ŷ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 (f m l ). 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 (f llm ) as posthoc correctors to refine predictions of an arbitrary f m l . compared with re-training and fine-tuning a model, this work has outstanding advantages in terms of cost and versatility. ## methodology in this section, we outline the workflow of llm-corr, 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. ## concluding discussion 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. ## limitations and ethic statement 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 ethic statement. our proposed framework, llm-corr, 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. molecules can be represented using various formats such as smiles string @xcite and geometry structures @xcite (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 @xcite . to overcome this limitation, @xcite 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.