Entity extraction model training method and device and entity extraction method and device

By dividing the NER recognition task into two subtasks: entity character set and character sequence recognition, and using the sequence prediction module, the problem of incorrect character sequence in entity recognition results in the NER framework is solved, and the accuracy of the entity extraction model is improved.

CN118535730APending Publication Date: 2024-08-23ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410551463.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-06
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

The existing NER extraction framework cannot guarantee the correct character order of the extraction results in entity recognition tasks, making it unusable in actual business scenarios.

Method used

By dividing the NER recognition task into two subtasks: entity character set recognition and character sequence recognition, the encoder and sequence prediction module of the initial entity extraction model are used to learn the entity character set and sequence of the input text, and build an N×N sequence prediction matrix. P is used to determine the loss function and update the model parameters until the target entity extraction model is obtained.

Benefits of technology

It solves the problem of incorrect character order in entity recognition results in the NER framework, improves the accuracy of the entity extraction model, and enables usable results to be generated in actual business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535730A
    Figure CN118535730A
Patent Text Reader

Abstract

The embodiment of the invention discloses an entity extraction model training method, which is characterized in that a sequence prediction module is added in an NER training framework, an entity character set of an input text is learned through an NER main framework, and an entity character sequence of the input text is learned through the sequence prediction module. In this way, the problem that the character sequence of the entity recognition result of the current NER frame is wrong can be solved. The training device of the entity extraction model, and the entity extraction method and device provided by the embodiment of the specification also have the above beneficial effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical fields of artificial intelligence and natural language processing, and particularly relates to a method and device for training an entity extraction model and an entity extraction method. Background Art

[0002] The NER (Named Entity Recognition) task refers to the entity recognition task, aiming to identify entities in a text. The current NER extraction framework usually only solves the scope screening of entities and cannot guarantee the reading order of the extracted content. For example, the extracted person's name is "Three Zhangs", but the actual extraction result is "Zhang San", resulting in the problem that the extraction result is unavailable in actual business scenarios. Summary of the Invention

[0003] One or more embodiments of the present specification provide a method and device for training an entity extraction model and an entity extraction method, which can solve the problem of incorrect character order in the entity extraction result in the entity recognition task.

[0004] In a first aspect, a method for training an entity extraction model is provided. The training method includes:

[0005] Obtain a training sample set, where the training sample set includes at least one text sample and the entity label of the text sample; the entity label includes a first label and a second label, the first label is used to represent the type and character set of the entity, and the second label is used to represent the character order of the entity;

[0006] Input the text sample into the encoder of the initial entity extraction model to obtain the character features of the text sample;

[0007] Input the character features of the text sample into the decoder of the initial entity extraction model to obtain the character set of the predicted entity;

[0008] Determine a first loss function according to the character set of the predicted entity and the first label;

[0009] Input the character features of the text sample into the order prediction module of the initial entity extraction model to obtain the character feature order of the predicted entity;

[0010] Determine a second loss function according to the character feature order of the predicted entity and the second label;

[0011] Update the parameters of the initial entity extraction model according to the first loss function and the second loss function until a target entity extraction model is obtained.

[0012] As an optional implementation manner of the method described in the first aspect, obtaining the text sample specifically includes:

[0013] Get page image sample;

[0014] Perform OCR recognition on the page image sample to obtain the text sample.

[0015] As an optional implementation of the method of the first aspect, the first tag uses the same mark to mark each character in the same entity so as to lose the character order of the entity.

[0016] As an optional implementation of the method described in the first aspect, the sequence prediction module learns the character feature sequence of the predicted entity by constructing an N×N sequence prediction matrix P, where N represents the total number of character features of the text sample; each element Pi j in the sequence description matrix P represents the sequential relationship between the i-th character feature and the j-th character feature of the text sample.

[0017] Specifically, determining the second loss function according to the character feature sequence of the predicted entity and the second label may include:

[0018] The second loss function is determined according to the character feature sequence of the predicted entity described by the sequence prediction matrix P and the character sequence of the entity described by the second label.

[0019] Specifically, the above training method may also include:

[0020] The sequence prediction matrix P is initialized according to the character feature sequence of the text sample.

[0021] In a second aspect, a training device for an entity extraction model is provided, comprising:

[0022] A first data acquisition module is used to acquire a training sample set, wherein the training sample set includes at least one text sample and an entity label of the text sample; the entity label includes a first label and a second label, wherein the first label is used to represent the type and character set of the entity, and the second label is used to represent the character sequence of the entity;

[0023] The first processing module is used to input the text sample into the encoder of the initial entity extraction model to obtain the character features of the text sample; input the character features of the text sample into the decoder of the initial entity extraction model to obtain the character set of the predicted entity; determine the first loss function according to the character set of the predicted entity and the first label; input the character features of the text sample into the sequence prediction module of the initial entity extraction model to obtain the character feature sequence of the predicted entity; determine the second loss function according to the character feature sequence of the predicted entity and the second label; update the parameters of the initial entity extraction model according to the first loss function and the second loss function until the target entity extraction model is obtained.

[0024] As an optional implementation of the device described in the second aspect, the sequence prediction module learns the character feature sequence of the predicted entity by constructing an N×N sequence prediction matrix P, where N represents the total number of character features of the text sample; each element Pi j in the sequence description matrix P represents the sequential relationship between the i-th character feature and the j-th character feature of the text sample.

[0025] Specifically, the sequence prediction module is specifically used to determine the second loss function according to the character feature sequence of the predicted entity described by the sequence prediction matrix and the character sequence of the entity described by the second label.

[0026] In a third aspect, an entity extraction method is provided, comprising:

[0027] Get the target text;

[0028] Input the target text into an entity extraction model pre-trained according to the entity extraction model training method described above, and obtain a character set of the target entity output by a decoder of the entity extraction model, and a character sequence of the target entity output by a sequence prediction module of the entity extraction model;

[0029] An entity extraction result of the target text is determined according to the character set of the target entity and the character sequence of the target entity.

[0030] As an optional implementation manner of the method according to the third aspect, obtaining the target document specifically includes:

[0031] Get the target page image;

[0032] Perform OCR recognition on the target page image to obtain the target text.

[0033] In a fourth aspect, an entity extraction device is provided, comprising:

[0034] A second data acquisition module is used to acquire the target text;

[0035] The second processing module is used to input the target text into the entity extraction model pre-trained according to the above-mentioned entity extraction model training method, obtain the character set of the target entity output by the decoder of the entity extraction model, and the character sequence of the target entity output by the sequence prediction module of the entity extraction model; determine the entity extraction result of the target text according to the character set of the target entity and the character sequence of the target entity.

[0036] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program runs on an electronic device, the electronic device executes the above-mentioned entity extraction model training method, or executes the above-mentioned entity extraction method.

[0037] In a sixth aspect, an electronic device is provided, including:

[0038] at least one memory for storing a program;

[0039] At least one processor is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute the above-mentioned entity extraction model training method, or execute the above-mentioned entity extraction method.

[0040] The beneficial effect of the training method of the entity extraction model described in the embodiment of this specification is that a subtask of entity character order prediction is added to the traditional NER training framework, that is, the entity character set of the input text is learned through the NER main framework, and then a sequence prediction module is added to learn the entity character order of the input text. In this way, the problem of character order error in the entity recognition result of the current NER framework can be solved.

[0041] The entity extraction model training device, entity extraction method and device described in the embodiments of this specification also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0043] Figure 1 A flowchart of a method for training an entity extraction model described in an embodiment of this specification is exemplarily shown.

[0044] Figure 2 The structural diagram of an entity extraction model described in the embodiment of this specification is exemplarily shown.

[0045] Figure 3 The schematic diagram of the initialization process of a sequential prediction matrix P described in an embodiment of this specification is exemplarily shown.

[0046] Figure 4 The structural diagram of a training device for an entity extraction model described in an embodiment of this specification is exemplarily shown.

[0047] Figure 5 A flowchart of an entity extraction method described in an embodiment of this specification is exemplarily shown.

[0048] Figure 6 The schematic diagram of the structure of an entity extraction device described in an embodiment of this specification is exemplarily shown.

[0049] Figure 7 The structural diagram of an electronic device described in an embodiment of this specification is exemplarily shown. DETAILED DESCRIPTION

[0050] First of all, it should be noted that the terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates otherwise.

[0051] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Therefore, it should be recognized by those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0052] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0053] Most of the current research and development of NER (Named Entity Recognition) frameworks focuses on basic document content understanding, and the design of downstream tasks is too simple, resulting in information extraction problems in actual scenarios. It only solves the range screening of entities and does not guarantee the reading order of the extracted content. For example, the extracted person's name is "San Zhang", but the actual extraction result is "Zhang San", which leads to the problem of being unusable in actual business scenarios.

[0054] In view of this, one or more embodiments of the present specification propose an entity extraction model training and entity extraction method and device, which can solve the problem of incorrect character order in entity extraction results in entity recognition tasks.

[0055] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0056] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.

[0057] Please refer to Figure 1 , Figure 1 A flowchart of a method for training an entity extraction model proposed in one or more embodiments of this specification. Figure 1 The training method shown can be executed by a training device for an entity extraction model, which can be set on a terminal device or a server. The terminal device can be a smart device such as a mobile phone, a tablet computer, a desktop computer, a portable notebook, etc. The server can be an independent server or a server cluster composed of multiple servers.

[0058] like Figure 1 As shown, the above-mentioned entity extraction model training method includes steps S100-S112.

[0059] S100: Obtain a training sample set.

[0060] The training sample set mentioned above includes at least one text sample and an entity label of the text sample.

[0061] The text sample can usually be obtained from the OCR recognition result of the page image sample. For example, the text sample can be constructed based on all or part of the OCR recognition result of the page image sample. The above-mentioned page image sample can be a photo, a webpage screenshot, etc. The page image sample can contain only text information or multimodal information such as text and image, which is not limited in this embodiment.

[0062] Entity tags are used to annotate entities in text samples. In conventional NER frameworks, sequence annotation usually uses entity tags to represent the part of speech and morphological information of entities. Common annotation methods include BIO annotation, BIOSE annotation, and IOB annotation. Taking BIO annotation as an example, the principle of BIO annotation is to annotate each character of a word (including the starting character, middle character, and end character of the word) as one of the three types of B, I, and O. Among them, B indicates that the character is the starting character of the word, I indicates that the character is the middle character of the word, and O indicates that the character is not the starting or middle character of any word. Considering that the above-mentioned text samples are usually the OCR recognition results of page image samples, and there may be problems such as character dislocation and overlap in page image samples, the OCR recognition results, that is, the order of characters in the text sample may be wrong. Therefore, when performing BIO annotation on such text samples, the order of the three types of tags B, I, and O may also be wrong.

[0063] In order to solve the above problems, this embodiment improves the current NER training method and divides the NER recognition task into two subtasks, the first subtask is used to identify the character set contained in the entity, and the second subtask is used to identify the character order of the entity. Accordingly, the entity label used in this embodiment includes a first label and a second label, wherein the first label is used to represent the type and character set of the entity, and the second label is used to represent the character order of the entity.

[0064] In a feasible implementation, the first label above uses the same mark to mark each character in the same entity, so as to lose the character order of the entity. Taking the entity "Zhang San" in the text sample as an example, when the entity "Zhang San" is marked with BIO, the label is Zhang (B-name) San (I-name). In order to lose the character order of the entity, this embodiment adopts a new marking method, that is, marking it as Zhang (E-name) San (E-name). Through this marking method, the character order of the entity can be lost, so that the entity extraction model only learns the character set of the entity in the first subtask.

[0065] S102: Input the text sample into the encoder of the initial entity extraction model to obtain character features of the text sample.

[0066] This embodiment improves the existing NER recognition framework by adding a sequence prediction module to the original NER recognition framework to learn the character sequence of entities. The backbone network of the NER recognition framework can be implemented using a network structure such as BERT, LayoutLM, etc., which is not limited in this embodiment.

[0067] The following takes LayoutLM as an example of the encoder of the above entity extraction model to illustrate the structure of the above entity extraction model.

[0068] Please refer to Figure 2 , Figure 2 A schematic diagram of the structure of an entity extraction model is shown schematically. Figure 2 As shown, the entity extraction model includes a main frame on the left and a sequential prediction module on the right. Among them, the main frame includes an encoder and a decoder, and the encoder is implemented using the LayoutLM model. The input of the LayoutLM model is a text sample (the text sample specifically refers to the OCR recognition result of the page image sample). The text sample includes text content and text position information. The input layer of the LayoutLM model maps the text content to a word vector, maps the text position information to a text position vector, and then combines the word vector and the text position vector as the input vector of the feature extraction network of the LayoutLM model. After the LayoutLM model extracts features from the input vector, the character features of the text sample [CLS, T1, T2, T3, T4...Tn-3, Tn-2, Tn-1, Tn] can be obtained.

[0069] The above text position vector is a 2D position vector. When constructing the text position vector, for each character's OCR text detection box, a coordinate system is constructed based on the text sample, and then the coordinates (x0, y0) are used to describe the position of the upper left corner of the text detection box in the text sample coordinate system, and the coordinates (x1, y1) are used to describe the position of the lower right corner of the text detection box in the text sample coordinate system. Then, four position embedding vectors are constructed through the embedding table, representing x0, y0, x1, and y1 respectively, to obtain a 2D position vector.

[0070] S104: Inputting the character features of the text sample into the decoder of the initial entity extraction model to obtain a character set of the predicted entity.

[0071] The above-mentioned decoder is an output layer that is only related to a specific task. The structure of the decoder can be adaptively selected according to the specific task. For example, in this embodiment, learning is required for the first subtask. Therefore, the decoder of this embodiment is used to predict the character set of the entity. All decoders that can achieve this purpose can be applied to this step.

[0072] S106: Determine a first loss function according to the character set of the predicted entity and the first label.

[0073] Specifically, a difference set may be obtained between the character set represented by the first label and the character set of the predicted entity, and the first loss function mentioned above may be constructed based on the difference set.

[0074] S108: Inputting the character features of the text sample into the sequence prediction module of the initial entity extraction model to obtain the character feature sequence of the predicted entity.

[0075] Please continue to refer to Figure 2 , considering that the order of character features extracted by the encoder is not necessarily correct, it is necessary to learn the character order of the predicted entity through the sequential prediction module. Since the character feature order of the corresponding predicted entity in the character features of the text sample is consistent with the character order of the predicted entity, the character order of the predicted entity can be learned by learning the character feature order of the predicted entity. Specifically, the sequential prediction module can construct an N×N sequential prediction matrix P to learn the character feature order of the predicted entity. The row elements of the sequential prediction matrix P represent each character feature of the text sample, that is, [CLS, T1, T2, T3, T4...Tn-3, Tn-2, Tn-1, Tn], and the column elements of the sequential prediction matrix P also represent each character feature of the text sample, that is, [CLS, T1, T2, T3, T4...Tn-3, Tn-2, Tn-1, Tn]. Each element Pij in the order prediction matrix P represents the order relationship between the i-th character feature Ti and the j-th character feature Tj of the text sample. The value of Pij can be set according to the requirements. For example, it can be set to a specific value (for example, Pij = 1) to indicate that the i-th character feature and the j-th character feature of the text sample are connected head to tail, that is, the i-th character feature and the j-th character feature of the text sample belong to the same entity and the character order of the entity is Ti->Tj. Figure 2 As shown, the elements with a value of 1 in the sequential prediction matrix P indicate that the character features at the corresponding positions are connected head to tail. Figure 2 There are two paths T2->T3 and Tn-3->Tn-2->Tn-1 in the , which means that the character features T2->T3 and Tn-3->Tn-2->Tn-1 are two entities.

[0076] Considering that the order prediction matrix P needs to predict the values ​​of N×N elements, the amount of calculation is large, and the order of some characters in the text sample (that is, the OCR recognition result) is correct, the order prediction matrix P can be initialized according to the character order of the text sample. The following is a specific example to illustrate the initialization method of the order prediction matrix P, please refer to Figure 3 , Figure 3 The text content of the text sample shown in (a) is "I use Alipay to pay." The sentence contains two entities, one entity is "Alipay" and the other entity is "payment", that is, the character order of the entity "Alipay" should be "pay->pay->bao", and the character order of the entity "payment" should be "pay->money". However, due to the error in OCR recognition, this sentence is broken into two short sentences: segment1 = "I use payment", segment2 = "Bao Lai pays." The character order of these two short sentences is currently "I->use->pay->pay" and "Bao->come->pay->money->.". Obviously, the character order of the entities in the sentence is not completely correct at this time. However, in segment1, the order of the characters "pay->pay" is correct, and in segment2, the order of the characters "pay->money" is also correct. When initializing the order prediction matrix P, the order prediction matrix P can be initialized according to the character order of segment1 and segment2. The result is as follows: Figure 3 As shown in (b) in . Through the continuous training of the entity extraction model, the element values ​​in the order prediction matrix P will be continuously updated, and finally a sequence prediction matrix representing the correct entity character order is obtained, that is, Figure 3 The sequential prediction matrix shown in (c) in .

[0077] S110: Determine a second loss function according to the character feature sequence of the predicted entity and the second label.

[0078] Please continue to refer to Figure 2 and Figure 3 Specifically, the entity character sequence represented by the second label can be constructed as an N×N target matrix, which is as follows: Figure 3 As shown in (c) in the figure, the second loss function is constructed based on the difference between the sequential prediction matrix P of the predicted entity and the target matrix.

[0079] S112: Update the parameters of the initial entity extraction model according to the first loss function and the second loss function until the target entity extraction model is obtained.

[0080] In an achievable implementation, the first loss function and the second loss function may be combined to perform end-to-end training on the initial entity extraction model. Specifically, the first loss function and the second loss function may be weighted and summed to obtain a total loss function, and the total loss function may be used to iteratively update the parameters of the initial entity extraction model until a target entity extraction model that meets preset conditions is obtained.

[0081] In this training method, the current general NER recognition framework is improved, a sequence prediction module is added to the NER recognition framework, and the NER recognition task is divided into an entity character set recognition task and an entity character sequence recognition task. The entity character set recognition task is trained through the main framework of the NER recognition framework, and the entity character sequence recognition task is trained through the sequence prediction module. Based on the recognition results of the main framework of the NER recognition framework and the recognition results of the sequence prediction module, the entity part of speech and entity character sequence can be determined. This solves the problem of incorrect character order in the recognition results of the existing NER recognition framework.

[0082] In addition, this training method simplifies the label design of the NER recognition task. For the same entity, a normalized label is used to annotate it, thereby losing the entity character order and reducing the difficulty of model learning.

[0083] On the other hand, this training method also initializes the sequence prediction matrix of the sequence prediction module based on the prior knowledge of the OCR recognition results (text samples), which makes the learning cost of the model lower and improves the convergence speed of the model.

[0084] The above is a training method for the entity extraction model described in one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding training device, such as Figure 4 shown.

[0085] Figure 4 The structural diagram of a training device for an entity extraction model is schematically shown, and the training device comprises:

[0086] The first data acquisition module 401 is used to acquire a training sample set. The training sample set includes at least one text sample and an entity label of the text sample. The entity label includes a first label and a second label, wherein the first label is used to represent the type and character set of the entity, and the second label is used to represent the character order of the entity.

[0087] The first processing module 402 is used to input the text sample into the encoder of the initial entity extraction model to obtain the character features of the text sample; input the character features of the text sample into the decoder of the initial entity extraction model to obtain the character set of the predicted entity; determine the first loss function according to the character set of the predicted entity and the first label; input the character features of the text sample into the sequence prediction module of the initial entity extraction model to obtain the character feature sequence of the predicted entity; determine the second loss function according to the character feature sequence of the predicted entity and the second label; update the parameters of the initial entity extraction model according to the first loss function and the second loss function until the target entity extraction model is obtained.

[0088] Optionally, the above-mentioned sequence prediction module can specifically learn to predict the character feature sequence of the entity by constructing an N×N sequence prediction matrix P, where N represents the total number of character features of the text sample; each element Pij in the sequence description matrix P represents the sequence relationship between the i-th character feature and the j-th character feature of the text sample. The value of Pij can be set according to demand. For example, it can be set to when Pij is a specific value (for example, Pij=1), indicating that there is a head-to-tail relationship between the i-th character feature and the j-th character feature of the text sample, that is, indicating that the i-th character feature and the j-th character feature of the text sample belong to the same entity and the character sequence of the entity is Ti->Tj. Considering that the sequence prediction matrix P needs to predict the values ​​of N×N elements, the amount of calculation is large, and the order of some characters in the text sample (that is, the OCR recognition result) is correct, therefore, the sequence prediction matrix P can be initialized according to the character sequence of the text sample.

[0089] Optionally, the sequence prediction module can determine the second loss function based on the character feature order of the predicted entity described by the sequence prediction matrix P and the character order of the entity described by the second label. Specifically, the sequence prediction module can construct the character order of the entity represented by the second label as an N×N target matrix. The above-mentioned second loss function is constructed based on the difference between the sequence prediction matrix P of the predicted entity and the target matrix.

[0090] For the above-mentioned training device of an entity extraction model, taking a module as an example of a software functional unit, the first data acquisition module 401 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the first data acquisition module 401 may include code running on multiple hosts / virtual machines / containers. The multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with close geographical locations. Among them, usually a region may include multiple AZs.

[0091] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.

[0092] As an example of a hardware functional unit, the first data acquisition module 401 may include at least one computing device, such as a server, etc. Alternatively, the first data acquisition module 401 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0093] The multiple computing devices included in the first data acquisition module 401 can be distributed in the same region or in different regions. The multiple computing devices included in the first data acquisition module 401 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the first data acquisition module 401 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0094] In other embodiments, the first data acquisition module 401 can be used to execute any step in the above-mentioned entity extraction model training method, and the first processing module 402 can be used to execute any step in the above-mentioned entity extraction model training method. The steps that the first data acquisition module 401 and the first processing module 402 are responsible for implementing can be specified as needed, and the first data acquisition module 401 and the first processing module 402 respectively implement different steps in the above-mentioned entity extraction model training method to realize all functions of the above-mentioned entity extraction model training device.

[0095] In this implementation, the training device of the entity extraction model can also be applied to computing devices such as computers and servers, or to a computing device cluster including at least one computing device, to realize the training function of the entity extraction model.

[0096] This embodiment also proposes an entity extraction method, please refer to Figure 5 , Figure 5 A flowchart of an entity extraction method proposed in one or more embodiments of this specification. Figure 5 The entity extraction method shown can be executed by an entity extraction device, which can be set in a terminal device or a server. The terminal device can be a smart device such as a mobile phone, a tablet computer, a desktop computer, a portable notebook, etc. The server can be an independent server or a server cluster composed of multiple servers.

[0097] like Figure 5 As shown, the entity extraction method includes steps S500 to S504:

[0098] S500: Acquire target text.

[0099] The target text mentioned above may specifically refer to an OCR recognition result, that is, the target text mentioned above is obtained by performing OCR recognition on the target page image.

[0100] S502: Input the target text into a pre-trained entity extraction model to obtain a character set of the target entity output by a decoder of the entity extraction model and a character sequence of the target entity output by a sequence prediction module of the entity extraction model.

[0101] The above-mentioned entity extraction model is pre-trained by the above-mentioned entity extraction model training method.

[0102] S504: Determine the entity extraction result of the target text according to the character set of the target entity and the character sequence of the target entity.

[0103] The main framework part of the entity extraction model outputs the character set of the predicted entity, and the order prediction module of the entity extraction model outputs the character sequence of the predicted entity. By combining the output results of these two parts, the entity recognition result with the correct character sequence can be obtained.

[0104] Corresponding to the above entity extraction method, this embodiment also provides an entity extraction device, please refer to Figure 6 , Figure 6 An entity extraction device is shown as an example, which can be used to implement the above-mentioned entity extraction method. It should be noted that an entity extraction method described in one or more embodiments of the present application can rely on Figure 6The entity extraction device shown is implemented, but not limited to this device.

[0105] like Figure 6 As shown, the entity extraction device includes:

[0106] The second data acquisition module 601 is used to acquire the target text.

[0107] The second processing module 602 is used to input the target text into a pre-trained entity extraction model to obtain the character set of the target entity output by the decoder of the entity extraction model and the character sequence of the target entity output by the sequence prediction module of the entity extraction model; and determine the entity extraction result of the target text based on the character set of the target entity and the character sequence of the target entity.

[0108] For the second data acquisition module 601, the target text acquired by this module can be the OCR recognition result of the target page image. The target page image can be a photo, a web page screenshot, etc. The target page image can contain only text information, or it can contain multimodal information such as text and images. This embodiment does not impose any restrictions on this.

[0109] For the second processing module 602, the module can pre-train the entity extraction model by using the above-mentioned entity extraction model training method in an online or offline manner, or can load an entity extraction model pre-trained by using the above-mentioned entity extraction model training method.

[0110] For the above-mentioned entity extraction device, taking a module as an example of a software functional unit, the second data acquisition module 601 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the second data acquisition module 601 may include code running on multiple hosts / virtual machines / containers. The multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with close geographical locations. Among them, usually a region may include multiple AZs.

[0111] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.

[0112] As an example of a hardware functional unit, the second data acquisition module 601 may include at least one computing device, such as a server, etc. Alternatively, the second data acquisition module 601 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0113] The multiple computing devices included in the second data acquisition module 601 can be distributed in the same region or in different regions. The multiple computing devices included in the second data acquisition module 601 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the second data acquisition module 601 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0114] In other embodiments, the second data acquisition module 601 can be used to execute any step in the above-mentioned entity extraction method, and the second processing module 602 can be used to execute any step in the above-mentioned entity extraction method. The steps that the second data acquisition module 601 and the second processing module 602 are responsible for implementing can be specified as needed, and the second data acquisition module 601 and the second processing module 602 respectively implement different steps in the above-mentioned entity extraction method to realize all the functions of the above-mentioned entity extraction device.

[0115] In this implementation, the entity extraction device can also be applied to computing devices such as computers and servers, or to a computing device cluster including at least one computing device, to implement the entity extraction function.

[0116] In some embodiments, an electronic device is also provided. Figure 7 , the electronic device includes: a bus 701, a processor 702, a memory 703 and a communication interface 704. The processor 702, the memory 703 and the communication interface 704 communicate with each other through the bus 701. The electronic device can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the electronic device.

[0117] The bus 701 may be a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The use of only one line does not mean that there is only one bus or one type of bus. Bus 701 may include a path for transmitting information between various components of the electronic device (eg, processor 702, memory 703, and communication interface 704).

[0118] The processor 702 may include any one or more of a processor such as a CPU, a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0119] The memory 703 may include a volatile memory, such as a random access memory (RAM). The memory 703 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0120] The memory 703 stores executable program codes, and the processor 702 executes the executable program codes to respectively implement the functions of the first data acquisition module 401 and the first processing module 402, that is, to implement the functions of the training device for the entity extraction model, thereby implementing the training method for the entity extraction model. Alternatively, the processor 702 executes the executable program codes to respectively implement the functions of the second data acquisition module 601 and the second processing module 602, that is, to implement the functions of the entity extraction device, thereby implementing the entity extraction method.

[0121] The communication interface 704 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the electronic device and other devices or a communication network.

[0122] In some embodiments, a computer-readable storage medium is also provided, on which a computer program is stored. When the computer program is executed by a processor, it implements the above-mentioned training method of the entity extraction model, or implements the above-mentioned entity extraction method.

[0123] The computer-readable storage medium may be any available medium that can be stored in an electronic device or a data storage device such as a data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the electronic device to execute the above-mentioned entity extraction model training method, or to execute the above-mentioned entity information extraction method.

[0124] It is to be understood that the structure illustrated in the embodiments of this specification does not constitute a specific limitation on the system of the embodiments of this specification. In other embodiments of the specification, the above system may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0125] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0126] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0127] It should be noted that the above examples are only specific embodiments of the present invention, and the present invention is obviously not limited to the above examples, and there are many similar variations. All variations directly derived or associated from the contents disclosed by the technicians in this field should fall within the protection scope of the present invention.

Claims

1. A training method for an entity extraction model, comprising: Acquire a training sample set, wherein the training sample set includes at least one text sample and an entity label of the text sample; The entity tag includes a first tag and a second tag, the first tag is used to represent the type and character set of the entity, and the second tag is used to represent the character order of the entity; Inputting the text sample into an encoder of an initial entity extraction model to obtain character features of the text sample; Inputting the character features of the text sample into the decoder of the initial entity extraction model to obtain a character set of the predicted entity; Determining a first loss function according to the character set of the predicted entity and the first label; Inputting the character features of the text sample into the sequence prediction module of the initial entity extraction model to obtain the character feature sequence of the predicted entity; Determining a second loss function according to the character feature sequence of the predicted entity and the second label; According to the first loss function and the second loss function, the parameters of the initial entity extraction model are updated until the target entity extraction model is obtained.

2. The method according to claim 1, obtaining the text sample, specifically comprising: Get page image sample; Perform OCR recognition on the page image sample to obtain the text sample.

3. The method as claimed in claim 1, wherein the first tag uses the same mark to mark each character in the same entity so as to lose the character order of the entity.

4. According to the method described in claim 1, the sequence prediction module learns the character feature sequence of the predicted entity by constructing an N×N sequence prediction matrix P, where N represents the total number of character features of the text sample; each element Pij in the sequence description matrix P represents the sequence relationship between the i-th character feature and the j-th character feature of the text sample.

5. The method according to claim 4, determining a second loss function according to the character feature sequence of the predicted entity and the second label, specifically comprising: The second loss function is determined according to the character feature sequence of the predicted entity described by the sequence prediction matrix P and the character sequence of the entity described by the second label.

6. The method of claim 4, further comprising: The sequence prediction matrix P is initialized according to the character feature sequence of the text sample.

7. A training device for an entity extraction model, comprising: A first data acquisition module, used to acquire a training sample set, wherein the training sample set includes at least one text sample and an entity label of the text sample; The entity tag includes a first tag and a second tag, the first tag is used to represent the type and character set of the entity, and the second tag is used to represent the character order of the entity; The first processing module is used to input the text sample into the encoder of the initial entity extraction model to obtain the character features of the text sample; input the character features of the text sample into the decoder of the initial entity extraction model to obtain the character set of the predicted entity; determine the first loss function according to the character set of the predicted entity and the first label; input the character features of the text sample into the sequence prediction module of the initial entity extraction model to obtain the character feature sequence of the predicted entity; determine the second loss function according to the character feature sequence of the predicted entity and the second label; update the parameters of the initial entity extraction model according to the first loss function and the second loss function until the target entity extraction model is obtained.

8. In the device as described in claim 7, the sequence prediction module learns the character feature sequence of the predicted entity by constructing an N×N sequence prediction matrix P, where N represents the total number of character features of the text sample; each element Pij in the sequence description matrix P represents the sequence relationship between the i-th character feature and the j-th character feature of the text sample.

9. In the device as described in claim 8, the sequence prediction module is specifically used to determine the second loss function based on the character feature sequence of the predicted entity described by the sequence prediction matrix P and the character sequence of the entity described by the second label.

10. An entity extraction method, comprising: Get the target text; Inputting the target text into an entity extraction model pre-trained according to the method according to any one of claims 1 to 6, obtaining a character set of the target entity output by a decoder of the entity extraction model, and a character sequence of the target entity output by a sequence prediction module of the entity extraction model; An entity extraction result of the target text is determined according to the character set of the target entity and the character sequence of the target entity.

11. The method according to claim 10, wherein obtaining the target document comprises: Get the target page image; Perform OCR recognition on the target page image to obtain the target text.

12. An entity extraction device, comprising: A second data acquisition module is used to acquire the target text; The second processing module is used to input the target text into the entity extraction model pre-trained according to the method according to any one of claims 1 to 6, obtain the character set of the target entity output by the decoder of the entity extraction model, and the character sequence of the target entity output by the sequence prediction module of the entity extraction model; determine the entity extraction result of the target text according to the character set of the target entity and the character sequence of the target entity.

13. A computer-readable storage medium storing a computer program, wherein when the computer program is executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 6, or the method according to claim 10 or 11.

14. An electronic device comprising: at least one memory for storing a program; At least one processor is used to execute the program stored in the memory, when the program stored in the memory is executed, the processor is used to execute the method according to any one of claims 1 to 6, or execute the method according to claim 10 or 11.