Text classification methods, devices, systems, storage media, and products based on large language models
By receiving text and labels through a pre-trained large language model and constructing prompt words for text classification, this technology solves the problems of high cost and high threshold in existing technologies, achieving high-accuracy text classification with low cost and low threshold, and supporting lightweight JSON format and third-party application interfaces.
Patent Information
- Application Number
- CN202411684772.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2044-11-22
AI Technical Summary
Existing text classification methods are costly and have high operational barriers, making it difficult to achieve high-accuracy classification that is low-cost, has low operational barriers, and is more universal.
A pre-trained large language model is used to receive the text to be classified and the classification labels through the user interface of the text classification system. Prompt words are constructed to classify at different levels, and classification results in JSON format are generated. The text understanding ability of the pre-trained model is then used for classification.
It reduces the cost of text classification, provides a universal classification method with low barriers to entry, generates highly reliable results, supports lightweight JSON format for easy parsing and display, and provides an interface for third-party applications to call.
Smart Images

Figure CN119647408B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text classification technology, and in particular to a text classification method, apparatus, system, storage medium and product based on a large language model. Background Technology
[0002] In today's information age, with the explosive growth of information, people have raised diverse needs for processing text information, one of which is text classification. Text classification refers to the use of computer technology to automatically categorize text according to certain classification standards or systems, and it is an important foundation for data management technologies such as information mining and retrieval.
[0003] Currently, one approach to text classification is through graph neural network modeling, while another is through feature extraction. Both methods have limitations: the former requires specific model building and training, which is costly, while the latter requires complex pre-processing, resulting in a high barrier to entry.
[0004] Therefore, it is necessary to provide a solution to achieve a low-cost, low-barrier-to-operation, and more universal high-accuracy text classification method. Summary of the Invention
[0005] The main objective of this application is to provide a text classification method, apparatus, system, storage medium, and product based on a large language model, aiming to achieve a low-cost, low-operation-barrier, and more universal high-accuracy text classification method.
[0006] To achieve the above objectives, this application proposes a text classification method based on a large language model, applied to a text classification system. The method includes:
[0007] The text classification system receives user input or selection of text to be classified and classification labels through its user interface.
[0008] Based on the text to be classified and the classification label, prompt words are constructed, and a pre-trained large language model is called to classify the text at different levels to generate classification results.
[0009] In one embodiment, when the current classification method is a single-level multi-classification method, the classification labels are multiple parallel classification labels. The step of constructing prompt words based on the text to be classified and the classification labels, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results includes:
[0010] The text to be classified and each classification label are combined with the initial prompt words preset by the system to construct structured prompt words as input to the large language model, guiding the large language model to output the initial classification results in JSON format.
[0011] In one embodiment, before the step of constructing prompt words based on the text to be classified and the classification label, and calling a pre-trained large language model to classify the text to be classified at different levels and generate classification results, the method further includes:
[0012] The text classification system receives user-inputted or selected post-processed text through its user interface. The post-processed text includes further descriptions of some or all of the classification labels.
[0013] The method further includes:
[0014] The initial classification results, post-processing text, and system-preset post-processing prompts are integrated into new prompts.
[0015] The integrated new prompt words are used as input parameters to call the large language model, and the initial classification result is re-examined to obtain the final classification result.
[0016] In one embodiment, when the current classification method is a multi-level single classification method, the classification labels are multi-level classification labels in a tree structure. The step of constructing prompt words based on the text to be classified and the classification labels, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results includes:
[0017] All category labels of the first-level category are combined with the system's preset prompt words and used as input to the large language model to generate the first-level category result, which serves as the first-level category label. All category labels of the second-level category under the first-level category label are combined with the system's preset prompt words and used as input to the large language model to generate the second-level category result. This operation is repeated until leaf node category labels are generated.
[0018] In one embodiment, the next level category label in the multi-level category label is a component of the previous level category label, and the category labels at the same level are mutually exclusive.
[0019] In one embodiment, the method further includes:
[0020] The classification results were normalized using regular expressions to remove text that did not conform to the JSON format.
[0021] In one embodiment, the method further includes:
[0022] The classification results are displayed to the user, and / or an interface is provided on the text classification system for third-party applications to call.
[0023] In one embodiment, before the step of constructing prompt words based on the text to be classified and the classification label, and calling a pre-trained large language model to classify the text to be classified at different levels and generate classification results, the method further includes:
[0024] The system receives a text classification method selected by the user in the user interface, wherein the text classification method includes: single-level multi-classification and / or multi-level single-classification; and / or
[0025] Receive the pre-trained large language model selected by the user in the user interaction interface.
[0026] In one embodiment, the step of receiving user input or selection of the text to be classified and the classification label through the user interface of the text classification system further includes:
[0027] The text classification system includes different pre-trained large language models for users to choose from, and / or text classification prompts and / or post-processing prompts can be set in the text classification system.
[0028] This application also proposes a text classification device based on a large language model, the device comprising:
[0029] The receiving module is used to receive the text to be classified and the classification label input or selected by the user through the user interface of the text classification system.
[0030] The classification module is used to construct prompt words based on the text to be classified and the classification label, and call a pre-trained large language model to classify the text to be classified at different levels to generate classification results.
[0031] This application also proposes a text classification system based on a large language model, the system comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the text classification method based on a large language model as described above.
[0032] This application also proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the text classification method based on a large language model as described above.
[0033] This application also proposes a computer program product comprising a computer program that, when executed by a processor, implements the steps of the text classification method based on a large language model as described above.
[0034] The present application proposes one or more technical solutions, which have at least the following technical effects: It provides a text classification method, apparatus, system, storage medium, and product based on a large language model. Through a user interface of the text classification system, it receives user input or selection of text to be classified and classification labels; constructs prompt words based on the text to be classified and classification labels; and calls a pre-trained large language model to classify the text at different levels, generating classification results. Since the present application's technical solution uses a pre-trained large language model for classification, no specific training is required, thus reducing the cost of text classification. Moreover, the provided classification method is more general and has a lower barrier to entry; only classification criteria need to be provided to achieve text classification using prompt word engineering. Based on the large language model, the model has extremely strong text understanding capabilities, resulting in highly reliable generated results. Therefore, the present application's technical solution provides a low-cost, low-barrier-to-use text classification method based on a large language model, capable of achieving different levels of classification. Furthermore, since the text classification results are in a lightweight and easily parsed JSON format, the present application can not only intuitively display the classification results to users but also provide interfaces for third-party applications, expanding the application scenarios of text classification. Attached Figure Description
[0035] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0036] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a flowchart illustrating the first embodiment of the text classification method based on a large language model in this application.
[0038] Figure 2 This is a schematic diagram of the architecture of the text classification system involved in the embodiment of the text classification method based on a large language model in this application;
[0039] Figure 3 This is a flowchart illustrating the processing of a single-level multi-classification module involved in the text classification method based on a large language model in this application.
[0040] Figure 4 This is a flowchart illustrating the processing of the multi-level single-classification module involved in the text classification method based on a large language model in this application.
[0041] Figure 5This is a schematic diagram of the classification label structure of the multi-level single classification module involved in the text classification method based on the large language model of this application;
[0042] Figure 6 This is a flowchart illustrating the second embodiment of the text classification method based on a large language model in this application.
[0043] Figure 7 This is a flowchart illustrating the third embodiment of the text classification method based on a large language model in this application.
[0044] Figure 8 This is a schematic diagram of the module structure of the text classification device based on a large language model according to an embodiment of this application;
[0045] Figure 9 This is a schematic diagram of the system architecture of the hardware operating environment involved in the text classification method based on a large language model in the embodiments of this application.
[0046] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0047] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0048] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0049] The main solution of this application embodiment is as follows: Through the user interface of the text classification system, the system receives the text to be classified and the classification labels selected by the user; constructs prompt words based on the text to be classified and the classification labels; and calls a pre-trained large language model to classify the text to be classified at different levels, generating classification results. Since this application's technical solution uses a pre-trained large language model for classification, no specific training is required, thus reducing the cost of text classification; moreover, the provided classification method is more general and has a lower barrier to entry, requiring only the classification criteria to be provided to achieve text classification using prompt word engineering; based on the large language model, the model has extremely strong text understanding capabilities, resulting in highly reliable generated results. Therefore, this application's technical solution provides a low-cost, low-barrier-to-use text classification method based on a large language model, capable of achieving different levels of classification, and the text classification results are in a lightweight, easily parsed JSON format. Furthermore, in addition to visually displaying the classification results to the user, this application also provides an interface for third-party applications to call, expanding the application scenarios of text classification.
[0050] Current technologies include methods for text classification such as graph neural network modeling and feature extraction. However, these methods all have limitations. The former requires specific model building and training, which is costly, while the latter requires complex pre-processing, resulting in a high barrier to entry.
[0051] Therefore, this application provides a solution that enables a low-cost, low-barrier-to-operation, and more universal high-accuracy text classification method.
[0052] Based on this, embodiments of this application provide a text classification method based on a large language model, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the text classification method based on a large language model in this application.
[0053] In this embodiment, the text classification method based on a large language model includes steps S10 to S20. The following provides a detailed explanation of each step.
[0054] like Figure 1 As shown, the first embodiment of this application proposes a text classification method based on a large language model, the method comprising:
[0055] Step S10: Receive the text to be classified and the classification label selected by the user through the user interface of the text classification system.
[0056] The technical solution of this embodiment can realize a low-cost, low-operation-threshold, and more universal high-accuracy text classification method.
[0057] The executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, or server; or an electronic device or text classification system capable of performing the above functions. The following description uses a text classification system as an example to illustrate this embodiment.
[0058] like Figure 2 As shown, the architecture of the text classification system in this embodiment can include three modules: a user interface, a classification module, and a large language model, wherein:
[0059] The user interface is mainly used to provide users with the means to complete related operations, such as inputting the text to be classified, classification labels, post-processed text, as well as selecting classification methods and large language models.
[0060] The classification module has preset prompts and a classification process. Depending on the text classification method, the classification module can be divided into a single-level multi-classification module (i.e., a single-level multi-result classification module) and a multi-level single-classification module (i.e., a multi-level single-result classification module).
[0061] The large language model module is a pre-trained large language model that is used by the classification module to classify text and output the classification results.
[0062] Specifically, firstly, the system receives the text to be categorized and the category labels entered or selected by the user based on the user's actions on the user interface. Furthermore, it can also receive post-processing text entered or selected by the user, whereby the post-processing text includes further descriptions of some or all of the category labels.
[0063] The text to be classified can come from various platforms or data sources, such as data management platforms for information mining and retrieval, or various databases or other network platforms.
[0064] The classification labels can be pre-set and stored in the text classification system, or they can be customized by the user and input into the text classification system through the user interface.
[0065] As one implementation method, depending on the needs of text classification, the classification tags can conform to different classification methods. For example, for a single-level multi-classification method, the classification tags can be multiple parallel classification tags, and for a multi-level single-classification method, the classification tags can be multi-level classification tags in a tree structure.
[0066] For multi-level category labels, the next level category label is a component of the previous level category label, and category labels at the same level are mutually exclusive.
[0067] Step S20: Construct prompt words based on the text to be classified and the classification label, and call the pre-trained large language model to classify the text to be classified at different levels to generate classification results.
[0068] This embodiment can classify texts at different levels using a pre-trained large language model without requiring specific training, thus reducing the cost of text classification. Moreover, the provided text classification method is more general and has a lower barrier to entry; only the classification criteria need to be provided to achieve text classification using prompt word engineering. Based on the large language model, the model has extremely strong text understanding capabilities and generates highly reliable results.
[0069] The text classification system can pre-install different pre-trained large language models, text classification methods, classification labels, post-processing texts, etc. for users to choose from, and preset text classification prompts and post-processing prompts.
[0070] Among them, text classification prompts and post-processing prompts can be configured according to different fields or scenarios.
[0071] Large Language Models (LLMs) are artificial intelligence models with a large number of parameters. They are trained on massive amounts of data using deep learning algorithms to understand and generate natural language. These models can perform various language tasks, such as text generation, translation, question answering, and text summarization.
[0072] Prompts are the text input into these large models to guide them in generating specific outputs. Prompts can range from simple questions or instructions to more complex text containing multiple instructions or contextual information.
[0073] Combining large models with prompt words can create powerful interactive systems capable of understanding and responding to complex queries, providing personalized content, and even simulating domain-specific experts. For example, a well-designed prompt word can guide a language model to generate an article on a specific topic or answer a question from a specialized field. Therefore, combining large models with prompt words can improve model performance and the relevance of the output.
[0074] The pre-training corpus required for training large language models is a large-scale collection of text data used in the pre-training phase of large language models. It typically contains a wide range of text content from multiple domains and sources, suitable for training general-purpose base models. These corpora can be further subdivided into web page data, language text, book data, academic materials, code, parallel corpora, social media, and encyclopedias, etc.
[0075] In this embodiment, a pre-trained large language model is used in conjunction with text classification prompts and post-processing prompts to achieve effective text classification.
[0076] In this embodiment, the user can select a text classification method in the user interface, input the text to be classified, classification labels, post-processing text, and select a large language model to classify the text to be classified.
[0077] The text classification system constructs prompt words based on the user-inputted or selected text to be classified and the classification labels, and calls a large language model to generate classification results in JSON format.
[0078] Therefore, as one implementation, the step of constructing prompt words based on the text to be classified and the classification label, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results may further include:
[0079] The system receives the text classification method selected by the user in the user interface, wherein the text classification method includes: single-level multi-classification and / or multi-level single-classification; and / or
[0080] The system receives the pre-trained large language model selected by the user in the user interaction interface.
[0081] The above scheme enables the system to classify the text based on the user's selected text classification method, the input text to be classified, classification labels, post-processed text, and the selected large language model.
[0082] Furthermore, before the step of receiving the text to be classified and the classification label selected by the user through the user interface of the text classification system, the following may also be included:
[0083] The text classification system includes different pre-trained large language models for users to choose from, and / or text classification prompts and / or post-processing prompts can be set in the text classification system.
[0084] In this embodiment, the solution can classify the text to be classified at different levels. Specifically, it can include single-level multi-classification and multi-level single-classification.
[0085] As one implementation method, when the current classification method is a single-level multi-classification method, the classification labels are multiple parallel classification labels. The step of constructing prompt words based on the text to be classified and the classification labels, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results may include:
[0086] The text to be classified and each classification label are combined with the initial prompt words preset by the system to construct structured prompt words as input to the large language model, guiding the large language model to output the initial classification results in JSON format.
[0087] Furthermore, when the system receives post-processed text input or selected by the user through the user interface of the text classification system, the method further includes:
[0088] The initial classification results, post-processing text, and system-preset post-processing prompts are integrated into new prompts.
[0089] The integrated new prompt words are used as input parameters to call the large language model, and the initial classification result is re-examined to obtain the final classification result.
[0090] In other words, for unipolar multi-class classification, the text classification system constructs prompt words based on the above classification results and post-processed text, calls a large language model, and performs a back-check on the above classification results to generate classification results in JSON format. This allows for more accurate text classification. Furthermore, the text classification results are in a structured JSON format, providing users with an intuitive view while also offering API calls for third-party application developers to conveniently use the text classification results.
[0091] The aforementioned single-level multi-classification processing flow can be executed through the single-level multi-classification module.
[0092] Specifically, the processing flowchart of the single-level multi-classification module is as follows: Figure 3 As shown, single-level multi-classification refers to a single-level multi-classification module having multiple parallel classification labels. Each classification label is a classification target, and the final classification result is one or more classification labels. These classification labels in this text classification system consist of two elements: classification name and classification reason. The classification name is used to identify the classification result, and the classification reason serves as the classification basis for the large language model.
[0093] The processing flow of the single-level multi-classification module is as follows:
[0094] First, the single-level multi-classification module combines the user-input classification labels, the text to be classified, and the system's preset prompt words through prompt word engineering to construct structured prompt words as input to the large language model, guiding the large language model to output the initial classification results in JSON format.
[0095] Then, the single-level multi-classification module integrates the initial classification results, post-processing text, and system-preset post-processing prompts into new prompts. The post-processing text contains further descriptions of some or all of the classification labels. The single-level multi-classification module uses these new prompts as input parameters to call the large language model, which then performs a back-check on the initial classification results to obtain classification results with higher accuracy. Finally, the single-level multi-classification module uses regular expressions and other methods to standardize the classification results, removing any text that may not conform to the JSON format.
[0096] As another implementation, when the current classification method is a multi-level single classification method, the classification labels are multi-level classification labels in a tree structure. The step of constructing prompt words based on the text to be classified and the classification labels, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results may include:
[0097] All category labels of the first-level category are combined with the system's preset prompt words and used as input to the large language model to generate the first-level category result, which serves as the first-level category label. All category labels of the second-level category under the first-level category label are combined with the system's preset prompt words and used as input to the large language model to generate the second-level category result. This operation is repeated until leaf node category labels are generated.
[0098] In this multi-level classification label, the next level classification label is a component of the previous level classification label, and the classification labels at the same level are mutually exclusive.
[0099] The aforementioned multi-level single-classification processing flow can be executed through the multi-level single-classification module.
[0100] Specifically, the processing flowchart of the multi-level single-classification module can be as follows: Figure 4 As shown,
[0101] Among them, multi-level single classification means that the multi-level single classification module has a tree-structured classification label. The classification label structure of the multi-level single classification module can be as follows: Figure 5 As shown, each category label consists of a label name and a classification reason. The tree-structured category labels include category labels at different levels. Sub-category labels are components of their parent category labels. Category labels at the same level are mutually exclusive. The final classification result is the category label of a certain leaf node.
[0102] The processing flow of the multi-level single-classification module is as follows:
[0103] First, the multi-level single-classification module uses prompt word engineering to combine all the category labels of the first-level category with the system's preset prompt words, using this as input to the large language model to generate a first-level classification result, i.e., a first-level category label. Based on this, the multi-level single-classification module combines all the second-level category labels under the obtained first-level category label with the system's preset prompt words, using this as input to the large language model to generate second-level classification results. This process is repeated until leaf node category labels are generated. Finally, the multi-level single-classification module uses regular expressions and other methods to normalize the classification results, removing any text that may not conform to the JSON format.
[0104] This embodiment, through the above-described scheme, specifically through the user interface of the text classification system, receives the text to be classified and the classification labels selected by the user; constructs prompt words based on the text to be classified and the classification labels, and calls a pre-trained large language model to classify the text to be classified at different levels, generating classification results. Since this technical solution uses a pre-trained large language model for classification, no specific training is required, thus reducing the cost of text classification; moreover, the provided classification method is more general and has a lower barrier to entry, requiring only the classification criteria to achieve text classification using prompt word engineering; based on the large language model, the model has extremely strong text understanding capabilities, resulting in highly reliable generated results. Therefore, this technical solution provides a low-cost, low-barrier-to-use text classification method based on a large language model, capable of achieving different levels of classification. Furthermore, since the text classification results are in a lightweight and easily parsed JSON format, this application can not only intuitively display the classification results to the user but also provide an interface for third-party applications to call, expanding the application scenarios of text classification.
[0105] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 6 After step S20, the text classification method based on a large language model further includes step S30.
[0106] Step S30: Use regular expressions to normalize the classification results and remove text that does not conform to the JSON format.
[0107] JSON (JavaScript Object Notation) is a lightweight data-interchange format. It's a text-based data format used for transmitting data in web applications. It uses human-readable text to store and represent data objects, consisting of key-value pairs, similar to dictionaries or objects in programming languages. JSON data is easy for humans to read and write, and also easy for machines to parse and generate.
[0108] The advantages of JSON format are:
[0109] Easy to read and write: JSON has a concise and clear format, making it easy for humans to read and write.
[0110] Cross-platform: JSON is language-independent and can be parsed and generated by a variety of programming languages, including but not limited to JavaScript, Python, Java, C#, etc.
[0111] Lightweight: Compared to other data formats such as XML, JSON is lighter, which makes it more efficient in network transmission.
[0112] Easy to parse and generate: Most modern programming languages have ready-made libraries for parsing and generating JSON data, which makes processing JSON data very convenient.
[0113] Clear data structure: JSON's data structure (key-value pairs) clearly expresses the hierarchy and relationships of the data.
[0114] Supports data compression: JSON can be compressed, reducing storage space and network transmission time.
[0115] Flexibility: JSON allows the use of arrays and objects (key-value pairs) to build complex data structures, while providing good support for data types (such as strings, numbers, booleans, arrays, objects, and null).
[0116] Self-descriptive: The JSON data format is self-descriptive, which means that the structure and content of the data can be understood without external metadata.
[0117] Wide support: Due to its simplicity and practicality, JSON has been widely supported and used in web development and API design.
[0118] Easy to debug: Errors in JSON format are usually easy to identify and debug because of their simple and intuitive structure.
[0119] Scalability: JSON allows developers to define their own data structures, which makes it highly scalable when dealing with different data needs.
[0120] No need to declare element types: Unlike formats such as XML that require explicit declaration of element types, JSON does not require declaration of element types, which simplifies the process of creating and parsing data.
[0121] These advantages make JSON one of the preferred formats for data exchange in modern web applications.
[0122] In this embodiment, regular expressions are used to normalize the classification results and remove text that does not conform to the JSON format, which can further improve the accuracy of text classification. Moreover, since the text classification results are in a lightweight and easy-to-parse JSON format, this application can not only display the classification results to users intuitively, but also provide an interface for third-party applications to call, thus expanding the application scenarios of text classification.
[0123] This embodiment, through the above-described scheme, specifically through the user interface of the text classification system, receives the text to be classified and the classification labels selected by the user; constructs prompt words based on the text to be classified and the classification labels, and calls a pre-trained large language model to classify the text to be classified at different levels, generating classification results. Since this technical solution uses a pre-trained large language model for classification, no specific training is required, thus reducing the cost of text classification; moreover, the provided classification method is more general and has a lower barrier to entry, requiring only the classification criteria to achieve text classification using prompt word engineering; based on the large language model, the model has extremely strong text understanding capabilities, resulting in highly reliable generated results. Therefore, this technical solution provides a low-cost, low-barrier-to-use text classification method based on a large language model, capable of achieving different levels of classification. Furthermore, since the text classification results are in a lightweight and easily parsed JSON format, this application can not only intuitively display the classification results to the user but also provide an interface for third-party applications to call, expanding the application scenarios of text classification.
[0124] Based on the first or second embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to the first or second embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 7 In step S30, after normalizing the classification results using regular expressions and removing text that does not conform to the JSON format, the text classification method based on the large language model further includes step S40.
[0125] Step S40: Display the classification results to the user, and / or provide an interface on the text classification system for third-party applications to call.
[0126] The text classification system implemented in this embodiment can intuitively provide the classification results to users. Because the classification results are in a lightweight and easy-to-parse JSON format, the system can also provide an interface for third-party applications to call.
[0127] Compared with existing technologies, this embodiment, based on a pre-trained large language model, achieves a low-cost, low-barrier-to-operation, and more universal high-accuracy text classification method.
[0128] This embodiment of the technical solution receives user-inputted or selected text to be classified and classification labels through the user interface of the text classification system; constructs prompt words based on the text to be classified and classification labels, and calls a pre-trained large language model to classify the text to be classified at different levels, generating classification results. Since this technical solution uses a pre-trained large language model for classification, no specific training is required, thus reducing the cost of text classification; moreover, the provided classification method is more general and has a lower barrier to entry, requiring only the classification criteria to be provided to achieve text classification using prompt word engineering; based on the large language model, the model has extremely strong text understanding capabilities, resulting in highly reliable generated results. Therefore, this technical solution provides a low-cost, low-barrier-to-use text classification method based on a large language model, capable of achieving different levels of classification. Furthermore, since the text classification results are in a lightweight and easily parsed JSON format, this system can not only intuitively display the classification results to users but also provide interfaces for third-party applications, expanding the application scenarios of text classification.
[0129] Furthermore, embodiments of this application also propose a text classification device based on a large language model, such as... Figure 8 As shown, the device includes:
[0130] The receiving module 10 is used to receive the text to be classified and the classification label input or selected by the user through the user interaction interface of the text classification system.
[0131] The classification module 20 is used to construct prompt words based on the text to be classified and the classification label, and call a pre-trained large language model to classify the text to be classified at different levels to generate classification results.
[0132] The text classification device based on a large language model provided in this application employs the text classification method based on a large language model in the above embodiments, which can achieve a low-cost, low-operation-barrier, and more universal high-accuracy text classification method. Compared with the prior art, the beneficial effects of the text classification device based on a large language model provided in this application are the same as those of the text classification method based on a large language model provided in the above embodiments, and other technical features in the text classification device based on a large language model are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0133] Furthermore, to achieve the above objectives, this application also proposes a text classification system based on a large language model, the system comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the text classification method based on a large language model as described above.
[0134] The following is for reference. Figure 9This document illustrates a structural diagram suitable for implementing a text classification system based on a large language model, as described in the embodiments of this application. The text classification system based on a large language model in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 9 The text classification system based on a large language model shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0135] like Figure 9 As shown, a text classification system based on a large language model may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the text classification system based on the large language model. The processing device 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the large language model-based text classification system to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows a large language model-based text classification system with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented alternatively.
[0136] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0137] The text classification system based on a large language model provided in this application, employing the text classification method based on a large language model in the above embodiments, can achieve a low-cost, low-operation-barrier, and more universal high-accuracy text classification method. Compared with the prior art, the beneficial effects of the text classification system based on a large language model provided in this application are the same as those of the text classification method based on a large language model provided in the above embodiments, and other technical features of this text classification system based on a large language model are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0138] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0139] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the text classification method based on a large language model as described above.
[0140] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, 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, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0141] The aforementioned computer-readable storage medium may be included in a text classification system based on a large language model; or it may exist independently and not be assembled into a text classification system based on a large language model.
[0142] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by a text classification system based on a large language model, the text classification system based on a large language model: receives user input or selection of text to be classified and classification labels through the user interface of the text classification system; constructs prompt words based on the text to be classified and classification labels; and calls a pre-trained large language model to classify the text to be classified at different levels, generating classification results.
[0143] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0144] 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 this application. 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 the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can 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.
[0145] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0146] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described text classification method based on a large language model. This enables a low-cost, low-barrier-to-operation, and more universally applicable high-accuracy text classification method. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the text classification method based on a large language model provided in the above embodiments, and will not be repeated here.
[0147] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the text classification method based on a large language model as described above.
[0148] The computer program product provided in this application can realize a low-cost, low-operation-barrier, and more universal high-accuracy text classification method. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the text classification method based on a large language model provided in the above embodiments, and will not be repeated here.
[0149] The technical solutions proposed in this application, including one or more, have at least the following technical effects: Through the user interface of the text classification system, the system receives user-inputted or selected text to be classified and classification labels; constructs prompt words based on the text to be classified and classification labels, and calls a pre-trained large language model to classify the text to be classified at different levels, generating classification results. Since the technical solutions of this application use a pre-trained large language model for classification, no specific training is required, thus reducing the cost of text classification; moreover, the provided classification method is more general and has a lower barrier to entry, requiring only the classification criteria to be provided to achieve text classification using prompt word engineering; based on the large language model, the model has extremely strong text understanding capabilities, resulting in highly reliable generated results. Therefore, the technical solutions of this application provide a low-cost, low-barrier-to-use text classification method based on a large language model, capable of achieving different levels of classification. Furthermore, since the text classification results are in a lightweight and easily parsed JSON format, the system can not only intuitively display the classification results to users but also provide interfaces for third-party applications to call, expanding the application scenarios of text classification.
[0150] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A text classification method based on a large language model, characterized in that, The method, applied to a text classification system, includes: The text classification system receives user input or selection of text to be classified and classification labels through its user interface. Based on the text to be classified and the classification label, prompt words are constructed, and a pre-trained large language model is called to classify the text at different levels to generate classification results; When the current classification method is a multi-level single classification method, the classification labels are multi-level classification labels in a tree structure. The steps of constructing prompt words based on the text to be classified and the classification labels, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results include: All category labels of the first-level category are combined with the system's preset prompt words and used as input to the large language model to generate the first-level category result, which serves as the first-level category label. All category labels of the second-level category under the first-level category label are combined with the system's preset prompt words and used as input to the large language model to generate the second-level category result. This operation is repeated until leaf node category labels are generated.
2. The method as described in claim 1, characterized in that, When the current classification method is a single-level multi-classification method, the classification labels are multiple parallel classification labels. The steps of constructing prompt words based on the text to be classified and the classification labels, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results include: The text to be classified and each classification label are combined with the initial prompt words preset by the system to construct structured prompt words as input to the large language model, guiding the large language model to output the initial classification results in JSON format.
3. The method as described in claim 2, characterized in that, Before the step of constructing prompt words based on the text to be classified and the classification label, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results, the following steps are also included: The text classification system receives user-inputted or selected post-processed text through its user interface. The post-processed text includes further descriptions of some or all of the classification labels. The method further includes: The initial classification results, post-processing text, and system-preset post-processing prompts are integrated into new prompts. The integrated new prompt words are used as input parameters to call the large language model, and the initial classification result is re-examined to obtain the final classification result.
4. The method as described in claim 3, characterized in that, In the multi-level classification labels, the next level classification label is a component of the previous level classification label, and the classification labels at the same level are mutually exclusive.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: The classification results were normalized using regular expressions to remove text that did not conform to the JSON format.
6. The method according to any one of claims 1 to 4, characterized in that, The method further includes: The classification results are displayed to the user, and / or an interface is provided on the text classification system for third-party applications to call.
7. The method according to any one of claims 1 to 4, characterized in that, Before the step of constructing prompt words based on the text to be classified and the classification label, and calling a pre-trained large language model to classify the text to be classified at different levels to generate classification results, the following steps are also included: The system receives a text classification method selected by the user in the user interface, wherein the text classification method includes: single-level multi-classification and / or multi-level single-classification; and / or Receive the pre-trained large language model selected by the user in the user interaction interface.
8. The method according to any one of claims 1 to 4, characterized in that, Before the step of receiving user input or selection of text to be classified and classification labels through the user interface of the text classification system, the following steps are included: The text classification system includes different pre-trained large language models for users to choose from, and / or text classification prompts and / or post-processing prompts can be set in the text classification system.
9. A text classification device based on a large language model, characterized in that, The device includes: The receiving module is used to receive the text to be classified and the classification label input or selected by the user through the user interface of the text classification system. The classification module is used to construct prompt words based on the text to be classified and the classification label, and call a pre-trained large language model to classify the text to be classified at different levels and generate classification results; When the current classification method is a multi-level single classification method, the classification labels are multi-level classification labels in a tree structure. The classification module is also used to combine all the classification labels of the first-level category with the system's preset prompt words as input to the large language model to generate a first-level classification result as a first-level classification label. Then, it combines all the classification labels of the second-level category under the first-level classification label with the system's preset prompt words as input to the large language model to generate a second-level classification result. This operation is repeated until leaf node classification labels are generated.
10. A text classification system based on a large language model, characterized in that, The system includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the text classification method based on a large language model as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the text classification method based on a large language model as described in any one of claims 1 to 8.
12. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the text classification method based on a large language model as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Recognition method for improving complex and diverse data distribution based on conditional domain prompt learning
CN118196472A
Method for processing large-scale domain question annotation through large language model
CN118210919A