Large language model-based zero-labeled text hierarchical classification method, device and equipment
By designing prompts based on thought chains and utilizing multi-level labels and reasoning logic, the problem of dependence on labeled data in text classification by large language models is solved, and efficient hierarchical text classification under zero-label conditions is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 齐鲁空天信息研究院
- Filing Date
- 2025-06-09
- Publication Date
- 2026-04-24
AI Technical Summary
Traditional hierarchical classification methods require a large amount of labeled data for model pre-training and fine-tuning, which cannot adapt to changes in new labeling systems. Furthermore, large language models cannot directly apply their diversity understanding capabilities in text classification.
It adopts a thought chain-based prompt word design, which guides the large language model to perform hierarchical text classification by creating multi-level labels and inference logic prompt words, including text semantic compression and keyword extraction, adding example content constraints to the output, and providing a hierarchical classification correction mechanism.
It enables hierarchical text classification with zero labeled data, improving the classification accuracy and adaptability of large language models and reducing dependence on labeled data.
Smart Images

Figure CN120561309B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and text classification technology, specifically to a zero-labeled hierarchical text classification method, apparatus, and electronic device based on a large language model. Background Technology
[0002] Traditional hierarchical classification methods typically employ a pre-training-fine-tuning approach. The pre-training process utilizes self-supervised learning on large-scale unlabeled text data, while the fine-tuning process fixes some of the model's parameters determined during pre-training and updates these parameters using labeled event feedback text. The drawbacks of this method are the need for pre-training, the requirement for a large amount of labeled data during fine-tuning, and the inability of the trained model to adapt to new labeling systems. Changes in categories necessitate relabeling data and retraining the model.
[0003] Large Language Models (LLMs) also possess exceptional capabilities for text classification tasks. However, because LLMs have not been specifically trained for text classification applications, and because the text formats of their responses are diverse and generally cannot be used as usable labels, applying the superior text understanding capabilities of LLMs to text classification is a pressing issue that needs to be addressed. Summary of the Invention
[0004] In view of this, the present invention provides a method, apparatus and electronic device for zero-labeled text hierarchical classification based on a large language model.
[0005] According to a first aspect of the present invention, a zero-labeled text hierarchical classification method based on a large language model is provided, comprising: acquiring a text to be classified and preset multi-level labels, wherein the multi-level labels are used to indicate the category of the text to be classified at different text levels; creating a first-level label containing multi-level labels and a first-level prompt word containing inference logic, inputting the first-level prompt word and the text to be classified into a large language model, so that the large language model generates a first-level label classification result of the text to be classified according to the inference logic of the first-level prompt word; determining the next-level label corresponding to the first-level label based on the first-level label classification result, creating a next-level prompt word containing the next-level label and inference logic, and inputting it into the large language model, so that the large language model generates a next-level label classification result of the text to be classified; repeating the step of determining the next-level label classification result until the label classification results of the text to be classified at each level under the multi-level labels are obtained, wherein the prompt words corresponding to each level of label classification result contain the corresponding label and inference logic.
[0006] According to an embodiment of the present invention, creating a first-level label containing multi-level tags and a first-level prompt word for reasoning logic, and inputting the first-level prompt word and the text to be classified into a large language model includes: performing text semantic compression on the text to be classified to obtain a summary of the text to be classified; and inputting the first-level prompt word and the summary of the text to be classified into the large language model to obtain the first-level label classification result.
[0007] According to an embodiment of the present invention, performing text semantic compression on the text to be classified to obtain a summary of the text to be classified includes: creating summary prompt words containing first-level tags, inputting the summary prompt words and the text to be classified into a large language model, and enabling the large language model to extract useful information about each first-level tag of the text to be classified according to the classification prompt words, thereby obtaining a summary of the text to be classified.
[0008] According to an embodiment of the present invention, the reasoning logic of the prompt words corresponding to each level of label classification results includes a keyword extraction instruction. The keyword extraction instruction is used to guide the large language model to extract keywords related to the labels in the text to be classified, and to classify the text to be classified into the corresponding label category according to the keywords.
[0009] According to an embodiment of the present invention, the prompt words corresponding to each level of label classification result also include example content, which is used to constrain the output results of the large language model.
[0010] According to an embodiment of the present invention, each example content includes a question, a reasoning process, and an answer.
[0011] According to an embodiment of the present invention, the method further includes: during the process of obtaining the classification results of each level of labels sequentially, adding additional categories in addition to the multi-level labels to the prompt words corresponding to each level of label classification result; when the large language model classifies the text to be classified into the additional category, correcting the previous level label of the current level label, and then continuing the step of determining the classification results of the next level label.
[0012] According to an embodiment of the present invention, when the large language model classifies the text to be classified into an additional category, the correction of the parent label of the current level label includes: when the large language model classifies the text to be classified into an additional category, obtaining all other sibling labels that have not been classified in the current level label; creating correction prompt words containing all other sibling labels and reasoning logic, inputting the correction prompt words into the large language model to obtain the current level label result of the text to be classified; and correcting the corresponding parent label of the current level label according to the current level label result.
[0013] A second aspect of the present invention provides a zero-labeled text hierarchical classification device based on a large language model, comprising: an acquisition module for acquiring text to be classified and preset multi-level labels, wherein the multi-level labels indicate the categories of the text to be classified at different text levels; a first classification module for creating first-level labels containing multi-level labels and first-level prompt words with reasoning logic, inputting the first-level prompt words and the text to be classified into a large language model, thereby enabling the large language model to generate first-level label classification results for the text to be classified according to the reasoning logic of the first-level prompt words; a second classification module for determining the next-level labels corresponding to the first-level labels based on the first-level label classification results, creating next-level prompt words containing next-level labels and reasoning logic, and inputting them into the large language model, thereby enabling the large language model to generate next-level label classification results for the text to be classified; and a third classification module for repeating the step of determining the next-level label classification results until the label classification results of the text to be classified at each level under the multi-level labels are obtained, wherein the prompt words corresponding to each level of label classification result contain the corresponding labels and reasoning logic.
[0014] A third aspect of the present invention provides an electronic device, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the methods of any of the above embodiments.
[0015] According to embodiments of the present invention, the zero-labeled text hierarchical classification method, apparatus, and electronic device based on a large language model achieves hierarchical text classification without zero data labeling, compared to the pre-training-fine-tuning method, which requires a large amount of labeled data. Addressing the issue of the diversity of responses from large language models when directly using them for classification, the present invention designs prompt words based on the Chain of Thought (CoT), which can constrain the model's output, ensuring that the large language model's responses conform to the classification label system. Attached Figure Description
[0016] The above-described features, other objects, and advantages of the present invention will become clearer from the following description of embodiments of the invention with reference to the accompanying drawings, in which:
[0017] Figure 1 A flowchart illustrating a zero-labeled text hierarchical classification method based on a large language model according to an embodiment of the present invention is shown.
[0018] Figure 2 A schematic diagram illustrating a news hierarchy classification label according to an embodiment of the present invention is shown.
[0019] Figure 3 A flowchart illustrating a zero-labeled text hierarchical classification method based on a large language model according to yet another embodiment of the present invention is shown.
[0020] Figure 4 This schematic diagram illustrates the structural block diagram of a zero-labeled text hierarchical classification device based on a large language model according to an embodiment of the present invention.
[0021] Figure 5 The diagram illustrates an electronic device suitable for implementing a zero-labeled hierarchical text classification method based on a large language model, according to an embodiment of the present invention. Detailed Implementation
[0022] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the invention for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.
[0023] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0024] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0025] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0026] Figure 1 A flowchart illustrating a zero-labeled text hierarchical classification method based on a large language model according to an embodiment of the present invention is shown. Figure 2 The illustration shows a label diagram for news hierarchy classification according to an embodiment of the present invention.
[0027] like Figure 1As shown, the zero-labeled text hierarchical classification method based on a large language model in this embodiment includes operations S110 to S140. This invention does not specifically limit the version of the large language model; any mainstream large language model available on the market is acceptable.
[0028] In operation S110, the text to be classified and the preset multi-level labels are obtained. The multi-level labels are used to indicate the category of the text to be classified at different text levels.
[0029] The text to be categorized can be a sentence or a paragraph, a news article, or dialogue content; this invention does not impose specific limitations. Multi-level tags typically include at least two levels of tags, and the number of tag levels can be determined according to the categorization requirements; the more levels, the more detailed the categorization. A parent tag usually corresponds to one or more child tags.
[0030] like Figure 2 As shown, taking news categories as an example, the primary tags can include "Entertainment," "Sports," and "Technology." Sub-tags for "Entertainment" can include "Music" and "Movies," for "Sports" sub-tags can include "Football," "Basketball," and "Tennis," and for "Technology" sub-tags can include "Digital" and "Internet." In some cases, the sub-tags for "Music" can be further categorized (not shown in the figure), such as "Classical," "Folk," and "Rap." It should be noted that these tag categories can be added or removed according to actual classification needs; for example, the "Sports" tag can also include "Table Tennis." This invention does not limit the specific number of tag levels or tag content.
[0031] In operation S120, a first-level label containing multi-level labels and a first-level prompt word with reasoning logic are created. The first-level prompt word and the text to be classified are input into the large language model, so that the large language model generates the first-level label classification result of the text to be classified according to the reasoning logic of the first-level prompt word.
[0032] A first-level prompt word containing a first-level label can be created using instructions, with inference logic added within the instruction. The inference logic (or reasoning basis) refers to the intermediate reasoning process, which can include the problem's solution, intermediate reasoning steps, and any external knowledge related to the problem. In other words, the label prompt words are constructed based on a Chain of Thought (CoT) approach. A Chain of Thought is a method that allows a large language model to progressively output the reasoning process for complex problems. By constraining the output of the large language model through the Chain of Thought approach, the current-level classification label can be directly obtained. This process does not require data annotation.
[0033] In operation S130, based on the first-level label classification results, the next-level label corresponding to the first-level label is determined, a next-level prompt word containing the next-level label and reasoning logic is created, and input into the large language model, so that the large language model generates the next-level label classification results of the text to be classified.
[0034] Once the first-level tag is determined, you can find the next-level tag based on the multi-level tags. For example... Figure 2 As shown, for example, if the text to be classified can be categorized into the first-level tag "Entertainment," then the lower-level tags can include "Music" and "Movies." The process of determining the classification results of the lower-level tags is similar to the process of determining the classification results of the upper-level tags; it also uses thought chain-based prompts to guide the large language model to determine the tag classification results. This process does not require data annotation.
[0035] Understandably, when a multi-level tag system contains only two levels of tags, operations S110 to S130 described above are sufficient to classify all tags. When the multi-level tag system contains more than two levels of tags, such as four levels, operation S140 can be performed. In other words, in some cases, operation S140 can be omitted, depending on the number of tag levels to be classified.
[0036] In operation S140, the steps for determining the next level of label classification results are repeated until the label classification results of the text to be classified under the multi-level labels are obtained. Among them, the prompt words corresponding to each level of label classification result contain the corresponding labels and reasoning logic.
[0037] The process of determining third-, fourth-, and higher-level labels is the same as that of determining second-level labels, and so on, so it will not be repeated here. It is important to emphasize that thought-chain-based prompts are used to constrain the model's output during the determination of each label classification result. No data annotation is required throughout the entire process.
[0038] Through the above embodiments, compared to the pre-training-fine-tuning method which requires a large amount of labeled data, this invention achieves hierarchical text classification with zero data labeling. Addressing the issue of the diversity of responses from large language models when directly using them for classification, this invention designs thought chain-based prompt words that constrain the model's output, ensuring that the large language model's responses conform to the classification label system.
[0039] In some embodiments, the above operation S120, namely creating a first-level label containing multi-level labels and a first-level prompt word for reasoning logic, and inputting the first-level prompt word and the text to be classified into a large language model, may include: performing text semantic compression on the text to be classified to obtain a summary of the text to be classified; and inputting the first-level prompt word and the summary of the text to be classified into a large language model to obtain the first-level label classification result.
[0040] In this embodiment, text semantic compression is a process of refining the content of the original text to generate a summary that retains the core semantics. Then, the large language model determines the label categories based on the summary and the prompt words. In this way, when the text to be classified is long, the input length can be reduced, the processing efficiency of the large language model can be improved, and at the same time, the key classification features are retained, balancing the computational cost and the classification accuracy.
[0041] In some embodiments, text semantic compression of the text to be classified may specifically include: creating a summary prompt word containing first-level labels, inputting the summary prompt word and the text to be classified into the large language model, and enabling the large language model to extract useful information about each first-level label of the text to be classified according to the classification prompt of the summary prompt word, so as to obtain the summary of the text to be classified.
[0042] As an example, the prompt word of the large language model can be as follows: Extract the main content related to "XX", "XX", "XX" from the following text; <text>Text to be classified< / text>.
[0043] In the above example, "XX" can represent different label names, such as "Entertainment", "Sports", "Technology". Adding classification categories in the prompt word can help the large language model extract information beneficial to label classification, thereby improving the processing efficiency of the large language model.
[0044] In some embodiments, the inference logic of the prompt word corresponding to each level of label classification result in this article may include a keyword extraction instruction, which is used to guide the large language model to extract keywords related to the label in the text to be classified, and classify the text to be classified into the corresponding label category according to the keywords. That is to say, it can guide the large language model to perform two-step reasoning: first locate the keyword evidence, and then classify based on the evidence. By increasing the extraction of keywords, it helps to improve the accuracy of complex text classification of the large language model.
[0045] Furthermore, in some embodiments, the prompt word corresponding to each level of label classification result in this article may also include example content, which is used to constrain the output result of the large language model. An example refers to providing the large language model with the basic format of an input-output pair in a few-shot manner. Each example may include, for example: question, reasoning process, and answer.
[0046] Combining the above multiple embodiments, the prompting words based on the chain of thought provided in this article can include three parts: instructions, logical basis, and examples. Generally speaking, instructions can be used to describe the problem and inform the output format of the large language model. The logical basis refers to the intermediate reasoning process, which can include the solution to the problem, intermediate reasoning steps, and any external knowledge related to the problem. Examples refer to the basic format that provides input-output pairs for the large language model in a few-shot manner. By adding keyword extraction, it helps to improve the accuracy of complex text classification of the large language model; adding examples can constrain the output results of the large language model. The following gives a specific example of a prompting word:
[0047] <Instruction>You are a classifier, and you need to classify the text I give you into the categories: {"XX", "XX", "XX"} according to the requirements. First, you need to extract the keywords in this text that are helpful for category classification, and classify them into the correct category in combination with the keywords. The classification result is returned in json format.
[0048] < / Instruction>
[0049] <Example> Text content: ……
[0050] {
[0051] "Keywords": "xx, xx,xx",
[0052] "Classification result": "xx"
[0053] }< / Example>
[0054] <Text>Abstract< / Text>.
[0055] In some embodiments, the zero-annotation text hierarchical classification method provided by the present invention may further include: in the process of obtaining the classification results of each level of labels in sequence, adding additional categories outside the multi-level labels to the prompting words corresponding to the classification results of each level of labels. When the large language model classifies the text to be classified into the additional category, correct the upper-level label of the current-level label, and continue with the determination step of the classification result of the next-level label after correction.
[0056] The additional category can be different label fields outside the preset multi-level labels, for example, it can be indicated by the "other" category. Taking the additional category as the "other" category as an example, the prompting words for secondary label classification can be as follows:
[0057] <Instruction>You are a classifier, and you need to classify the text I give you into the categories: {"XX", "XX", "other"} according to the requirements. First, you need to extract the keywords in this text that are helpful for category classification, and classify them into the correct category in combination with the keywords. The classification result is returned in json format.
[0058] < / Instruction>
[0059] <Example> Text content: ……
[0060] {
[0061] "Keyword": "xx, xx, xx",
[0062] "Classification result": "xx"
[0063] }< / Example>
[0064] <Text>Abstract< / Text>
[0065] Input the above secondary label classification prompt words into the large language model. If the classification result is "Other" category, it indicates that there may be a classification error in the primary label and it cannot match the corresponding secondary label. Therefore, the upper-level label of the current-level label can be corrected. For each level of classification where there may be a classification error, the present invention designs a hierarchical classification correction mechanism. According to the new classification result of this level, the upper-level classification result is corrected, and the classification error is prevented from being transmitted to the next level.
[0066] Specifically, when the large language model classifies the text to be classified into an additional category, the correction of the upper-level label of the current-level label may include: when the large language model classifies the text to be classified into an additional category, obtain all other sibling labels in the current-level label that have not been classified; create a correction prompt word containing all other sibling labels and the inference logic, input the correction prompt word into the large language model to obtain the current-level label result of the text to be classified; according to the current-level label result, correct the corresponding upper-level label of the current-level label.
[0067] Continue with Figure 2 the news hierarchical classification label diagram shown as an example. For example, when the primary label is determined to be the "Sports" category, the secondary labels of the text to be classified should be attributable to the "Football", "Basketball", "Tennis" categories. After inputting the prompt word containing the secondary labels into the large language model and obtaining the classification result of the "Other" category, new secondary label prompt words can be created with secondary labels other than "Football", "Basketball", "Tennis", that is, "Music", "Movie", "Digital", "Internet", and input into the large language model. If the large language model inputs the label classification result of "Music", the primary label of the text to be classified can be corrected from "Sports" to "Entertainment".
[0068] Based on the above multiple embodiments, the present invention also provides a zero-annotation text hierarchical classification method based on a large language model. The following combines Figure 3 and oneSpecific example data will be provided for illustration. It should be noted that these example data are merely illustrative and do not constitute further limitations on the present invention.
[0069] Figure 3 A flowchart illustrating a zero-labeled text hierarchical classification method based on a large language model according to another embodiment of the present invention is shown.
[0070] like Figure 3 As shown, the zero-labeled text hierarchical classification method based on a large language model in this embodiment may include operations S310 to S390.
[0071] In operation S310, obtain the text to be classified and the labels for hierarchical classification.
[0072] When operating the S320, semantic compression is performed on the text to be classified. Based on the first-level labels of the hierarchical classification, large language model prompts can be designed to extract summaries of the text to be classified.
[0073] In operation S330, primary tag classification is performed. A large language model prompt word based on thought chains can be designed to perform primary tag classification on the text summary extracted in operation S320 and obtain the primary tags of the text.
[0074] In operation S340, the next-level tags are obtained and categorized. First, the next-level tags are obtained. Based on the categorization obtained in operation S330, the first-level tags are then retrieved, which are the corresponding next-level tags, i.e., the second-level tags. For example... Figure 2 As shown, the next-level tags corresponding to the "Sports" tag are: Football, Basketball, and Tennis. Additionally, an "Other" category can be added to this second-level tag. Based on the new second-level tags, a large language model prompt word based on thought chains can be designed to categorize the second-level tags.
[0075] A thought chain-based prompt can consist of three parts: instruction, logical basis, and example.
[0076] In operation S350, the classification result is processed to determine whether it belongs to the "Other" category. If operation S340 classifies the result as "Other", the hierarchical classification correction in operation S360 is performed; otherwise, operation S380 is performed.
[0077] When operating the S360, perform hierarchical classification correction. Obtain all secondary tags except the current secondary tag, design a large language model prompt word based on thought chain, obtain the secondary tags of the text, and correct the primary tags of the text.
[0078] In operation S370, determine the modified classification result for this level.
[0079] In operation S380, determine if there are any next-level labels. If there are next-level labels (such as third-level labels, fourth-level labels, etc.) for classification, repeat operations S340 to S370 until the final label classification result is obtained, i.e., operation S390.
[0080] Based on the aforementioned zero-labeled text hierarchical classification method based on a large language model, this invention also provides a zero-labeled text hierarchical classification device based on a large language model. The following will combine... Figure 4 The device is described in detail.
[0081] Figure 4 The diagram illustrates the structure of a zero-labeled text hierarchical classification device based on a large language model according to an embodiment of the present invention.
[0082] like Figure 4 As shown, the zero-labeled text hierarchical classification device 400 based on a large language model in this embodiment includes an acquisition module 410, a first classification module 420, a second classification module 430, and a third classification module 440.
[0083] The acquisition module 410 can be used to acquire the text to be classified and preset multi-level labels, whereby the multi-level labels indicate the category of the text to be classified at different text levels. In one embodiment, the acquisition module 410 can be used to perform the operation S110 described above, which will not be repeated here.
[0084] The first classification module 420 can be used to create first-level labels containing multi-level tags and first-level prompt words with reasoning logic. The first-level prompt words and the text to be classified are input into a large language model, which then generates the first-level label classification result of the text according to the reasoning logic of the first-level prompt words. In one embodiment, the first classification module 420 can be used to perform the operation S120 described above, which will not be repeated here.
[0085] The second classification module 430 can be used to determine the next-level label corresponding to the first-level label based on the classification result of the first-level label, create a next-level prompt word containing the next-level label and reasoning logic, and input it into the large language model so that the large language model generates the next-level label classification result of the text to be classified. In one embodiment, the second classification module 430 can be used to perform the operation S130 described above, which will not be repeated here.
[0086] The third classification module 440 can be used to repeat the steps of determining the next level of label classification results until the label classification results of the text to be classified under the multi-level labels are obtained. The prompt words corresponding to each level of label classification result contain the corresponding labels and reasoning logic. In one embodiment, the third classification module 440 can be used to perform the operation S140 described above, which will not be repeated here.
[0087] It should be emphasized that the third category module 440 only needs to be used when the multi-level tags exceed two levels. When the multi-level tags only have two levels, the third category module 440 can be removed or disabled.
[0088] In some embodiments, the first classification module 420 may further include a text semantic compression module (not shown in the figure). The text semantic compression module can be used to perform text semantic compression on the text to be classified, obtaining a summary of the text to be classified; the first-level prompt words and the summary of the text to be classified are then input into a large language model to obtain the first-level label classification result. In some embodiments, the text semantic compression module can also be used to create summary prompt words containing first-level labels, input the summary prompt words and the text to be classified into a large language model, so that the large language model extracts useful information about each first-level label from the text to be classified according to the classification prompts of the summary prompt words, thus obtaining a summary of the text to be classified.
[0089] In some embodiments, the zero-labeled text hierarchical classification device 400 may further include a hierarchical classification correction module (not shown in the figure). The hierarchical classification correction module can be used to add additional categories beyond the multi-level labels to the prompt words corresponding to each level of label classification result during the process of obtaining the classification results of each level of labels sequentially. When the large language model classifies the text to be classified into the additional category, the upper-level label of the current level label is corrected, and the step of determining the classification result of the next level label continues after the correction.
[0090] In some embodiments, the hierarchical classification correction module can also be used to obtain all other sibling labels that have not been classified in the current level label when the large language model classifies the text to be classified into an additional category; create correction prompt words containing all other sibling labels and reasoning logic; input the correction prompt words into the large language model to obtain the current level label result of the text to be classified; and correct the corresponding parent label of the current level label based on the current level label result.
[0091] For details regarding the relevant content, please refer to the previous text; it will not be repeated here.
[0092] According to embodiments of the present invention, any plurality of the above modules can be combined into one module, or any one of the modules can be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules can be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of the present invention, at least one of the above modules can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of software, hardware, and firmware methods, or in a suitable combination of any of these. Alternatively, at least one of the above modules can be at least partially implemented as a computer program module, which, when run, can perform corresponding functions.
[0093] Figure 5 The diagram illustrates an electronic device suitable for implementing a zero-labeled hierarchical text classification method based on a large language model, according to an embodiment of the present invention.
[0094] like Figure 5 As shown, an electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage portion 508 into a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0095] RAM 503 stores various programs and data required for the operation of electronic device 500. Processor 501, ROM 502, and RAM 503 are interconnected via bus 504. Processor 501 executes various operations of the method flow according to embodiments of the present invention by executing programs in ROM 502 and / or RAM 503. It should be noted that programs may also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 may also execute various operations of the method flow according to embodiments of the present invention by executing programs stored in one or more memories.
[0096] According to an embodiment of the present invention, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to a bus 504. The electronic device 500 may also include one or more of the following components connected to the input / output (I / O) interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 510 as needed so that computer programs read from it can be installed into the storage section 508 as needed.
[0097] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present invention.
[0098] According to embodiments of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of the present invention, the computer-readable storage medium may include ROM 502 and / or RAM 503 and / or one or more memories other than ROM 502 and RAM 503 described above.
[0099] Embodiments of the present invention also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the zero-labeled text hierarchical classification method based on a large language model provided in the embodiments of the present invention.
[0100] When the computer program is executed by the processor 501, it performs the functions defined in the system / apparatus of this invention. According to embodiments of the invention, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0101] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 509, and / or installed from a removable medium 511. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0102] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by processor 501, it performs the functions defined in the system of this embodiment of the invention. According to embodiments of the invention, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0103] According to embodiments of the present invention, program code for executing the computer programs provided in the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0104] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0105] Those skilled in the art will understand that the features described in the various embodiments of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments of the present invention can be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All such combinations and / or combinations fall within the scope of the present invention.
[0106] The embodiments of the present invention have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of the invention. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of the invention, and all such substitutions and modifications should fall within the scope of the invention.
Claims
1. A zero-labeled text hierarchical classification method based on a large language model, characterized in that, include: Obtain the text to be classified and preset multi-level labels, wherein the multi-level labels are used to indicate the category of the text to be classified at different text levels; Create a first-level label containing the multi-level labels and a first-level prompt word with reasoning logic. Input the first-level prompt word and the text to be classified into the large language model, so that the large language model generates the first-level label classification result of the text to be classified according to the reasoning logic of the first-level prompt word. Based on the first-level tag classification result, determine the next-level tag corresponding to the first-level tag, create a next-level prompt word containing the next-level tag and the reasoning logic, and input it into the large language model so that the large language model generates the next-level tag classification result of the text to be classified; Repeat the steps to determine the next level of label classification results until the label classification results of the text to be classified under the multi-level labels are obtained. The prompt words corresponding to each level of label classification result contain the corresponding labels and the reasoning logic. In the process of sequentially obtaining the classification results of the various levels of tags, an additional category other than the multi-level tags is added to the prompt words corresponding to each level of tag classification result. When the large language model classifies the text to be classified into the additional category, the parent tag of the current level tag is corrected, and the step of determining the classification result of the next level tag continues after the correction. The step of correcting the parent tag of the current level tag when the large language model classifies the text to be classified into the additional category includes: When the large language model classifies the text to be classified into the additional category, it obtains all other sibling tags in the current level that have not been classified. Create a correction prompt word containing all other sibling tags and the reasoning logic, input the correction prompt word into the large language model, and obtain the current level tag result of the text to be classified; Based on the current level tag result, correct the corresponding parent level tag of the current level tag.
2. The zero-label text hierarchical classification method according to claim 1, characterized in that, The step of creating a first-level label containing the multi-level labels and a first-level prompt word containing the reasoning logic, and inputting the first-level prompt word and the text to be classified into the large language model includes: The text to be classified is subjected to semantic compression to obtain a summary of the text to be classified; The first-level prompt words and the summary of the text to be classified are input into the large language model to obtain the first-level label classification result.
3. The zero-label text hierarchical classification method according to claim 2, characterized in that, The process of performing text semantic compression on the text to be classified to obtain a summary of the text to be classified includes: Create summary prompts containing the first-level tags, input the summary prompts and the text to be classified into the large language model, and enable the large language model to extract useful information about each of the first-level tags from the text to be classified according to the classification prompts of the summary prompts, so as to obtain a summary of the text to be classified.
4. The zero-label text hierarchical classification method according to claim 1, characterized in that, The reasoning logic for the prompt words corresponding to each level of label classification results includes keyword extraction instructions. These instructions guide the large language model to extract keywords related to the labels from the text to be classified and to classify the text into the corresponding label categories based on the keywords.
5. The zero-labeled text hierarchical classification method according to claim 1 or 4, characterized in that, Each level of label classification result includes prompt words with example content, which is used to constrain the output of the large language model.
6. The zero-label text hierarchical classification method according to claim 5, characterized in that, Each example content includes a question, reasoning process, and answer.
7. A zero-labeled text hierarchical classification device based on a large language model, characterized in that, include: The acquisition module is used to acquire the text to be classified and preset multi-level labels, wherein the multi-level labels are used to indicate the category of the text to be classified at different text levels; The first classification module is used to create a first-level label containing the multi-level labels and a first-level prompt word with reasoning logic. The first-level prompt word and the text to be classified are input into the large language model, so that the large language model generates the first-level label classification result of the text to be classified according to the reasoning logic of the first-level prompt word. The second classification module is used to determine the next-level label corresponding to the first-level label based on the classification result of the first-level label, create a next-level prompt word containing the next-level label and the reasoning logic, and input it into the large language model so that the large language model generates the next-level label classification result of the text to be classified. The third classification module is used to repeat the steps of determining the next level of label classification results until the label classification results of the text to be classified under the multi-level labels are obtained. The prompt words corresponding to each level of label classification result contain the corresponding labels and the reasoning logic. The hierarchical classification correction module is used to add additional categories beyond the multi-level labels to the prompt words corresponding to each level of label classification result during the process of obtaining the classification results of the various levels of labels sequentially. When the large language model classifies the text to be classified into the additional category, the parent label of the current level label is corrected, and the step of determining the classification result of the next level label continues after the correction. The step of correcting the parent label of the current level label when the large language model classifies the text to be classified into the additional category includes: When the large language model classifies the text to be classified into the additional category, it obtains all other sibling tags in the current level that have not been classified. Create a correction prompt word containing all other sibling tags and the reasoning logic, input the correction prompt word into the large language model, and obtain the current level tag result of the text to be classified; Based on the current level tag result, correct the corresponding parent level tag of the current level tag.
8. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method, system and server for hierarchically classifying long text network information
CN118535728A
Text classification method, device and system based on large language model, storage medium and product
CN119647408A