Text classification method, device and system based on large language model, storage medium and product
Through the text classification method based on large language model, the text classification is classified using pre-trained models, and the problems of high cost and high operation threshold in the existing technology are solved, low-cost and low-threshold high-accuracy text classification is achieved, and the application scenarios are expanded.
Patent Information
- Application Number
- CN202411684772.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-11-22
AI Technical Summary
The existing text classification methods have problems with high cost and high operating threshold, especially the need to targeted model construction and training models, or complex pre-operation is required.
The text classification method based on the large language model is adopted, and the text to be classified and the classification tags are received through the user interaction interface, the prompt words are constructed and the pre-trained large language model is called for classification at different levels, and the classification results are generated.
It realizes a high-accuracy text classification method with low cost, low operation threshold and more general, which reduces the cost of text classification, improves the universality and convenience of use of methods, and is convenient for display and third-party application calls because the results are in JSON format.
Smart Images

Figure CN119647408A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text classification, and in particular to a text classification method, device, system, storage medium and product based on a large language model. Background Art
[0002] In the current information age, various information is growing explosively, and people have put forward various requirements for the processing of text information, and text classification is one of them. Text classification refers to the use of computer technology to automatically classify text according to certain classification standards or systems. It is an important basis for data management related technologies such as information mining and retrieval.
[0003] At present, one method is to achieve text classification through graph neural network modeling, and another method is to achieve text classification through feature extraction. These text classification methods have certain limitations. The former requires targeted model construction and training, which is costly, and the latter requires more complex pre-operation, resulting in a high threshold for operation.
[0004] Therefore, it is necessary to provide a solution to achieve a low-cost, low-threshold and more universal high-accuracy text classification method. Summary of the invention
[0005] The main purpose of this application is to provide a text classification method, device, system, storage medium and product based on a large language model, aiming to achieve a low-cost, low-operation threshold and more general high-accuracy text classification method.
[0006] To achieve the above objectives, the present application proposes a text classification method based on a large language model, which is applied to a text classification system. The method includes:
[0007] Receiving 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;
[0008] A prompt word is constructed according to the text to be classified and the classification label, and a pre-trained large language model is called to classify the text to be classified at different levels to generate a classification result.
[0009] In one embodiment, when the current classification mode is a single-level multi-classification mode, the classification labels are multiple parallel classification labels, the steps of constructing prompt words according to 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, and generating classification results include:
[0010] The text to be classified and each classification label are combined with the initial prompt word preset by the system to construct a structured prompt word as the input of the large language model, and guide the large language model to output the initial classification result in JSON format.
[0011] In one embodiment, the step of constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating the classification result also includes:
[0012] Receiving post-processed text input or selected by a user through a user interaction interface of the text classification system, wherein the post-processed text includes a further description of part or all of the classification labels;
[0013] The method further comprises:
[0014] Integrate the initial classification result, the post-processing text and the post-processing prompt word preset by the system into a new prompt word;
[0015] The integrated new prompt word is used as an input parameter to call the large language model, and the initial classification result is back-checked to obtain a final classification result.
[0016] In one embodiment, when the current classification mode is a multi-level single classification mode, the classification label is a multi-level classification label in a tree structure, the steps of constructing prompt words according to 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 generating a classification result include:
[0017] Combine all the classification labels of the first-level classification with the system preset prompt words as the input of the large language model to generate a first-level classification result as the first-level classification label. Combine all the classification labels of the second-level classification under the first-level classification label with the system preset prompt words as the input of the large language model to generate a second-level classification result. Repeat this operation until a leaf node classification label is generated.
[0018] In one embodiment, the next level classification tags in the multi-level classification tags are components of the previous level classification tags, and the classification tags at the same level are mutually exclusive.
[0019] In one embodiment, the method further comprises:
[0020] The classification results are normalized using regular expressions to remove text that does not conform to the JSON format.
[0021] In one embodiment, the method further comprises:
[0022] The classification result is presented to the user, and / or an interface is provided on the text classification system for a third-party application to call.
[0023] In one embodiment, the step of constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating the classification result also includes:
[0024] receiving a text classification method selected by a user in the user interaction interface, the text classification method including: a single-level multi-classification method and / or a multi-level single-classification method; and / or
[0025] A pre-trained large language model selected by a user in the user interaction interface is received.
[0026] In one embodiment, before the step of receiving 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, the step further includes:
[0027] Different pre-trained large language models are built into the text classification system for users to choose from, and / or text classification prompt words and / or post-processing prompt words are set in the text classification system.
[0028] The present application also proposes a text classification device based on a large language model, the device comprising:
[0029] A receiving module, used for receiving 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;
[0030] The classification module is used to construct prompt words according to 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 a classification result.
[0031] The present 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 the large language model as described above.
[0032] The present application also proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the text classification method based on a large language model as described above are implemented.
[0033] The present application also proposes a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the text classification method based on a large language model as described above are implemented.
[0034] One or more technical solutions proposed in this application have at least the following technical effects: providing a text classification method, device, system, storage medium and product based on a large language model, receiving 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; constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels to generate classification results. Since the technical solution of this application adopts a pre-trained large language model for classification, no targeted training is required, thereby reducing the cost of text classification; and the classification method provided is more general and has a lower threshold for use. Only by providing a classification basis can the prompt word project be used to realize text classification; based on the large language model to classify the text, the model has a strong text understanding ability and the generated results are highly reliable. Therefore, the technical solution of this application provides a low-cost, low-threshold text classification method based on the large language model, which can realize classification at different levels. In addition, since the text classification result is in a lightweight, easy-to-parse JSON format, this application can not only intuitively display the classification results to the user, but also provide an interface for third-party application calls, expanding the application scenario of text classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0037] Figure 1 A flowchart diagram of the first embodiment of the text classification method based on a large language model of the present application;
[0038] Figure 2 This is a schematic diagram of the architecture of a text classification system involved in an embodiment of a text classification method based on a large language model of the present application;
[0039] Figure 3 This is a processing flow chart of a single-level multi-classification module involved in an embodiment of a text classification method based on a large language model of this application;
[0040] Figure 4 This is a processing flow chart of a multi-level single classification module involved in an embodiment of a text classification method based on a large language model of the present application;
[0041] Figure 5A schematic diagram of a classification label structure of a multi-level single classification module involved in an embodiment of a text classification method based on a large language model of the present application;
[0042] Figure 6 A flowchart diagram of the second embodiment of the text classification method based on a large language model of the present application;
[0043] Figure 7 A flowchart diagram of a third embodiment of a text classification method based on a large language model of the present application;
[0044] Figure 8 This is a schematic diagram of the module structure of a text classification device based on a large language model according to an embodiment of the present application;
[0045] Fig. 9 Schematic diagram of the system structure of the hardware operating environment involved in the text classification method based on a large language model in the embodiment of the present application.
[0046] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0048] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0049] The main solution of the embodiment of the present application is: through the user interaction interface of the text classification system, receiving the text to be classified and the classification label input or selected by the user; constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating classification results. Since the technical solution of the present application adopts the pre-trained large language model for classification, no targeted training is required, thereby reducing the cost of text classification; and the classification method provided is more general, and the threshold for use is low. Only the classification basis needs to be provided to realize text classification using the prompt word engineering; the text is classified based on the large language model, and the model has a strong text understanding ability, and the generated results are highly reliable. Therefore, the technical solution of the present application provides a low-cost, low-threshold text classification method based on the large language model, which can realize classification at different levels, and because the text classification result is in a lightweight, easy-to-parse JSON format. In addition, in addition to being able to intuitively display the classification results to the user, the present application can also provide an interface for third-party application calls, expanding the application scenarios of text classification.
[0050] Due to the existing technology, text classification is achieved through graph neural network modeling, and there are also methods of achieving text classification through feature extraction, etc. These text classification methods have certain limitations. The former requires targeted model construction and training, which is costly, and the latter requires more complex pre-operations, resulting in a high threshold for operation.
[0051] Therefore, the present application provides a solution that can realize a low-cost, low-operation threshold and more universal high-accuracy text classification method.
[0052] Based on this, the present application embodiment provides a text classification method based on a large language model. Figure 1 , Figure 1 This is a flowchart of the first embodiment of the text classification method based on a large language model of the present application.
[0053] In this embodiment, the text classification method based on the large language model includes steps S10 to S20, each of which is explained in detail below.
[0054] like Figure 1 As shown, the first embodiment of the present application proposes a text classification method based on a large language model, the method comprising:
[0055] Step S10, receiving 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;
[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 execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a terminal or server such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a text classification system, etc. The following takes the text classification system as an example to illustrate this embodiment.
[0058] like Figure 2 As shown, the architecture of the text classification system of this embodiment may include three modules, namely: a user interaction interface, a classification module, and a large language model, wherein:
[0059] The user interaction interface is mainly used to provide users with related operations, such as inputting the text to be classified, classification labels, post-processing text, selecting classification methods, selecting large language models, etc.
[0060] Classification module: prompt words are preset in this module, and the classification process is constructed. According to different text classification methods, 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] Large language model: This module is a pre-trained large language model, which is used for the classification module to call, classify the text, and output the classification results.
[0062] Specifically, first, the system receives the text to be classified and the classification label input or selected by the user according to the user's operation on the user interaction interface. Further, the system may also receive the post-processing text input or selected by the user, wherein the post-processing text includes a further description of part or all of the classification labels.
[0063] The text to be classified may come from a variety of platforms or data sources, for example, from data management platforms such as information mining and retrieval, or from various databases or other network platforms.
[0064] The classification labels may be pre-set by the text classification system and stored in the text classification system, or may be customized by the user and input into the text classification system through a user interaction interface.
[0065] As an implementation method, according to the needs of text classification, the classification label can conform to different classification methods. For example, corresponding to the single-level multi-classification method, the classification label can be multiple parallel classification labels; corresponding to the multi-level single classification method, the classification label can be a multi-level classification label with a tree structure.
[0066] For multi-level classification labels, the next-level classification labels are components of the previous-level classification labels, and the classification labels at the same level are mutually exclusive.
[0067] Step S20, constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels to generate a classification result.
[0068] This embodiment can classify the text to be classified at different levels through a pre-trained large language model without the need for targeted training, thereby reducing the cost of text classification. In addition, the text classification method provided is more general and has a lower threshold for use. Text classification can be achieved using prompt word engineering by only providing a classification basis. Text is classified based on a large language model, and the model has extremely strong text understanding capabilities and generates results with high reliability.
[0069] Among them, the text classification system can pre-build different pre-trained large language models, text classification methods, classification labels, post-processing texts, etc. for users to choose from, and preset text classification prompt words and post-processing prompt words.
[0070] Among them, text classification prompt words and post-processing prompt words can be configured according to different fields or scenarios.
[0071] Large Language Models, or LLMs for short, are artificial intelligence models with a large number of parameters that are trained on large amounts of data using deep learning algorithms to understand and generate natural language. These models can perform a variety of language tasks, such as text generation, translation, question answering, and text summarization.
[0072] Prompts are text input into these large models to guide the model to generate specific outputs. Prompts can be simple questions or instructions, or more complex text containing multiple instructions or contextual information.
[0073] Combining large models with prompts can create powerful interactive systems that can understand and respond to a variety of complex queries, provide personalized content, and even simulate experts in specific fields. For example, a well-designed prompt can guide a language model to generate an article on a specific topic or answer questions in a professional field. Therefore, combining large models with prompts can improve the performance of the model and the relevance of the output.
[0074] The pre-training corpus required in the large language model training process is a large-scale text data collection used in the pre-training stage of the large language model. It usually contains a wide range of text content from multiple fields and sources, and is suitable for training general basic models. These corpora can be further subdivided into web page data, language texts, book data, academic materials, codes, parallel corpora, social media, and encyclopedias.
[0075] In this embodiment, effective classification of text is achieved through the use of a pre-trained large language model combined with text classification prompt words and post-processing prompt words.
[0076] In this embodiment, the user can select a text classification method in the user interaction interface, input the text to be classified, the classification label, the 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 text to be classified and classification labels input or selected by the user and calls the large language model to generate classification results, which are in JSON format.
[0078] Therefore, as an implementation method, the step of constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating the classification result may also include:
[0079] The system receives a text classification method selected by the user in the user interaction interface, wherein the text classification method includes: a single-level multi-classification method and / or a multi-level single-classification method; and / or
[0080] The system receives a pre-trained large language model selected by a user in the user interaction interface.
[0081] Through the above scheme, the system can classify the text to be classified according to the text classification method selected by the user, the input text to be classified, the classification label, the 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 input or selected by the user through the user interaction interface of the text classification system, the following steps may be further included:
[0083] Different pre-trained large language models are built into the text classification system for users to choose from, and / or text classification prompt words and / or post-processing prompt words are set in the text classification system.
[0084] Among them, the scheme of this embodiment 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 an implementation mode, when the current classification mode is a single-level multi-classification mode, the classification labels are multiple parallel classification labels, the step of constructing prompt words according to 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, and generating classification results may include:
[0086] The text to be classified and each classification label are combined with the initial prompt word preset by the system to construct a structured prompt word as the input of the large language model, and guide the large language model to output the initial classification result in JSON format.
[0087] Furthermore, when the system receives the post-processed text input or selected by the user through the user interaction interface of the text classification system, the method further includes:
[0088] Integrate the initial classification result, the post-processing text and the post-processing prompt word preset by the system into a new prompt word;
[0089] The integrated new prompt word is used as an input parameter to call the large language model, and the initial classification result is back-checked to obtain a final classification result.
[0090] That is to say, for single-pole multi-classification, the text classification system constructs prompt words based on the above classification results and post-processed text and calls the large language model to check the above classification results and generate classification results in JSON format, so that the text classification can be more accurately achieved. Moreover, the text classification results are in structured JSON format, which provides users with intuitive viewing while also providing interface calls for third-party application developers to conveniently use the text classification results.
[0091] Among them, the above-mentioned single-level multi-classification processing flow can be executed by a single-level multi-classification module.
[0092] Specifically, the processing flow chart of the single-level multi-classification module is as follows: Figure 3 As shown, single-level multi-classification means that the single-level multi-classification module has multiple classification labels in parallel, 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 are composed of two elements: classification name and classification reason, among which the classification name is used to identify the classification result; the classification reason is used as the classification basis of 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 classification labels input by the user, the text to be classified and the system preset prompt words through prompt word engineering, constructs structured prompt words as the input of the large language model, and guides 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 the system-preset post-processing prompt words into new prompt words, where the post-processing text contains a further description of some or all classification labels. The single-level multi-classification module uses the integrated new prompt words as input parameters to call the large language model, and back-checks 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 normalize the classification results and remove text that may not conform to the JSON format.
[0096] As another implementation, when the current classification mode is a multi-level single classification mode, the classification label is a multi-level classification label in a tree structure, the step of constructing prompt words according to 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 generating a classification result may include:
[0097] Combine all the classification labels of the first-level classification with the system preset prompt words as the input of the large language model to generate a first-level classification result as the first-level classification label. Combine all the classification labels of the second-level classification under the first-level classification label with the system preset prompt words as the input of the large language model to generate a second-level classification result. Repeat this operation until a leaf node classification label is generated.
[0098] Among them, the next level classification label in the multi-level classification label is a component of the previous level classification label, and the classification labels at the same level are mutually exclusive.
[0099] Among them, the above-mentioned multi-level single classification processing flow can be executed by a multi-level single classification module.
[0100] Specifically, the processing flow chart of the multi-level single classification module can be as follows Figure 4 As shown,
[0101] Among them, the multi-level single classification, that is, the multi-level single classification module has a classification label with a tree structure. The classification label structure of the multi-level single classification module can be as follows Figure 5 As shown in the figure, each classification label consists of a label name and a classification reason. The classification labels in the tree structure include classification labels at different levels. The secondary classification labels are components of the upper-level classification labels. The classification labels at the same level are mutually exclusive. The final classification result is the classification label of a leaf node.
[0102] The processing flow of the multi-level single classification module is as follows:
[0103] First, the multi-level single classification module combines all the classification labels of the first-level classification with the system preset prompt words through the prompt word engineering, and uses them as the input of the large language model to generate the first-level classification results, that is, to obtain a first-level classification label. On this basis, the multi-level single classification module combines all the second-level classification labels under the first-level classification label with the system preset prompt words as the input of the large language model to generate the second-level classification results, and repeats this operation until the leaf node classification label is generated. Finally, the multi-level single classification module uses regular expressions and other methods to normalize the classification results and remove possible text that does not conform to the JSON format.
[0104] This embodiment, through the above scheme, specifically receives 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; constructs prompt words according to the text to be classified and the classification label, and calls the pre-trained large language model to classify the text to be classified at different levels to generate classification results. Since the technical solution of this application adopts the pre-trained large language model for classification, no targeted training is required, thereby reducing the cost of text classification; and the classification method provided is more general and has a low threshold for use. Only the classification basis needs to be provided to realize text classification using the prompt word engineering; the text is classified based on the large language model, and the model has a strong text understanding ability and the generated results are highly reliable. Therefore, the technical solution of this application provides a low-cost, low-threshold text classification method based on the large language model, which can realize classification at different levels. In addition, since the text classification result is in a lightweight, easy-to-parse JSON format, this application can not only intuitively display the classification results to the user, but also provide an interface for third-party application calls, expanding the application scenarios of text classification.
[0105] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can refer to the above introduction, and will not be repeated in the following. Figure 6 , after step S20, the text classification method based on the large language model further includes step S30.
[0106] Step S30, using regular expressions to normalize the classification results, and removing text that does not conform to the JSON format.
[0107] Among them, JSON (JavaScript Object Notation) is a lightweight data exchange format. The full name of JSON in Chinese is "JavaScript Object Notation". This is a text-based data format used to transmit data in network applications. It uses a human-readable text format to store and represent data objects, which are composed of key-value pairs, similar to dictionaries or objects in programming languages. Data in JSON format is easy for people to read and write, and it is 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 format that is easy for humans to read and write.
[0110] Cross-platform: JSON is independent of programming languages and can be parsed and generated by multiple 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 to parse and generate JSON data, which makes it very convenient to process JSON data.
[0113] Clear data structure: JSON's data structure (key-value pairs) clearly expresses the hierarchy and relationship of data.
[0114] Support data compression: JSON can be compressed to reduce storage space and network transmission time.
[0115] Flexibility: JSON allows complex data structures to be built using arrays and objects (key-value pairs), while having good support for data types (such as strings, numbers, Boolean values, arrays, objects, and null).
[0116] Self-describing: The JSON data format is self-describing, 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 is widely supported and used in web development and API design.
[0118] Easy to debug: Errors in the JSON format are usually easy to identify and debug because its structure is simple and intuitive.
[0119] Extensibility: JSON allows developers to define their own data structures, which makes it highly extensible when dealing with different data requirements.
[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] The above advantages make JSON one of the preferred formats for data exchange in modern network applications.
[0122] In this embodiment, the classification results are normalized using regular expressions to 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, easy-to-parse JSON format, in addition to intuitively displaying the classification results to users, this application can also provide an interface for third-party applications to call, expanding the application scenarios of text classification.
[0123] This embodiment, through the above scheme, specifically receives 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; constructs prompt words according to the text to be classified and the classification label, and calls the pre-trained large language model to classify the text to be classified at different levels to generate classification results. Since the technical solution of this application adopts the pre-trained large language model for classification, no targeted training is required, thereby reducing the cost of text classification; and the classification method provided is more general and has a low threshold for use. Only the classification basis needs to be provided to realize text classification using the prompt word engineering; the text is classified based on the large language model, and the model has a strong text understanding ability and the generated results are highly reliable. Therefore, the technical solution of this application provides a low-cost, low-threshold text classification method based on the large language model, which can realize classification at different levels. In addition, since the text classification result is in a lightweight, easy-to-parse JSON format, this application can not only intuitively display the classification results to the user, but also provide an interface for third-party application calls, expanding the application scenarios of text classification.
[0124] Based on the first or second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those of the first or second embodiment can refer to the above introduction, and will not be repeated later. Figure 7 In step S30, the classification result is normalized using a regular expression to remove text that does not conform to the JSON format. The text classification method based on the large language model also includes step S40.
[0125] Step S40: displaying the classification result to the user, and / or providing an interface on the text classification system for a third-party application to call.
[0126] The text classification implemented by the text classification system of this embodiment can intuitively provide classification results to users. Since the classification results are in a lightweight, easy-to-parse JSON format, the system can also provide an interface for third-party applications to call.
[0127] Compared with the prior art, this embodiment implements a low-cost, low-operation threshold and more universal high-accuracy text classification method based on a pre-trained large language model.
[0128] The technical solution of this embodiment receives 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; constructs prompt words according to the text to be classified and the classification label, and calls the pre-trained large language model to classify the text to be classified at different levels to generate classification results. Since the technical solution of this application adopts the pre-trained large language model for classification, no targeted training is required, thereby reducing the cost of text classification; and the classification method provided is more general and has a low threshold for use. Only the classification basis needs to be provided to realize text classification using the prompt word engineering; the text is classified based on the large language model, and the model has a strong text understanding ability and the generated results are highly reliable. Therefore, the technical solution of this application provides a low-cost, low-threshold text classification method based on the large language model, which can realize classification at different levels. In addition, since the text classification result is in a lightweight, easy-to-parse JSON format, the system of this application can not only intuitively display the classification results to the user, but also provide an interface for third-party application calls, expanding the application scenarios of text classification.
[0129] In addition, the present application also proposes a text classification device based on a large language model, such as Figure 8 As shown, the device comprises:
[0130] A receiving module 10, configured 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 according to 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 a classification result.
[0132] The text classification device based on a large language model provided by the present application adopts the text classification method based on a large language model in the above-mentioned embodiment, which can realize a low-cost, low-operation threshold 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 by the present application are the same as the beneficial effects of the text classification method based on a large language model provided by the above-mentioned embodiment, and the other technical features of the text classification device based on a large language model are the same as the features disclosed in the above-mentioned embodiment method, which will not be repeated here.
[0133] In addition, to achieve the above-mentioned purpose, the present 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] Reference below Fig. 9, which shows a schematic diagram of the structure of a text classification system based on a large language model suitable for implementing the embodiment of the present application. The text classification system based on a large language model in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The text classification system based on the large language model shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0135] like Fig. 9 As shown, the text classification system based on the large language model may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the text classification system based on the large language model are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the text classification system based on the large language model to communicate wirelessly or wired with other devices to exchange data. Although the text classification system based on the large language model with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.
[0136] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0137] The text classification system based on a large language model provided by the present application adopts the text classification method based on a large language model in the above-mentioned embodiment, which can realize a low-cost, low-operation threshold 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 by the present application are the same as the beneficial effects of the text classification method based on a large language model provided by the above-mentioned embodiment, and the other technical features of the text classification system based on a large language model are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0138] It should be understood that the various parts disclosed in this application can be implemented by 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 one or more embodiments or examples in a suitable manner.
[0139] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the text classification method based on the large language model as described above are implemented.
[0140] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. 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 combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0141] The computer-readable storage medium may be included in the text classification system based on the large language model; or may exist independently without being assembled into the text classification system based on the large language model.
[0142] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the text classification system based on the large language model, the text classification system based on the large language model: receives 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; constructs prompt words according to the text to be classified and the classification label, and calls the pre-trained large language model to classify the text to be classified at different levels to generate a classification result.
[0143] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0144] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0145] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0146] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned text classification method based on a large language model, and can realize a low-cost, low-operation threshold, and more universal 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 the beneficial effects of the text classification method based on a large language model provided in the above-mentioned embodiment, and will not be repeated here.
[0147] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the text classification method based on the large language model as described above.
[0148] The computer program product provided by this application can realize a low-cost, low-operation threshold and more universal high-accuracy text classification method. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the text classification method based on the large language model provided by the above embodiment, which will not be repeated here.
[0149] One or more technical solutions proposed in this application have at least the following technical effects: receiving 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; constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels to generate classification results. Since the technical solution of this application adopts the pre-trained large language model for classification, no targeted training is required, thereby reducing the cost of text classification; and the classification method provided is more general and has a lower threshold for use. Only the classification basis needs to be provided to realize text classification using the prompt word engineering; the text is classified based on the large language model, and the model has a strong text understanding ability and the generated results are highly reliable. Therefore, the technical solution of this application provides a low-cost, low-threshold text classification method based on the large language model, which can realize classification at different levels. In addition, since the text classification result is in a lightweight, easy-to-parse JSON format, the system of 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.
[0150] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A text classification method based on a large language model, characterized in that: Applied to a text classification system, the method comprises: Receiving 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; A prompt word is constructed according to the text to be classified and the classification label, and a pre-trained large language model is called to classify the text to be classified at different levels to generate a classification result.
2. The method according to claim 1, characterized in that When the current classification mode is a single-level multi-classification mode, the classification labels are multiple parallel classification labels, the steps of constructing prompt words according to the text to be classified and the classification labels, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating classification results include: The text to be classified and each classification label are combined with the initial prompt word preset by the system to construct a structured prompt word as the input of the large language model, and guide the large language model to output the initial classification result in JSON format.
3. The method according to claim 2, characterized in that The step of constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating the classification result also includes: Receiving post-processed text input or selected by a user through a user interaction interface of the text classification system, wherein the post-processed text includes a further description of part or all of the classification labels; The method further comprises: Integrate the initial classification result, the post-processing text and the post-processing prompt word preset by the system into a new prompt word; The integrated new prompt word is used as an input parameter to call the large language model, and the initial classification result is back-checked to obtain a final classification result.
4. The method according to claim 3, characterized in that When the current classification mode is a multi-level single classification mode, the classification label is a multi-level classification label in a tree structure, the steps of constructing prompt words according to 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 generating a classification result include: Combine all the classification labels of the first-level classification with the system preset prompt words as the input of the large language model to generate a first-level classification result as the first-level classification label. Combine all the classification labels of the second-level classification under the first-level classification label with the system preset prompt words as the input of the large language model to generate a second-level classification result. Repeat this operation until a leaf node classification label is generated.
5. The method according to claim 4, characterized in that The next level classification label in the multi-level classification label is a component of the previous level classification label, and the classification labels at the same level are mutually exclusive.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The classification results are normalized using regular expressions to remove text that does not conform to the JSON format.
7. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The classification result is presented to the user, and / or an interface is provided on the text classification system for a third-party application to call.
8. The method according to any one of claims 1 to 5, characterized in that The step of constructing prompt words according to the text to be classified and the classification label, and calling the pre-trained large language model to classify the text to be classified at different levels, and generating the classification result also includes: receiving a text classification method selected by a user in the user interaction interface, the text classification method including: a single-level multi-classification method and / or a multi-level single-classification method; and / or A pre-trained large language model selected by a user in the user interaction interface is received.
9. The method according to any one of claims 1 to 5, characterized in that Before the step of receiving 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, the following step is further included: Different pre-trained large language models are built into the text classification system for users to choose from, and / or text classification prompt words and / or post-processing prompt words are set in the text classification system.
10. A text classification device based on a large language model, characterized in that: The device comprises: A receiving module, used for receiving 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; The classification module is used to construct prompt words according to 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 a classification result.
11. A text classification system based on a large language model, characterized in that: The system comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is 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 9.
12. 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 9.
13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the text classification method based on a large language model as claimed in any one of claims 1 to 9 are implemented.
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
Short text classification method and device, storage medium and computing equipment
CN118277846A
Large language model cue word injection attack detection method and device based on context learning
CN118734314A
Method and apparatus for function with text
KR1020150097962A
Cited By
Hierarchical tag generation method and device, electronic equipment and storage medium
CN120319243A
Hierarchical label generation method, device, electronic device and storage medium
CN120319243B
Hierarchical text classification method and device based on hybrid experts
CN120541225A
Zero-annotation text hierarchical classification method, device and equipment based on large language model
CN120561309A
Large language model-based zero-labeled text hierarchical classification method, device and equipment
CN120561309B