This U.S. patent application claims priority under 35 U.S.C. § 119 to: Indian Patent Application number 202321086642, filed on Dec. 18, 2023. The entire contents of the aforementioned application are incorporated herein by reference.
The embodiments herein generally relate to the field of Natural Language Processing and, more particularly, to a method and system for perplexity and log-likelihood based approach for text classification using causal Language Models (LMs).
In recent years, the autoregressive or causal Language models (LM) like Generative pre-trained transformers (GPT)-3 and GPT-Neo have been successful in a variety of natural language processing tasks such as summarization, machine translation, question answering, etc. Recently, there have been attempts to use such LMs for text classification in zero-shot or few-shot manner. In these approaches, there are several challenges for using moderate-sized LMs like GPT-Neo-2.7B for text classification in both zero-shot as well as few-shot settings. In a zero-shot setting, getting the LM to generate an output containing the expected class labels is challenging. E.g., in case of SST-2 dataset for sentiment prediction, in spite of providing specific instruction in the prompt, for only around 10% test instances, the generated text contained the expected Positive and Negative labels. Most cases resulted in generating some random text or generating some text containing words like mess or brilliant from which the actual labels need to be inferred in a non-trivial way as can be seen in Table 1.
text)
In a few-shot setting, the generated output conforms to the expected format in most cases. However, due to the limited context window of the LM, a large number of training instances cannot be provided in the prompt. This limits the ability of the LM to exploit the available labelled examples. Another way of exploiting training examples is through fine-tuning the LM. However, this requires specialized hardware resources (like GPUs with significant RAM) and time for fine-tuning.
Very large LMs like GPT-3 may not face these above challenges, but their usage through Application Programming Interfaces (APIs) entails sharing the data to be classified and this may not be desirable for private and confidential data.
Moderate-sized LMs such as GPT-Neo-2.7B can be deployed with very limited hardware in-house. Thus they can be useful resources for text classification requirements of organizations, where data privacy is critical. However, achieving text classification with desired accuracy using moderate sized LMs still remain an unaddressed technical challenge considering the technical limitations of such LMs as mentioned above.
Embodiments of the present disclosure present technological improvements as solutions to one or more of the above-mentioned technical problems recognized by the inventors in conventional systems.
For example, in one embodiment, a method for text classification is provided. The method includes receiving a text, predefined numbers of class labels, a set of key phrases associated with each of the predefined class labels, and a connector sentence, wherein the text is to be classified into one or more class labels from among predefined class labels.
Further, the method includes generating a plurality of label-specific augmentations for the text based on each key phrase among the set of key phrases associated with each of the predefined class labels, and the connector sentence.
Further, the method includes deriving via a Language Model (LM) executed by one or more hardware processors, perplexity based key phrase level features and log-likelihood based key phrase level features for each of the plurality of label-specific augmentations. Each of the perplexity based key phrase level features captures a reduction in perplexity of a key phrase from the set of key phrases, wherein the reduction in perplexity is a ratio of conditional perplexity of the key phrase given the text to be classified, to the perplexity of the key phrase. Each of the log-likelihood based key phrase level features captures an increase in log-likelihood of the key phrase from the set of key phrases, wherein the increase in log-likelihood is a difference between conditional log-likelihood of the key phrase given the text to be classified, and log-likelihood of the key phrase.
Furthermore, the method includes determining, i) a class level perplexity based feature for each of the predefined class labels as a minimum of perplexity based key phrase level features associated with the corresponding class label, and ii) a class level log-likelihood based feature for each of the predefined class labels as maximum of log-likelihood based key phrase level features associated with the corresponding class label.
Further, the method includes predicting for a zero shot classification, the one or more class labels for the text based on one of: i) value of perplexity based class level features lying below a minimum threshold value; and ii) value of log-likelihood based class level features lying above a maximum threshold value.
Furthermore, the method includes enhancing an accuracy of prediction of text classification of the text into one or more class labels using a pretrained supervised machine learning classifier that utilizes the perplexity based key phrase level features, log-likelihood based key phrase level features, the class level perplexity based features, and the class level log-likelihood based features. The supervised machine learning classifier is trained on the perplexity based key phrase level features, log-likelihood based key phrase level features, the class level perplexity based features, and the class level log-likelihood based features obtained for a training data.
In another aspect, a system for text classification is provided. The system comprises a memory storing instructions; one or more Input/Output (I/O) interfaces; and one or more hardware processors coupled to the memory via the one or more I/O interfaces, wherein the one or more hardware processors are configured by the instructions to receive a text, predefined numbers of class labels, a set of key phrases associated with each of the predefined class labels, and a connector sentence, wherein the text is to be classified into one or more class labels from among predefined class labels.
Further, the system is configured to generate a plurality of label-specific augmentations for the text based on each key phrase among the set of key phrases associated with each of the predefined class labels, and the connector sentence.
Further, the system is configured to derive via a Language Model (LM) executed by the one or more hardware processors, perplexity based key phrase level features and log-likelihood based key phrase level features for each of the plurality of label-specific augmentations. Each of the perplexity based key phrase level features captures a reduction in perplexity of a key phrase from the set of key phrases, wherein the reduction in perplexity is a ratio of conditional perplexity of the key phrase given the text to be classified, to the perplexity of the key phrase. Each of the log-likelihood based key phrase level features captures an increase in log-likelihood of the key phrase from the set of key phrases, wherein the increase in log-likelihood is a difference between conditional log-likelihood of the key phrase given the text to be classified, and log-likelihood of the key phrase.
Furthermore, the system is configured to determine, i) a class level perplexity based feature for each of the predefined class labels as a minimum of perplexity based key phrase level features associated with the corresponding class label, and ii) a class level log-likelihood based feature for each of the predefined class labels as maximum of log-likelihood based key phrase level features associated with the corresponding class label.
Further, the system is configured to predict for a zero shot classification, the one or more class labels for the text based on one of: i) value of perplexity based class level features lying below a minimum threshold value; and ii) value of log-likelihood based class level features lying above a maximum threshold value.
Furthermore, the system is configured to enhance an accuracy of prediction of text classification of the text into one or more class labels using a pretrained supervised machine learning classifier that utilizes the perplexity based key phrase level features, log-likelihood based key phrase level features, the class level perplexity based features, and the class level log-likelihood based features. The supervised machine learning classifier is trained on the perplexity based key phrase level features, log-likelihood based key phrase level features, the class level perplexity based features, and the class level log-likelihood based features obtained for a training data.
In yet another aspect, there are provided one or more non-transitory machine-readable information storage mediums comprising one or more instructions, which when executed by one or more hardware processors causes a method for text classification. The method includes receiving a text, predefined numbers of class labels, a set of key phrases associated with each of the predefined class labels, and a connector sentence, wherein the text is to be classified into one or more class labels from among predefined class labels.
Further, the method includes generating a plurality of label-specific augmentations for the text based on each key phrase among the set of key phrases associated with each of the predefined class labels, and the connector sentence.
Further, the method includes deriving via a Language Model (LM) executed by the one or more hardware processors, perplexity based key phrase level features and log-likelihood based key phrase level features for each of the plurality of label-specific augmentations. Each of the perplexity based key phrase level features captures a reduction in perplexity of a key phrase from the set of key phrases, wherein the reduction in perplexity is a ratio of conditional perplexity of the key phrase given the text to be classified, to the perplexity of the key phrase. Each of the log-likelihood based key phrase level features captures an increase in log-likelihood of the key phrase from the set of key phrases, wherein the increase in log-likelihood is a difference between conditional log-likelihood of the key phrase given the text to be classified, and log-likelihood of the key phrase.
Furthermore, the method includes determining, i) a class level perplexity based feature for each of the predefined class labels as a minimum of perplexity based key phrase level features associated with the corresponding class label, and ii) a class level log-likelihood based feature for each of the predefined class labels as maximum of log-likelihood based key phrase level features associated with the corresponding class label.
Further, the method includes predicting for a zero shot classification, the one or more class labels for the text based on one of: i) value of perplexity based class level features lying below a minimum threshold value; and ii) value of log-likelihood based class level features lying above a maximum threshold value.
Furthermore, the method includes enhancing an accuracy of prediction of text classification of the text into one or more class labels using a pretrained supervised machine learning classifier that utilizes the perplexity based key phrase level features, log-likelihood based key phrase level features, the class level perplexity based features, and the class level log-likelihood based features. The supervised machine learning classifier is trained on the perplexity based key phrase level features, log-likelihood based key phrase level features, the class level perplexity based features, and the class level log-likelihood based features obtained for a training data.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
The accompanying drawings, which are incorporated in and constitute a part of this disclosure, illustrate exemplary embodiments and, together with the description, serve to explain the disclosed principles:
It should be appreciated by those skilled in the art that any block diagrams herein represent conceptual views of illustrative systems and devices embodying the principles of the present subject matter. Similarly, it will be appreciated that any flow charts, flow diagrams, and the like represent various processes which may be substantially represented in computer readable medium and so executed by a computer or processor, whether or not such computer or processor is explicitly shown.
Exemplary embodiments are described with reference to the accompanying drawings. In the figures, the left-most digit(s) of a reference number identifies the figure in which the reference number first appears. Wherever convenient, the same reference numbers are used throughout the drawings to refer to the same or like parts. While examples and features of disclosed principles are described herein, modifications, adaptations, and other implementations are possible without departing from the scope of the disclosed embodiments.
While Language Models (LMs) enhance performance across various Natural Language Processing (NLP) tasks, prior research has revealed several challenges when applying them to text classification, such as designing appropriate prompts in zero-shot setting, limited input prompt length when using in-context learning, and costly as well as time consuming fine-tuning. Given these constraints, there is a line of research which explores ways using moderate-sized LMs for text classification. One of the recent prominent work in this area is by Min et al. (2022). They introduce “noisy channel” as well as “direct” methods which compute conditional probability of the input text given the label or vice versa, for few-shot text classification through in-context learning and prompt tuning.
Another work by Estienne (2023) wherein the authors propose to calibrate output probabilities of a LM through prior adaptation to perform text classification tasks. They propose two variations of their approach-unsupervised (UCPA) where no labelled data is needed and semi-unsupervised (SUCPA) where some training examples (600) are used for prior adaptation. Both Min et al. (2022) and Estienne (2023) are considered as Baseline approaches for performance of the method and system disclosed herein as they use moderate-sized LMs such as Generative pre-trained transformers (GPT2-XL).
A method and system disclosed herein, partially is based on similar approach of Min et.al. (2022) of computing conditional perplexity but there are several key differences such as (i) computing multiple features (perplexity (PPL) and (log-likelihood (LL)) using domain knowledge based key phrases, (ii) no limitation on number of training examples, and (iii) learning ML classifier based on these features.
Further, the technical limitations of moderate sized causal/autoregressive Language Models (LMs) mentioned in the background section are addressed by embodiments of the present disclosure. The central idea relied on is that generating new text using LMs is not absolutely essential for text classification as it is in case of other tasks such as summarization or machine translation, because the final goal is simply to discriminate among a finite set of class labels.
Embodiments of the method and system disclosed herein provides perplexity and log-likelihood based approach for text classification using causal or autoregressive Language Models (LMs). The method discloses a two-step technique for text classification. In the first step, for any text X to be classified, a set of feature values are elicited from the LM based on perplexity and log-likelihood of certain label-specific augmentations of X. These augmentations are of the form “X. This text is about (key phrase).” where only a set of key phrases associated with each class label is required. In a zero shot setting, only this first step is required, and a class label is predicted by a simple relative comparison of these feature values. In a supervised setting where labelled training instances are available, the second step is needed to train a light-weight supervised machine learning (ML) classifier using the feature values obtained for the training instances. The trained classifier can then be used to predict the class label for any new instance to be classified.
Even though LMs mostly discussed herein are moderate sized (#parameters≤2.7B) and open-source autoregressive language models for text classification, it can be understood that the method is equally applicable for Large LMs (LLMs). The system and method disclosed herein attempts to improve the accuracy of the moderate-sized LMs by using our technique with respect to standard zero-shot/few-shot prompting techniques using these LMs.
Mentioned below is the well-known concept of Perplexity and the way it has been used by the method disclosed herein. Also explained is the Log-likelihood function and the manner in which both perplexity and log-likelihood is used for text classification using causal LMs.
Perplexity: This is used in the art as a metric to evaluate language models. Intuitively, a better model of a text is the one which assigns a higher probability to a word that actually occurs. However, in the method disclosed herein, the perplexity is used for a different purpose; judging plausibility of a text fragment using an autoregressive or causal LM and comparing multiple such text fragments to decide which one is the most plausible. Here, by plausibility of a text, means it is seemingly more reasonable or probable.
Consider a text fragment X=[w1, w2, . . . ,wn], which consists of n tokens. The perplexity of X as computed by an LM (M) is as follows:
The conditional perplexity of a text fragment X given another text C=[c1, c2, . . . , cm] as its prefix, can be computed as:
Similarly, log-likelihood and conditional log-likelihood for any text X are computed as follows:
Overall, the lower the perplexity of X (or higher the log-likelihood of X), better is its plausibility.
Referring now to the drawings, and more particularly to
In an embodiment, the system 100 includes a processor(s) 104, communication interface device(s), alternatively referred as input/output (I/O) interface(s) 106, and one or more data storage devices or a memory 102 operatively coupled to the processor(s) 104. The system 100 with one or more hardware processors is configured to execute functions of one or more functional blocks of the system 100.
Referring to the components of system 100, in an embodiment, the processor(s) 104, can be one or more hardware processors 104. In an embodiment, the one or more hardware processors 104 can be implemented as one or more microprocessors, microcomputers, microcontrollers, digital signal processors, central processing units, state machines, logic circuitries, and/or any devices that manipulate signals based on operational instructions. Among other capabilities, the one or more hardware processors 104 are configured to fetch and execute computer-readable instructions stored in the memory 102. In an embodiment, the system 100 can be implemented in a variety of computing systems including laptop computers, notebooks, hand-held devices such as mobile phones, workstations, mainframe computers, servers, and the like.
The I/O interface(s) 106 can include a variety of software and hardware interfaces, for example, a web interface, a graphical user interface and the like and can facilitate multiple communications within a wide variety of networks N/W and protocol types, including wired networks, for example, LAN, cable, etc., and wireless networks, such as WLAN, cellular and the like. In an embodiment, the I/O interface(s) 106 can include one or more ports for connecting to a number of external devices or to another server or devices.
The memory 102 may include any computer-readable medium known in the art including, for example, volatile memory, such as static random access memory (SRAM) and dynamic random access memory (DRAM), and/or non-volatile memory, such as read only memory (ROM), erasable programmable ROM, flash memories, hard disks, optical disks, and magnetic tapes.
In an embodiment, the memory 102 includes a plurality of modules 110 such as the causal LM, also referred to as autoregressive LM or LM, the Machine Learning (ML) classifier and the like. Further, the memory can include the set of class labels and the set of key phrases associated with each class label. The plurality of modules 110 include programs or coded instructions that supplement applications or functions performed by the system 100 for executing different steps involved in the process of text classification, being performed by the system 100. The plurality of modules 110, amongst other things, can include routines, programs, objects, components, and data structures, which performs particular tasks or implement particular abstract data types. The plurality of modules 110 may also be used as, signal processor(s), node machine(s), logic circuitries, and/or any other device or component that manipulates signals based on operational instructions. Further, the plurality of modules 110 can be used by hardware, by computer-readable instructions executed by the one or more hardware processors 104, or by a combination thereof. The plurality of modules 110 can include various sub-modules (not shown).
Further, the memory 102 may comprise information pertaining to input(s)/output(s) of each step performed by the processor(s) 104 of the system 100 and methods of the present disclosure.
Further, the memory 102 includes a database 108. The database (or repository) 108 may include a plurality of abstracted pieces of code for refinement and data that is processed, received, or generated as a result of the execution of the plurality of modules in the module(s) 110. The received data can include the text that is received for classification, predefined class labels identified for text classification, a set of key phrases per class label and the like. The results include generated prompts comprising a plurality of label-specific augmentations for the text. The class label predicted for the received text and the like.
Although the data base 108 is shown internal to the system 100, it will be noted that, in alternate embodiments, the database 108 can also be implemented external to the system 100, and communicatively coupled to the system 100. The data contained within such an external database may be periodically updated. For example, new data may be added into the database (not shown in
The task of text classification is to assign one or more applicable class labels from a pre-defined set of labels L to a piece of text X. There have been several attempts to use autoregressive LMs for text classification where a response is generated from an LM by providing the text to be classified as part of a prompt. The method and system 100 herein hypothesizes that there is no need to generate new text using an LM for text classification as it is only needed to discriminate among a finite set of class labels. Hence, rather than asking an LM to generate some new text, it is enough to simply compare plausibility of a set of text fragments (label-specific augmentations as shown in Table 2), where each augmentation corresponds to a specific class label. In each label-specific augmentation, the text to be classified (X) is unbold font, the connector sentence(S) is shown in italics and the key phrases are shown in bold font. The fijPPL and fijIL feature values are computed using the Generative pre-trained transformers (GPT2-XL™) model. It can be understood that a different appropriate connector sentence is used for different datasets. Further, for any dataset any other connector sentence can also be used. But it should be fixed for all key phrases.
Text to be classified, X
Class labels with corresponding
key phrases:
Sports: sports, a sporting event,
Business: business, economy,
Science: science, space exploration,
For the example sentence in Table 2, it can be clearly seen that out of all the label-specific augmentations, the texts A21 and A22 look comparatively more plausible and hence the corresponding class label Business is the most appropriate. Here, it is expected expect that each class label is described by a set of key phrases based on the domain knowledge (examples in Table 2). There is no restriction on the number of key phrases to be used for each class, except that each class must have at least one key phrase which describes it. In absence of any domain knowledge, the class label itself can be used as one of the key phrases.
Explained now through mathematical model is how does the system 100 quantify the plausibility of these text fragments through multiple features in the PPL and LL based first step for identifying class label for the text, and then learn a suitable function which maps these feature values to the appropriate class label using the ML classifier using supervised learning.
Problem Setting: Input: (i) L={L1, . . . ,LC} (a set of C class labels), (ii) {Pi=pi1, pi2, . . . pini} (a set of ni key phrases for each class label Li∈L), (iii) X=[w1, w2, . . . ,wn] (text with n tokens to be classified), and (iv) M (an autoregressive LM)
Output: One or more class labels (⊂L) which are assigned to X
Training Regime: A small set of training instances where each instance is of the form (Xt, Lt) where Lt is a set of gold-standard labels for Xt such that Lt⊂L. Here at most 500 training instances across all the datasets are considered.
First step (PPL and LL based features): In this step, for each instance X (either text X to be classified or a training instance Xt), a set of feature values corresponding to each key phrase and class label are obtained from the LM M. For each class label Li, for its each key phrase pij, the following two feature values are obtained.
Here, the first feature capture reduction in perplexity of the key phrase pij and the second feature captures increase in its log-likelihood, when X is provided as part of its prefix.
To ensure a proper English sentence formation which links the key phrase to its prefix X, a connector sentence S of the form This news is about1. So, X+S forms the prefix context of a key phrase as shown in Table 2 above. The intuition is that if the key phrase pij is semantically related to the text X, the conditional perplexity PPLM(pij|X+S) when conditioned on X+S should be lower than PPLM(pij|S), which is only conditioned on S. Hence, the lower the fijPPL(X) value, higher the chance that the text is really about pij. Similarly, the higher the fijLL(X) value, higher the chance that the text is about pij. For the example sentence in Table 2, these feature values are shown for various key phrases. Also, the choice of a connector sentence does not have much effect on the final predictions because—(i) S is common across all the key phrases for a given dataset and (ii) S is conditioned upon in both the terms PPLM(pij|X+S) and PPLM(pij|S) (also LLM(pij|X+S) and LLM(pij|S)) and hence the effect of any specific S is cancelled. This is empirically observed in the experimental results depicted in
Intuitively, for each class, the best feature values across all its key phrases are stored as separate class-level features. Hence, overall for each instance, the number of features is equal to 2.
Zero-shot classification (ZS-PPL/ZS-LL): The above feature values computed for any text X are themselves enough to predict a class label in zero-shot manner. Here, the predicted class label is the one whose key phrase led to the minimum perplexity ratio or the maximum log-likelihood increase.
Although there is inter-dependence between perplexity and log-likelihood, both PPL and LL features are necessary. A detailed discussion is presented below:
As known, perplexity and log-likelihood are related as
where n is the number of tokens (word pieces) within p. This would imply that when the key phrases consist of exactly the same number of to kens (n), then exactly the same ordering of the feature values for both PPL and LL based features is obtained. This would in-turn lead to the same predictions by both Zero Shot (ZS)-PPL and ZS-LL. But in practice, the key phrases may contain different number of tokens, leading to different relative ordering of PPL and LL based features. When an example was studies, it was observed the first key phrase (having 2 tokens) has a better LL than the second key phrase (having 3 tokens) but vice versa in case of PPL. Hence, exploring both PPL and LL based features is important.
Second Step (supervised ML classifier): Learning a classifier. This step is needed only in the case of supervised setting where labelled training instances are available. In the above zero-shot classification rule (ZSPPL/ZSLL), a very simple function which maps the feature values to a class label is used, i.e., simply considering minimum or maximum over certain feature values. On the other hand, if training instances are available, a much more complex function which maps these feature values to a class label can be learned. Hence, in this step, the system 100 simply learns a supervised machine learning classifier using the feature values obtained for the training instances. This ML classifier can then be used to predict class labels for new unseen instances. Multiple light-weight classifiers are explored, and it is observed logistic regression (LR) and support vector machines (SVM) to be the best performing in both multi-class and multi-label (one-vs-all) settings.
Horizontal Scaling: The feature values are scaled for each instance such that minimum feature value is set to 0 and the maximum is set to 1. Such a scaling is performed separately for perplexity based features and log-likelihood based features. It can be noted that this is different from the usual min-max scaling where a fixed feature is scaled across multiple instances, whereas herein scaling of multiple features for a fixed instance is performed. Intuitively, the feature values are such that the relative values of these features compared to each other is important for determining the final class label.
Discussion on explainability: The predictions of the system 100 technique are explainable by design. For each predicted label, an explanation is generated in the form of a ranked list of key phrases (sorted using fijPPL or fijLL) associated with the predicted class (examples in Appendix Table 3).
In an embodiment, the system 100 comprises one or more data storage devices or the memory 102 operatively coupled to the processor(s) 104 and is configured to store instructions for execution of steps of the method 200 by the processor(s) or one or more hardware processors 104. The steps of the method 200 of the present disclosure will now be explained with reference to the components or blocks of the system 100 as depicted in
Referring to the steps of the method 200, at step 202 of the method 200, the one or more hardware processors 104 are configured by the instructions to receive a text (X), predefined numbers of class labels as (L), a set of key phrases (P) associated with each of the predefined class labels, and a connector sentence(S) as mathematically expressed and explained in conjunction with
Once X, L, P are received, at step 204 of the method 200, the one or more hardware processors 104 are configured by the instructions to generate a plurality of prompts, also referred to as a plurality of label-specific augmentations, for the text based on each key phrase among the set of key phrases associated with each of the predefined class labels, and the connector sentence as can be seen in Table 2.
At step 206 of the method 200, the one or more hardware processors 104 are configured by the instructions to derive via the LM (model M) executed by the one or more hardware processors 104, perplexity based key phrase level features and log-likelihood based key phrase level features for each of the plurality of label-specific augmentations. Each of the perplexity based key phrase level features captures a reduction in perplexity of a key phrase from the set of key phrases, wherein the reduction in perplexity is a ratio of conditional perplexity of the key phrase given the text to be classified, to the perplexity of the key phrase as in equation 5. Each of the log-likelihood based key phrase level features captures an increase in log-likelihood of the key phrase from the set of key phrases, wherein the increase in log-likelihood is a difference between conditional log-likelihood of the key phrase given the text to be classified, and log-likelihood of the key phrase as in equation 6.
Further, at step 208 of the method 200, the one or more hardware processors 104 are configured by the instructions to determine, i) a class level perplexity based feature for each of the predefined class labels as a minimum of the perplexity based key phrase level features associated with the corresponding class label as in equation 7, and ii) a class level log-likelihood based feature for each of the predefined class labels as maximum of log-likelihood based key phrase level features associated with the corresponding class label as in equation 8.
At step 210 of the method 200, the one or more hardware processors 104 are configured by the instructions to predict the one or more class labels for the text based on one of: i) value of class level perplexity based features lying below a minimum threshold value; and ii) value of class level log-likelihood based features lying above a maximum threshold value. Thus, step 210 enables predicting class labels based on zero shot (ZS-PPL/LL) classification. Theses PPL and LL feature values computed for any text X are themselves enough to predict the class label in zero-shot manner. If objective is to determine only single class label then here, the predicted class label is the one whose key phrase led to the minimum perplexity ratio or the maximum log-likelihood increase.
Further, if labelled training instances are available, then at step 212 of the method, a pretrained supervised machine learning classifiers trained on available labelled instances is used to enhance accuracy of prediction of text classification by using second step as explained in
Irrespective of whether single step (ZS) or two step ML classifier based approach is used, for each predicted class label of the text, an explanation is generated in the form of a ranked list of key phrases sorted using values of the perplexity based key phrase level features or the log-likelihood based key phrase level features.
Datasets: Five publicly available datasets with different properties are used. Broadly, the text classification task is of two types—(i) topical where the class labels roughly correspond to the topics being discussed in the text and (ii) non-topical where the class labels generally correspond to some semantic property of the text as a whole. Herein during experimentation, popular topical datasets—AGNews (Zhang et al., 2015) (4 classes) and DBPedia (Lehmann et al., 2015) (14 classes) are considered. Further, two popular non-topical datasets—SST-2 (Socher et al., 2013) which is a binary sentiment analysis dataset and TREC (Voorhees and Tice, 2000) where one of the 6 answer types are to be predicted for various questions are considered. In addition to these single-label datasets, also considered is a multi-label dataset Ethos (Mollas et. al., 2020) where the goal is to predict one or more hate types for a hate speech comment.
Table 4 below shows the set of key phrases used for each class in these datasets. The connector sentences used for the different datasets are as follows: SST2—This comment finds the movie to be, TREC—The answer will be, AGNews—This news is about, DBPedia—This text is about, and Ethos—This comment is about.
ZS-KP: As a variant of the vanilla zero-shot prompting approach, which guides the LM only based on the instruction for the task, a zero-shot with key phrases baseline is used. Along with the task instruction, the definition of the class label is included in terms of the key phrases which are used in the disclosed system 100 implementing the method 200. One sentence per class label is added to the prompt followed by the task instruction. E.g., to explain the AGNews' Sports class, the sentence ‘The Sports TOPIC news is about sports, a sporting event, sporting awards, a sports champion, a sportsperson, wins or losses in sports, or prize money.’ to the prompt (a similar example for SST2 is shown in Table 1.
ZS-KP-CoT: This is a variant of the above ZS-KP baseline which also includes a Chain-of-Thought (CoT) instruction to press the LM to arrive at the answer, reasoning through a step-by-step process. The instruction Let's think step-by-step is appended. as proposed in (Kojima et al., 2022) to the prompt in ZS-KP and parse the output to arrive at the predicted class label. The predictions are evaluated for both ZS-KP and ZS-KP-CoT leniently, where the prediction is considered to be correct even if the exact class name is not present in the generated text, but a corresponding key phrase is.
FS-ICL: As part of the few shot in-context learning (Brown et al., 2020) baseline, a set of k (=6) examples are randomly selected from the training data to build a prompt with the instruction and selected examples. Finally, the input test instance is appended to obtain the class label. In this FS-ICL baseline, the LMs considered were able to predict the exact class label and did not require any answer parsing as in the above zero-shot baselines.
CHT: A supervised baseline is also considered, where a classification head (CH) is tuned on top of the LM using the exact same labelled examples that are considered for training the ML classifier of the system 100 (at second step of classification). However, the layers of the LM are not allowed to get trained thereby keeping its inherent pre-training intact. This baseline gives the necessary comparison with the system 100 where labelled examples are used without fine-tuning the LM.
Results and Analysis: For all experiments, two moderate-sized autoregressive LMs—Generative pre-trained transformers (GPT-Neo-405 2.7B) (Black et al., 2021) and GPT2-XL (Radford et al., 2019) were considered. The focus of experiments was to compare multiple techniques of using the same model for text classification. For all datasets except Ethos, the accuracy is used as the evaluation metric, whereas for the multi-label Ethos dataset, micro-averaged F1-score across class labels is used. Table 5 shows the experimental results for the GPT-Neo-2.7B model. Here, the system 100 with —SVM and LR classifiers, outperforms all other baselines. Even the zero-shot technique ZS-PPL implemented by the system 100 outperforms the few-shot baseline for TREC, AGNews, DBPedia, and Ethos.
Table 6 below shows the experimental results for the GPT2-XL model. The reason for choosing this model for experiments was mainly to compare our results with Estienne (2023) which is the most relevant prior work as mentioned earlier. In the case of GPT2-XL model as well, system 100 outperforms all other baselines, including Estienne (2023). Again, the zero-shot techniques ZS-PPL and ZS-LL implemented by the system 100, outperform the few-shot baseline for AGNews, DBPedia and Ethos. ZS-PPL and ZS-LL also outperform the channel models of Min et al. (2022) in both zero-shot as well as few-shot settings. Experimentation was performed with another baseline CHT-BERT, a variant of CHT using an encoder-only model (bert-large-uncased). Though CHT-BERT outperforms CHT, the system 100 still proves to be better than this CHT-BERT baseline.
In table 6 Comparison of baselines and the system 100 for the GPT2-XL model. (†These numbers are using GPT2-Large model and the authors have observed similar performance for GPT2-XL making it comparable. *The baseline CHT-BERT is based on the encoder model bert-large-uncased.
Ablation Analysis: A detailed ablation analysis is carried out to quantify the contribution of each of the following—(i) horizontal scaling, (ii) perplexity-based (PPL) features, (iii) log-likelihood-based (LL) features, (iv) key phrase-level features, and (v) class-level features. Table 7 shows the ablation analysis results for the GPT2-XL model.
Horizontal scaling: This is clearly observed to be useful across all the datasets because the performance degrades without such scaling. Similarly, LL features and key phrase-level features are observed to be useful consistently across all the datasets. The class-level features are also similarly observed to be useful, though the decrease in accuracy is not prominent. On the other hand, mixed results are observed for the PPL features across multiple datasets for the GPT2-XL model.
Effect of number of key phrases: To measure the contribution of using multiple key phrases, two experiments were carried out. The first experiment evaluates the performance of the ML classifiers od the system 100 in the extreme case of using just one key phrase per class. The last rows for SVM and LR in Table 7 shows the accuracy numbers for all datasets in this case (used is the first key phrase for each class in Table 4). Even though there is a significant drop in accuracy as compared with the default setting, the accuracy is still better than the few-shot and CHT baselines for most of the datasets. The second experiment evaluates the effect of varying the number of key phrases used per class for the TREC dataset as shown in
Effect of number of training instances: The effect of varying the number of training instances is evaluated for the TREC dataset as it had the largest difference between the zero-shot and supervised (SVM/LR) accuracy.
Effect of different connector sentences: The effect of using multiple connector sentences is evaluated for TREC as shown in
USE CASE: Analysis of Financial Audit Reports: Financial audit is a complex process used by organizations to assure the stakeholders about the quality and trustworthiness of the governance (Whittington and Pany, 2021; Arens and Loebbecke, 1999). One important outcome of an audit is the audit report prepared by the auditors, wherein the auditor declares the Financial Statements of a company are free from material misstatement, are fair and accurate and are presented in accordance with the relevant accounting standards. A good comprehensive audit report is an important indicator of a good audit. Audit monitoring bodies such as ‘The Chartered Accountants (CA) Society of India’ have issued guidelines on the contents of audit reports, wherein they describe a set of audit aspects which the auditor should touch upon and describe. The problem of verifying whether an audit report has covered these audit aspects, can be modelled as a multi-class multi-label text classification problem where each sentence in the report can be labelled with zero or more audit aspects. A set of 15 audit aspects from standard auditing checklist (ICAI, 2017) and Companies (Auditor's Report) Order, 2020 (CARO) (ICAI, 2020), such as payables, inventory, and fixed assets is identified.
Audit Dataset: 3744 web-scraped audit reports made available by Maka et al. (2020) for the year 2014 are used. As getting gold-standard labelled examples was time and effort intensive, silver-standard training data (1097 sentences) were automatically obtained with the help of regular expression based patterns. These patterns were constructed using a set of key phrases obtained for each class by consulting domain experts. Same set of key phrases were used by system 100 for this classification problem.
Test dataset: For evaluating the classification performance, a set of 10 audit reports (1668 sentences) were labelled manually by domain experts.
Results: Table 8 shows the micro-averaged F1-scores on the test dataset, using GPT2-XL. Output is also compared with a ChatGPT baseline using zero-shot prompting and observe a comparable performance.
The general challenges for handling the Audit report use case is summarized below: A multi-label classification problem with no labelled sentences available is a challenging task. With the help of the system 100 implementing the method 200, build a classification system could be built quickly which—(i) captures domain knowledge about audit aspects in terms of multiple corresponding key phrases, (ii) can be deployed in-house with limited resources to avoid sharing the data outside the organization, (iii) provides some explanations with each predicted label, and (iv) achieves reasonable performance (comparable with zero-shot ChatGPT) with a moderate-sized open-source LM.
Thus the method 200 implemented by the system 100 discloses a two-step classification using moderate-sized (#params≤2.7B) autoregressive/causal Language Models (LM). In the first step, for a text instance to be classified, a set of perplexity and log-likelihood based features are obtained from an LM. A light-weight classifier (SVM or LR) is trained in the second step to predict the final label. The system enables a new way of exploiting the available labelled instances, in addition to the existing ways like fine-tuning LMs or in-context learning. It neither needs any parameter updates in LMs like fine-tuning nor it is restricted by the number of training examples to be provided in the prompt like in-context learning. The key advantages of the disclosed system are explainability through most suitable key phrases and its applicability in resource poor environment
The written description describes the subject matter herein to enable any person skilled in the art to make and use the embodiments. The scope of the subject matter embodiments is defined by the claims and may include other modifications that occur to those skilled in the art. Such other modifications are intended to be within the scope of the claims if they have similar elements that do not differ from the literal language of the claims or if they include equivalent elements with insubstantial differences from the literal language of the claims.
It is to be understood that the scope of the protection is extended to such a program and in addition to a computer-readable means having a message therein; such computer-readable storage means contain program-code means for implementation of one or more steps of the method, when the program runs on a server or mobile device or any suitable programmable device. The hardware device can be any kind of device which can be programmed including e.g. any kind of computer like a server or a personal computer, or the like, or any combination thereof. The device may also include means which could be e.g. hardware means like e.g. an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a combination of hardware and software means, e.g. an ASIC and an FPGA, or at least one microprocessor and at least one memory with software processing components located therein. Thus, the means can include both hardware means, and software means. The method embodiments described herein could be implemented in hardware and software. The device may also include software means. Alternatively, the embodiments may be implemented on different hardware devices, e.g. using a plurality of CPUs.
The embodiments herein can comprise hardware and software elements. The embodiments that are implemented in software include but are not limited to, firmware, resident software, microcode, etc. The functions performed by various components described herein may be implemented in other components or combinations of other components. For the purposes of this description, a computer-usable or computer readable medium can be any apparatus that can comprise, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
The illustrated steps are set out to explain the exemplary embodiments shown, and it should be anticipated that ongoing technological development will change the manner in which particular functions are performed. These examples are presented herein for purposes of illustration, and not limitation. Further, the boundaries of the functional building blocks have been arbitrarily defined herein for the convenience of the description. Alternative boundaries can be defined so long as the specified functions and relationships thereof are appropriately performed. Alternatives (including equivalents, extensions, variations, deviations, etc., of those described herein) will be apparent to persons skilled in the relevant art(s) based on the teachings contained herein. Such alternatives fall within the scope of the disclosed embodiments. Also, the words “comprising,” “having,” “containing,” and “including,” and other similar forms are intended to be equivalent in meaning and be open ended in that an item or items following any one of these words is not meant to be an exhaustive listing of such item or items or meant to be limited to only the listed item or items. It must also be noted that as used herein and in the appended claims, the singular forms “a,” “an,” and “the” include plural references unless the context clearly dictates otherwise.
Furthermore, one or more computer-readable storage media may be utilized in implementing embodiments consistent with the present disclosure. A computer-readable storage medium refers to any type of physical memory on which information or data readable by a processor may be stored. Thus, a computer-readable storage medium may store instructions for execution by one or more processors, including instructions for causing the processor(s) to perform steps or stages consistent with the embodiments described herein. The term “computer-readable medium” should be understood to include tangible items and exclude carrier waves and transient signals, i.e., be non-transitory. Examples include random access memory (RAM), read-only memory (ROM), volatile memory, nonvolatile memory, hard drives, CD ROMs, DVDs, flash drives, disks, and any other known physical storage media.
It is intended that the disclosure and examples be considered as exemplary only, with a true scope of disclosed embodiments being indicated by the following claims.
| Number | Date | Country | Kind |
|---|---|---|---|
| 202321086642 | Dec 2023 | IN | national |