CN116662547A - Text classification method, device, system and medium - Google Patents

Text classification method, device, system and medium Download PDF

Info

Publication number
CN116662547A
CN116662547A CN202310683287.1A CN202310683287A CN116662547A CN 116662547 A CN116662547 A CN 116662547A CN 202310683287 A CN202310683287 A CN 202310683287A CN 116662547 A CN116662547 A CN 116662547A
Authority
CN
China
Prior art keywords
text
prompt
mask
template
training
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310683287.1A
Other languages
Chinese (zh)
Inventor
詹乐
陈鑫
陈明忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202310683287.1A priority Critical patent/CN116662547A/en
Publication of CN116662547A publication Critical patent/CN116662547A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/02Knowledge representation; Symbolic representation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a text classification method, a device, a system and a medium, wherein the method comprises the following steps: collecting original text data, and constructing a training sample fused with knowledge data and a prompt template according to the original text data, wherein the training sample comprises mask text; inputting the training sample into a pre-constructed prompt learning model for training until the model converges, wherein the prompt learning model predicts the mask text; inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized; and performing text type mapping according to the target mask text, and determining the target text type of the text to be identified. The training samples fused with the knowledge data and the prompt templates are used for prompt learning training so as to complete text classification tasks, enrich text context information, enhance text classification effect and effectively improve text classification accuracy.

Description

Text classification method, device, system and medium
Technical Field
The present invention relates to the technical field of financial science and technology, and in particular, to a text classification method, apparatus, system, and medium.
Background
Currently, the financial industry has a great deal of hugging artificial intelligence technology because of its natural scene adaptation and data richness, wherein text classification is an important branch field in artificial intelligence, and is widely used in various financial scenes. For example, in an intelligent customer service scene of a bank, the user intention can be identified through a text classification technology, and corresponding questions or answers are pushed to the user; in a content pushing scene of banking software, news content can be identified and classified to realize personalized content pushing and the like.
The conventional classification method mainly uses machine learning to extract information such as topics, intentions, keywords, etc. of text, and then classifies the information. The method is fast but not accurate enough, long texts with complex intention are difficult to distinguish, the accuracy of text classification results is reduced, and the application effect of text classification in intelligent customer service or content pushing and other scenes is further affected.
Disclosure of Invention
In view of the foregoing deficiencies of the prior art, it is therefore an object of the present invention to provide a method, apparatus, system and medium for text classification applicable to financial technology or other related fields, for improving the accuracy of text classification.
The technical scheme of the invention is as follows:
a text classification method, comprising:
collecting original text data, and constructing a training sample fused with knowledge data and a prompt template according to the original text data, wherein the training sample comprises mask text;
inputting the training sample into a pre-constructed prompt learning model for training until the model converges, wherein the prompt learning model predicts the mask text;
inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized;
and performing text type mapping according to the target mask text, and determining the target text type of the text to be identified.
In one embodiment, the collecting the original text data, constructing a training sample with knowledge data and a prompt template fused according to the original text data, where the training sample includes mask text, and the method includes:
collecting original text data, carrying out knowledge extraction on the original text data, and carrying out classification labeling according to a knowledge extraction result to obtain a training text;
acquiring a preset prompt template, and generating a prompt training template containing mask text according to the original text data and the prompt template;
and adding the training texts and the prompt training templates in one-to-one correspondence, and constructing to obtain the training samples.
In one embodiment, the collecting the original text data, performing knowledge extraction on the original text data, and performing classification labeling according to the knowledge extraction result to obtain training text, including:
collecting original text data, and extracting knowledge entities and/or entity relations in the original text data;
matching the knowledge entity and/or entity relation with a knowledge dictionary of a preset text type;
and classifying and labeling the original text data according to the matching result to obtain a training text.
In one embodiment, the training text is obtained after classifying and labeling the original text data according to the matching result, which specifically includes:
and marking the preset text type corresponding to the successfully matched knowledge dictionary as 1, and marking the preset text type corresponding to the unsuccessfully matched knowledge dictionary as 0.
In one embodiment, the step of obtaining the preset prompt template, generating a prompt training template including mask text according to the original text data and the prompt template, includes:
acquiring a preset prompting template, wherein the prompting template comprises a mask position;
and splicing the original text data with the prompt template, marking the mask position according to the text type of the original text data, and filling mask text into the mask position to generate the prompt training template.
In one embodiment, the inputting the to-be-recognized prompt template constructed based on the to-be-recognized text into the prompt learning model predicts the target mask text in the to-be-recognized prompt template, including:
acquiring a text to be recognized, and generating a prompt template to be recognized according to the text to be recognized and the prompt template, wherein the prompt template to be recognized comprises a target mask position;
and inputting the prompt template to be identified into the prompt learning model, and predicting to obtain the target mask text at the target mask position.
In one embodiment, the text type mapping according to the target mask text, and determining the target text type of the text to be identified includes:
matching the target mask text with a preset mask prompt dictionary, and determining a target mask prompt dictionary matched with the target mask text;
and determining the target text type corresponding to the target mask prompt dictionary according to the mapping relation between the mask prompt dictionary and the preset text type.
A text classification device, comprising:
the system comprises a sample construction module, a training module and a prompt module, wherein the sample construction module is used for acquiring original text data, constructing a training sample fused with knowledge data and a prompt template according to the original text data, and the training sample comprises mask text;
the model training module is used for inputting the training sample into a pre-constructed prompt learning model to train until the model converges, and the prompt learning model predicts the mask text;
the mask prediction module is used for inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized;
and the mapping classification module is used for mapping the text types according to the target mask text and determining the target text types of the texts to be identified.
A text classification system, the system comprising at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the text classification method described above.
A non-transitory computer-readable storage medium storing computer-executable instructions that, when executed by one or more processors, cause the one or more processors to perform the text classification method described above.
The beneficial effects are that: compared with the prior art, the embodiment of the invention carries out prompt learning training through the training sample fused with knowledge data and the prompt template to complete the text classification task, enrich the context information of the text, enhance the text classification effect and effectively improve the accuracy of text classification.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a flowchart of a text classification method according to an embodiment of the present invention;
fig. 2 is a flowchart of step S100 in the text classification method according to the embodiment of the present invention;
fig. 3 is a flowchart of step S101 in the text classification method according to the embodiment of the present invention;
fig. 4 is a flowchart of step S102 in the text classification method according to the embodiment of the present invention;
fig. 5 is a flowchart of step S300 in the text classification method according to the embodiment of the present invention;
fig. 6 is a flowchart of step S400 in the text classification method according to the embodiment of the present invention;
fig. 7 is a schematic diagram of a functional module of a text classification device according to an embodiment of the present invention;
fig. 8 is a schematic hardware structure of a text classification system according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail below in order to make the objects, technical solutions and effects of the present invention more clear and distinct. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. Embodiments of the present invention are described below with reference to the accompanying drawings.
Currently, the financial industry has a great deal of hugging artificial intelligence technology because of its natural scene adaptation and data richness, wherein text classification is an important branch field in artificial intelligence, and is widely used in various financial scenes. For example, in an intelligent customer service scene of a bank, the user intention can be identified through a text classification technology, and corresponding questions or answers are pushed to the user; in a content pushing scene of banking software, news content can be identified and classified to realize personalized content pushing and the like.
The conventional classification method mainly uses machine learning to extract information such as topics, intentions, keywords, etc. of text, and then classifies the information. The method is fast but not accurate enough, long texts with complex intention are difficult to distinguish, the accuracy of text classification results is reduced, and the application effect of text classification in intelligent customer service or content pushing and other scenes is further affected.
In order to solve the above-mentioned problems, the present invention provides a text classification method, please refer to fig. 1, and fig. 1 is a flowchart of an embodiment of the text classification method provided by the present invention. The text classification method provided in the present embodiment is applied to a system including a terminal device, a network and a server, wherein the network is a medium for providing a communication link between the terminal device and the server, and may include various connection types, such as a wired, wireless communication link, or an optical fiber cable, etc.; the operating system on the terminal device may include a handheld device operating system (iPhone operating system, iOS system), an android system, or other operating system, and the terminal device is connected to the server through a network to implement interaction, so as to perform operations of receiving or sending data, and may specifically be various electronic devices that have a display screen and support web browsing, including but not limited to smartphones, tablet computers, portable computers, desktop servers, and the like. As shown in fig. 1, the method specifically includes the following steps:
s100, acquiring original text data, and constructing a training sample fused with knowledge data and a prompt template according to the original text data, wherein the training sample comprises mask text.
In this embodiment, the collection manner of the original text data may be collected from a designated text database, or from historical data in an application scenario, for example, from historical communication data of a customer service system, etc. The training sample fused with the knowledge data and the prompt template is obtained by collecting the original text data and constructing the sample, the subsequent model training is carried out, and the text classification effect is enhanced by adding the rich knowledge data and the flexible prompt template into the training sample.
The constructed training samples comprise masking texts, namely, words with one or more positions are masked in each training sample, the masking texts can convert a text classification task at the downstream into a masking prediction task at the pre-training stage, the method is suitable for text classification scenes with high labeling cost and fewer labeling samples, labeling work is reduced, and training efficiency is improved.
In one embodiment, as shown in fig. 2, step S100 includes:
s101, acquiring original text data, carrying out knowledge extraction on the original text data, and carrying out classification labeling according to a knowledge extraction result to obtain a training text;
s102, acquiring a preset prompt template, and generating a prompt training template containing mask text according to the original text data and the prompt template;
s103, adding the training texts and the prompt training templates in one-to-one correspondence, and constructing to obtain the training samples.
In this embodiment, the constructed training sample is composed of two parts, one part is training text and the other part is prompting training template. In training text, more knowledge information is added in order to enrich the context information of the text to increase the long text classification effect. The training text is obtained by carrying out knowledge extraction on the original text data and carrying out classification labeling according to the relation between the knowledge extraction result and the classification labels. In the prompt training templates, the original text data is substituted into the prompt templates based on the preset prompt templates, namely the prompt templates, so that the prompt training templates containing the mask texts are generated, wherein the prompt templates can be manually generated or automatically generated, and the number and types of the prompt templates are various, so that the positions and the description contents of the mask texts in the prompt training templates are enriched, and further the effect of the follow-up mask prediction is improved.
After the training text with knowledge and the flexible and various prompt training templates are obtained respectively, the training text with knowledge and the flexible and various prompt training templates are added in a one-to-one correspondence manner, namely, the training text which is attributed to the same original text data and the prompt training templates are added, so that training samples with knowledge and mask text are constructed, and accurate and efficient text prediction training is realized.
In one embodiment, as shown in fig. 3, step S101 includes:
s1011, collecting original text data, and extracting knowledge entities and/or entity relations in the original text data;
s1012, matching the knowledge entity and/or entity relation with a knowledge dictionary of a preset text type;
and S1013, classifying and labeling the original text data according to the matching result to obtain a training text.
In this embodiment, the training text needs to classify and label the original text data, for example, "how the product manager performs service acceptance before project delivery", and the true classification result is question-answer class; "Shenzhen how hot today" truly marks a boring class. During labeling, the knowledge entity and/or entity relation in the original text data can be extracted for classification labeling, for example, a 'product manager', 'production', 'acceptance' is extracted, a question-answer class is labeled as 1, and other classes are labeled as 0; extracting Shenzhen ' and ' weather ' marked as 1 in the chatting class and the other class as 0, namely adding original labeling information to perform model training. Because the data volume is large, knowledge dictionaries of all preset text types can be constructed in advance to improve the labeling efficiency, the extracted entities and/or entity relations are matched with the knowledge dictionaries, and the original text data is automatically classified and labeled based on the matching result to obtain training texts. Specifically, when an entity or entity relation falls into a certain knowledge dictionary, the preset text type corresponding to the knowledge dictionary is marked as 1, and the preset microblog types of other knowledge dictionaries which do not fall into the knowledge dictionary are marked as 0, so that efficient dictionary matching marking is realized.
In one embodiment, as shown in fig. 4, step S102 includes:
s1021, acquiring a preset prompting template, wherein the prompting template comprises mask positions;
s1022, splicing the original text data with the prompt template, marking the mask position according to the text type of the original text data, and filling mask text into the mask position to generate the prompt training template.
In this embodiment, in generating the alert training templates, the alert templates of different types are obtained, where the alert templates include mask positions, and the mask positions in the different alert templates may be different, so as to improve diversity of the templates and facilitate improvement of the model training effect. And splicing the collected original text data with the prompt template, marking the mask position according to the text type of the original text data, and filling the mask text to generate the prompt training template.
Taking two alert templates, "this is a __ problem", "this is related to __", it is possible to obtain, after combining the two original text data, how the product manager performs the business acceptance before the project is put into production, "this is a __ problem", "how the product manager performs the business acceptance before the project is put into production", "this is related to __", "how hot today" is, this is a __ problem "," how hot today "is, and" four alert training templates "this is related to __".
And training the text of the mask position in the template for the four prompts, and filling corresponding description words, namely mask text, based on the text type labels. For example, a corresponding mask prompt dictionary is created in advance for each preset text type, wherein the mask prompt dictionary comprises a plurality of words, and words are randomly filled in the corresponding dictionary when the mask text is filled in. For example, in the above embodiment, any one of the terms { project, professional, business, management } may be filled in the mask positions of the first two templates, and any one of the terms { weather, climate, region, season } may be filled in the mask positions of the second two templates. Therefore, a prompt training template with mask texts is generated by combining flexible and various prompt templates with original text data, a downstream text classification task is converted into a prediction task for the mask texts in the template, the method is more suitable for marking training scenes with less labels, and the labeling workload is reduced.
S200, inputting the training sample into a pre-constructed prompt learning model for training until the model converges, and predicting the mask text by the prompt learning model.
In this embodiment, the training samples obtained by construction are input into a pre-constructed prompt learning model for training, specifically, the model may adopt a 6-layer transform infrastructure, that is, a 6-layer Encoder block is adopted, the hidden layer dimension is 512, the number of attention headers is 8, the text vector of the training text and the text vector of the prompt training template are added as an input of an Embedding layer, the context overall vector is obtained through the Encoder module, finally, mapping of the full connection layer is performed, and the model is optimized by using a loss function until the model converges, so that the prompt learning model for predicting the mask text at the mask position in the input text can be obtained.
S300, inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized.
In this embodiment, when text classification is performed on the text to be recognized, a prompt template to be recognized is also constructed based on the prompt template in combination with the text to be recognized, and is input into the converged prompt learning model to perform text prediction of the mask position, so as to obtain the target mask text in the prompt template to be recognized.
In one embodiment, as shown in fig. 5, step S300 includes:
s301, acquiring a text to be recognized, and generating a prompt template to be recognized according to the text to be recognized and the prompt template, wherein the prompt template to be recognized comprises a target mask position;
s302, inputting the prompt template to be identified into the prompt learning model, and predicting to obtain the target mask text at the target mask position.
In this embodiment, the obtained text to be recognized and the preset prompting template are first generated into the prompting template to be recognized, and based on the mask setting in the prompting template, the prompting template to be recognized includes the target mask position, for example, the text to be recognized is "how the Shenzhen weather today", based on the prompting template, "how the Shenzhen weather today is, which is a __ problem", and "how the Shenzhen weather today is, which is related to __", wherein the space position is the target mask position. And inputting the target mask text into a prompt learning model to obtain target mask text, such as weather and climate, at a target mask position of model prediction output, wherein the predicted target mask text is used as an accurate basis for text classification.
S400, performing text type mapping according to the target mask text, and determining the target text type of the text to be identified.
In this embodiment, the text type mapping is performed between the predicted target mask text and the preset text type, so that the target text type of the text to be recognized can be determined by the text type in which the target mask text falls. The training samples fused with the knowledge data and the prompt templates are used for prompt learning training, the original task is converted into words at the predicted mask position, and the text classification task is completed through the mapping relation between the mask text and the real labels, so that the text context information is enriched, the text classification effect is enhanced, and the text classification accuracy is effectively improved.
In one embodiment, as shown in fig. 6, step S400 includes:
s401, matching the target mask text with a preset mask prompt dictionary, and determining a target mask prompt dictionary matched with the target mask text;
s402, determining a target text type corresponding to the target mask prompt dictionary according to the mapping relation between the mask prompt dictionary and a preset text type.
In this embodiment, a plurality of mask prompt dictionaries are preset, each mask prompt dictionary maps a preset text type, for example, a mask prompt dictionary { project, professional, business, management } is preset for question-answering class, a mask prompt dictionary { weather, climate, region, season } is preset for boring class, and the length of each mask prompt dictionary can be set at any time and can update words therein according to requirements so as to adapt to the requirement change of text classification.
When the text classification is carried out based on the predicted target mask text, the predicted target mask text is firstly matched with each mask prompt dictionary, the matched target mask prompt dictionary is determined, namely, which dictionary the current predicted target mask text falls into is judged, and then the target text type corresponding to the target mask prompt dictionary can be determined based on the mapping relation between each mask prompt dictionary and the preset text type. For example, according to what the text to be recognized is, after the prompt template is constructed and the text is predicted by the mask, the predicted text is obtained as weather and climate, and the dictionary in which the predicted text falls corresponds to the boring class, so that the text to be recognized can be classified into the boring class, and the text classification task is converted into the mask prediction by the flexible prompt template and then the label mapping is carried out, thereby not only enhancing the effect of text classification, but also reducing the requirement on manual labeling and further reducing the training cost.
Another embodiment of the present invention provides a text classification apparatus, as shown in fig. 7, the apparatus 1 includes:
the sample construction module 11 is used for acquiring original text data, and constructing a training sample fused with knowledge data and a prompt template according to the original text data, wherein the training sample comprises mask text;
the model training module 12 is configured to input the training sample into a pre-constructed prompt learning model for training until the model converges, where the prompt learning model predicts the mask text;
a mask prediction module 13, configured to input a prompt template to be recognized constructed based on a text to be recognized into the prompt learning model, and predict and obtain a target mask text in the prompt template to be recognized;
and the mapping classification module 14 is used for mapping the text types according to the target mask text and determining the target text type of the text to be identified.
The modules referred to in the present invention refer to a series of computer program instruction segments capable of performing specific functions, which are more suitable for describing the text classification execution process than the program, and specific embodiments of each module refer to the corresponding method embodiments and are not repeated herein.
In one embodiment, the sample construction module 11 includes:
the knowledge extraction unit is used for collecting original text data, carrying out knowledge extraction on the original text data, and carrying out classification labeling according to a knowledge extraction result to obtain a training text;
the template generation unit is used for acquiring a preset prompt template and generating a prompt training template containing mask text according to the original text data and the prompt template;
and the sample construction unit is used for adding the training texts and the prompt training templates in one-to-one correspondence to construct the training samples.
In one embodiment, the knowledge extraction unit includes:
the extraction unit is used for collecting original text data and extracting knowledge entities and/or entity relations in the original text data;
the matching unit is used for matching the knowledge entity and/or entity relation with a knowledge dictionary of a preset text type;
and the labeling unit is used for classifying and labeling the original text data according to the matching result to obtain a training text.
In one embodiment, the labeling unit is specifically configured to:
and marking the preset text type corresponding to the successfully matched knowledge dictionary as 1, and marking the preset text type corresponding to the unsuccessfully matched knowledge dictionary as 0.
In one embodiment, the template generating unit includes:
the template acquisition unit is used for acquiring a preset prompting template, wherein the prompting template comprises a mask position;
and the filling generation unit is used for splicing the original text data with the prompt template, marking the mask position according to the text type of the original text data, and generating the prompt training template after filling mask text in the mask position.
In one embodiment, the mask prediction module 13 includes:
the generating unit is used for acquiring a text to be identified, generating a prompt template to be identified according to the text to be identified and the prompt template, wherein the prompt template to be identified comprises a target mask position;
and the prediction unit is used for inputting the prompt template to be identified into the prompt learning model and predicting to obtain the target mask text at the target mask position.
In one embodiment, the map classification module 14 includes:
the dictionary matching unit is used for matching the target mask text with a preset mask prompt dictionary and determining a target mask prompt dictionary matched with the target mask text;
and the classification mapping unit is used for determining the target text type corresponding to the target mask prompt dictionary according to the mapping relation between the mask prompt dictionary and the preset text type.
Another embodiment of the present invention provides a text classification system, as shown in fig. 8, the system 10 comprising:
one or more processors 110 and a memory 120, one processor 110 being illustrated in fig. 8, the processors 110 and the memory 120 being coupled via a bus or other means, the bus coupling being illustrated in fig. 8.
Processor 110 is used to implement various control logic for system 10, which may be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), a single-chip microcomputer, ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Also, the processor 110 may be any conventional processor, microprocessor, or state machine. The processor 110 may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP, and/or any other such configuration.
The memory 120 is used as a non-volatile computer readable storage medium for storing non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions corresponding to the text classification method in the embodiment of the present invention. The processor 110 performs various functional applications of the system 10 and data processing, i.e., implements the text classification method in the method embodiments described above, by running non-volatile software programs, instructions, and units stored in the memory 120.
Memory 120 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created from the use of system 10, etc. In addition, memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 120 may optionally include memory located remotely from processor 110, which may be connected to system 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more units are stored in memory 120 that, when executed by one or more processors 110, perform the steps of:
collecting original text data, and constructing a training sample fused with knowledge data and a prompt template according to the original text data, wherein the training sample comprises mask text;
inputting the training sample into a pre-constructed prompt learning model for training until the model converges, wherein the prompt learning model predicts the mask text;
inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized;
and performing text type mapping according to the target mask text, and determining the target text type of the text to be identified.
In one embodiment, the collecting the original text data, constructing a training sample with knowledge data and a prompt template fused according to the original text data, where the training sample includes mask text, and the method includes:
collecting original text data, carrying out knowledge extraction on the original text data, and carrying out classification labeling according to a knowledge extraction result to obtain a training text;
acquiring a preset prompt template, and generating a prompt training template containing mask text according to the original text data and the prompt template;
and adding the training texts and the prompt training templates in one-to-one correspondence, and constructing to obtain the training samples.
In one embodiment, the collecting the original text data, performing knowledge extraction on the original text data, and performing classification labeling according to the knowledge extraction result to obtain training text, including:
collecting original text data, and extracting knowledge entities and/or entity relations in the original text data;
matching the knowledge entity and/or entity relation with a knowledge dictionary of a preset text type;
and classifying and labeling the original text data according to the matching result to obtain a training text.
In one embodiment, the training text is obtained after classifying and labeling the original text data according to the matching result, which specifically includes:
and marking the preset text type corresponding to the successfully matched knowledge dictionary as 1, and marking the preset text type corresponding to the unsuccessfully matched knowledge dictionary as 0.
In one embodiment, the step of obtaining the preset prompt template, generating a prompt training template including mask text according to the original text data and the prompt template, includes:
acquiring a preset prompting template, wherein the prompting template comprises a mask position;
and splicing the original text data with the prompt template, marking the mask position according to the text type of the original text data, and filling mask text into the mask position to generate the prompt training template.
In one embodiment, the inputting the to-be-recognized prompt template constructed based on the to-be-recognized text into the prompt learning model predicts the target mask text in the to-be-recognized prompt template, including:
acquiring a text to be recognized, and generating a prompt template to be recognized according to the text to be recognized and the prompt template, wherein the prompt template to be recognized comprises a target mask position;
and inputting the prompt template to be identified into the prompt learning model, and predicting to obtain the target mask text at the target mask position.
In one embodiment, the text type mapping according to the target mask text, and determining the target text type of the text to be identified includes:
matching the target mask text with a preset mask prompt dictionary, and determining a target mask prompt dictionary matched with the target mask text;
and determining the target text type corresponding to the target mask prompt dictionary according to the mapping relation between the mask prompt dictionary and the preset text type.
Embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer-executable instructions for execution by one or more processors, e.g., to perform the method steps S100-S400 of fig. 1 described above.
By way of example, nonvolatile storage media can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, RAM may be available in many forms such as Synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environments described herein are intended to comprise one or more of these and/or any other suitable types of memory.
In summary, in the text classification method, device, system and medium disclosed by the invention, the method constructs a training sample fused with knowledge data and a prompt template according to original text data by collecting the original text data, wherein the training sample comprises mask text; inputting the training sample into a pre-constructed prompt learning model for training until the model converges, wherein the prompt learning model predicts the mask text; inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized; and performing text type mapping according to the target mask text, and determining the target text type of the text to be identified. The training samples fused with the knowledge data and the prompt templates are used for prompt learning training so as to complete text classification tasks, enrich text context information, enhance text classification effect and effectively improve text classification accuracy.
Of course, those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-volatile computer readable storage medium, which when executed may comprise the steps of the above described method embodiments, to instruct related hardware (e.g., processors, controllers, etc.). The storage medium may be a memory, a magnetic disk, a floppy disk, a flash memory, an optical memory, etc.
It is to be understood that the invention is not limited in its application to the examples described above, but is capable of modification and variation in light of the above teachings by those skilled in the art, and that all such modifications and variations are intended to be included within the scope of the appended claims.

Claims (10)

1. A method of text classification, comprising:
collecting original text data, and constructing a training sample fused with knowledge data and a prompt template according to the original text data, wherein the training sample comprises mask text;
inputting the training sample into a pre-constructed prompt learning model for training until the model converges, wherein the prompt learning model predicts the mask text;
inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized;
and performing text type mapping according to the target mask text, and determining the target text type of the text to be identified.
2. The text classification method according to claim 1, wherein the collecting the original text data, and constructing a training sample with knowledge data and a prompt template fused according to the original text data, wherein the training sample includes mask text, includes:
collecting original text data, carrying out knowledge extraction on the original text data, and carrying out classification labeling according to a knowledge extraction result to obtain a training text;
acquiring a preset prompt template, and generating a prompt training template containing mask text according to the original text data and the prompt template;
and adding the training texts and the prompt training templates in one-to-one correspondence, and constructing to obtain the training samples.
3. The text classification method according to claim 2, wherein the collecting the original text data, performing knowledge extraction on the original text data, and performing classification labeling according to a knowledge extraction result to obtain the training text comprises:
collecting original text data, and extracting knowledge entities and/or entity relations in the original text data;
matching the knowledge entity and/or entity relation with a knowledge dictionary of a preset text type;
and classifying and labeling the original text data according to the matching result to obtain a training text.
4. The text classification method according to claim 3, wherein the training text is obtained after classifying and labeling the original text data according to the matching result, and specifically comprises:
and marking the preset text type corresponding to the successfully matched knowledge dictionary as 1, and marking the preset text type corresponding to the unsuccessfully matched knowledge dictionary as 0.
5. The text classification method according to claim 2, wherein the step of generating a prompt training template including mask text from the original text data and the prompt template by acquiring a preset prompt template includes:
acquiring a preset prompting template, wherein the prompting template comprises a mask position;
and splicing the original text data with the prompt template, marking the mask position according to the text type of the original text data, and filling mask text into the mask position to generate the prompt training template.
6. The text classification method according to claim 1, wherein inputting the prompt to be recognized template constructed based on the text to be recognized into the prompt learning model predicts the target mask text in the prompt to be recognized template, and includes:
acquiring a text to be recognized, and generating a prompt template to be recognized according to the text to be recognized and the prompt template, wherein the prompt template to be recognized comprises a target mask position;
and inputting the prompt template to be identified into the prompt learning model, and predicting to obtain the target mask text at the target mask position.
7. The text classification method according to claim 1, wherein the text type mapping according to the target mask text, determining the target text type of the text to be recognized, comprises:
matching the target mask text with a preset mask prompt dictionary, and determining a target mask prompt dictionary matched with the target mask text;
and determining the target text type corresponding to the target mask prompt dictionary according to the mapping relation between the mask prompt dictionary and the preset text type.
8. A text classification device, comprising:
the system comprises a sample construction module, a training module and a prompt module, wherein the sample construction module is used for acquiring original text data, constructing a training sample fused with knowledge data and a prompt template according to the original text data, and the training sample comprises mask text;
the model training module is used for inputting the training sample into a pre-constructed prompt learning model to train until the model converges, and the prompt learning model predicts the mask text;
the mask prediction module is used for inputting a prompt template to be recognized constructed based on the text to be recognized into the prompt learning model, and predicting to obtain a target mask text in the prompt template to be recognized;
and the mapping classification module is used for mapping the text types according to the target mask text and determining the target text types of the texts to be identified.
9. A text classification system, the system comprising at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the text classification method of any of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer-executable instructions which, when executed by one or more processors, cause the one or more processors to perform the text classification method of any of claims 1-7.
CN202310683287.1A 2023-06-09 2023-06-09 Text classification method, device, system and medium Pending CN116662547A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310683287.1A CN116662547A (en) 2023-06-09 2023-06-09 Text classification method, device, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310683287.1A CN116662547A (en) 2023-06-09 2023-06-09 Text classification method, device, system and medium

Publications (1)

Publication Number Publication Date
CN116662547A true CN116662547A (en) 2023-08-29

Family

ID=87709478

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310683287.1A Pending CN116662547A (en) 2023-06-09 2023-06-09 Text classification method, device, system and medium

Country Status (1)

Country Link
CN (1) CN116662547A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116861258A (en) * 2023-08-31 2023-10-10 腾讯科技(深圳)有限公司 Model processing method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116861258A (en) * 2023-08-31 2023-10-10 腾讯科技(深圳)有限公司 Model processing method, device, equipment and storage medium
CN116861258B (en) * 2023-08-31 2023-12-01 腾讯科技(深圳)有限公司 Model processing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN112685565B (en) Text classification method based on multi-mode information fusion and related equipment thereof
CN107861954B (en) Information output method and device based on artificial intelligence
CN112328761B (en) Method and device for setting intention label, computer equipment and storage medium
CN111143556B (en) Automatic counting method and device for software function points, medium and electronic equipment
CN116662547A (en) Text classification method, device, system and medium
CN116303537A (en) Data query method and device, electronic equipment and storage medium
CN115757731A (en) Dialogue question rewriting method, device, computer equipment and storage medium
CN112434746B (en) Pre-labeling method based on hierarchical migration learning and related equipment thereof
CN112199954B (en) Disease entity matching method and device based on voice semantics and computer equipment
CN112036186A (en) Corpus labeling method and device, computer storage medium and electronic equipment
CN111968624B (en) Data construction method, device, electronic equipment and storage medium
CN112182157B (en) Training method of online sequence labeling model, online labeling method and related equipment
CN112417996A (en) Information processing method and device for industrial drawing, electronic equipment and storage medium
CN117234505A (en) Interactive page generation method, device, equipment and storage medium thereof
CN115730603A (en) Information extraction method, device, equipment and storage medium based on artificial intelligence
CN110852103A (en) Named entity identification method and device
CN112732423B (en) Process migration method, device, equipment and medium
CN114118068B (en) Method and device for amplifying training text data and electronic equipment
CN115759292A (en) Model training method and device, semantic recognition method and device, and electronic device
CN114842982A (en) Knowledge expression method, device and system for medical information system
CN114637831A (en) Data query method based on semantic analysis and related equipment thereof
CN113420869A (en) Translation method based on omnidirectional attention and related equipment thereof
CN114444470B (en) Method, device, medium and equipment for recognizing domain named entities in patent text
CN118012935A (en) Data extraction and auditing method and device, computer equipment and storage medium
CN117235260A (en) Text labeling method, device, equipment and storage medium based on artificial intelligence

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination