Medical text detection method, model training method and related devices

By extracting the semantic representation of characters in medical text and predicting the score matrix, the problems of entity nesting and relationship overlap in medical text are solved, and efficient medical text data processing and utilization are achieved.

CN114385787BActive Publication Date: 2025-06-03BEIJING HUIJI ZHIYI TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111626959.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-06-03
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

The prior art is difficult to effectively solve the problem of overlapping entity nesting and entity relationships in medical texts, resulting in the waste of data resources and human resources.

Method used

Provide a medical text detection method and model training method. By extracting the semantic representations of each character in the medical text to be tested, and based on these semantic representations predict score matrix, the target medical entity and relationship are decoded to solve the problems of entity nesting and relationship overlap.

Benefits of technology

It realizes effective processing of entity nesting and relationship overlap in medical text, reduces the duplication of data annotation, and improves the utilization efficiency of medical text data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385787B_ABST
    Figure CN114385787B_ABST
Patent Text Reader

Abstract

The present application discloses a medical text detection method, a training method of a model, and related devices. The method includes: obtaining a medical text to be detected; extracting semantic representations of each character in the medical text to be detected; predicting a plurality of score matrices based on the semantic representations of each character; and decoding a target medical entity and a target medical relationship in the medical text to be detected based on the plurality of score matrices. The above solution can simultaneously solve the problems of entity nesting and entity relationship overlap in medical texts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of intelligent medical technology, and in particular, to a medical text detection method, a model training method, and related devices. Background Art

[0002] In recent years, with the gradual improvement of hospital information systems, more and more electronic medical record data has been collected and stored. Mining and integrating the medical knowledge hidden in the massive medical text data will effectively improve the quality and efficiency of medical services.

[0003] Currently, with the development of computer technology, computer-aided mining of medical knowledge in medical text data has become a research hotspot. Existing artificial intelligence methods rely heavily on manually labeled data. For different "entity and relationship" requirements, a large amount of medical record data needs to be labeled to enable the model to fully learn. However, when new requirements arise, due to the incompatibility of the labeling system, researchers can only reconstruct a new labeling system and label a large amount of data, resulting in serious waste of data resources and human resources. Summary of the Invention

[0004] The main technical problem to be solved by the present application is to provide a medical text detection method, a model training method, and related devices, which can simultaneously solve the problems of entity nesting and entity relationship overlap in medical texts.

[0005] To solve the above technical problems, a first aspect of the present application provides a medical text detection method, including: obtaining a medical text to be tested; wherein, the medical text to be tested contains a preset number of characters; extracting semantic representations of each character in the medical text to be tested; based on the semantic representations of each character, predicting a plurality of score matrices; wherein, the length and width of each score matrix are both preset values, and the plurality of score matrices include a first score matrix related to several medical entity categories respectively and a second score matrix related to several medical relationship categories respectively, and the first element value at the first position in the first score matrix represents the possibility that the word formed by the first related characters at the first position belongs to the medical entity category, and the second element value at the second position in the second score matrix represents the possibility that the relationship formed by the second related characters at the second position belongs to the medical relationship category, and the first related characters and the second related characters both belong to the medical text to be tested; decoding the target medical entities and target medical relationships in the medical text to be tested based on the plurality of score matrices.

[0006] To solve the above technical problems, the second aspect of the present application provides a method for training a medical text detection model, including: obtaining a sample medical text; wherein the sample medical text contains a preset number of sample characters, and the sample medical text is annotated with sample medical entities and their affiliated medical entity categories, as well as sample medical relationships and their affiliated medical relationship categories; encoding, based on the sample medical entities and their affiliated medical entity categories, to obtain a first sample score matrix respectively related to several medical entity categories, and encoding, based on the sample medical relationships and their affiliated medical relationship categories, to obtain a second sample score matrix respectively related to several medical relationship categories; wherein the length and width of each sample score matrix are both preset values, the first sample element value at the first matrix position in the first sample score matrix indicates whether the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second sample element value at the second matrix position in the second sample score matrix indicates whether the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category, and the first sample-related characters and the second sample-related characters both belong to the sample medical text; using the medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical text to obtain a first prediction score matrix respectively related to several medical entity categories and a second prediction score matrix respectively related to several medical relationship categories; wherein the length and width of each prediction score matrix are both preset values, the first prediction element value at the first matrix position in the first prediction score matrix indicates the possibility that the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second prediction element value at the second matrix position in the second prediction score matrix indicates the possibility that the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category; adjusting the network parameters of the medical text detection model based on the difference between the sample score matrix and the prediction score matrix.

[0007] To solve the above technical problems, a third aspect of the present application provides a medical text detection device, including: a text acquisition module for acquiring a medical text to be detected; wherein the medical text to be detected contains a preset number of characters; a semantic extraction module for extracting semantic representations of each character in the medical text to be detected; a score prediction module for predicting a plurality of score matrices based on the semantic representations of each character; wherein the length and width of each score matrix are both preset values, and the plurality of score matrices include a first score matrix respectively related to a plurality of medical entity categories and a second score matrix respectively related to a plurality of medical relationship categories, and the first element value at the first position in the first score matrix represents the possibility that the word formed by the first related characters at the first position belongs to the medical entity category, and the second element value at the second position in the second score matrix represents the possibility that the relationship formed by the second related characters at the second position belongs to the medical relationship category, and the first related characters and the second related characters both belong to the medical text to be detected; a matrix decoding module for decoding the target medical entity and the target medical relationship in the medical text to be detected based on the plurality of score matrices.

[0008] To solve the above technical problems, a training device for a medical text detection model is provided in the fourth aspect of the present application, including: a sample acquisition module for acquiring sample medical texts; wherein the sample medical texts contain a preset number of sample characters, and the sample medical texts are labeled with sample medical entities and their affiliated medical entity categories, as well as sample medical relationships and their affiliated medical relationship categories; a matrix encoding module for encoding, based on the sample medical entities and their affiliated medical entity categories, to obtain first sample score matrices respectively related to several medical entity categories, and encoding, based on the sample medical relationships and their affiliated medical relationship categories, to obtain second sample score matrices respectively related to several medical relationship categories; wherein the length and width of each sample score matrix are both preset values, the first sample element value at the first matrix position in the first sample score matrix indicates whether the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second sample element value at the second matrix position in the second sample score matrix indicates whether the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category, and the first sample-related characters and the second sample-related characters both belong to the sample medical texts; a model detection module for using the medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical texts to obtain a first prediction score matrix respectively related to several medical entity categories and a second prediction score matrix respectively related to several medical relationship categories; wherein the length and width of each prediction score matrix are both preset values, the first prediction element value at the first matrix position in the first prediction score matrix indicates the possibility that the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second prediction element value at the second matrix position in the second prediction score matrix indicates the possibility that the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category; a parameter adjustment module for adjusting the network parameters of the medical text detection model based on the difference between the sample score matrix and the prediction score matrix.

[0009] To solve the above technical problems, an electronic device is provided in the fifth aspect of the present application, including a mutually coupled memory and a processor, wherein program instructions are stored in the memory, and the processor is configured to execute the program instructions to implement the medical text detection method in the first aspect or the training method of the medical text detection model in the second aspect above.

[0010] To solve the above technical problems, a computer-readable storage medium is provided in the sixth aspect of the present application, storing program instructions that can be run by a processor, and the program instructions are used to implement the medical text detection method in the first aspect or the training method of the medical text detection model in the second aspect above.

[0011] In the above solution, by extracting the semantic representations of each character in the medical text to be tested and based on the semantic representations of each character, a first score matrix related to several medical entity categories and a second score matrix related to several medical relationship categories can be predicted. Therefore, the first score matrix related to different medical entity categories is different, and the second score matrix related to different medical relationship categories is different, enabling the subsequent decoding based on several score matrices to simultaneously solve the problems of entity nesting and entity relationship overlap. Description of the Drawings

[0012] Figure 1 is a schematic flowchart of an embodiment of the medical text detection method provided by this application;

[0013] Figure 2 is a schematic structural diagram of an embodiment of the BERT pre-training architecture provided by this application;

[0014] Figure 3 is a schematic diagram of an embodiment of the first score matrix provided by this application;

[0015] Figure 4 is a schematic diagram of an embodiment of the second score matrix provided by this application;

[0016] Figure 5 is Figure 1 a schematic flowchart of an embodiment of step S13 shown;

[0017] Figure 6 is a schematic structural diagram of an embodiment of the medical text detection model provided by this application;

[0018] Figure 7 is Figure 1 a schematic flowchart of an embodiment of step S14 shown;

[0019] Figure 8 is Figure 7 a schematic flowchart of an embodiment of step S141 shown;

[0020] Figure 9 is Figure 7 a schematic flowchart of an embodiment of step S142 shown;

[0021] Figure 10 is Figure 7 a schematic flowchart of an embodiment of step S143 shown;

[0022] Figure 11 is a schematic flowchart of an embodiment of the training method of the medical text detection model provided by this application;

[0023] Figure 12Schematic diagram of the process of training a medical text detection model using sample medical texts of several annotation systems according to an embodiment of the present application;

[0024] Figure 13 Yes Figure 12 Schematic diagram of the process of an embodiment of step S1202 shown;

[0025] Figure 14 Schematic diagram of an embodiment of the heterogeneous annotation system integration process provided by the present application;

[0026] Figure 15 Yes Figure 11 Schematic diagram of the process of an embodiment of step S1104 shown;

[0027] Figure 16 Schematic diagram of the process of an embodiment of obtaining the sub-loss corresponding to the first current position according to the contrast loss function provided by the present application;

[0028] Figure 17 Schematic diagram of the process of an embodiment of determining the loss of the medical text detection model provided by the present application;

[0029] Figure 18 Schematic diagram of the framework of an embodiment of the medical text detection device provided by the present application;

[0030] Figure 19 Schematic diagram of the framework of an embodiment of the training device of the medical text detection model provided by the present application;

[0031] Figure 20 Schematic diagram of the framework of an embodiment of the electronic device provided by the present application;

[0032] Figure 21 Schematic diagram of the framework of an embodiment of the computer-readable storage medium provided by the present application. Detailed implementation manners

[0033] The following will describe the solutions of the embodiments of the present application in detail with reference to the accompanying drawings of the specification.

[0034] In the following description, specific details such as specific system architectures, interfaces, and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the present application.

[0035] The terms "system" and "network" are often used interchangeably in this document. The term "and / or" in this document is merely a description of the association relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, both A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects before and after are in an "or" relationship. In addition, "multiple" in this document means two or more than two.

[0036] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of an embodiment of the medical text detection method provided by this application. It should be noted that if there are substantially the same results, this embodiment is not limited to Figure 1 the shown process sequence. As Figure 1 shown, this embodiment includes:

[0037] Step S11: Obtain the medical text to be tested.

[0038] The method of this embodiment is used to decode the medical text to be tested to obtain the target medical entities and target medical relationships in the medical text to be tested. The medical text to be tested described in this document can be, but is not limited to, the first page of a medical record, progress notes, examination and test results, doctor's orders, surgical records, or nursing records, etc., and no specific limitation is made here.

[0039] In one embodiment, the medical text to be tested can be any medical text that needs to be decoded to obtain the target medical entities and target medical relationships, and can be specifically obtained from local storage or cloud storage. It can be understood that in other embodiments, it can also be obtained by using an image acquisition device to acquire an image of the current medical text.

[0040] Step S12: Extract the semantic representations of each character in the medical text to be tested.

[0041] In this embodiment, the semantic representations of each character in the medical text to be tested are extracted. In one embodiment, a multi-layer Transformer model can be used to extract the semantic representations of each character in the medical text to be tested.

[0042] It can be understood that in other embodiments, the multi-layer Transformer architecture in the pre-trained BERT model on medical text data can also be used to extract the semantic representations of each character in the medical text to be tested, so that the extracted semantic representations of each character not only carry rich syntactic, part-of-speech, semantic and other information in the open domain, but also carry the language feature information of medical text data.

[0043] Among them, by stacking multiple Transformer models and performing self-supervised training on the pre-training architecture of BERT (Bidirectional Encoder Representations from Transformers), a large amount of text data is used to train on the pre-training architecture of BERT, so as to integrate various types of information carried in the text (such as syntactic, part-of-speech, dependency, semantic, etc. information) into the model parameters; then the medical text data is used as pre-training data to train the Transformer module in the above-mentioned trained model, so as to obtain a BERT model pre-trained on medical text data. The model parameters of this BERT model pre-trained on medical text data not only carry rich syntactic, part-of-speech, semantic and other information in the open domain, but also through pre-training in the field of medical text data, the model parameters better carry the language feature information of medical text data.

[0044] Specifically, as Figure 2 shown, Figure 2 is a schematic structural diagram of an embodiment of the BERT pre-training architecture provided by this application. The main body and task design of the BERT pre-training model follow the BERT pre-training architecture. The BERT pre-training architecture includes an input module, a context encoding module, and a self-supervised task module. The obtained medical text data (such as the first page of the medical record, the progress record, the inspection and test results, the doctor's order record, the operation record, or the nursing record, etc.) is constructed into the input of the BERT pre-training model; a piece of medical text data consists of two clauses, and the composition of the two clauses has two different forms. In half of the examples, the two clauses are presented as upper and lower sentences in natural language, while in the other half of the examples, the lower sentence is obtained by random selection, and the two clauses are connected by [SEP]. This upper and lower sentence pairing strategy constitutes the Figure 2 in the "predict the next sentence" task; in addition, in addition to the upper and lower sentence settings, 15% of the words in a piece of medical text data are also masked, and the masked words are marked with [MASK] to form the "[MASK] prediction" task, which requires the model to be able to predict the specific words to which the masked sentence belongs. The entire pre-training process performs self-supervised training under the guidance of the "predict the next sentence" task and the "[MASK] prediction" task; in the training, both sub-tasks use cross-entropy as the loss function to adjust the network parameters of the BERT pre-training model until the pre-training model converges to obtain a BERT model pre-trained on medical text data.

[0045] Among them, the main part of the BERT pre-training architecture is composed of a context encoding module, which contains 12 layers of transformer architecture.

[0046] Step S13: Based on the semantic representations of each character, several score matrices are predicted.

[0047] Since medical text data is a data type with a specific style, in medical text data, entity tags usually show a nested phenomenon. For example, for "ulnar nerve release", this entity belongs to the "surgery" type, but "ulnar nerve" belongs to the "body part", and "release" belongs to the "surgical procedure", so there is a nesting of entity positions between surgery and body part, and between surgery and surgical procedure. In addition, in medical text data, there will also be problems of overlapping entity relationships, which are usually manifested as "head entity overlap", "tail entity overlap", and "both head and tail entity overlap". For example, for "having a headache for three days and coming to our hospital for a CT examination", "head - headache" constitutes a "body part - symptom" relationship, and "head - examination" constitutes a "body part - examination method" relationship, so the head entity overlaps.

[0048] Therefore, in this embodiment, according to the semantic representations of each character, a number of score matrices can be predicted. Among them, the length and width of each score matrix are both preset values. The number of score matrices includes a first score matrix related to several medical entity categories respectively and a second score matrix related to several medical relationship categories respectively. That is to say, according to the semantic representations of each character, a first score matrix related to several medical entity categories and a second score matrix related to several medical relationship categories can be predicted, so that when decoding based on the number of score matrices subsequently, the target medical entities and target medical relationships in the medical text to be tested can be obtained, thereby solving the problems of entity nesting and overlapping entity relationships simultaneously.

[0049] Optionally, the size of the preset value, the number of score matrices, the number of the first score matrix and the second score matrix in the number of score matrices are not limited, and can be specifically set according to actual usage needs. For example, the number of score matrices is H, the number of the first score matrix related to several medical entity categories is E, and the number of the second score matrix related to several medical relationship categories is R; the length and width of each score matrix are both N; therefore, according to the semantic representations of each character, H score matrices can be predicted.

[0050] Among them, the value of the first element at the first position in the first score matrix represents the possibility that the word composed of the first related characters at the first position belongs to the medical entity category, and the first related characters belong to the medical text to be tested. That is to say, each cell in the first score matrix is defined as the possibility that a certain two first related characters in the whole sequence form a medical entity. Among them, the specific position of the first position in the first score matrix and the manifestation form of the first element value are not limited, and can be specifically set according to actual usage needs. For example, the first element value is 1.

[0051] In one embodiment, the first position is located in the i-th row and the j-th column of the first score matrix, the first related characters are the i-th character and the j-th character in the medical text to be tested, and the first element value indicates the possibility that the word composed of the i-th character and the j-th character in the medical text to be tested belongs to the medical entity category. In other words, the first element value located at the first position indicates the possibility that the word composed of the i-th character and the j-th character in the medical text to be tested belongs to a certain medical entity category, that is, different types of entities correspond to different first score matrices, so that the entity nesting problem can be solved when decoding is performed based on the score matrix later.

[0052] For example, if Figure 3 As shown, Figure 3 This is a schematic diagram of an embodiment of the first score matrix provided by the present application. The first position is located in the 9th row and the 2nd column in the first score matrix. The first related character is the 9th character "head" and the 2nd character "pain" in the medical text to be tested "headache for three days, accompanied by cough". The first element value represents the possibility that the word "headache" composed of the 9th character "head" and the 2nd character "pain" in the medical text to be tested "headache for three days, accompanied by cough" belongs to the medical entity "symptom". Since the first score matrix represents the possibility of belonging to a certain medical entity category, in Figure 3 The first score matrix shown in FIG. 1 also includes a word “cough” belonging to the medical entity “symptom”. Figure 3 The first position is also located in the 7th row and 8th column of the first score matrix, and the corresponding first related character is the possibility that the word "cough" composed of the 7th character "cough" and the 8th character "cough" in the medical text to be tested "headache for three days, accompanied by cough" belongs to the medical entity "symptom".

[0053] Specifically, taking the medical text to be tested "Headache for three days, accompanied by cough" as an example, the medical text to be tested includes two symptom entities "headache" and "cough", a part entity "head" and a duration entity "three days". First, the medical text to be tested is segmented according to characters and punctuation marks to obtain "Head#ache#three#days#,#accompanied#cough#.", where "#" represents a separator, indicating that this should be segmented. The length of the sentence after segmentation is recorded as N. Since the length of the medical text to be tested is 9, N is 9 at this time; after segmentation, a sentence is constructed for each type of medical entity. , that is, to construct a matrix matrix; for example, taking the medical entity of "symptom" as an example to construct a matrix. Since "head" and "ache" can form a symptom entity, the position at the intersection of the vertical axis "head" and the horizontal axis "ache" in the matrix will be marked with the first element value, that is, 1, indicating that these two Chinese characters in the sequence can form a symptom entity. Similarly, since "cough" and "sore throat" can form a symptom entity, the position at the intersection of the vertical axis "cough" and the horizontal axis "sore throat" in the matrix will be marked with the first element value, that is, 1, thus constructing the first score matrix corresponding to the "symptom" entity. It should be noted that in this embodiment, when marking the first element value, the vertical axis of the matrix is used as the start of the medical entity, and the horizontal axis is used as the end of the medical entity. Therefore, when constructing matrices and marking based on other medical entity types subsequently, the vertical axis of the matrix is always used as the start of the medical entity, and the horizontal axis is used as the end of the medical entity. Therefore, as Figure 3 shown, the marked first element values are always retained in the upper triangle of the first score matrix, and the lower triangle is masked by "*".

[0054] In other embodiments, the first position is in the j-th row and the i-th column of the first score matrix. The first related characters are the j-th character and the i-th character in the medical text to be tested. The first element value represents the possibility that the word formed by the j-th character and the i-th character in the medical text to be tested in sequence belongs to the medical entity category. That is to say, when marking the first element value, it can also be that the horizontal axis of the matrix is used as the start of the medical entity, and the vertical axis is used as the end of the medical entity, which is not specifically limited here.

[0055] In this embodiment, the second element value at the second position in the second score matrix represents the possibility that the relationship formed by the second related characters at the second position belongs to the medical relationship category. The second related characters all belong to the medical text to be tested. That is to say, each cell in the second score matrix is defined as the possibility that a certain two second related characters in the entire sequence form a medical relationship category. Among them, the specific position of the second position in the second score matrix and the manifestation form of the second element value are not limited, and can be specifically set according to actual usage needs. For example, the second element value is 1.

[0056] In one embodiment, the second position is in the m-th row and the n-th column of the second score matrix. The second related characters include the m-th character and the n-th character in the medical text to be tested. The second element value represents the possibility that the relationship formed by the m-th character and the n-th character in the medical text to be tested belonging to different entities belongs to the medical relationship category. That is to say, different entity relationship types correspond to different second score matrices, so as to avoid the problem of entity relationship overlap when decoding based on the score matrix subsequently.

[0057] For example, as Figure 4 shown, Figure 4This is a schematic diagram of an embodiment of the second score matrix provided by this application. Taking the medical text to be tested "headache for three days, accompanied by cough" as an example, there is a relationship between the symptom entity "headache" and the duration entity "three days". First, the medical text to be tested is segmented according to Chinese characters and punctuation marks, so as to obtain "head#ache#three#days#,#accompanied#by#cough#.", where "#" represents a delimiter, indicating that it should be segmented here. The length of the segmented sentence is denoted as N. Since the length of the medical text to be tested is 9, N is 9 at this time. After segmentation, a matrix of is constructed for each medical entity relationship type, that is, a matrix of is constructed; for example, taking the relationship between the symptom entity "headache" and the duration entity "three days" as an example to construct a matrix. Since there is a relationship between "headache" and "three days", all the intersections of the vertical axis "headache" and the horizontal axis "three days" are marked with the second element value, that is, 1, so as to obtain the second score matrix. A 2*2 identity matrix will appear in the second score matrix to represent the relationship between two medical entities. It should be noted that in this embodiment, when marking the second element value, the vertical axis of the matrix is used as the start of the relationship, and the horizontal axis is used as the end of the relationship. Therefore, when constructing and marking matrices based on other medical entity relationship types subsequently, the vertical axis of the matrix is used as the start of the relationship, and the horizontal axis is used as the end of the relationship. Therefore, as Figure 4 shown, the second score matrix is an asymmetric structure, and values may appear in both the upper triangle and the lower triangle.

[0058] In other embodiments, the second position is located in the nth row and the mth column of the second score matrix. The second related characters include the nth character and the mth character in the medical text to be tested. The second element value represents the possibility that the relationship formed by the nth character and the mth character in the medical text to be tested belonging to different medical entities belongs to the medical relationship category. That is to say, when marking the second element value, the horizontal axis of the matrix can also be used as the start of the relationship, and the vertical axis can be used as the end of the relationship. Therefore, when constructing and marking matrices based on other entity relationship types subsequently, the horizontal axis of the matrix is used as the start of the relationship, and the vertical axis is used as the end of the relationship.

[0059] Step S14: Decode the target medical entity and the target medical relationship in the medical text to be tested based on a plurality of score matrices.

[0060] In this embodiment, according to a plurality of score matrices, the target medical entity and the target medical relationship in the medical text to be tested are decoded. For example, as Figure 3 and Figure 4 shown, including a first score matrix and a second score matrix, the target medical entities decoded in the medical text to be tested are "headache" and "cough", and the target medical relationship decoded in the medical text to be tested is "headache - three days".

[0061] In the above embodiments, by extracting the semantic representations of each character in the medical text to be measured and based on the semantic representations of each character, a first score matrix related to several medical entity categories and a second score matrix related to several medical relationship categories can be predicted. Therefore, the first score matrix related to different medical entity categories is different, and the second score matrix related to different medical relationship categories is different. When decoding based on several score matrices subsequently, the problems of entity nesting and entity relationship overlap are solved simultaneously.

[0062] Please refer to Figure 5 , Figure 5 which Figure 1 is a schematic flowchart of an embodiment of step S13 shown. It should be noted that if there are substantially the same results, this embodiment is not limited to Figure 5 the Figure 5 flow order shown. As

[0063] Step S131: Perform spatial mapping based on the semantic representations of a preset number of characters to obtain several feature matrices.

[0064] In this embodiment, by performing spatial mapping according to the semantic representations of a preset number of characters, several feature matrices can be obtained. Among them, the length and width of each feature matrix are the preset number and the feature dimension respectively. The several feature matrices include a first feature matrix related to several medical entity categories and a second feature matrix related to several medical relationship categories respectively. The number of the first feature matrix related to several medical entity categories and the second feature matrix related to several medical relationship categories is not limited and can be specifically set according to actual usage needs.

[0065] In one embodiment, the score matrix corresponding to the subsequent feature matrix is obtained by a medical text detection model detecting the medical text to be measured. The medical text detection model includes a semantic extraction network, and the semantic extraction network is used to perform a semantic extraction operation to extract the semantic representations of a preset number of characters. In a specific embodiment, as Figure 6 shown, Figure 6It is a schematic structural diagram of an embodiment of the medical text detection model provided by this application. The medical text detection model includes an input module and a semantic extraction network. The semantic extraction network contains a 12-layer Transformer architecture. Therefore, the multi-layer Transformer parameters of the pre-trained BERT model on the above-mentioned medical text data can be used as the initialization parameters of the 12-layer Transformer of the semantic extraction network, so that the semantic representation of the extracted characters not only carries rich syntactic, morphological, semantic and other information in the open domain, but also carries the language feature information of the medical text data. Specifically, the input module receives the medical text to be tested, and after splitting by characters, it is used as the input of the medical text detection model. The input sequence is denoted as , where N represents the text length of the input sequence.

[0066] In one embodiment, as Figure 6 shown, the medical text detection model includes several spatial mapping networks. Among them, the spatial mapping network includes several first mapping networks and several second mapping networks. Different first mapping networks perform spatial mapping for different medical entity categories, and different second mapping networks perform spatial mapping for different medical relationship categories. That is to say, several first mapping networks are used to perform spatial mapping based on the semantic representations of a preset number of characters to obtain a first feature matrix related to several medical entity categories; several second mapping networks are used to perform spatial mapping based on the semantic representations of a preset number of characters to obtain a second feature matrix related to several medical relationship categories. Among them, the numbers of the spatial mapping network, the first mapping network, and the second mapping network are not limited, and can be specifically set according to actual usage needs.

[0067] In a specific embodiment, as Figure 6 shown, the spatial mapping network is connected in parallel after the semantic extraction network. The spatial mapping network performs spatial mapping based on the semantic representations of a preset number of characters to obtain several feature matrices.

[0068] In one embodiment, as Figure 6 shown, the spatial mapping network is a multi-layer perceptron containing multiple network layers, and activation functions are provided in all network layers except the last network layer. Among them, the number of the multiple network layers and the number of layers of the multiple network layers are not limited, and can be specifically set according to actual usage needs. For example, the multiple network layers are 2 layers, and the activation function is provided in the second layer of the 2-layer network layer. The spatial mapping network includes 100 2-layer network layers. Among them, the number of the multiple network layers is expressed as:

[0069]

[0070] Among them, H represents the sum of the number of medical entities and the number of relationships; E represents the number of medical entities; R represents the number of relationships. It should be noted that the number of medical entities is the sum of all medical entities in the medical text scenario, rather than the sum of medical entities in a single sentence; the number of relationships is the total number of all relationships in the medical text scenario, rather than the sum of relationships in a single sentence.

[0071] Furthermore, each multi-layer network layer can convert the semantic representation output by the semantic extraction network into a feature matrix , where N represents the sequence length and D represents the feature dimension.

[0072] Step S132: For each feature matrix, based on the feature matrix and its transposed matrix, obtain the score matrix corresponding to the feature matrix.

[0073] In this embodiment, for each feature matrix, according to the feature matrix and its transposed matrix, obtain the score matrix corresponding to the feature matrix. The specific formula of the score matrix is as follows:

[0074]

[0075] Among them, represents the score matrix; represents the feature matrix; represents the transposed matrix. Among them, E score matrices are used to decode the target medical entities in the medical text to be tested in the subsequent stage, and R score matrices are used to decode the target medical relationships in the medical text to be tested in the subsequent stage.

[0076] Please refer to Figure 7 , Figure 7 is Figure 1 a schematic flowchart of an embodiment of step S14 shown. It should be noted that if there are substantially the same results, this embodiment is not limited to Figure 7 the shown process sequence. As Figure 7 shown, this embodiment includes:

[0077] S141: Based on the first element values that meet the first condition in the first score matrix related to the medical entity category, decode the target medical entities belonging to the medical entity category.

[0078] In the above method, when the medical text to be tested is input into the medical text detection model, H score matrices will be obtained. Since in the encoding stage, the first 1 to E first score matrices represent medical entities, and the (E + 1)-th to R-th second score matrices represent medical entity relationships. Therefore, in this application, the target medical entities are decoded first, and then the target medical relationships are decoded. The decoding of the target medical relationships depends on the target medical entities.

[0079] Therefore, in this embodiment, according to the first element value that satisfies the first condition in the first score matrix related to the medical entity category, the target medical entity belonging to the medical entity category is decoded. That is to say, it is possible to determine whether a cell in the first score matrix can represent a certain type of medical entity by the magnitude of the first element value in the cell. If the first element value in the first score matrix related to the medical entity category satisfies the first condition, it is considered that the first related character corresponding to the horizontal axis here as the starting position and the first related character corresponding to the vertical axis as the ending position can form a complete target medical entity.

[0080] In one embodiment, the first condition may be that the first element value is greater than the first threshold. For example, the first threshold is 0, that is, the target medical entity belonging to the medical entity category can be decoded according to the first element value greater than 0 in the first score matrix related to the medical entity category. In addition, since the first element value represents the possibility that the word composed of the first related characters at the first position belongs to the medical entity category, the greater the first element value, the greater the possibility that the first related characters on the horizontal and vertical axes of the cell corresponding to the first element value form the target medical entity. Conversely, the smaller the first element value, the smaller the possibility of forming the target medical entity.

[0081] In a specific embodiment, as Figure 8 shown, Figure 8 is Figure 7 a schematic flowchart of an embodiment of step S141 shown. Decoding the target medical entity belonging to the medical entity category specifically includes the following sub-steps:

[0082] Step S81: Respectively take several medical entity categories as the current entity category, and take the first score matrix related to the current entity category as the first current matrix.

[0083] In this embodiment, respectively take several medical entity categories as the current entity category, and take the first score matrix related to the current entity category as the first current matrix.

[0084] Step S82: Obtain the first target position where the first element value that satisfies the first condition in the first current matrix is located.

[0085] In this embodiment, obtain the first target position where the first element value that satisfies the first condition in the first current matrix is located. Among them, the first condition is not specifically limited and can be specifically set according to actual usage needs.

[0086] For example, as Figure 3As shown, taking the first condition that the first element value is greater than 0 as an example, the first target positions in the first current matrix where the first element value is greater than 0 are the 2nd column of the 1st row and the 8th column of the 7th row. Therefore, the corresponding positions of the 2nd column of the 1st row and the 8th column of the 7th row are taken as the first target positions.

[0087] Step S83: Use the words formed by the first related characters at the first target positions as the target medical entities belonging to the current entity category.

[0088] In this embodiment, the words formed by the first related characters at the first target positions are used as the target medical entities belonging to the current entity category. For example, as Figure 3 shown, the first target positions are the corresponding positions of the 2nd column of the 1st row and the 8th column of the 7th row. The word "headache" formed by the first related characters "head" and "ache" at the first target position "the 2nd column of the 1st row", and the word "cough" formed by the first related characters "cough" and "throat" at the first target position "the 8th column of the 7th row", that is, the words "headache" and "cough" are used as the target medical entities belonging to the current entity category.

[0089] Further, traverse all the first element values that meet the first condition in the first score matrix related to the medical entity category in the above manner, so as to obtain a set of target medical entities , where , , .

[0090] S142: Obtain the candidate medical relationships formed by the target medical entities, and obtain the medical relationship category to which the candidate medical relationships belong as the candidate relationship category.

[0091] In this embodiment, obtain the candidate medical relationships formed by the target medical entities, and select the medical relationship category to which the candidate medical relationships belong as the candidate relationship category. That is to say, combine the target medical entities to form candidate medical relationships, and use the medical relationship category to which the candidate medical relationships belong as the candidate relationship category.

[0092] In a specific embodiment, arrange and combine each pair of the target medical entities to obtain candidate medical relationships. For example, the target medical entities include "cough", "headache" and "three days", so after arranging and combining these three target medical entities pairwise, the obtained candidate medical relationships are: "cough" - "headache", "headache" - "three days", "headache" - "cough", "headache" - "three days", "three days" - "cough" and "three days" - "headache".

[0093] In a specific embodiment, as Figure 9 shown, Figure 9 is Figure 7The flowchart of an embodiment of step S142. The determination of the candidate relationship category specifically includes the following sub-steps:

[0094] Step S91: Based on the sequence of the two target medical entities in the candidate medical relationship and the medical entity categories to which they belong respectively, obtain the medical relationship category to which the candidate medical relationship belongs.

[0095] In this embodiment, based on the sequence of the two target medical entities in the candidate medical relationship and the medical entity categories to which they belong respectively, obtain the medical relationship category to which the candidate medical relationship belongs. For example, the candidate medical relationships are: "cough" - "three days" and "three days" - "cough". Since the medical entity category to which "cough" belongs is symptom, and the medical entity category to which "three days" belongs is duration, the medical relationship category to which the candidate medical relationship "cough - three days" belongs is "symptom - duration", and the medical relationship category to which the candidate medical relationship "three days - cough" belongs is "duration - symptom".

[0096] Step S92: Use the medical relationship category to which the candidate medical relationship belongs as the candidate relationship category.

[0097] In this embodiment, use the medical relationship category to which the candidate medical relationship belongs as the candidate relationship category. For example, the medical relationship category to which the candidate medical relationship "cough - three days" belongs is "symptom - duration", so "symptom - duration" is used as the candidate relationship category.

[0098] S143: Based on that the second element values in the reference area of the second score matrix related to the candidate relationship category meet the second condition, decode to obtain the target medical relationship.

[0099] In this embodiment, based on that the second elements in the reference area of the second score matrix related to the candidate relationship category meet the second condition, decode to obtain the target medical relationship. Among them, the second related characters corresponding to the reference area are included in the candidate medical relationship. The second condition is not limited and can be specifically set according to actual usage needs. For example, the second condition is that the proportion of the second element values greater than the second threshold in the reference area is greater than or equal to the third threshold. For example, the second threshold is 0, and the third threshold is 0.8. That is to say, the proportion of the second element values greater than 0 in the reference area is greater than or equal to 0.8.

[0100] In a specific embodiment, as Figure 10 shown, Figure 10 is Figure 7 The flowchart of an embodiment of step S143 shown. The decoding to obtain the target medical relationship specifically includes the following sub-steps:

[0101] Step S1001: Respectively take each candidate medical relationship as the current medical relationship, take the candidate relationship category to which the current medical relationship belongs as the current medical category, and take the second score matrix related to the current medical category as the second current matrix.

[0102] In this embodiment, respectively take each candidate medical relationship as the current medical relationship, take the candidate relationship category to which the current medical relationship belongs as the current relationship category, and take the second score matrix related to the current medical category as the second current matrix. For example, as Figure 4 shown, taking the candidate medical relationship "headache" - "three days" as an example, so the current medical relationship is "headache" - "three days", the candidate relationship category "symptom - duration" to which the current medical relationship belongs is taken as the current medical category, and the second score matrix related to the current medical category (as Figure 4 shown) is taken as the second current matrix.

[0103] Step S1002: Count the total value of the second element values that meet the second condition in the reference area of the second current matrix.

[0104] In this embodiment, count the total value of the second element values that meet the second condition in the reference area of the second current matrix. Specifically, through the start and end positions of the target entities in the target entity pair, a small matrix, i.e., the reference area, can be segmented from the second current matrix. For this small matrix, use the voting method to determine whether the reference area can represent the existence of a relationship between the two target entities; for the reference area, if the second element value in a cell meets the second condition, then this cell can be considered as one vote, and count the final number of votes, that is, count the total value of the second element values that meet the second condition.

[0105] For example, as Figure 4 shown, through the start and end positions of the target entity pair "headache" and "three days", the reference area can be segmented from the second current matrix, and the total value of the second element values that meet the second condition in the reference area is counted as 4.

[0106] Step S1003: Based on the total value meeting the second condition, take the current medical relationship as the target medical relationship.

[0107] In this embodiment, according to the total value meeting the second condition, take the current medical relationship as the target medical relationship. Specifically, when the total value meets the second condition, it indicates that the reference area represents the existence of a specific relationship between the two target entities, so the current medical relationship can be taken as the target medical relationship, that is, the target medical relationship is decoded.

[0108] For example, as Figure 4As shown, taking the case where the proportion of second element values ​​greater than 0 in the reference area is greater than or equal to 0.8 and the current medical relationship is "symptom-duration" as an example, the total value of the second element values ​​that meet the second condition in the reference area is 4, and the proportion of the total value is 1 greater than 0.8, so the current medical relationship "symptom-duration" is taken as the target medical relationship.

[0109] See also Figure 11 , Figure 11 1 is a flow chart of an embodiment of a training method for a medical text detection model provided in this application. It should be noted that if there are substantially the same results, this embodiment does not use Figure 11 The process sequence shown is limited. Figure 11 As shown, this embodiment includes:

[0110] Step S1101: Obtain sample medical text.

[0111] In this embodiment, a sample medical text is obtained, wherein the sample medical text contains a preset number of sample characters, and the sample medical text is annotated with sample medical entities and the medical entity categories to which they belong, as well as sample medical relationships and the medical relationship categories to which they belong. Among them, the size of the preset value is not limited, and can be specifically set according to actual use needs. For example, taking the sample medical text of "headache for three days, accompanied by cough" as an example, it is annotated with two sample symptom entities "headache" and "cough", a sample part entity "head", a sample duration entity "three days", and sample symptom-duration relationships of "headache" and "three days".

[0112] In one embodiment, the sample medical text may be, but is not limited to, the medical record cover, medical history record, examination and test results, doctor's order record, operation record or nursing record, etc., and is not specifically limited here.

[0113] In one embodiment, the sample medical text may be any medical text that needs to be decoded to obtain sample medical entities and sample medical relationships, and may be obtained from local storage or cloud storage. It is understandable that in other embodiments, the sample medical text may also be obtained by performing image acquisition on the current sample medical text through an image acquisition device.

[0114] Step S1102: Based on the sample medical entities and the medical entity categories to which they belong, encode to obtain a first sample score matrix respectively related to several medical entity categories, and based on the sample medical relationships and the medical relationship categories to which they belong, encode to obtain a second sample score matrix respectively related to several medical relationship categories.

[0115] In this embodiment, according to the sample medical entities and their affiliated medical entity categories, a first sample score matrix related to several medical entity categories is encoded respectively; and according to the sample medical relationships and their affiliated medical relationship categories, a second sample score matrix related to several medical relationship categories is encoded respectively. Wherein, the length and width of each sample score matrix are both preset values. The first sample element value at the first matrix position in the first sample score matrix indicates whether the word composed of the first sample-related characters at the first matrix position belongs to the medical entity category, and the second sample element value at the second matrix position in the second sample score matrix indicates whether the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category. The first sample-related characters and the second sample-related characters both belong to the sample medical text.

[0116] Optionally, the size of the preset value and the number of the first sample score matrix and the second sample score matrix are not limited and can be specifically set according to actual usage needs. For example, there are E first sample score matrices and R second sample score matrices; the length and width of each sample score matrix are both N; and E of the first sample score matrices and R of the second sample score matrices are encoded.

[0117] Step S1103: Use the medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical text to obtain a first predicted score matrix related to several medical entity categories and a second predicted score matrix related to several medical relationship categories respectively.

[0118] In this embodiment, use the medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical text to obtain a first predicted score matrix related to several medical entity categories and a second predicted score matrix related to several medical relationship categories respectively. That is to say, the medical text detection model will first perform semantic extraction on the sample medical text to extract the semantic representations of each sample character in the sample medical text; then, according to the semantic representations of each sample character, perform score prediction to obtain a first predicted score matrix related to several medical entity categories and a second predicted score matrix related to several medical relationship categories respectively. Wherein, the length and width of each predicted score matrix are both preset values.

[0119] Optionally, the size of the preset value and the number of the first predicted score matrix and the second predicted score matrix are not limited and can be specifically set according to actual usage needs. For example, there are E first predicted score matrices and R second predicted score matrices; the length and width of each predicted score matrix are both N.

[0120] Among them, the first predicted element value at the first matrix position in the first predicted score matrix represents the possibility that the word composed of the first sample-related characters at the first matrix position belongs to the medical entity category. That is to say, each cell in the first predicted score matrix is defined as the possibility that a certain two first predicted-related characters in the entire sequence form a medical entity. Among them, the specific position of the first matrix position in the first predicted score matrix is not limited and can be specifically set according to actual usage needs. The second predicted element value at the second matrix position in the second predicted score matrix represents the possibility that the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category. That is to say, each cell in the second predicted score matrix is defined as the possibility that a certain two second sample-related characters in the entire sequence form a medical relationship category. Among them, the specific position of the second matrix position in the second predicted score matrix is not limited and can be specifically set according to actual usage needs.

[0121] In one embodiment, as Figure 12 shown, Figure 12 FIG. is a schematic flowchart of an embodiment of training a medical text detection model using sample medical texts of several annotation systems. Training the medical text detection model using medical texts of several annotation systems specifically includes the following sub-steps:

[0122] Step S1201: For each annotation system, construct a system dictionary based on the annotated words in the sample medical texts related to the annotation system.

[0123] Since the annotation system of the sample medical text is designed according to the function of the model to be trained, if only the sample medical text data of one annotation system is used, the data volume is too small, and the accuracy of the trained medical text detection model is insufficient. However, if the label systems are not distinguished and directly used for training the medical text detection model, it will also affect the trained medical text detection model. Therefore, in this application, according to the similarity between each reference annotation system and the target annotation system, the order of each reference annotation system used for training the model is adjusted.

[0124] Therefore, in this embodiment, first, for each annotation system, construct a system dictionary according to the annotated words in the sample medical texts of the annotation system. That is to say, a system dictionary will be constructed corresponding to each annotation system for subsequent calculation of similarity. Specifically, for various reference annotation systems, denote them as , where N represents that there are currently N different annotation systems in total; for the target annotation system, denote it as ; for the reference annotation system i, extract the annotated words under each label from the reference annotation system to construct the system dictionary corresponding to the reference annotation system i; construct the system dictionary corresponding to the target annotation system in the same way Among them, the specific algorithm for constructing the system dictionary based on the labeled words in the sample medical text is not limited and can be specifically set according to actual usage needs.

[0125] Step S1202: Obtain the training order of several annotation systems based on the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems.

[0126] In this embodiment, the training order of several annotation systems is obtained based on the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems. Among them, the training order of the target annotation system is the last one. That is to say, subsequently, the model will be trained using the reference annotation system first, and then the trained model parameters will be pruned for training the target annotation system, so as to transfer the similar information between different annotation systems to the target annotation system, thereby improving the accuracy of the medical text detection model.

[0127] In one embodiment, as Figure 13 shown, Figure 13 is Figure 12 a schematic flowchart of an embodiment of step S1202 shown. The intersection over union between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems is used as the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems, and specifically includes the following sub-steps:

[0128] Step S1301: Use the intersection over union between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems as the similarity.

[0129] In this embodiment, the intersection over union between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems is used as the similarity. The specific formula is as follows:

[0130]

[0131] Among them, represents the system dictionary corresponding to the reference annotation system i; represents the system dictionary corresponding to the target annotation system. This similarity is used to measure the overlapping degree of the two system dictionaries. If the dictionary overlapping degree is relatively high, it indicates that there are many similar medical entities labeled in the reference annotation system and the target annotation system, thus ensuring that sufficient information in the current system can be transferred to the target entity.

[0132] Step S1302: Determine the training order of several annotation systems in ascending order of similarity.

[0133] In this embodiment, the training order of several annotation systems is determined in ascending order of similarity. Specifically, after calculating the similarity between different reference annotation systems and the target annotation system, we sort them in ascending order according to the similarity scores. The larger the score, the higher the similarity between the two annotation systems. Since the reference annotation system with a small similarity to the target annotation system is considered to be less helpful for the medical text detection model to ultimately learn the knowledge of the target annotation system, it is in the initial stage of training the medical text detection model. While the reference annotation system with a large similarity to the target annotation system is considered to be more helpful for the medical text detection model to ultimately learn the knowledge of the target annotation system, so it is in the later stage of training the medical text detection model.

[0134] For example, as Figure 14 shown, Figure 14 is a schematic diagram of an embodiment of the heterogeneous annotation system integration process provided by this application. Currently, there are N different reference annotation systems, specifically including reference annotation system 1, reference annotation system 2, reference annotation system 3,..., reference annotation system n. After arranging them in ascending order of similarity, the training order of several annotation systems determined is: reference annotation system 2, reference annotation system n - 1,..., reference annotation system n.

[0135] Step S1203: According to the training order of several annotation systems, select an annotation system as the current annotation system, and based on the sample medical text using the current annotation system, perform the steps of using the medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical text to obtain a first predicted score matrix related to several medical entity categories and a second predicted score matrix related to several medical relationship categories, and subsequent steps until the training converges under the current annotation system.

[0136] In this embodiment, according to the training order of several annotation systems determined above, select an annotation system as the current annotation system, and based on the sample medical text using the current annotation system, perform the steps of using the medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical text to obtain a first predicted score matrix related to several medical entity categories and a second predicted score matrix related to several medical relationship categories, and subsequent steps until the training converges under the current annotation system.

[0137] Specifically, as Figure 14 and 6As shown, the medical text detection model is first trained on the reference annotation system with the lowest similarity. After the training on the first reference annotation system is completed, its parameters are saved, and the medical text detection model is denoted as model1. The context encoding module and the spatial mapping module are initialized using model1. Among them, the last layer of the multi-layer perceptron in the spatial mapping module is not initialized. After the initialization of the parameters, it is trained on the reference annotation system with the second lowest similarity in the similarity ranking. After the training is completed, it is denoted as model2. The above process is repeated until the medical text detection model modeln is obtained. Finally, the model parameters are initialized in the same way on the target annotation system, and the medical text detection model is trained. The trained medical text detection model is saved as modeltarget. Through this cascading method, the medical text detection model gradually transfers and utilizes the similarity information between different reference annotation systems to the target annotation system, and can use the data under all annotation systems, thereby improving the performance of the medical text detection model.

[0138] Step S1204: Determine whether there is an unselected annotation system.

[0139] In this embodiment, it is determined whether there is an unselected annotation system, so as to determine whether to re-execute step S1203 subsequently. When there is an unselected annotation system, step S1205 is executed.

[0140] Step S1205: In response to there still being an unselected annotation system, re-execute the step of selecting an annotation system as the current annotation system and subsequent steps according to the training order of several annotation systems.

[0141] In this embodiment, in response to there still being an unselected annotation system, re-execute the step of training according to several annotation systems and selecting an annotation system as the current annotation system and subsequent steps. That is, after all annotation systems, namely all reference annotation systems and the target annotation system, are selected for training the medical text detection model, the training of the medical text detection model is completed.

[0142] Step S1104: Adjust the network parameters of the medical text detection model based on the difference between the sample score matrix and the predicted score matrix.

[0143] In this embodiment, according to the differences between the sample score matrix and the predicted score matrix, the network parameters of the medical text detection model are adjusted, so that the medical text detection model converges, and the training of the medical text detection model is completed. The sample score matrix includes a first sample score matrix respectively related to several medical entity categories and a second sample score matrix respectively related to several medical relationship categories. The predicted score matrix includes a first predicted score matrix respectively related to several medical entity categories and a second predicted score matrix respectively related to several medical relationship categories. Therefore, the network parameters of the medical text detection model are adjusted according to the differences between the first sample score matrix and the first predicted score matrix and the differences between the second sample score matrix and the second predicted score matrix, so that the converged medical text detection model can simultaneously solve the entity nesting problem and the entity relationship overlap problem in the sample medical text.

[0144] Please refer to Figure 15 , Figure 15 is Figure 11 a schematic flowchart of an embodiment of step S1104 shown in the figure. It should be noted that if there are substantially the same results, this embodiment is not limited to Figure 15 the process sequence shown in the figure. As Figure 15 shown in the figure, this embodiment includes:

[0145] Step S1501: The matrix positions in the sample score matrix where the sample element values meet the preset conditions are used as positive example positions, and each positive example position is respectively used as the first current position, and the category to which the sample score matrix where the first current position is located belongs is used as the first current category.

[0146] In this embodiment, the matrix positions in the sample score matrix where the sample element values meet the preset conditions are used as positive example positions, and each positive example position is respectively used as the first current position, and the category to which the sample score matrix where the first current position is located belongs is used as the first current category.

[0147] In one embodiment, the preset condition is that the sample element value in the sample score matrix is greater than 0, then the matrix positions in the sample score matrix where the sample element values are greater than 0 are positive example positions. It can be understood that in other embodiments, the preset condition can also be that the sample element value in the sample score matrix is equal to 1 or greater than 1, etc., which is not limited herein and can be specifically set according to actual usage needs. For example, taking Figure 3 as an example, the preset condition is that the sample element value in the sample score matrix is greater than 0, then Figure 3 the matrix positions in the first row and the second column and the matrix positions in the seventh row and the ninth column are positive example positions; at this time, Figure 3The matrix positions at the 1st row and 2nd column, and the 7th row and 9th column in [matrix] are respectively used as the first current positions, and the category of the sample score matrix where the first current position is located, "medical entity category", is used as the first current category.

[0148] For another example, taking Figure 4 as an example, the preset condition is that the sample element value in the sample score matrix is greater than 0, then Figure 4 the matrix positions at the 1st row and 3rd column, 2nd row and 3rd column, 1st row and 4th column, and 2nd row and 4th column in [matrix] are respectively used as the first current positions, and the category of the sample score matrix where the first current position is located, "medical relationship category", is used as the first current category.

[0149] It should be noted that when the sample score matrix has both a medical relationship category and a medical entity category, the first current category will have both a medical entity category and a medical relationship category.

[0150] Step S1502: Based on the predicted element value at the first current position in the prediction score matrix related to the first current category, and the predicted element values at each matrix position in the prediction score matrix related to the first current category, obtain the sub-loss corresponding to the first current position.

[0151] In this embodiment, based on the predicted element value at the first current position in the prediction score matrix related to the first current category, and the predicted element values at each matrix position in the prediction score matrix related to the first current category, the sub-loss corresponding to the first current position is obtained. That is to say, when the first current category is a medical entity category, the sub-loss corresponding to the first current position will be obtained according to the predicted element value at the first current position in the prediction score matrix related to the medical entity category, and the predicted element values at each matrix position in the prediction score matrix related to the medical entity category; when the first current category is a medical relationship category, the sub-loss corresponding to the first current position will be obtained according to the predicted element value at the first current position in the prediction score matrix related to the medical relationship category, and the predicted element values at each matrix position in the prediction score matrix related to the medical relationship category.

[0152] The multi-label classification loss can effectively guide the medical text detection model to learn which are entity labels in the matrix. However, in many annotation systems, the annotation data hides another type of information, that is, the comparison information between annotated and unannotated. Theoretically, in a certain type of entity matrix, the scores of the annotated cells should be as close to each other as possible during quality inspection, while the scores of the unannotated cells should be as far away as possible. Therefore, in one embodiment, as Figure 16 shown Figure 16It is a schematic flowchart of an embodiment of obtaining the first sub-loss corresponding to the first current position according to the contrast loss function provided by the present application. The contrast loss function is introduced to guide the medical text detection model to learn such information, which specifically includes the following sub-steps:

[0153] Step S1601: Based on the predicted element values at each matrix position in the predicted score matrix related to the first current category, obtain the first value corresponding to each matrix position.

[0154] In this embodiment, according to the predicted element values at each matrix position in the predicted score matrix related to the first current category, the first value corresponding to each matrix position is obtained. In a certain medical entity class matrix, the scores of the marked matrix positions should be as close to each other as possible during quality inspection, while the unmarked matrix positions should be as far away as possible.

[0155] Step S1602: Statistically sum the first values corresponding to each matrix position in the predicted score matrix related to the first current category to obtain the second value.

[0156] In this embodiment, the sum of the first values corresponding to each matrix position in the predicted score matrix related to the first current category is statistically calculated to obtain the second value. That is to say, the first values corresponding to each matrix position obtained in step S1601 will be statistically summed to obtain the second value.

[0157] Step S1603: Use the ratio of the first value corresponding to the first current position in the predicted score matrix related to the first current category to the second value as the sub-loss corresponding to the first current position.

[0158] In this embodiment, the ratio of the first value corresponding to the first current position in the predicted score matrix related to the first current category to the second value is used as the sub-loss corresponding to the first current position. The specific formula is as follows:

[0159]

[0160] Among them, represents the predicted score matrix related to the first current category; represents the first value corresponding to each matrix position; represents the second value.

[0161] Step S1503: Statistically sum the sub-losses corresponding to each positive example position to obtain the first loss.

[0162] In this embodiment, the sub-losses corresponding to each positive example position are statistically summed to obtain the first loss, so as to be able to adjust the network parameters of the medical text detection model based on the first loss in the subsequent process. The specific formula is as follows:

[0163]

[0164] Among them, represents the first loss; represents the first value corresponding to each matrix position; represents the second value.

[0165] Step S1504: Based on the first loss, adjust the network parameters of the medical text detection model.

[0166] In this embodiment, the first loss is calculated according to the above method, and thus the network parameters of the medical text detection model are adjusted according to the first loss. Specifically, optimization methods such as gradient descent can be used to adjust the network parameters of the medical text detection model based on the first loss, and steps S1501 - step S1503 can be repeated to adjust the network parameters of the model until the medical text detection model converges.

[0167] For each medical entity matrix, it can be regarded as a multi-label classification matrix, and the multi-classification loss can be used to guide the adjustment of the model network parameters. Similarly, for each

[0168] medical relationship matrix, the multi-label classification loss can also be introduced. In this way, the loss of the entire medical text detection model can be unified into the multi-label classification loss. Among them, the loss function is not specifically limited. Therefore, as Figure 17 shown, Figure 17 is a schematic flowchart of an embodiment for determining the loss of the medical text detection model provided by this application. Before adjusting the network parameters of the medical text detection model based on the first loss, the following sub-steps are specifically included:

[0169] Step S1701: Use the matrix positions in the sample score matrix where the sample element values do not meet the preset conditions as negative example positions, and use each negative example position as the second current position respectively, and use the category to which the sample score matrix where the second current position is located belongs as the second current category.

[0170] In this embodiment, the matrix positions in the sample score matrix where the sample element values do not meet the preset conditions are used as negative example positions, and each negative example position is used as the second current position respectively, and the category to which the sample score matrix where the second current position is located belongs is used as the second current category.

[0171] In one embodiment, the preset condition is that the sample element value in the sample score matrix is greater than 0, and the matrix position where the sample element value in the sample score matrix is less than or equal to 0 is the negative example position. It can be understood that in other embodiments, the preset condition can also be that the sample element value in the sample score matrix is equal to 1 or greater than 1, etc., which is not limited herein and can be specifically set according to actual usage needs.

[0172] Step S1702: Obtain a first sub-item value based on the predicted element value at the first current position in the prediction score matrix related to the first current category.

[0173] In this embodiment, a first sub-item value is obtained according to the predicted element value at the first current position in the prediction score matrix related to the first current category. Among them, the first sub-item value is negatively correlated with the predicted element value at the first current position. The specific formula is as follows:

[0174]

[0175] Among them, represents the first sub-item value; represents the prediction score matrix related to the first current category; represents the predicted element value at the i-th first current position.

[0176] Step S1703: Obtain a second sub-item value based on the predicted element value at the second current position in the prediction score matrix related to the second current category.

[0177] In this embodiment, a second sub-item value is obtained according to the predicted element value at the second current position in the prediction score matrix related to the second current category. Among them, the second sub-item value is positively correlated with the predicted element value at the second current position. The specific formula is as follows:

[0178]

[0179] Among them, represents the second sub-item value; represents the prediction score matrix related to the second current category; represents the predicted element value at the i-th second current position.

[0180] Step S1704: Obtain a second loss based on the first sub-item value and the second sub-item value.

[0181] In this embodiment, a second loss is obtained according to the first sub-item value and the second sub-item value. The specific formula is as follows:

[0182]

[0183] Among them, represents the second loss; Represents the second sub-item value; Represents the first sub-item value.

[0184] Therefore, in a specific embodiment, after determining the first loss and the second loss, the network parameters of the medical text detection model will be adjusted according to the first loss and the second loss. That is to say, the network parameters of the medical text detection model will be adjusted under the joint guidance of the entity-relationship loss and the contrast loss. Optionally, in an embodiment, the first loss and the second loss can be weighted and summed to obtain the total loss, and then the network parameters of the medical text detection model are adjusted according to the total loss. The specific formula is as follows:

[0185]

[0186] Wherein, Represents the total loss; Represents the first loss; Represents the second loss; , Represents hyperparameters. Among them, the sizes of and are not specifically limited and can be specifically set according to actual usage needs. For example, , .

[0187] Please refer to Figure 18 , Figure 18 which is a schematic framework diagram of an embodiment of the medical text detection device provided by this application. The medical text detection device 180 includes: a text acquisition module 181, a semantic extraction module 182, a score prediction module 183, and a matrix decoding module 184. The text acquisition module 181 is used to acquire the medical text to be detected; wherein, the medical text to be detected contains a preset number of characters; the semantic extraction module 182 is used to extract the semantic representations of each character in the medical text to be detected; the score prediction module 183 is used to predict a plurality of score matrices based on the semantic representations of each character; wherein, the length and width of each score matrix are both preset values, and the plurality of score matrices include a first score matrix respectively related to several medical entity categories and a second score matrix respectively related to several medical relationship categories, and the first element value at the first position in the first score matrix represents the possibility that the word composed of the first related characters at the first position belongs to the medical entity category, and the second element value at the second position in the second score matrix represents the possibility that the relationship formed by the second related characters at the second position belongs to the medical relationship category, and the first related characters and the second related characters both belong to the medical text to be detected; the matrix decoding module 184 is used to decode the target medical entity and the target medical relationship in the medical text to be detected based on the plurality of score matrices.

[0188] Among them, the above first position is located at the i-th row and j-th column in the first score matrix, the first related characters are the i-th character and the j-th character in the medical text to be tested, and the first element value represents the possibility that the word formed by the sequential arrangement of the i-th character and the j-th character in the medical text to be tested belongs to the medical entity category; or, the above first position is located at the j-th row and i-th column in the first score matrix, the first related characters are the j-th character and the i-th character in the medical text to be tested, and the first element value represents the possibility that the word formed by the sequential arrangement of the j-th character and the i-th character in the medical text to be tested belongs to the medical entity category.

[0189] Among them, the above second position is located at the m-th row and n-th column in the second score matrix, the second related characters include the m-th character and the n-th character in the medical text to be tested, and the second element value represents the possibility that the relationship formed by the m-th character and the n-th character belonging to different entities in the medical text to be tested belongs to the medical relationship category; or, the above second position is located at the n-th row and m-th column in the second score matrix, the second related characters include the n-th character and the m-th character in the medical text to be tested, and the second element value represents the possibility that the relationship formed by the n-th character and the m-th character belonging to different entities in the medical text to be tested belongs to the medical relationship category.

[0190] Among them, the score prediction module 183 is used to predict a number of score matrices based on the semantic representations of each character, specifically including: performing spatial mapping based on the semantic representations of a preset number of characters to obtain a number of feature matrices; where the length and width of each feature matrix are the preset number and the feature dimension respectively, and the number of feature matrices includes a first feature matrix related to several medical entity categories respectively and a second feature matrix related to several medical relationship categories respectively; for each feature matrix, based on the feature matrix and its transposed matrix, the score matrix corresponding to the feature matrix is obtained.

[0191] Among them, the above number of score matrices are obtained by the medical text detection model processing the medical text to be tested, and the medical text detection model includes a number of spatial mapping networks; where the number of spatial mapping networks includes a number of first mapping networks and a number of second mapping networks, and different first mapping networks perform spatial mapping of different medical entity categories, and different second mapping networks perform spatial mapping of different medical relationship categories.

[0192] Among them, the above spatial mapping network is a multi-layer perceptron including multiple network layers, and activation functions are provided in all network layers except the last network layer; and / or, the above medical text detection model includes a semantic extraction network, the semantic extraction network is used to perform semantic extraction operations, and a number of spatial mapping networks are connected in parallel after the semantic extraction network.

[0193] Among them, the matrix decoding module 184 is used to decode the target medical entities and target medical relationships in the medical text to be tested based on a number of score matrices, specifically including: decoding the target medical entities belonging to the medical entity category based on the first element values that meet the second condition in the first score matrix related to the medical entity category; obtaining the candidate medical relationships formed by the target medical entities, and obtaining the medical relationship category to which the candidate medical relationships belong as the candidate relationship category; decoding the target medical relationship based on the second element values in the reference area of the second score matrix related to the candidate relationship category meeting the second condition; wherein, the second relevant characters corresponding to the reference area are included in the candidate medical relationship.

[0194] Among them, the matrix decoding module 184 is used to decode the target medical entities belonging to the medical entity category based on the first element values that meet the first condition in the first score matrix related to the medical entity category, specifically including: respectively taking several medical entity categories as the current entity category, and taking the first score matrix related to the current entity category as the first current matrix; obtaining the first target positions where the first element values that meet the first condition are located in the first current matrix; taking the words composed of the first relevant characters at the first target positions as the target medical entities belonging to the current entity category.

[0195] Among them, the matrix decoding module 184 is used to obtain the candidate medical relationships formed by the target medical entities, specifically including: arranging and combining each pair of the target medical entities to obtain the candidate medical relationships; the matrix decoding module 184 is used to obtain the medical relationship category to which the candidate medical relationships belong as the candidate relationship category, specifically including: obtaining the medical relationship category to which the candidate medical relationships belong based on the sequence order of the two target medical entities in the candidate medical relationship and their respective medical entity categories; taking the medical relationship category to which the candidate medical relationships belong as the candidate relationship category.

[0196] Among them, the matrix decoding module 184 is used to decode the target medical relationship based on the second element values in the reference area of the second score matrix related to the candidate relationship category meeting the second condition, specifically including: respectively taking each candidate medical relationship as the current medical relationship, taking the candidate relationship category to which the current medical relationship belongs as the current medical category, and taking the second score matrix related to the current medical category as the second current matrix; counting the total number of the second element values that meet the first condition in the reference area of the second current matrix; taking the current medical relationship as the target medical relationship based on the total number meeting the second condition.

[0197] Please refer to Figure 19 , Figure 19It is a schematic framework diagram of an embodiment of a training device for a medical text detection model provided by this application. The training device 190 of the medical text detection model includes: a sample acquisition module 191, a matrix encoding module 192, a model detection module 193, and a parameter adjustment module 194. The sample acquisition module 191 is used to acquire sample medical texts; among them, the sample medical texts contain a preset number of sample characters, and the sample medical texts are labeled with sample medical entities and their affiliated medical entity categories, as well as sample medical relationships and their affiliated medical relationship categories; the matrix encoding module 192 is used to encode, based on the sample medical entities and their affiliated medical entity categories, to obtain first sample score matrices respectively related to several medical entity categories, and to encode, based on the sample medical relationships and their affiliated medical relationship categories, to obtain second sample score matrices respectively related to several medical relationship categories; among them, the length and width of each sample score matrix are both preset values, the first sample element value at the first matrix position in the first sample score matrix indicates whether the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second sample element value at the second matrix position in the second sample score matrix indicates whether the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category, and the first sample-related characters and the second sample-related characters both belong to the sample medical texts; the model detection module 193 is used to sequentially perform semantic extraction and score prediction on the sample medical texts by using the medical text detection model to obtain a first prediction score matrix respectively related to several medical entity categories and a second prediction score matrix respectively related to several medical relationship categories; among them, the length and width of each prediction score matrix are both preset values, the first prediction element value at the first matrix position in the first prediction score matrix indicates the possibility that the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second prediction element value at the second matrix position in the second prediction score matrix indicates the possibility that the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category; the parameter adjustment module 194 is used to adjust the network parameters of the medical text detection model based on the difference between the sample score matrix and the prediction score matrix.

[0198] Among them, the parameter adjustment module 194 is used to adjust the network parameters of the medical text detection model based on the difference between the sample score matrix and the predicted score matrix, specifically including: regarding the matrix positions in the sample score matrix where the sample element values meet the preset conditions as positive example positions, and respectively taking each positive example position as the first current position, and taking the category to which the sample score matrix where the first current position is located belongs as the first current category; based on the predicted element value at the first current position in the predicted score matrix related to the first current category, and the predicted element values at each matrix position in the predicted score matrix related to the first current category, obtaining the sub-loss corresponding to the first current position; counting the sub-losses corresponding to each positive example position respectively to obtain the first loss; and adjusting the network parameters of the medical text detection model based on the first loss.

[0199] Among them, the parameter adjustment module 194 is used to obtain the sub-loss corresponding to the first current position based on the predicted element value at the first current position in the predicted score matrix related to the first current category, and the predicted element values at each matrix position in the predicted score matrix related to the first current category, specifically including: obtaining the first value corresponding to each matrix position based on the predicted element values at each matrix position in the predicted score matrix related to the first current category; where the first value is positively correlated with the predicted element value; counting the sum of the first values corresponding to each matrix position in the predicted score matrix related to the first current category to obtain the second value; and taking the ratio of the first value corresponding to the first current position in the predicted score matrix related to the first current category to the second value as the sub-loss corresponding to the first current position.

[0200] Among them, before the parameter adjustment module 194 adjusts the network parameters of the medical text detection model based on the first loss, it specifically further includes: regarding the matrix positions in the sample score matrix where the sample element values do not meet the preset conditions as negative example positions, and respectively taking each negative example position as the second current position, and taking the category to which the sample score matrix where the second current position is located belongs as the second current category; obtaining the first sub-item value based on the predicted element value at the first current position in the predicted score matrix related to the first current category; where the first sub-item value is negatively correlated with the predicted element value at the first current position; and obtaining the second sub-item value based on the predicted element value at the second current position in the predicted score matrix related to the second current category, where the second sub-item value is positively correlated with the predicted element value at the second current position; obtaining the second loss based on the first sub-item value and the second sub-item value; the parameter adjustment module 194 is used to adjust the network parameters of the medical text detection model based on the first loss, specifically including: adjusting the network parameters based on the first loss and the second loss.

[0201] Among them, the above sample medical text involves several annotation systems, and the several annotation systems include a target annotation system and at least one reference annotation system. The parameter adjustment module 194 is further configured to: for each annotation system, construct a system dictionary based on the annotated words in the sample medical text related to the annotation system; obtain the training order of the several annotation systems based on the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems; wherein, the training order of the target annotation system is the last; according to the training order of the several annotation systems, select an annotation system as the current annotation system, and based on the sample medical text using the current annotation system, perform the steps of sequentially performing semantic extraction and score prediction on the sample medical text using the medical text detection model to obtain a first prediction score matrix related to several medical entity categories and a second prediction score matrix related to several medical relationship categories, and subsequent steps, until the training converges under the current annotation system; in response to there being still annotation systems not selected, re-execute the steps of selecting an annotation system as the current annotation system according to the training order of the several annotation systems and subsequent steps.

[0202] Among them, the parameter adjustment module 194 is configured to obtain the training order of the several annotation systems based on the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems, specifically including: taking the intersection-over-union ratio between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems as the similarity; determining the training order of the several annotation systems in ascending order of similarity.

[0203] Please refer to Figure 20 , Figure 20 is a schematic framework diagram of an embodiment of the electronic device provided in the present application. The electronic device 200 includes a mutually coupled memory 201 and a processor 202. Program instructions are stored in the memory 201, and the processor 202 is configured to execute the program instructions to implement the steps in any of the above embodiments of the medical text detection method or the training method of the medical text detection model. Specifically, the electronic device 200 may include, but is not limited to: desktop computers, laptop computers, servers, mobile phones, tablet computers, etc., which are not limited herein.

[0204] Specifically, the processor 202 is used to control itself and the memory 201 to implement the steps in any of the above-described embodiments of the medical text detection method or the training method of the medical text detection model. The processor 202 may also be referred to as a CPU (Central Processing Unit). The processor 202 may be an integrated circuit chip with signal processing capabilities. The processor 202 may also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Additionally, the processor 202 may be implemented jointly by integrated circuit chips.

[0205] Please refer to Figure 21 , Figure 21 FIG. is a schematic framework diagram of an embodiment of the computer-readable storage medium provided by the present application. The computer-readable storage medium 210 stores program instructions 211 that can be run by a processor. The program instructions 211 are used to implement the steps in any of the above-described embodiments of the medical text detection method or the training method of the medical text detection model.

[0206] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.

[0207] The above descriptions of the various embodiments tend to emphasize the differences between the various embodiments. Their similarities or similarities can be referred to each other. For the sake of brevity, they will not be repeated in this article.

[0208] In several embodiments provided by the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.

[0209] The unit described as a separate component may or may not be physically separated, and the component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed across multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0210] In addition, each functional unit in various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0211] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that makes a contribution to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods in various embodiments of the present application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs, etc., which can store program codes.

[0212] The above description is only for the embodiments of the present application and does not limit the patent scope of the present application. Any equivalent structural or equivalent process transformation made using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.

Claims

1. A medical text detection method, characterized in that, it includes: Obtain the medical text to be tested; wherein, the medical text to be tested contains a preset number of characters; Extract the semantic representations of each of the characters in the medical text to be tested; Based on the semantic representations of each of the characters, several score matrices are predicted; wherein, the length and width of each of the score matrices are the preset number, and the several score matrices include a first score matrix respectively related to several medical entity categories and a second score matrix respectively related to several medical relationship categories, and the first element value at the first position in the first score matrix represents the possibility that the word composed of the first related characters at the first position belongs to the medical entity category, and the second element value at the second position in the second score matrix represents the possibility that the relationship formed by the second related characters at the second position belongs to the medical relationship category, and the first related characters and the second related characters both belong to the medical text to be tested; Based on the several score matrices, decode the target medical entities and target medical relationships in the medical text to be tested; Wherein, the decoding of the target medical entities and target medical relationships in the medical text to be tested based on the several score matrices includes: Based on the first element values that meet the first condition in the first score matrix related to the medical entity category, decode the target medical entities belonging to the medical entity category, and the first condition includes that the first element value is greater than the first threshold; Obtain the candidate medical relationships formed by the target medical entities, and obtain the medical relationship category to which the candidate medical relationships belong as the candidate relationship category; Based on the second element values in the reference area of the second score matrix related to the candidate relationship category meeting the second condition, decode the target medical relationship, the second related characters corresponding to the reference area are included in the candidate medical relationship, and the second condition includes that the proportion of the second element values greater than the second threshold in the reference area is greater than or equal to the third threshold.

2. The method according to claim 1, characterized in that, The first position is in the i-th row and j-th column of the first score matrix, the first related characters are the i-th character and the j-th character in the medical text to be tested, and the first element value represents the possibility that the word composed of the i-th character and the j-th character in the medical text to be tested arranged in sequence belongs to the medical entity category; Or, the first position is in the j-th row and i-th column of the first score matrix, the first related characters are the j-th character and the i-th character in the medical text to be tested, and the first element value represents the possibility that the word composed of the j-th character and the i-th character in the medical text to be tested arranged in sequence belongs to the medical entity category.

3. The method according to claim 1, characterized in that, The second position is located in the m-th row and n-th column of the second score matrix. The second related characters include the m-th character and the n-th character in the medical text to be tested. The second element value represents the possibility that the relationship formed by the m-th character and the n-th character in the medical text to be tested belonging to different entities belongs to the medical relationship category; Alternatively, the second position is located in the n-th row and m-th column of the second score matrix. The second related characters include the n-th character and the m-th character in the medical text to be tested. The second element value represents the possibility that the relationship formed by the n-th character and the m-th character in the medical text to be tested belonging to different entities belongs to the medical relationship category.

4. The method according to claim 1, wherein, the predicting a plurality of score matrices based on the semantic representations of the respective characters includes: performing spatial mapping based on the semantic representations of the preset number of characters to obtain a plurality of feature matrices; wherein, the length and width of each feature matrix are the preset number and the feature dimension respectively, and the plurality of feature matrices include a first feature matrix respectively related to a plurality of medical entity categories and a second feature matrix respectively related to a plurality of medical relationship categories; for each of the feature matrices, based on the feature matrix and its transposed matrix, obtaining the score matrix corresponding to the feature matrix.

5. The method according to claim 4, wherein, the plurality of score matrices are obtained by a medical text detection model processing the medical text to be tested, and the medical text detection model includes a plurality of spatial mapping networks; wherein, the plurality of spatial mapping networks include a plurality of first mapping networks and a plurality of second mapping networks. Different first mapping networks perform spatial mapping of different medical entity categories, and different second mapping networks perform spatial mapping of different medical relationship categories.

6. The method according to claim 5, wherein, the spatial mapping network is a multi-layer perceptron including multiple network layers, and activation functions are provided in all network layers except the last network layer; and / or, the medical text detection model includes a semantic extraction network, and the semantic extraction network is used to perform semantic extraction operations, and the plurality of spatial mapping networks are connected in parallel after the semantic extraction network.

7. The method according to claim 1, wherein, the decoding of the target medical entity belonging to the medical entity category based on the first element value satisfying the first condition in the first score matrix related to the medical entity category includes: respectively taking the plurality of medical entity categories as the current entity category, and taking the first score matrix related to the current entity category as the first current matrix; obtaining the first target position where the first element value satisfying the first condition in the first current matrix is located; taking the word formed by the first related characters at the first target position as the target medical entity belonging to the current entity category.

8. The method according to claim 1, wherein, The obtaining of candidate medical relationships formed by the target medical entities includes: Pairwise arranging and combining each of the target medical entities to obtain the candidate medical relationships; The obtaining of the medical relationship category to which the candidate medical relationship belongs as the candidate relationship category includes: Based on the sequence of the two target medical entities in the candidate medical relationship and their respective medical entity categories, obtaining the medical relationship category to which the candidate medical relationship belongs; Taking the medical relationship category to which the candidate medical relationship belongs as the candidate relationship category.

9. The method according to claim 1, wherein, the decoding of the target medical relationship based on that the second element values in the reference area of the second score matrix related to the candidate relationship category satisfy the second condition includes: Respectively taking each of the candidate medical relationships as the current medical relationship, taking the candidate relationship category to which the current medical relationship belongs as the current medical category, and taking the second score matrix related to the current medical category as the second current matrix; Counting the total number of second element values in the reference area of the second current matrix that satisfy the second condition; Based on that the total value satisfies the second condition, taking the current medical relationship as the target medical relationship.

10. A training method for a medical text detection model, wherein, it includes: Obtaining a sample medical text; wherein, the sample medical text contains a preset number of sample characters, and the sample medical text is labeled with sample medical entities and their respective medical entity categories, as well as sample medical relationships and their respective medical relationship categories; Based on the sample medical entities and their respective medical entity categories, encoding to obtain first sample score matrices respectively related to several medical entity categories, and based on the sample medical relationships and their respective medical relationship categories, encoding to obtain second sample score matrices respectively related to several medical relationship categories; wherein, the length and width of each sample score matrix are both the preset number, the first sample element value at the first matrix position in the first sample score matrix indicates whether the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, the second sample element value at the second matrix position in the second sample score matrix indicates whether the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category, and the first sample-related characters and the second sample-related characters both belong to the sample medical text; Use a medical text detection model to sequentially perform semantic extraction and score prediction on the sample medical text to obtain a first predicted score matrix related to several types of the medical entity categories and a second predicted score matrix related to several types of the medical relationship categories; wherein, the length and width of each predicted score matrix are the preset values, the first predicted element value at the first matrix position in the first predicted score matrix represents the possibility that the word composed of the first sample-related characters at the first matrix position belongs to the medical entity category, and the second predicted element value at the second matrix position in the second predicted score matrix represents the possibility that the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category; Based on the difference between the sample score matrix and the predicted score matrix, adjust the network parameters of the medical text detection model; Wherein, the adjusting the network parameters of the medical text detection model based on the difference between the sample score matrix and the predicted score matrix includes: Take the matrix positions in the sample score matrix where the sample element values meet the preset conditions as positive example positions, and take each of the positive example positions as the first current position respectively, and take the category to which the sample score matrix where the first current position is located belongs as the first current category; Based on the predicted element value at the first current position in the predicted score matrix related to the first current category and the predicted element values at each matrix position in the predicted score matrix related to the first current category, obtain the sub-loss corresponding to the first current position; Statistically calculate the sub-losses corresponding to each of the positive example positions respectively to obtain the first loss; Based on the first loss, adjust the network parameters of the medical text detection model.

11. The method according to claim 10, wherein, the obtaining the sub-loss corresponding to the first current position based on the predicted element value at the first current position in the predicted score matrix related to the first current category and the predicted element values at each matrix position in the predicted score matrix related to the first current category includes: Based on the predicted element values at each matrix position in the predicted score matrix related to the first current category, obtain the first values corresponding to each matrix position; wherein, the first values are positively correlated with the predicted element values; Statistically calculate the sum of the first values corresponding to each matrix position in the predicted score matrix related to the first current category to obtain the second value; Take the ratio of the first value corresponding to the first current position in the predicted score matrix related to the first current category to the second value as the sub-loss corresponding to the first current position.

12. The method according to claim 10, wherein, before the adjusting the network parameters of the medical text detection model based on the first loss, the method further includes: Take the matrix positions in the sample score matrix where the sample element values do not meet the preset conditions as negative example positions, and take each of the negative example positions as the second current position respectively, and take the category to which the sample score matrix where the second current position is located belongs as the second current category; Based on the predicted element value at the first current position in the prediction score matrix related to the first current category, obtain a first sub-item value; wherein, the first sub-item value is negatively correlated with the predicted element value at the first current position; and, Based on the predicted element value at the second current position in the prediction score matrix related to the second current category, obtain a second sub-item value, wherein the second sub-item value is positively correlated with the predicted element value at the second current position; Based on the first sub-item value and the second sub-item value, obtain a second loss; The adjusting the network parameters of the medical text detection model based on the first loss includes: Adjust the network parameters based on the first loss and the second loss.

13. The method according to claim 10, wherein, The sample medical text involves several annotation systems, and the several annotation systems include a target annotation system and at least one reference annotation system. The method further includes: For each of the annotation systems, construct a system dictionary based on the annotation words in the sample medical text related to the annotation system; Based on the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems, obtain the training order of the several annotation systems; wherein, the training order of the target annotation system is the last; According to the training order of the several annotation systems, select one of the annotation systems as the current annotation system, and based on the sample medical text using the current annotation system, perform the steps of sequentially performing semantic extraction and score prediction on the sample medical text by using the medical text detection model to obtain a first prediction score matrix related to several medical entity categories and a second prediction score matrix related to several medical relationship categories respectively, and subsequent steps, until the training converges under the current annotation system; In response to there being still annotation systems not selected, re-execute the step of selecting one of the annotation systems as the current annotation system according to the training order of the several annotation systems and subsequent steps.

14. The method according to claim 13, wherein, The obtaining the training order of the several annotation systems based on the similarity between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems includes: Take the intersection over union between the system dictionary corresponding to the target annotation system and the system dictionaries corresponding to various reference annotation systems as the similarity; Determine the training order of the several annotation systems in ascending order of the similarity.

15. A medical text detection device, wherein, Comprising: A text acquisition module for acquiring a medical text to be detected; wherein, the medical text to be detected contains a preset number of characters; A semantic extraction module, used for extracting the semantic representation of each character in the medical text to be tested; A score prediction module is configured to predict a plurality of score matrices based on the semantic representation of each of the characters; wherein the length and width of each of the score matrices are both the preset values, the plurality of score matrices include first score matrices respectively related to a plurality of medical entity categories and second score matrices respectively related to a plurality of medical relationship categories, and the first element value at the first position in the first score matrix indicates the possibility that a word composed of the first related character at the first position belongs to the medical entity category, the second element value at the second position in the second score matrix indicates the possibility that a relationship formed by the second related character at the second position belongs to the medical relationship category, and the first related character and the second related character both belong to the medical text to be tested; A matrix decoding module, used for decoding and obtaining target medical entities and target medical relations in the medical text to be tested based on the plurality of score matrices; The decoding based on the plurality of score matrices to obtain the target medical entities and target medical relations in the medical text to be tested includes: Decoding to obtain a target medical entity belonging to the medical entity category based on a first element value in a first score matrix related to the medical entity category that satisfies a first condition, wherein the first condition includes that the first element value is greater than a first threshold; Acquire a candidate medical relationship formed by the target medical entity, and acquire a medical relationship category to which the candidate medical relationship belongs as a candidate relationship category; The target medical relationship is decoded based on that the second element value in the reference area in the second score matrix related to the candidate relationship category satisfies the second condition, and the second related character corresponding to the reference area is included in the candidate medical relationship. The second condition includes that the proportion of the second element value in the reference area greater than the second threshold is greater than or equal to the third threshold.

16. A training device for a medical text detection model, It is characterized in that include: A sample acquisition module, used to acquire sample medical text; wherein the sample medical text includes a preset number of sample characters, and the sample medical text is annotated with sample medical entities and the medical entity categories to which they belong, as well as sample medical relations and the medical relation categories to which they belong; A matrix encoding module, which is used to encode, based on the sample medical entities and their affiliated medical entity categories, to obtain first sample score matrices respectively related to several types of the medical entity categories, and encode, based on the sample medical relationships and their affiliated medical relationship categories, to obtain second sample score matrices respectively related to several types of the medical relationship categories; wherein, the length and width of each sample score matrix are both the preset value, the first sample element value at the first matrix position in the first sample score matrix indicates whether the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, the second sample element value at the second matrix position in the second sample score matrix indicates whether the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category, and the first sample-related characters and the second sample-related characters both belong to the sample medical text; A model detection module, which is used to sequentially perform semantic extraction and score prediction on the sample medical text by using a medical text detection model, to obtain a first prediction score matrix respectively related to several types of the medical entity categories and a second prediction score matrix respectively related to several types of the medical relationship categories; wherein, the length and width of each prediction score matrix are both the preset value, the first prediction element value at the first matrix position in the first prediction score matrix indicates the possibility that the word formed by the first sample-related characters at the first matrix position belongs to the medical entity category, and the second prediction element value at the second matrix position in the second prediction score matrix indicates the possibility that the relationship formed by the second sample-related characters at the second matrix position belongs to the medical relationship category; A parameter adjustment module, which is used to adjust the network parameters of the medical text detection model based on the difference between the sample score matrix and the prediction score matrix; Wherein, adjusting the network parameters of the medical text detection model based on the difference between the sample score matrix and the prediction score matrix includes: Taking the matrix positions in the sample score matrix where the sample element values meet the preset conditions as positive example positions, respectively taking each of the positive example positions as a first current position, and taking the category to which the sample score matrix where the first current position is located belongs as a first current category; Based on the prediction element value at the first current position in the prediction score matrix related to the first current category and the prediction element values at each matrix position in the prediction score matrix related to the first current category, obtaining the sub-loss corresponding to the first current position; Counting the sub-losses respectively corresponding to each of the positive example positions to obtain a first loss; Adjusting the network parameters of the medical text detection model based on the first loss.

17. An electronic device, characterized in that, it includes a mutually coupled memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the medical text detection method according to any one of claims 1 to 9, or the training method of the medical text detection model according to any one of claims 10 to 14.

18. A computer-readable storage medium, characterized in that, it stores program instructions that can be run by a processor, and the program instructions are used to implement the medical text detection method according to any one of claims 1 to 9, or the training method of the medical text detection model according to any one of claims 10 to 14.

Citation Information

Patent Citations

  • Method and device for extracting entity relationship in text, equipment and storage medium

    CN113704392A