Text recognition method, device, computer readable medium and electronic device

By adding classification marks to the text recognition model and using the model trained by labeling entity tags and classification tags for identification, the problems of high cost and low accuracy of manual construction feature in the prior art are solved, and efficient text recognition and entity extraction are achieved .

CN113761190BActive Publication Date: 2025-02-14TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110492354.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-06
Publication Date
2025-02-14
Estimated Expiration
2041-05-06

AI Technical Summary

Technical Problem

When the prior art recognizes negative information in network text, artificial construction features are costly and the characteristics are prone to sparseness, and large-scale corpus labeling affects the training effect, resulting in low accuracy.

Method used

By adding classification marks to the text to be identified, an input object is generated, and a text recognition model trained in the text text with the target sample labeled entity label and classification label is used to identify, extract entities and classification results.

Benefits of technology

It realizes the extraction of entities in text while classifying text, improves the accuracy of text recognition, reduces labor costs, and improves the efficiency of entity recognition and text classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113761190B_ABST
    Figure CN113761190B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a text recognition method, device, computer-readable medium and electronic device. The text recognition method includes: adding a first classification mark to the text to be recognized to generate an input object corresponding to the text to be recognized; inputting the input object into a text recognition model, the text recognition model is trained based on a target sample text carrying annotated entity labels and annotated classification labels; obtaining the predicted entity labels corresponding to each character in the text to be recognized output by the text recognition model and the predicted classification labels corresponding to the first classification mark; generating an entity recognition result for the text to be recognized based on the predicted entity labels, and generating a classification result for the text to be recognized based on the predicted classification labels. The technical solution of the embodiments of the present application can realize the extraction of entities in the text while classifying the text, and can improve the accuracy of text recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer and communication technology, and in particular to a text recognition method, device, computer-readable medium and electronic device. Background Art

[0002] Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. Text recognition, as an important application in natural language processing, is widely used in text content detection.

[0003] In order to identify negative information in online text information, related technologies often use artificial features or large-scale corpus training models to identify negative information. However, the cost of artificially constructing features is high, and features are prone to sparseness. A large amount of corpus annotation will affect the training effect, which can easily lead to poor results and low accuracy. Summary of the invention

[0004] The embodiments of the present application provide a text recognition method, device, computer-readable medium and electronic device, which can, to a certain extent, achieve the extraction of entities in the text while classifying the text, and can improve the accuracy of text recognition.

[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0006] According to one aspect of an embodiment of the present application, a text recognition method is provided, comprising: adding a first classification mark to a text to be recognized to generate an input object corresponding to the text to be recognized; inputting the input object into a text recognition model, the text recognition model being trained based on a target sample text carrying annotated entity labels and annotated classification labels, the annotated entity labels being entity labels corresponding to each character in the target sample text, and the annotated classification labels being classification labels corresponding to a second classification mark added to the target sample text; obtaining predicted entity labels corresponding to each character in the text to be recognized output by the text recognition model and predicted classification labels corresponding to the first classification mark; generating an entity recognition result for the text to be recognized based on the predicted entity labels, and generating a classification result for the text to be recognized based on the predicted classification labels.

[0007] According to one aspect of an embodiment of the present application, a text recognition device is provided, comprising: a first adding unit, configured to add a first classification mark to a text to be recognized, so as to generate an input object corresponding to the text to be recognized; a first input unit, configured to input the input object into a text recognition model, wherein the text recognition model is trained based on a target sample text carrying annotated entity labels and annotated classification labels, wherein the annotated entity labels are entity labels corresponding to each character in the target sample text, and the annotated classification labels are classification labels corresponding to a second classification mark added to the target sample text; an acquiring unit, configured to acquire predicted entity labels corresponding to each character in the text to be recognized output by the text recognition model and predicted classification labels corresponding to the first classification mark; a generating unit, configured to generate an entity recognition result for the text to be recognized based on the predicted entity labels, and to generate a classification result for the text to be recognized based on the predicted classification labels.

[0008] In some embodiments of the present application, based on the aforementioned scheme, the first adding unit is configured to: divide the text to be recognized in units of characters to generate a character sequence corresponding to the text to be recognized; add the first classification mark to the character sequence to obtain a new character sequence, and use the new character sequence as the input object corresponding to the text to be recognized.

[0009] In some embodiments of the present application, based on the aforementioned scheme, the generation unit is configured to: recognize characters in the text to be recognized that are continuously positioned and whose corresponding predicted entity labels indicate the same entity as the same entity, and obtain an entity recognition result for the text to be recognized; and use the classification category indicated by the predicted classification label as the classification result for the text to be recognized.

[0010] In some embodiments of the present application, based on the aforementioned scheme, the device also includes: a second adding unit, configured to add the second classification mark to the target sample text to generate a sample input object corresponding to the target sample text; a second input unit, configured to input the sample input object into the model to be trained to obtain the prediction score of each character in the target sample text output by the model to be trained for each entity label and the second classification mark for each classification label; a determination unit, configured to determine a loss function based on the labeled entity label, the labeled classification label and the prediction score, and adjust the parameters of the model to be trained based on the loss function to obtain the text recognition model.

[0011] In some embodiments of the present application, based on the aforementioned scheme, the determination unit includes: a prediction score determination subunit, configured to determine, based on the labeled entity label and the labeled classification label, a target prediction score corresponding to an entity label that is the same as the labeled entity label and a classification label that is the same as the labeled classification label from the prediction score; and a loss function determination subunit, configured to determine the loss function based on the target prediction score.

[0012] In some embodiments of the present application, based on the aforementioned scheme, the loss function determination subunit is configured to: calculate the ratio between the target prediction score and the sum of the prediction scores; perform a logarithmic operation on the ratio to obtain an operation result, and determine the loss function based on the operation result.

[0013] In some embodiments of the present application, based on the aforementioned scheme, the second adding unit is configured to: divide the target sample text into characters to generate a character sequence corresponding to the target sample text; add the second classification mark to the character sequence to obtain a new character sequence, and use the new character sequence as a sample input object corresponding to the target sample text.

[0014] In some embodiments of the present application, based on the aforementioned scheme, the device also includes: a keyword acquisition unit, configured to acquire keywords from a pre-established keyword library; a sample text acquisition unit, configured to acquire sample texts containing the keywords based on the keywords; a labeling unit, configured to perform entity label and category label annotation on part of the sample texts in the acquired sample texts to generate initial sample texts; and a processing unit, configured to perform data enhancement processing on the initial sample text to generate the target sample text.

[0015] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured to: copy the initial sample text to obtain a copy of the initial sample text; and generate the target sample text according to the initial sample text and the copy of the initial sample text.

[0016] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured to: perform synonym replacement on the target keyword contained in the initial sample text to generate a sample text containing a synonym of the target keyword; and generate the target sample text based on the initial sample text and the sample text containing a synonym of the target keyword.

[0017] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured to: delete part of the text contained in the initial sample text to obtain a processed initial sample text; and generate the target sample text based on the initial sample text and the processed initial sample text.

[0018] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured to: randomly insert text into the initial sample text to obtain a new initial sample text; and generate the target sample text based on the initial sample text and the new initial sample text.

[0019] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the text recognition method as described in the above embodiment is implemented.

[0020] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the text recognition method as described in the above embodiments.

[0021] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text recognition method provided in the above various optional embodiments.

[0022] In the technical solutions provided in some embodiments of the present application, a first classification mark is added to the text to be recognized to generate an input object corresponding to the text to be recognized, and then the input object is input into a text recognition model. The text recognition model is trained based on a target sample text carrying annotated entity labels and annotated classification labels. The annotated entity labels are entity labels corresponding to each character in the target sample text, and the annotated classification labels are classification labels corresponding to the second classification mark added to the target sample text. Furthermore, the predicted entity labels corresponding to each character in the text to be recognized output by the text recognition model and the predicted classification labels corresponding to the first classification marks can be obtained. Finally, the entity recognition results for the text to be recognized can be generated based on the predicted entity labels, and the classification results for the text to be recognized can be generated based on the predicted classification labels. The technical solution of the embodiment of the present application recognizes the text to be recognized through a text recognition model. It does not require manual feature construction and can automatically extract semantic knowledge, which greatly reduces labor costs and improves the efficiency of entity recognition and text classification. The text recognition model can extract entities in the text to be recognized while classifying the text to be recognized. It adopts a joint training method for entity recognition tasks and text classification tasks. The two tasks share semantic knowledge, which increases the attention of the text recognition model to entities and improves the accuracy of entity recognition and text classification.

[0023] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0025] Figure 1 is a schematic diagram of an application environment of a text recognition method provided by an embodiment of the present application;

[0026] Figure 2 is a flowchart of a text recognition method provided by an embodiment of the present application;

[0027] Figure 3 An exemplary structural diagram of a text recognition model is shown;

[0028] Figure 4 is a flowchart of a text recognition model training method provided by an embodiment of the present application;

[0029] Figure 5is a flowchart of a method for determining a loss function provided by an embodiment of the present application;

[0030] Figure 6 is a flow chart of a method for generating a target sample text provided by an embodiment of the present application;

[0031] Figure 7 is a block diagram of a text recognition device provided by an embodiment of the present application;

[0032] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.

[0034] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.

[0035] It should be noted that the terms used in the specification and claims of this application and the above-mentioned drawings are only used to describe the embodiments and are not intended to limit the scope of this application. It should be understood that the terms "include", "comprises", "having", etc., when used in this article, specify the existence of the stated features, wholes, steps, operations, elements, components and / or their groups, but do not exclude the existence or addition of one or more of other features, wholes, steps, operations, elements, components and / or their groups.

[0036] It will be further understood that, although the terms "first", "second", "third", etc. may be used to describe various elements in this article, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element. For example, without departing from the scope of the present invention, the first element may be referred to as the second element. Similarly, the second element may be referred to as the first element. As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0037] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0038] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0039] It should be understood that, in the present application, “at least one (item)” means one or more, and “more than one” means two or more.

[0040] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.

[0041] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0042] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0043] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.

[0044] Machine Learning (ML) is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.

[0045] The solution provided in the embodiments of the present application involves technologies such as natural language processing and machine learning of artificial intelligence, which are specifically described by the following embodiments:

[0046] According to one aspect of the embodiments of the present application, a text recognition method is provided. Optionally, as an optional implementation, the text recognition method can be but is not limited to being applied to Figure 1 In the environment shown. The application environment includes a terminal device 101 and a server 102. The terminal device 101 and the server 102 perform data communication via a communication network. Optionally, the communication network can be a wired network or a wireless network, and the communication network can be at least one of a local area network, a metropolitan area network, and a wide area network.

[0047] The terminal device 101 is an electronic device that has a search function through the network. The electronic device can be a mobile terminal such as a smart phone, a tablet computer, a laptop, or a desktop computer, a projection computer, etc., which is not limited in the present embodiment.

[0048] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0049] In one embodiment of the present application, a text recognition model is provided in the server 102 , and the text recognition model is trained based on target sample texts carrying annotated entity labels and annotated classification labels.

[0050] After the terminal device 101 sends a text recognition request to the server 102, the server 102 adds a first classification tag to the text to be recognized, generates an input object corresponding to the text to be recognized, and uses the input object as the input of the text recognition model. The text recognition model performs text recognition and outputs the predicted entity labels corresponding to each character in the text to be recognized and the predicted classification labels corresponding to the first classification tag.

[0051] In other possible implementations, the text recognition model may also be sent from the server 102 to the terminal device 101 , and the terminal device 101 may use the text recognition model to recognize the text to be recognized, which is not limited in this embodiment.

[0052] One point that needs to be explained is that the text recognition model provided by the present application can be widely used in various fields. For example, the text recognition model is applied in the field of network text recognition. Network text can include public opinion text, for example. Specifically, a text recognition model is set in the background server of the application / portal website. The text recognition model is used to identify the classification of network text (negative or non-negative) and entities in the network text. After the application / portal website is started, users can post network texts according to their actual situation. The server can obtain the network texts posted by users from the open interface of the application or the portal website. After that, the server recognizes the network text through the text recognition model, determines whether the network text is negative, and extracts the entities and relationships inside the network text, so that risks can be discovered in time.

[0053] The identification of negative information about an enterprise is crucial to its risk control tasks. However, in actual scenarios, on the one hand, it is difficult for the enterprise to perceive external risks in a timely manner, and on the other hand, it often requires manual labor to spend a lot of time searching for negative information.

[0054] Current online text recognition solutions can be roughly divided into three categories: (1) Rule-based templates, which use negative keywords to trigger judgments, and those that meet the corresponding rules are judged as negative. (2) Traditional machine learning models, which use annotated corpus to manually construct a large number of features for classification training. (3) Deep learning models, which do not require manual feature construction, extract semantic features from text vectors, and further train classification models.

[0055] However, (1) rule templates are prone to misjudgment and require continuous supplementation and maintenance of rule template libraries. They rely on historical experience and cannot proactively discover new negative pattern expressions. (2) Traditional machine learning models have high costs for manually constructing features, and features are prone to sparseness. (3) Deep learning models rely on large-scale training corpora, and the quality of corpus annotations has a great impact on training results. In addition, online texts are usually complex, and using classification models alone often does not work well.

[0056] Based on this, an embodiment of the present application provides a text recognition method. The text recognition method in the present application can be applied to the recognition of online text. The online text is recognized through a text recognition model. The text recognition model can extract entities and relationships within the online text while identifying whether the online text is negative. The named entity recognition task and the classification task are jointly trained to implicitly increase the model's attention to important entities, share the semantic knowledge of the two tasks, better solve the problem of risk ambiguity, and improve the task accuracy.

[0057] Of course, the text recognition method in this application can also be applied to various other fields, which are not listed one by one here. In addition, in actual application, multiple text recognition models can be used simultaneously to recognize the text to be recognized. For example, the first text recognition model is used to determine the field to which the text to be recognized belongs, and based on the field to which it belongs, the text recognition model corresponding to the field is selected to classify the text to be recognized and perform entity recognition.

[0058] For ease of explanation, in the following method embodiments, only the execution subject of each step is a computer device as an example for introduction and explanation. The computer device can be any electronic device with computing and storage capabilities. For example, the computer device can be a server 102 or a terminal device 101. It should be noted that in the embodiments of the present application, the execution subject of each step can be the same computer device, or it can be executed by multiple different computer devices in interaction and cooperation, which is not limited here. It is also necessary to explain that in the embodiments of the present application, the execution subject of the following text recognition method and the execution subject of the following text recognition model training method can be the same computer device or different computer devices, which is not limited in the embodiments of the present application.

[0059] The implementation details of the technical solution of the embodiment of the present application are described in detail below:

[0060] Figure 2 A flowchart of a text recognition method according to an embodiment of the present application is shown, referring to Figure 2 As shown, the text recognition method includes:

[0061] Step S210: adding a first classification mark to the text to be recognized to generate an input object corresponding to the text to be recognized;

[0062] Step S220: input the input object into a text recognition model, where the text recognition model is trained based on a target sample text carrying annotated entity labels and annotated classification labels, where the annotated entity labels are entity labels corresponding to each character in the target sample text, and the annotated classification labels are classification labels corresponding to a second classification mark added to the target sample text;

[0063] Step S230, obtaining predicted entity labels corresponding to each character in the text to be recognized output by the text recognition model and predicted classification labels corresponding to the first classification mark;

[0064] Step S240: Generate an entity recognition result for the text to be recognized based on the predicted entity label, and generate a classification result for the text to be recognized based on the predicted classification label.

[0065] These steps are described in detail below.

[0066] In step S210, a first classification mark is added to the text to be recognized to generate an input object corresponding to the text to be recognized.

[0067] The text to be recognized refers to text of unknown category, that is, unclassified text. The text to be recognized may include multiple text characters, for example, multiple words, and may also include a character group consisting of words, numbers, letters, or punctuation marks. In an embodiment of the present application, the computer device obtains the text to be recognized before performing text recognition. Optionally, the text to be recognized may be text obtained in real time, or may be text previously obtained and stored in the computer device.

[0068] In a possible implementation, the user actively provides the above-mentioned text to be recognized to the computer device. Optionally, the user determines the text to be recognized according to actual conditions, and inputs the text to be recognized to the computer device or an associated device of the computer device, and further, the computer device obtains the text to be recognized. Among them, the input method of the text to be recognized can be text input, voice input, image input or gesture input, etc., which is not limited in the embodiment of the present application.

[0069] In another possible implementation, the computer device actively obtains the text to be recognized. Optionally, the computer device can obtain the text to be recognized from the network environment at a certain time interval. In this case, after the computer device classifies the text to be recognized, it can store the text to be recognized in a suitable location according to the category of the text to be recognized, such as a classification database. The time interval can be 1 second, 1 hour, 1 day or 1 week, etc.

[0070] After obtaining the text to be recognized, the computer device may add a first classification mark to the text to be recognized to generate an input object corresponding to the text to be recognized. Compared with the text to be recognized, the input object corresponding to the text to be recognized has a first classification mark added. It should be noted that the added first classification mark is only a mark representing the classification, and is not a specific classification category of the text to be recognized. The added first classification mark may be added to the beginning, middle or end of the text to be recognized. As an example, the first classification mark may be "RN". It should be noted that the first classification mark may not be limited to the above-mentioned English letters, and may also include but is not limited to at least one of the following forms: numbers, words, symbols, etc.

[0071] In an illustrative example, the text to be recognized is “How beautiful is she”, and the computer device adds a first classification mark RN at the beginning of the text to be recognized, and generates an input object “RN How beautiful is she” corresponding to the text to be recognized.

[0072] In one embodiment of the present application, a computer device may use a word segmentation method to divide the text to be recognized into units of characters to obtain a character sequence corresponding to the text to be recognized, and add a first classification mark to the character sequence to obtain a new character sequence, and then use the new character sequence as an input object corresponding to the text to be recognized.

[0073] In an illustrative example, the text to be recognized is "I want to listen to XXX's rice fragrance", and the computer device divides the text to be recognized to obtain a text sequence "I / want / to / listen / to / X / X / 's / rice / fragrance"; the computer device adds a first classification mark RN to the divided text sequence to generate a new text sequence "I / want / to / listen / to / X / X / 's / rice / fragrance / RN".

[0074] In step S220, the input object is input into a text recognition model, which is trained based on a target sample text carrying annotated entity labels and annotated classification labels. The annotated entity labels are entity labels corresponding to each character in the target sample text, and the annotated classification labels are classification labels corresponding to the second classification mark added to the target sample text.

[0075] The text recognition model may be a model obtained by pre-training the model to be trained using a preset target sample text. The trained text recognition model may have both entity recognition capability and text classification capability.

[0076] In one embodiment, the model to be trained may be a combination model, and the combination model may be: (1) a bidirectional encoder representation (Bidirectional Encoder Representation from Transformers, BERT), a model based on a long short-term memory network (Long Short-Term Memory, LSTM) and a conditional random field (CRF). (2) a bidirectional long short-term memory network (Bi-LSTM) and a conditional random field (CRF) model. (3) a bidirectional encoder representation (Bidirectional Encoder Representation from Transformers, BERT) and a conditional random field (CRF) model.

[0077] The target sample text is a specific data set related to text recognition. The target sample text contains annotated entity labels and annotated classification labels. The entity labels and classification labels can be manually annotated.

[0078] Among them, the annotated entity label is the entity label corresponding to each word in the target sample text. Optionally, the annotation scheme of the entity label can be designed according to actual needs. As an example, assuming that the entity label annotation scheme for the sample text is designed in advance to introduce seven roles (subject company\subject company qualifier\subject person\associated company\associated product\risk word\tense word), if the target sample text is "a certain company denies the threat of violence", then after the target sample text is annotated with entity labels, the <text, entity label corresponding to the text> can be obtained respectively: <a certain, subject company>, <public, subject company>, <company, subject company>, <no, tense word>, <recognize, tense word>, <violence, risk word>, <force, risk word>, <threat, risk word>, <threat, risk word>. It should be noted that the entity label annotation is not limited to the above method, and the entity label annotation scheme can also be designed according to actual needs.

[0079] The annotated classification label is a classification label corresponding to the second classification mark added to the target sample text. In an illustrative example, when the text recognition model is used to classify compliant text and illegal text, the classification label may include a compliant label and an illegal label; when the text recognition model is used to classify compliant text, bad information text or fraudulent information text, the classification label may be at least one of a compliant label, a bad information label and a fraudulent information label; when the text recognition model is used to classify negative text and non-negative text, the classification label may include a negative label and a non-negative label. The embodiments of the present application do not limit the specific content of the classification label.

[0080] Specifically, the computer device can input the input object corresponding to the above-mentioned text to be recognized into the text recognition model, and determine the prediction score of each character for each entity label and the first classification mark for each classification label based on the feature matrix between the output probability and the label, and the transfer matrix between the labels.

[0081] In step S230, the predicted entity label corresponding to each character in the text to be recognized output by the text recognition model and the predicted classification label corresponding to the first classification mark are obtained.

[0082] After the computer device inputs the input object into the text recognition model, it can determine the prediction score of each character for each entity label and the first classification mark for each classification label based on the feature matrix between the output probability and the label, and the transfer matrix between the labels.

[0083] In other words, the text recognition model can output the prediction scores of multiple paths. Each path is formed by combining the corresponding labels at each position in the text to be recognized. The path with the highest prediction score is the true path, the entity labels corresponding to each character in the true path are the predicted entity labels corresponding to each character in the text to be recognized, and the classification label corresponding to the first classification mark in the true path is the predicted classification label corresponding to the first classification mark.

[0084] In step S240, an entity recognition result for the text to be recognized is generated based on the predicted entity label, and a classification result for the text to be recognized is generated based on the predicted classification label.

[0085] In this embodiment, after obtaining the predicted entity labels and predicted classification labels output by the text recognition model, the computer device can generate entity recognition results for the text to be recognized based on the predicted entity labels, and can generate classification results for the text to be recognized based on the predicted classification labels.

[0086] As an example, the computer device may recognize characters that are consecutively located in the text to be recognized and whose corresponding predicted entity tags indicate the same entity as the same entity, thereby obtaining an entity recognition result for the text to be recognized.

[0087] Taking the text to be identified "A certain company enters the liquidation procedure" as an example, the predicted entity label corresponding to "A certain" is "the main company", the predicted entity label corresponding to "Public" is "the main company", and the predicted entity label corresponding to "Company" is "the main company". "A certain", "Public", and "Company" are consecutively positioned characters in the text to be identified, and the corresponding predicted entity labels indicate the same entity "the main company". Therefore, it can be determined that "A certain company" in the text to be identified is an entity.

[0088] As an example, the computer device may use the classification category indicated by the predicted classification label corresponding to the first classification mark as the classification result for the text to be recognized. For example, if the classification category indicated by the predicted classification label corresponding to the first classification mark added to the text to be recognized is "negative", then it can be determined that the text to be recognized is negative text.

[0089] Based on the technical solutions of the above embodiments, the text to be recognized is recognized by a text recognition model. There is no need to manually construct features, and semantic knowledge can be automatically extracted, which greatly reduces labor costs and improves the efficiency of entity recognition and text classification. The text recognition model can extract entities in the text to be recognized while classifying the text to be recognized. The entity recognition task and the text classification task are jointly trained. The two tasks share semantic knowledge, which increases the attention of the text recognition model to entities and improves the accuracy of entity recognition and text classification.

[0090] The above is a detailed introduction to the text recognition method. The above entity recognition tasks and classification tasks are handled by the text recognition model.

[0091] For example, reference Figure 3 , Figure 3 A structural diagram of a text recognition model is shown. The text recognition model 30 is a combination model, including a Bert model 301, an LSTM model 302 and a CRF model 303. The Bert model 301 is used to extract lexical, syntactic and bidirectional semantic features. It needs to be explained that the semantic features are features that reflect the semantics of the corresponding characters / words. It can be understood that the semantics here are the semantics expressed by the character / word in the target sample text. In other words, the semantics are the semantics reflected by the corresponding character / word in the context of the target sample text combined with the contextual content. The LSTM model 302 is used to capture the front and back position information and output the entity and category probability distribution map. The CRF model 303 is used to learn the law of adjacent label transfer and finally output the optimal prediction result.

[0092] In this embodiment, the process of recognizing the text to be recognized can be described as follows:

[0093] First, the text to be recognized is divided and the first classification mark RL is added to obtain the text sequence X1, X2…X N , the text sequence X1, X2…X N Input Bert model 301, X1, X2 represent the characters at the first and second positions in the text to be recognized, respectively, X N The corresponding one is the first classification mark RL. After the Bert model 301 obtains the text sequence to be input, it needs to convert the text into a vector (Embedding). Embedding is represented by E, that is, the input vector sequence E1, E2...E is obtained by conversion. N , the Bert model 301 is provided with several layers of encoding networks (ie, Trm), and each layer of the encoding network includes a multi-head attention layer and a feedforward neural network layer. The multi-head attention layer and the feedforward neural network layer are connected to the summation layer and the normalization layer. The input vector sequence E1, E2…E N Converted to output vector sequence T1, T2…T N .

[0094] Furthermore, the output vector sequence T1, T2…T N The LSTM model 302 is input, and the output of the LSTM model 302 is the probability of each character for each entity label and the first classification label for each classification label. These probabilities will be the input of the CRF model 303. At the output layer of the CRF model 303, the prediction scores of each character for each entity label and the first classification label for each classification label are determined based on the feature matrix between the probabilities and labels output by the LSTM model 302 and the transfer matrix between the labels.

[0095] In other words, the prediction result finally output by the CRF model 303 is the prediction scores corresponding to multiple paths, and each path is formed by combining the corresponding labels at each position in the text to be recognized, among which the path with the highest prediction score is the true path, the entity labels corresponding to each character in the true path are the predicted entity labels corresponding to each character in the text to be recognized, and the classification label corresponding to the first classification mark in the true path is the predicted classification label corresponding to the first classification mark.

[0096] Schematically, assuming that the representation of the true path A is (B-PER, E-PER, O, O, B-COM, I-COM, E-COM, TRUE), in which B-PER represents the first character label of a person's name, E-PER represents the last character label of a person's name, O represents an independent character label, B-COM represents the first character label of a company name, I-COM represents the middle character label of a company name, E-COM represents the last character label of a company name, and TRUE represents a classification label. It can be determined that the text to be identified contains a person's name entity (B-PER, E-PER) and a company entity (B-COM, I-COM, E-COM), the person's name entity is composed of the first and second characters in the text to be identified, the company entity is composed of the fifth, sixth and seventh characters in the text to be identified, and the classification category of the text to be identified is the classification category indicated by the classification label TRUE.

[0097] Please refer to Figure 4 , which shows a flow chart of a method for training a text recognition model provided by an embodiment of the present application. The method may include steps S410 to S430, which are described in detail as follows:

[0098] In step S410, a second classification mark is added to the target sample text to generate a sample input object corresponding to the target sample text.

[0099] Among them, the target sample text is the sample data used to train the text recognition model, and the computer device can directly pull the target sample text from the Internet. After pulling the target sample text, the second classification mark can be added to the target sample text to obtain the sample input object corresponding to the target sample text. Compared with the target sample text, the input object corresponding to the target sample text has a second classification mark added. It should be noted that the added second classification mark is only a mark representing the classification, not a specific classification category. The added second classification mark can be added to the beginning, middle or end of the target sample text. As an example, the second classification mark can be "RN". Of course, the second classification mark is not limited to the above-mentioned English letters, and can also include but is not limited to at least one of the following forms: numbers, words, symbols, etc.

[0100] In one embodiment, a computer device may use a word segmentation method to divide the target sample text into units of characters to obtain a character sequence corresponding to the target sample text, and add a second classification mark to the character sequence corresponding to the target sample text to obtain a new character sequence, and then use the new character sequence as a sample input object corresponding to the target sample text.

[0101] In step S420, the sample input object is input into the model to be trained to obtain the prediction scores of each character in the target sample text output by the model to be trained for each entity label and the second classification mark for each classification label.

[0102] During the training process, the computer device can input the sample input object into the model to be trained to train the model to be trained. The model to be trained can be a combination model, specifically: (1) a bidirectional encoder representation (BERT), a model based on a long short-term memory network (LSTM) and a conditional random field (CRF). (2) a bidirectional long short-term memory network (Bi-LSTM) and a conditional random field (CRF). (3) a bidirectional encoder representation (BERT) and a conditional random field (CRF) model.

[0103] Specifically, the computer device can divide and process the sample input object to generate a text sequence corresponding to the target sample text, and then process each character in the text sequence according to the order of each character in the text sequence to obtain a vector sequence, and then determine the output probability of each character in the target sample text for each entity label and the second classification label for each classification label based on the vector sequence, and determine the prediction score of each character for each entity label and the first classification label for each classification label based on the feature matrix between the output probability and the label, and the transfer matrix between the labels. That is, after the sample input object is input into the model to be trained, the prediction scores corresponding to multiple paths output by the model to be trained can be obtained, and each path is formed by combining the labels corresponding to each position in the text to be identified.

[0104] For example, assuming that the target sample text contains two characters, which are w0 and w1 in order, the second classification label is RN, the entity labels include label1 and label2, and the classification labels include class1 and class2, then the model to be trained can output the prediction scores corresponding to the eight paths:

[0105] Prediction score P1 of path 1 {label1, label1, class1}

[0106] The prediction score P2 of path 2 {label1, label1, class2}

[0107] Prediction score P3 of path 3 {label1, label2, class1}

[0108] Prediction score P4 of path 4 {label1, label2, class2}

[0109] Prediction score P5 of path 5 {label2, label1, class1}

[0110] The prediction score P6 of path 6 {label2, label1, class2}

[0111] Prediction score P7 of path 7 {label2, label2, class1}

[0112] Prediction score P8 of path 8 {label2, label2, class2}

[0113] In step S430, a loss function is determined according to the labeled entity labels, the labeled category labels, and the predicted scores, and the parameters of the model to be trained are adjusted according to the loss function to obtain a text recognition model.

[0114] Since the labeled entity labels and the labeled classification labels can be manually labeled labels, they represent correct labels. Therefore, the computer device can determine the loss function according to the prediction scores, labeled entity labels, and labeled classification labels output by the model to be trained, and adjust the model parameters of the model to be trained in the direction of minimizing the loss function. The loss function can be reduced by updating the model parameters, the model parameters of the model to be trained are continuously optimized and counted, and the model parameters that minimize the loss function are determined using the minimization principle to obtain a text recognition model.

[0115] In one embodiment, Figure 5 As shown, the method for determining the loss function may specifically include steps S510 to S520, which are described in detail as follows:

[0116] Step S510: According to the annotated entity label and the annotated classification label, a target prediction score corresponding to the entity label that is the same as the annotated entity label and the classification label that is the same as the annotated classification label is determined from the prediction scores.

[0117] After the sample input object is input into the model to be trained, the prediction scores of each character in the target sample text output by the model to be trained for each entity label and the second classification mark for each classification label can be obtained.

[0118] Since the target sample text contains corresponding annotated entity labels and annotated classification labels, the entity labels and classification labels can be manually annotated and are correct and real labels. Therefore, when determining the loss function, we can first determine the target prediction score corresponding to the entity label that is the same as the annotated entity label and the classification label that is the same as the annotated classification label from the prediction score based on the annotated entity label and the annotated classification label.

[0119] Continuing with the example in the above step S420, assuming that the labeled entity label of w0 is label1, the labeled entity label of w1 is label2, and the labeled classification label of the second classification mark is class1, then the target prediction score corresponding to the entity label that is the same as the labeled entity label and the classification label that is the same as the labeled classification label is determined from the prediction scores to be P3.

[0120] Step S520: Determine the loss function according to the target prediction score.

[0121] Since the target prediction score is determined based on the annotated entity label and the annotated classification label, it is the prediction score corresponding to the true path, that is, the target prediction score should be the highest among the prediction scores corresponding to all paths. Therefore, the loss function can be determined based on the target prediction score.

[0122] In one embodiment of the present application, determining the loss function according to the target prediction score may specifically include: calculating the ratio between the target prediction score and the sum of the prediction scores; performing a logarithmic operation on the comparison value to obtain an operation result, and determining the loss function according to the operation result. Schematically, the loss function It can be defined as the following formula (1):

[0123] Formula (1)

[0124] in, is the target prediction score, , , is the prediction score.

[0125] In one embodiment of the present application, the target sample text may be a training text directly obtained by a computer device from the Internet, or may be a sample text obtained by processing the directly obtained text, such as Figure 6 As shown, in this embodiment, the text recognition method may further specifically include steps S610 to S640, which are specifically described as follows:

[0126] Step S610: Acquire keywords from a pre-established keyword library.

[0127] The pre-established keyword library refers to a vocabulary library consisting of pre-set words that can be selected as keywords, and the keyword library includes multiple keywords.

[0128] Optionally, different keyword libraries are set for texts of different categories. The keyword library corresponding to each category of text refers to a vocabulary consisting of pre-set words that can be selected as keywords for this type of text. For example, the keyword library corresponding to the text of the entertainment category includes words related to entertainment, such as the names of entertainment stars, the names of film and television dramas, the names of variety shows, etc.; for another example, the keyword library corresponding to the text of the sports category includes words related to sports, such as the names of sports stars, the names of sports events, the names of teams, etc.; for another example, the keyword library corresponding to the text of the public opinion category includes words related to public opinion risks, such as notification, false, etc.

[0129] Therefore, in order to obtain the target sample text for model training, keywords can be obtained from the keyword library in advance, and then the training text can be obtained through keywords. It can be understood that the text obtained through keywords will be more relevant to the text required for model training.

[0130] Step S620: According to the keywords, obtain sample text containing the keywords.

[0131] After obtaining the keywords, the computer device may further obtain sample texts containing the keywords. For example, the computer device may obtain texts containing the keywords posted by users of the social software from an open interface of the social software as sample texts.

[0132] Step S630: annotate some sample texts in the acquired sample texts with entity labels and category labels to generate initial sample texts.

[0133] Furthermore, after obtaining the sample text, part of the sample text may be selected for entity labeling and category labeling to generate an initial sample text.

[0134] It should be noted that the selection method may be random selection or selecting some sample texts according to preset rules.

[0135] Step S640: Perform data enhancement processing on the initial sample text to generate a target sample text.

[0136] Since the problem of lack of training data is often encountered during the model training process, in order to address this problem, in this embodiment, after obtaining the initial sample text annotated with labels, the initial sample text can be further subjected to data enhancement processing to generate the target sample text.

[0137] In some embodiments of the present application, the data enhancement processing method may specifically include: copying the initial sample text to obtain a copy of the initial sample text; and generating a target sample text based on the initial sample text and the copy of the initial sample text.

[0138] In some embodiments of the present application, the data enhancement processing method may also include: performing synonym replacement on the target keyword contained in the initial sample text to generate a sample text containing synonyms of the target keyword; generating a target sample text based on the initial sample text and the sample text containing synonyms of the target keyword.

[0139] In some embodiments of the present application, the data enhancement processing method may also include: deleting part of the text contained in the initial sample text to obtain a processed initial sample text; generating a target sample text based on the initial sample text and the processed initial sample text.

[0140] In some embodiments of the present application, the data enhancement processing method may also include: randomly inserting text into the initial sample text to obtain a new initial sample text; and generating a target sample text based on the initial sample text and the new initial sample text.

[0141] Of course, it is understandable that the data enhancement processing method for the initial sample text can also be any combination of the above methods, for example, a combination of a copy method and a synonym replacement method; a combination of a copy method and a deletion processing method, etc. The present application embodiment is not specifically limited here.

[0142] In one embodiment of the present application, after the initial sample text is subjected to data enhancement processing, the data obtained after the data enhancement processing may be further subjected to posteriori cleaning. If abnormal text is found, it is removed, and then the target sample text is generated based on the text after removal.

[0143] In order to analyze the effect of the text recognition model in the embodiment of the present application (denoted as the V3 model), it is compared with the keyword trigger model (denoted as the V1 model) and the pipeline model trained for named entity recognition and classification tasks respectively (denoted as the V2 model). The comparison results are shown in Table 1 below.

[0144]

[0145] Table 1

[0146] Among them, the comparison indicators include precision, coverage and F1 value. Precision is the proportion of correct predictions of the classification model for a certain category in a given test set. Coverage is the proportion of positive classes in the samples that are correctly predicted by the classification model for a certain category in a given test set. F1 value is a value that comprehensively considers precision and coverage. As can be seen from Table 1, the accuracy and coverage of the text recognition model in the embodiment of the present application have been significantly improved.

[0147] The following describes an apparatus embodiment of the present application, which can be used to execute the text recognition method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned embodiment of the text recognition method of the present application.

[0148] Figure 7 A block diagram of a text recognition device according to an embodiment of the present application is shown, referring to Figure 7 As shown, a text recognition device 700 according to an embodiment of the present application includes: a first adding unit 702 , a first input unit 704 , an acquiring unit 706 and a generating unit 708 .

[0149] Among them, the first adding unit 702 is configured to add a first classification mark to the text to be recognized to generate an input object corresponding to the text to be recognized; the first input unit 704 is configured to input the input object into a text recognition model, and the text recognition model is trained based on a target sample text carrying annotated entity labels and annotated classification labels, the annotated entity labels are entity labels corresponding to each character in the target sample text, and the annotated classification labels are classification labels corresponding to the second classification mark added to the target sample text; the acquisition unit 706 is configured to acquire the predicted entity labels corresponding to each character in the text to be recognized output by the text recognition model and the predicted classification labels corresponding to the first classification marks; the generation unit 708 is configured to generate an entity recognition result for the text to be recognized based on the predicted entity labels, and generate a classification result for the text to be recognized based on the predicted classification labels.

[0150] In some embodiments of the present application, the first adding unit 702 is configured to: divide the text to be recognized in units of characters to generate a character sequence corresponding to the text to be recognized; add the first classification mark to the character sequence to obtain a new character sequence, and use the new character sequence as an input object corresponding to the text to be recognized.

[0151] In some embodiments of the present application, the generation unit 708 is configured to: recognize characters in the text to be recognized that are continuously located and whose corresponding predicted entity labels indicate the same entity as the same entity, and obtain an entity recognition result for the text to be recognized; and use the classification category indicated by the predicted classification label as the classification result for the text to be recognized.

[0152] In some embodiments of the present application, the device also includes: a second adding unit, configured to add the second classification mark to the target sample text to generate a sample input object corresponding to the target sample text; a second input unit, configured to input the sample input object into the model to be trained to obtain the prediction score of each character in the target sample text output by the model to be trained for each entity label and the second classification mark for each classification label; a determination unit, configured to determine a loss function based on the labeled entity label, the labeled classification label and the prediction score, and adjust the parameters of the model to be trained according to the loss function to obtain the text recognition model.

[0153] In some embodiments of the present application, the determination unit includes: a prediction score determination subunit, configured to determine, based on the labeled entity label and the labeled classification label, a target prediction score corresponding to an entity label that is identical to the labeled entity label and a classification label that is identical to the labeled classification label from the prediction score; and a loss function determination subunit, configured to determine the loss function based on the target prediction score.

[0154] In some embodiments of the present application, the loss function determination subunit is configured to: calculate the ratio between the target prediction score and the sum of the prediction scores; perform a logarithmic operation on the ratio to obtain an operation result, and determine the loss function based on the operation result.

[0155] In some embodiments of the present application, the second adding unit is configured to: divide the target sample text into characters to generate a character sequence corresponding to the target sample text; add the second classification mark to the character sequence to obtain a new character sequence, and use the new character sequence as a sample input object corresponding to the target sample text.

[0156] In some embodiments of the present application, the device also includes: a keyword acquisition unit, configured to acquire keywords from a pre-established keyword library; a sample text acquisition unit, configured to acquire sample texts containing the keywords based on the keywords; a labeling unit, configured to perform entity label and category label labeling on part of the acquired sample texts to generate initial sample texts; and a processing unit, configured to perform data enhancement processing on the initial sample text to generate the target sample text.

[0157] In some embodiments of the present application, the processing unit is configured to: copy the initial sample text to obtain a copy of the initial sample text; and generate the target sample text according to the initial sample text and the copy of the initial sample text.

[0158] In some embodiments of the present application, the processing unit is configured to: perform synonym replacement on the target keyword contained in the initial sample text to generate a sample text containing a synonym of the target keyword; and generate the target sample text based on the initial sample text and the sample text containing a synonym of the target keyword.

[0159] In some embodiments of the present application, the processing unit is configured to: delete part of the text included in the initial sample text to obtain a processed initial sample text; and generate the target sample text based on the initial sample text and the processed initial sample text.

[0160] In some embodiments of the present application, the processing unit is configured to: randomly insert text into the initial sample text to obtain a new initial sample text; and generate the target sample text based on the initial sample text and the new initial sample text.

[0161] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0162] It should be noted that Figure 8 The computer system 800 of the electronic device 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.

[0163] like Figure 8As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803, such as executing the method described in the above embodiment. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, the ROM 802 and the RAM 803 are connected to each other through the bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.

[0164] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.

[0165] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program 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 part 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, various functions defined in the system of the present application are executed.

[0166] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, 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), a 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 the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier, which carries a computer-readable computer program. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0167] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two 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 box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart 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.

[0168] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0169] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.

[0170] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0171] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation method of the present application.

[0172] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0173] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A text recognition method, characterized in that: The method comprises: Adding a first classification mark to the text to be recognized to generate an input object corresponding to the text to be recognized; Inputting the input object into a text recognition model, wherein the text recognition model is trained based on a target sample text carrying annotated entity labels and annotated classification labels, wherein the annotated entity labels are entity labels corresponding to each character in the target sample text, and the annotated classification labels are classification labels corresponding to a second classification mark added to the target sample text; Obtain the predicted entity label corresponding to each character in the text to be recognized and the predicted classification label corresponding to the first classification label output by the text recognition model, wherein the predicted entity label corresponding to each character in the text to be recognized and the predicted classification label corresponding to the first classification label are obtained by the CRF layer in the text recognition model according to the probability of each input character for each entity label and the first classification label for each classification label; the probability of each character for each entity label and the first classification label for each classification label is obtained by the LSTM layer in the text recognition model based on the input object; An entity recognition result for the text to be recognized is generated based on the predicted entity label, and a classification result for the text to be recognized is generated based on the predicted classification label.

2. The method according to claim 1, characterized in that Adding a first classification mark to the text to be recognized to generate an input object corresponding to the text to be recognized includes: Dividing the text to be recognized into units of characters to generate a character sequence corresponding to the text to be recognized; The first classification mark is added to the character sequence to obtain a new character sequence, and the new character sequence is used as an input object corresponding to the text to be recognized.

3. The method according to claim 1, characterized in that Generating an entity recognition result for the text to be recognized according to the predicted entity label, and generating a classification result for the text to be recognized according to the predicted classification label, including: Recognize characters in the text to be recognized that are consecutively located and whose corresponding predicted entity tags indicate the same entity as the same entity, and obtain an entity recognition result for the text to be recognized; The classification category indicated by the predicted classification label is used as the classification result for the text to be recognized.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Adding the second classification mark to the target sample text to generate a sample input object corresponding to the target sample text; Inputting the sample input object into the model to be trained, and obtaining the prediction score of each character in the target sample text output by the model to be trained for each entity label and the second classification mark for each classification label; A loss function is determined according to the annotated entity label, the annotated category label and the predicted score, and the parameters of the model to be trained are adjusted according to the loss function to obtain the text recognition model.

5. The method according to claim 4, characterized in that Determining a loss function according to the labeled entity label, the labeled classification label, and the predicted score includes: According to the annotated entity label and the annotated classification label, determining from the prediction scores a target prediction score corresponding to an entity label identical to the annotated entity label and a classification label identical to the annotated classification label; The loss function is determined according to the target prediction score.

6. The method according to claim 5, characterized in that Determining the loss function according to the target prediction score includes: Calculating a ratio between the target prediction score and the sum of the prediction scores; A logarithmic operation is performed on the ratio to obtain an operation result, and the loss function is determined according to the operation result.

7. The method according to claim 4, characterized in that Adding the second classification mark to the target sample text to generate a sample input object corresponding to the target sample text includes: Dividing the target sample text into characters to generate a character sequence corresponding to the target sample text; The second classification mark is added to the character sequence to obtain a new character sequence, and the new character sequence is used as a sample input object corresponding to the target sample text.

8. The method according to claim 4, characterized in that The method further comprises: Get keywords from a pre-built keyword library; According to the keyword, obtaining a sample text containing the keyword; Annotate some of the sample texts in the acquired sample texts with entity labels and category labels to generate initial sample texts; The initial sample text is subjected to data enhancement processing to generate the target sample text.

9. The method according to claim 8, characterized in that Performing data enhancement processing on the initial sample text to generate the target sample text includes: Copying the initial sample text to obtain a copy of the initial sample text; The target sample text is generated according to the initial sample text and a copy of the initial sample text.

10. The method according to claim 8, characterized in that Performing data enhancement processing on the initial sample text to generate the target sample text includes: Performing synonym replacement on the target keyword contained in the initial sample text to generate a sample text containing a synonym of the target keyword; The target sample text is generated according to the initial sample text and the sample text containing the synonym of the target keyword.

11. The method according to claim 8, characterized in that Performing data enhancement processing on the initial sample text to generate the target sample text includes: Deleting some of the words contained in the initial sample text to obtain a processed initial sample text; The target sample text is generated according to the initial sample text and the processed initial sample text.

12. The method according to claim 8, characterized in that Performing data enhancement processing on the initial sample text to generate the target sample text includes: randomly inserting text into the initial sample text to obtain a new initial sample text; The target sample text is generated according to the initial sample text and the new initial sample text.

13. A text recognition device, characterized in that: The device comprises: A first adding unit is configured to add a first classification mark to the text to be recognized, so as to generate an input object corresponding to the text to be recognized; A first input unit is configured to input the input object into a text recognition model, wherein the text recognition model is trained based on a target sample text carrying an annotated entity label and annotated classification label, wherein the annotated entity label is an entity label corresponding to each character in the target sample text, and the annotated classification label is a classification label corresponding to a second classification mark added to the target sample text; an acquisition unit, configured to acquire predicted entity labels corresponding to each character in the text to be recognized and predicted classification labels corresponding to the first classification mark output by the text recognition model, wherein the predicted entity labels corresponding to each character in the text to be recognized and the predicted classification labels corresponding to the first classification mark are obtained by the CRF layer in the text recognition model according to the probability of each input character for each entity label and the first classification mark for each classification label; the probability of each character for each entity label and the first classification mark for each classification label is obtained by the LSTM layer in the text recognition model based on the input object; A generating unit is configured to generate an entity recognition result for the text to be recognized based on the predicted entity label, and to generate a classification result for the text to be recognized based on the predicted classification label.

14. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text recognition method according to any one of claims 1 to 12 is implemented.

15. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the text recognition method according to any one of claims 1 to 12.

16. A computer program product, characterized in that The computer program product comprises computer instructions, which are suitable for being loaded by a processor and executing the text recognition method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Entity extraction and event classification method and device for expressway emergencies

    CN112084336A

  • Accident disaster news-based information structuralization method

    CN112269949A