A medical dialogue text matching method, device, equipment and storage medium
By dynamically encoding medical questions and answer statements and calculating cosine similarity, the problems of information lag and incomplete matching in existing technologies are solved, and automatic question answering for medical questions is realized.
Patent Information
- Application Number
- CN202310198551.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2043-03-03
AI Technical Summary
In existing technologies, keyword retrieval methods suffer from information lag and incomplete information matching, failing to provide accurate natural language answers to users' medical questions.
By dynamically encoding the target medical question and answer statements, dynamic word vectors and bidirectional sequence information are generated. The cosine similarity between feature vectors is calculated, and the answer statement with the highest cosine similarity is repeatedly selected to achieve matching.
It enables users to directly obtain accurate natural language medical answers, improving the accuracy of matching medical questions with answers.
Smart Images

Figure CN116069918B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of deep learning, and particularly relates to a medical dialogue text matching method, device, equipment and storage medium. BACKGROUND
[0002] With the rapid development and wide popularity of the Internet, people can obtain a large amount of information through search engines, but how to obtain the information needed or useful to oneself from a large amount of information has not been well solved. The general keyword retrieval in the prior art has a large amount of information lag and incomplete information matching, and is a low-form information retrieval, and the retrieval result has a non-natural language problem, which cannot directly answer the user's question.
[0003] In summary, how to realize a non-keyword retrieval manner to enable the user to directly obtain accurate and concise natural language answers to the medical question raised by the user and realize accurate matching of the medical question and the medical answer content is a technical problem to be solved in the field. SUMMARY
[0004] Therefore, the purpose of the present application is to provide a medical dialogue text matching method, device, equipment and storage medium, which can realize a non-keyword retrieval manner to enable the user to directly obtain accurate and concise natural language answers to the medical question raised by the user and realize accurate matching of the medical question and the medical answer content. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a medical dialogue text matching method, comprising:
[0006] When a target medical question sentence is received, a medical answer sentence is selected from a preset medical answer library;
[0007] The target medical question sentence and the medical answer sentence are dynamically encoded to generate corresponding first dynamic word vectors and second dynamic word vectors;
[0008] First and second bidirectional sequence information is generated based on the first and second dynamic word vectors;
[0009] First and second feature vectors of the first and second bidirectional sequence information are captured, respectively, and a cosine similarity between the first and second feature vectors is calculated;
[0010] The step of selecting a medical answer sentence from the preset medical answer library is repeatedly performed until a medical answer sentence corresponding to the maximum cosine similarity is determined as a target matching sentence and outputted.
[0011] Optionally, the step of dynamically encoding the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors includes:
[0012] The target medical question statement and the medical answer statement are subjected to character segmentation to obtain the segmented target medical question characters and medical answer characters;
[0013] The target medical question characters and the medical answer characters are dynamically encoded to obtain a first character code, a second character code, a first position code, a second position code, a first paragraph code, and a second paragraph code;
[0014] Calculate the self-attention of the first character encoding, the second character encoding, the first position encoding, the second position encoding, the first paragraph encoding, and the second paragraph encoding, and connect the self-attention to obtain the corresponding first dynamic word vector and second dynamic word vector.
[0015] Optionally, the calculation of self-attention for the first character code, the second character code, the first position code, the second position code, the first paragraph code, and the second paragraph code includes:
[0016] Calculate and package the mixed query, mixed key, and mixed value for each group of the target medical question characters and the medical answer characters to obtain the corresponding target matrix;
[0017] The target matrix is calculated using a multi-head self-attention mechanism to obtain the corresponding self-attention.
[0018] Optionally, after generating the corresponding first dynamic word vector and second dynamic word vector, the method further includes:
[0019] The first attention weight and the second attention weight corresponding to the first dynamic word vector and the second dynamic word vector are calculated respectively using a preset sentence-level attention mechanism algorithm.
[0020] Optionally, generating the first bidirectional sequence information and the second bidirectional sequence information based on the first dynamic word vector and the second dynamic word vector includes:
[0021] The first bidirectional sequence information and the second bidirectional sequence information are generated using the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector.
[0022] Optionally, generating the first bidirectional sequence information and the second bidirectional sequence information using the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector includes:
[0023] The first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector are forward-propagated to update the hidden vector of the target BiGRU model;
[0024] The target BiGRU model is used to sequentially flip the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector, and then propagate forward again to generate the target hidden vector;
[0025] The target hiding vector is concatenated to generate the first bidirectional sequence information and the second bidirectional sequence information.
[0026] Optionally, capturing the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively includes:
[0027] Obtain the first and second convolutional outputs corresponding to the first bidirectional sequence information and the second bidirectional sequence information of convolutional kernels of different sizes;
[0028] Max pooling is performed on the first convolution output and the second convolution output, and then concatenated to obtain the first feature vector and the second feature vector.
[0029] Secondly, this application discloses a medical dialogue text matching device, comprising:
[0030] The statement acquisition module is used to select a medical answer statement from a preset medical answer database when a target medical question statement is received;
[0031] The encoding module is used to dynamically encode the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors;
[0032] The sequence calculation module is used to calculate the first bidirectional sequence information and the second bidirectional sequence information of the first dynamic word vector and the second dynamic word vector, respectively.
[0033] The similarity calculation module is used to capture the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculate the cosine similarity between the first feature vector and the second feature vector.
[0034] The statement matching module is used to repeatedly execute the step of selecting medical answer statements from a preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output.
[0035] Thirdly, this application discloses an electronic device, including:
[0036] Memory, used to store computer programs;
[0037] A processor is configured to execute the computer program to implement the steps of the aforementioned disclosed medical dialogue text matching method.
[0038] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed medical dialogue text matching method.
[0039] Therefore, this application discloses a medical dialogue text matching method, including: when a target medical question statement is received, selecting a medical answer statement from a preset medical answer database; dynamically encoding the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors; generating first bidirectional sequence information and second bidirectional sequence information based on the first dynamic word vectors and the second dynamic word vectors; capturing the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculating the cosine similarity between the first feature vector and the second feature vector; repeatedly executing the step of selecting a medical answer statement from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output. Thus, by dynamically encoding target medical question statements and medical answer statements in groups, obtaining their respective sequence information, calculating the corresponding cosine similarity, and selecting the most matching target medical question statement and medical answer statement, and determining the medical answer statement as the target matching statement and outputting it, the user terminal can directly receive the medical answer statement corresponding to the input target medical question statement, realizing automatic question and answering of medical questions. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0041] Figure 1 This is a flowchart of a medical dialogue text matching method disclosed in this application;
[0042] Figure 2 This is a flowchart of a specific medical dialogue text matching method disclosed in this application;
[0043] Figure 3 This is a flowchart of the method for generating bidirectional sequence information disclosed in this application;
[0044] Figure 4 This is a schematic diagram of the structure of a medical dialogue text matching device disclosed in this application;
[0045] Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0046] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0047] The rapid development and widespread adoption of the internet have enabled people to access vast amounts of information through search engines. However, the question of how to extract the information that people need or that is useful to them from this vast amount of information has remained largely unresolved. Current keyword retrieval technologies suffer from significant information lag and incomplete matching, representing a low-level form of information retrieval. Furthermore, the search results often contain non-natural language elements and cannot directly answer the user's questions.
[0048] Therefore, this application provides a medical dialogue text matching scheme that enables users to directly obtain accurate and concise natural language answers to their medical questions through a non-keyword retrieval method, achieving accurate matching between medical questions and medical answers.
[0049] Reference Figure 1 As shown in the figure, this application discloses a medical dialogue text matching method, including:
[0050] Step S11: When the target medical question statement is received, select a medical answer statement from the preset medical answer library.
[0051] In this embodiment, it detects whether the user terminal has sent a target medical question. When the user terminal sends a target medical question, it immediately selects a medical answer from a preset medical answer database. This preset medical answer database can be a local medical answer database or a medical answer database on an online platform; there is no specific limitation. The medical answer statements contained in the preset medical answer database are complete, natural language responses to medical questions.
[0052] Step S12: Dynamically encode the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors.
[0053] In this embodiment, an algorithm model based on BERT, BiGRU, and Multi-scale CNNs is initialized to generate a Siamese-based BRCNN model. This BRCNN model is used to perform character segmentation on the target medical question and answer statements, resulting in segmented target medical question and answer characters. The target medical question and answer characters are then dynamically encoded to obtain a first character code, a second character code, a first position code, a second position code, a first paragraph code, and a second paragraph code. Self-attention is calculated for the first character code, the second character code, the first position code, the second position code, the first paragraph code, and the second paragraph code, and these self-attentions are concatenated to obtain the corresponding first and second dynamic word vectors. It is understood that character segmentation is performed on the obtained target medical question and answer statements; for example, the target medical question statement is "I occasionally experience stabbing pain in my heart area." The medical answer statement obtained from the preset medical answer database is "Common causes of heart stabbing pain are coronary heart disease, angina pectoris, etc." Character-by-character segmentation can divide it into "My / heart / part / occasionally / has / stabbing / pain" and "Common / causes / of / heart / stabbing / pain / are / coronary / heart / disease, / angina / pain, etc.", which satisfies the requirement of dynamically generating word vectors based on sentence context. Specifically, the target medical question statement and the medical answer statement are each segmented into a character group, and the characters [CLS] and [SEP] are added to the beginning and end of the sentence respectively, representing InputTokens. q andInputToken a The formula for retrieving characters is as follows:
[0054] InputToken = [CLS, W1, W2, ..., W n [,SEP];
[0055] Among them, W i The i-th character of the target medical question statement or medical answer statement.
[0056] The obtained target medical question characters and medical answer characters are dynamically encoded to obtain the first character code, which is the character code of the target medical question characters; and the second character code, which is the character code of the medical answer characters. This can be understood as encoding the characters of the target medical question statement and the medical answer statement into an InputToken. q andInputToken aThe inputs are fed into the BERT model for training. According to the BERT model, the sentence is first processed by character embedding (Token), paragraph embedding (Segment), and position embedding (Position), and represented as follows:
[0057] Token = [T1, T2, ..., T N ];
[0058] Segment = [S1, S2, ..., S...] N ];
[0059] Position = [P1, P2, ..., P N ];
[0060] Among them, T i S is the character encoding corresponding to the i-th character in the InputToken. i S is the paragraph code corresponding to the i-th character in the InputToken. i This is the position encoding corresponding to the i-th character in the InputToken.
[0061] The above Token, Segment, and Position are summed together to form the final input of the BERT model. BERT Specifically, it is expressed as follows:
[0062] Input BERT = Token + Segment + Position; that is, Input BERT =[I1,I2,...,I N ], where I i =T i +S i +P i At this point, the input of the BERT model has been obtained. BERT Based on input BERT Calculate the corresponding self-attention and connect the self-attention to obtain the corresponding first dynamic word vector and second dynamic word vector.
[0063] Step S13: Generate first bidirectional sequence information and second bidirectional sequence information based on the first dynamic word vector and the second dynamic word vector.
[0064] In this embodiment, an attention-enhanced BiGRU model is used to generate bidirectional sequence information H of question and answer sentences using dynamic word vectors and self-attention. q and H a That is, the first bidirectional sequence information and the second bidirectional sequence information.
[0065] Step S14: Capture the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculate the cosine similarity between the first feature vector and the second feature vector.
[0066] In this embodiment, the first and second bidirectional sequence information obtained above are input into a Multi-scale CNN model to perform feature vector capture calculation, thereby extracting rich feature representations of the sentence, namely the first feature vector O. q Second eigenvector O a The first feature vector O is calculated using the cosine similarity formula below. q Second eigenvector O a The cosine similarity between them is calculated using the following formula:
[0067]
[0068] Where, ||·|| is the norm of the vector, O q It is the final representation of the target medical question sentence, O a This is the final representation of a medical answer sentence.
[0069] Step S15: Repeat the step of selecting medical answer statements from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output.
[0070] In this embodiment, after calculating the cosine similarity between a set of target medical question sentences and medical answer sentences, the process returns to the step of selecting medical answer sentences from a preset medical answer database and performs the subsequent processing to obtain a new set of cosine similarities. All cosine similarities are compared, and the medical answer sentences in the set with the highest cosine similarity are selected as the target medical answer sentences and output to the user, so as to achieve a perfect match between the target medical question sentences and the target medical answer sentences.
[0071] Therefore, this application discloses a medical dialogue text matching method, including: when a target medical question statement is received, selecting a medical answer statement from a preset medical answer database; dynamically encoding the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors; generating first bidirectional sequence information and second bidirectional sequence information based on the first dynamic word vectors and the second dynamic word vectors; capturing the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculating the cosine similarity between the first feature vector and the second feature vector; repeatedly executing the step of selecting a medical answer statement from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output. Thus, by dynamically encoding target medical question statements and medical answer statements in groups, obtaining their respective sequence information, calculating the corresponding cosine similarity, and selecting the most matching target medical question statement and medical answer statement, and determining the medical answer statement as the target matching statement and outputting it, the user terminal can directly receive the medical answer statement corresponding to the input target medical question statement, realizing automatic question and answering of medical questions.
[0072] Reference Figure 2 As shown, this embodiment of the invention discloses a specific method for matching medical dialogue text. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:
[0073] Step S21: When the target medical question statement is received, select a medical answer statement from the preset medical answer library.
[0074] Step S22: Dynamically encode the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors.
[0075] Step S23: Calculate the first attention weight and the second attention weight corresponding to the first dynamic word vector and the second dynamic word vector respectively using a preset sentence-level attention mechanism algorithm.
[0076] In this embodiment, after obtaining the first dynamic word vector and the second dynamic word vector, a sentence-level attention mechanism algorithm is used to calculate the first attention weight and the second attention weight of the target medical question statement and the medical answer statement corresponding to the first dynamic word vector and the second dynamic word vector, respectively. The self-attention of the first character encoding, the second character encoding, the first position encoding, the second position encoding, the first paragraph encoding, and the second paragraph encoding is calculated using the calculated first attention weight and the second attention weight. Specifically, this includes: calculating and packaging the mixed query, mixed key, and mixed value of each group of target medical question characters and medical answer characters to obtain the corresponding target matrix; and using a multi-head self-attention mechanism to calculate the target matrix to obtain the corresponding self-attention. It can be understood that the mixed self-attention function of a group of mixed queries, mixed keys, and mixed values of a sentence is calculated and packaged into matrices Q, K, and V, respectively. The formula for calculating the self-attention function is as follows:
[0077] Q = Input BERT W Q ;
[0078] K = Input BERT W K ;
[0079] V = Input BERT W V ;
[0080] Based on the hybrid self-attention function calculated using the above formula, the self-attention is calculated using a multi-head mechanism, as shown in the following formula:
[0081] MultiHead(Q,K,V)=Concat(head1,...,head h W O ;
[0082] Where h is the number of self-attention heads, head i Let be the attention weight of the i-th self-attention head.
[0083] head i =Attention(QW i Q ,KW i K VW i V );
[0084]
[0085] The multi-head self-attention values calculated in the above formula are concatenated and passed through a feedforward neural network to obtain the final output E.q and E a Then, based on the sentence-level attention mechanism algorithm and E... q Calculate the query, key, and value of the target medical question sentence.
[0086]
[0087]
[0088]
[0089] According to E a Calculate the query, key, and value of the medical answer sentence:
[0090]
[0091]
[0092]
[0093] Calculate the attention weights of the target medical question sentence.
[0094]
[0095] Calculate the attention weights of medical answer sentences.
[0096]
[0097] Step S24: Generate the first bidirectional sequence information and the second bidirectional sequence information using the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector.
[0098] In this embodiment, the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector are input into an attention-based improved BiGRU to obtain the first bidirectional sequence information and the second bidirectional sequence information.
[0099] Step S25: Capture the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculate the cosine similarity between the first feature vector and the second feature vector.
[0100] In this embodiment, the first and second convolutional outputs corresponding to the first and second bidirectional sequence information outputs of convolutional kernels of different sizes are obtained; max pooling is performed on the first and second convolutional outputs and they are concatenated to obtain the first and second feature vectors. It can be understood that the first and second bidirectional sequence information are input into Multi-scale CNNs to capture the feature vectors carried by n-grams of different sizes, and these are concatenated to obtain the final first feature vector O. q Second eigenvector O a Specifically, by using convolutional kernels of different sizes to perform convolution operations on the first and second bidirectional sequence information, information carried by n-grams of different sizes in a sequence of sentences is obtained. Given a set of convolutional kernels C = [c1, c2, ..., c...], ... t Each sentence is convolved using a different convolution kernel, and the formula is as follows:
[0101]
[0102] in, It is of size c i The convolution output of the convolution kernel, ReLU(·) is the activation function. and The parameter to be learned, s k (k = 1, 2, ..., mc) i +1) is c in the sentence i A continuous vector;
[0103] Then the outputs of each convolutional layer are concatenated to form the output of a convolutional kernel in the model. Where n is a unit of size c i The number of convolutional kernels; the output of all convolutional kernels. After performing max pooling on each element, the results are concatenated to form the final output O = [o1, o2, ..., o...]. t ], that is, the first eigenvector O q Second eigenvector O a Then, the cosine similarity between the first feature vector and the second feature vector is calculated.
[0104] Step S26: Repeat the step of selecting medical answer statements from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output.
[0105] For more detailed processing steps S21, S22, S25, and S26, please refer to the aforementioned disclosed embodiments; they will not be repeated here.
[0106] Therefore, it can be seen that when the BRCNN algorithm model, which is built based on BERT, BiGRU and Multi-scale CNNs, performs sentence matching on target medical question sentences and medical answer sentences, it can extract rich feature representations of sentences while dynamically generating word vectors according to sentence context. In addition, it can reduce the negative impact of redundant information during feature extraction and improve the accuracy of sentence question and answer matching.
[0107] Reference Figure 3 As shown, this embodiment of the invention discloses a specific method for generating bidirectional sequence information. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:
[0108] Step S31: Perform forward propagation on the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector to update the hidden vector of the target BiGRU model.
[0109] In this embodiment, a forward propagation is performed on the first attention weight, second attention weight, first dynamic word vector, and second dynamic word vector corresponding to the target medical question statement and the medical answer statement, respectively. The hidden vector h of the i-th character is... i Update according to the following formula:
[0110]
[0111]
[0112]
[0113]
[0114] Among them, e i ∈E=[e1,e2,...,e N ], a i ∈Attention=[a1,a2,...,a N ], It is a candidate state, containing the current input e. i and a i Information, z i It is an update gate, used to control how much state information from the previous time period is carried over to the current state, r i It is a reset gate that controls the number of candidate states to which information from the previous state is written; and the output is represented as
[0115] Step S32: Using the target BiGRU model, sequentially flip the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector, and then propagate forward again to generate the target hidden vector.
[0116] In this embodiment, the E and Attention sequences of the target medical question statement and the medical answer statement are reversed, that is:
[0117] E = [e N ,e N-1 ,...,e1];
[0118] Attention = [a N ,a N-1 ,...,a1];
[0119] Then, the flipped sentence sequence is propagated forward again according to the flipping formulas for E and Attention, as described above, to obtain the output.
[0120] Step S33: Connect the target hiding vector to generate first bidirectional sequence information and second bidirectional sequence information.
[0121] In this embodiment, then and The corresponding hidden vectors are concatenated to form the final output of the model, i.e., H = [h1, h2, ..., h...]. N ],in That is, to generate the first bidirectional sequence information and the second bidirectional sequence information.
[0122] Therefore, by improving the attention of the BiGRU model, the target BiGRU model can obtain bidirectional sequence information of the target medical question statement and the medical answer statement. Accordingly, in order to further reduce the influence of redundant information when extracting features from the bidirectional sequence information, the accuracy of question-answer matching is improved.
[0123] Reference Figure 4 As shown, the present invention also discloses a medical dialogue text matching device, comprising:
[0124] Statement acquisition module 11 is used to select a medical answer statement from a preset medical answer database when a target medical question statement is received;
[0125] Encoding module 12 is used to dynamically encode the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors;
[0126] Sequence calculation module 13 is used to calculate the first bidirectional sequence information and the second bidirectional sequence information of the first dynamic word vector and the second dynamic word vector, respectively;
[0127] The similarity calculation module 14 is used to capture the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculate the cosine similarity between the first feature vector and the second feature vector.
[0128] The statement matching module 15 is used to repeatedly execute the step of selecting medical answer statements from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output.
[0129] Therefore, this application discloses a medical dialogue text matching method, including: when a target medical question statement is received, selecting a medical answer statement from a preset medical answer database; dynamically encoding the target medical question statement and the medical answer statement to generate corresponding first dynamic word vectors and second dynamic word vectors; generating first bidirectional sequence information and second bidirectional sequence information based on the first dynamic word vectors and the second dynamic word vectors; capturing the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculating the cosine similarity between the first feature vector and the second feature vector; repeatedly executing the step of selecting a medical answer statement from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output. Thus, by dynamically encoding target medical question statements and medical answer statements in groups, obtaining their respective sequence information, calculating the corresponding cosine similarity, and selecting the most matching target medical question statement and medical answer statement, and determining the medical answer statement as the target matching statement and outputting it, the user terminal can directly receive the medical answer statement corresponding to the input target medical question statement, realizing automatic question and answering of medical questions.
[0130] Furthermore, embodiments of this application also disclose an electronic device, Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0131] Figure 5This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the medical dialogue text matching method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0132] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0133] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0134] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0135] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device 20 to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. It can be Windows Server, Netware, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the medical dialogue text matching method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.
[0136] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed medical dialogue text matching method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0137] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0138] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can implement the described functions using different methods for each specific application, but such implementation should not be considered beyond the scope of this application. The steps of the methods or algorithms described in connection with the embodiments disclosed herein can be implemented directly in hardware, software modules executed by a processor, or a combination of both. Software modules can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the art.
[0139] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0140] The above provides a detailed description of a medical dialogue text matching method, apparatus, and device storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for matching medical dialogue text, characterized in that, include: When a target medical question is received, a medical answer is selected from a preset medical answer database. The algorithm model based on BERT, BiGRU and Multi-scale CNNs is initialized to generate a BRCNN model with a Siamese structure, so as to perform character segmentation operation on the target medical question statement and the medical answer statement through the BRCNN model to obtain the segmented target medical question characters and medical answer characters; The target medical question characters and the medical answer characters are dynamically encoded to obtain a first character code, a second character code, a first position code, a second position code, a first paragraph code, and a second paragraph code; Calculate the self-attention of the first character encoding, the second character encoding, the first position encoding, the second position encoding, the first paragraph encoding, and the second paragraph encoding, and connect the self-attention to obtain the corresponding first dynamic word vector and second dynamic word vector; The first attention weight and the second attention weight corresponding to the first dynamic word vector and the second dynamic word vector are calculated respectively using a preset sentence-level attention mechanism algorithm; First bidirectional sequence information and second bidirectional sequence information are generated using the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector; First feature vectors and second feature vectors of the first bidirectional sequence information and the second bidirectional sequence information are captured respectively, and the cosine similarity between the first feature vector and the second feature vector is calculated. Repeat the step of selecting medical answer statements from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output; The step of generating the first bidirectional sequence information and the second bidirectional sequence information using the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector includes: The first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector are forward-propagated to update the hidden vector of the target BiGRU model; The target BiGRU model is used to sequentially flip the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector, and then propagate forward again to generate the target hidden vector; The target hiding vector is concatenated to generate the first bidirectional sequence information and the second bidirectional sequence information.
2. The medical dialogue text matching method according to claim 1, characterized in that, The calculation of self-attention for the first character encoding, the second character encoding, the first position encoding, the second position encoding, the first paragraph encoding, and the second paragraph encoding includes: Calculate and package the mixed query, mixed key, and mixed value for each group of the target medical question characters and the medical answer characters to obtain the corresponding target matrix; The target matrix is calculated using a multi-head self-attention mechanism to obtain the corresponding self-attention.
3. The medical dialogue text matching method according to claim 1, characterized in that, The first feature vector and the second feature vector, which respectively capture the first bidirectional sequence information and the second bidirectional sequence information, include: Obtain the first and second convolutional outputs corresponding to the first bidirectional sequence information and the second bidirectional sequence information of convolutional kernels of different sizes; Max pooling is performed on the first convolution output and the second convolution output, and then concatenated to obtain the first feature vector and the second feature vector.
4. A medical dialogue text matching device, characterized in that, include: The statement acquisition module is used to select a medical answer statement from a preset medical answer database when a target medical question statement is received; The encoding module is used to initialize the BRCNN model with a Siamese structure based on the algorithm model of BERT, BiGRU and Multi-scale CNNs, so as to perform character segmentation operation on the target medical question statement and the medical answer statement through the BRCNN model to obtain the segmented target medical question characters and medical answer characters; The target medical question characters and the medical answer characters are dynamically encoded to obtain a first character code, a second character code, a first position code, a second position code, a first paragraph code, and a second paragraph code; Calculate the self-attention of the first character encoding, the second character encoding, the first position encoding, the second position encoding, the first paragraph encoding, and the second paragraph encoding, and connect the self-attention to obtain the corresponding first dynamic word vector and second dynamic word vector; The medical dialogue text matching device is also used to calculate the first attention weight and the second attention weight corresponding to the first dynamic word vector and the second dynamic word vector respectively using a preset sentence-level attention mechanism algorithm; The sequence calculation module is used to generate first bidirectional sequence information and second bidirectional sequence information using the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector. The similarity calculation module is used to capture the first feature vector and the second feature vector of the first bidirectional sequence information and the second bidirectional sequence information respectively, and calculate the cosine similarity between the first feature vector and the second feature vector. The statement matching module is used to repeatedly execute the step of selecting medical answer statements from the preset medical answer database until the medical answer statement corresponding to the maximum cosine similarity is determined as the target matching statement and output. The sequence calculation module is specifically used to perform forward propagation on the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector to update the hidden vector of the target BiGRU model; and to use the target BiGRU model to sequentially flip the first attention weight, the second attention weight, the first dynamic word vector, and the second dynamic word vector, and then perform forward propagation again to generate the target hidden vector. The target hiding vector is concatenated to generate the first bidirectional sequence information and the second bidirectional sequence information.
5. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the medical dialogue text matching method as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, Used to store a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the medical dialogue text matching method as described in any one of claims 1 to 3.