Method, device, computer equipment and storage medium for recommending consultation response techniques

Through the trained reply script recommendation model, the embedding layer, entity extraction layer and encoding sub-model are used to generate accurate medical consultation responses, which solves the problems of long response time, high cost and low accuracy in the existing technology, and realizes efficient and professional medical consultation responses.

CN119296817BActive Publication Date: 2025-09-30PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411244408.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-05
Publication Date
2025-09-30
Estimated Expiration
2044-09-05

AI Technical Summary

Technical Problem

The existing artificial intelligence consultation system has a long response time, high cost, poor quality of consultation response text, and low accuracy. It is difficult to achieve doctor and department personalization functions, and there is a risk of logical or factual errors.

Method used

A trained reply script recommendation model is used, including an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model, and an output layer. Accurate reply scripts are generated through entity extraction and context understanding, and a pre-built script corpus and blockchain storage are used to improve security.

Benefits of technology

It shortens the inference response time, improves the efficiency and accuracy of medical consultations, generates more precise and professional responses, reduces the risk of logical errors, and enhances the model's semantic understanding capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119296817B_ABST
    Figure CN119296817B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of artificial intelligence and relates to a method for recommending reply scripts for medical consultations, comprising inputting a medical consultation text into a reply script recommendation model, the reply script recommendation model comprising an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model, and an output layer; vector encoding the medical consultation text through the embedding layer; entity extraction of the text embedding vector through the entity extraction layer; processing entity relationship triples and the medical consultation text through the first encoding sub-model; querying a speech corpus to obtain candidate reply texts; extracting semantic features from the candidate reply texts through the second encoding sub-model; and calculating text enhancement word vectors and text semantic vectors to obtain reply script recommendations. The present application also provides a medical consultation reply script recommendation device, computer equipment, and storage medium. In addition, the present application also relates to blockchain technology, and reply script recommendations can be stored in the blockchain. The present application can improve the efficiency and accuracy of intelligent medical consultations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of artificial intelligence and digital medical technology, and in particular to a method, apparatus, computer equipment, and storage medium for recommending response scripts for medical consultations. Background Art

[0002] Healthcare is a major application area for artificial intelligence, and outpatient consultations are a key area of ​​healthcare. During the consultation phase, AI technology can provide doctors with recommended conversational techniques, assisting them in the process of consultation, identifying the condition, and providing treatment recommendations. This can improve communication between doctors and patients, expedite the consultation process, enhance service quality, and boost patient satisfaction.

[0003] The current mainstream approach is to directly input historical conversations into a large model, leveraging its reasoning and generation capabilities to generate the necessary responses for doctors. However, this approach presents the following challenges: Large models require lengthy inference responses; supporting high levels of online concurrency requires high machine costs for inference; large models lack sufficient agility, making it difficult to implement personalized features such as doctor and department support; and large models are susceptible to "illusions," easily generating logically or factually incorrect but grammatically correct responses, leading to misdiagnosis. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to propose a method, device, computer equipment and storage medium for recommending medical consultation response words, so as to solve the technical problems in the related art of artificial intelligence medical consultation such as long response time, high cost, poor quality of medical consultation response text and low accuracy.

[0005] In order to solve the above technical problems, the present application provides a method for recommending reply words for medical consultation, which adopts the following technical solutions:

[0006] Receiving a medical inquiry text, and inputting the medical inquiry text into a trained reply speech recommendation model, wherein the reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model, and an output layer;

[0007] Performing vector encoding on the medical inquiry text through the embedding layer to obtain a text embedding vector, and inputting the text embedding vector into the entity extraction layer;

[0008] Performing entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples, and inputting the entity relationship triples and the medical inquiry text into the first encoding sub-model;

[0009] Performing contextual understanding on the entity relationship triples and the medical inquiry text through the first encoding sub-model to obtain a text-enhanced word vector containing contextual information, and inputting the text-enhanced word vector into the output layer;

[0010] Querying a pre-built discourse corpus based on the entity relationship triples to obtain candidate reply texts, and inputting the candidate reply texts into the second encoding sub-model;

[0011] Extracting semantic features from the candidate reply text using the second encoding sub-model to obtain a text semantic vector, and inputting the text semantic vector into the output layer;

[0012] The text enhancement word vector and the text semantic vector are calculated through the output layer to obtain a reply word recommendation.

[0013] In order to solve the above technical problems, the embodiment of the present application further provides a device for recommending reply words for medical consultation, which adopts the following technical solution:

[0014] An acquisition module is configured to receive a medical inquiry text and input the medical inquiry text into a trained reply speech recommendation model, wherein the reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model, and an output layer;

[0015] An embedding module, configured to perform vector encoding on the medical inquiry text through the embedding layer to obtain a text embedding vector, and input the text embedding vector into the entity extraction layer;

[0016] an entity extraction module, configured to perform entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples, and input the entity relationship triples and the medical inquiry text into the first encoding sub-model;

[0017] a first encoding module, configured to perform contextual understanding on the entity relationship triples and the medical inquiry text through the first encoding sub-model, obtain a text-enhanced word vector containing contextual information, and input the text-enhanced word vector into the output layer;

[0018] a query module, configured to query a pre-built discourse corpus based on the entity relationship triples to obtain candidate reply texts, and input the candidate reply texts into the second encoding sub-model;

[0019] A second encoding module is configured to extract semantic features from the candidate reply text using the second encoding sub-model to obtain a text semantic vector, and input the text semantic vector into the output layer;

[0020] The output module is used to calculate the text enhancement word vector and the text semantic vector through the output layer to obtain reply speech recommendations.

[0021] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0022] The computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the method for recommending medical consultation response techniques are implemented as described above.

[0023] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0024] The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the method for recommending medical consultation response techniques as described above.

[0025] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0026] The present application provides a method for recommending reply scripts for medical consultations. Reply script recommendations are generated by a trained reply script recommendation model, which can shorten the inference response time and improve the response efficiency. Entity extraction is performed through the entity extraction layer, which can enhance the model's semantic understanding and intention understanding of the medical consultation text. The first encoding sub-model performs contextual understanding of entity relationship triples and medical consultation texts to obtain text-enhanced word vectors containing contextual information, further enhancing the model's semantic understanding of the text. The second encoding sub-model processes the obtained candidate reply texts, which can combine the obtained reply script recommendations with the current medical consultation text and related medical entity expressions, thereby obtaining more accurate and effective replies that contain professional terms, thereby improving the efficiency and accuracy of intelligent medical consultations. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the solutions in this application, a brief introduction will be given below to the drawings required for use in the description of the embodiments of this application. Obviously, the drawings described below are some embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0028] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0029] Figure 2 This is a flowchart of an embodiment of a method for recommending reply words for a medical consultation according to the present application;

[0030] Figure 3 This is a structural diagram of an embodiment of a device for recommending replying techniques for medical consultation according to the present application;

[0031] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0033] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0034] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0035] like Figure 1 As shown, system architecture 100 may include a terminal device 101, a network 102, and a server 103. Terminal device 101 may be a laptop computer 1011, a tablet computer 1012, or a mobile phone 1013. Network 102 is a medium for providing a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0036] The user can use the terminal device 101 to interact with the server 103 via the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0037] The terminal device 101 can be various electronic devices with a display screen and supporting web browsing. In addition to the laptop computer 1011, tablet computer 1012 or mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer and a desktop computer, etc.

[0038] The server 103 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal device 101 .

[0039] It should be noted that the method for recommending reply words to medical consultation provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the device for recommending reply words to medical consultation is generally set in the server / terminal device.

[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0041] Continue to refer Figure 2 , shows a flowchart of an embodiment of a method for recommending a reply to a medical consultation according to the present application, comprising the following steps:

[0042] Step S201: receive the medical inquiry text and input the medical inquiry text into the trained reply speech recommendation model, wherein the reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model and an output layer.

[0043] Among them, the medical consultation text is the conversation content of the patient during the medical diagnosis process, which may include the patient's basic information, reason for consultation, symptoms, medical history, etc.

[0044] In this embodiment, the electronic device on which the method for recommending a reply to a medical consultation is executed (eg Figure 1 The server / terminal device shown in the figure can receive the medical consultation text via a wired connection or a wireless connection. It should be noted that the above-mentioned wireless connection methods may include but are not limited to 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra wideband) connections, and other wireless connection methods currently known or to be developed in the future.

[0045] In this embodiment, a medical inquiry text input by a user is received and input into a trained reply speech recommendation model. The reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model and an output layer. After the medical inquiry text is processed by the embedding layer, the entity extraction layer, the first encoding sub-model, the second encoding sub-model and the output layer, a reply speech recommendation that matches the medical inquiry text is output.

[0046] In some optional implementations, before the medical inquiry text is input into the reply script recommendation model, the medical inquiry text is cleaned to remove irrelevant characters in the medical inquiry text, such as special punctuation marks, blank characters, line breaks, spaces, etc.

[0047] Step S202: vector encoding is performed on the medical inquiry text through the embedding layer to obtain a text embedding vector, and the text embedding vector is input into the entity extraction layer.

[0048] In this embodiment, the embedding layer is used to convert the medical consultation text into a vector, including position embedding, word embedding and character embedding of the medical consultation text. Among them, position embedding provides information about the position of words in the sentence, which helps to understand the grammatical structure and contextual relationship of the sentence; word embedding captures the semantic information of the vocabulary, enabling the model to understand the meaning of the vocabulary in the context; character embedding captures character-level information, which helps the model process unknown vocabulary or spelling variants. By incorporating character-level information into the model, the model's ability to process complex data is improved.

[0049] In this embodiment, the text embedding vector includes a position embedding vector, a word embedding vector, and a character embedding vector.

[0050] Step S203: Entity extraction is performed on the text embedding vector through the entity extraction layer to obtain entity relationship triples, and the entity relationship triples and the medical inquiry text are input into the first encoding sub-model.

[0051] In the medical field, entities refer to specific pieces of information in text that have clear meaning, such as disease names, symptoms, drug names, dosages, medical procedures, body parts, etc. These entities are crucial for understanding and processing medical consultation texts and also play an important role in identifying the intent of medical consultation texts.

[0052] In this embodiment, the entity extraction layer uses the CasRel algorithm to identify and extract causal relationships in the medical consultation text, including causal relationships between entities such as symptoms, diseases, treatments, and drugs. For example, the relationship between the use of a certain drug and specific side effects, or the relationship between a certain lifestyle and the occurrence of a disease.

[0053] Among them, the entity extraction layer includes a head entity recognition sublayer and a relationship and tail entity joint recognition sublayer.

[0054] In some optional implementations of this embodiment, the step of performing entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples includes:

[0055] Input the text embedding vector into the head entity recognition sublayer for recognition and output all head entities;

[0056] The head entity input relations and tail entity joint recognition sublayer are recognized to obtain all specific relations and tail entities corresponding to each head entity;

[0057] Combine the head entity, specific relation and tail entity to obtain the entity-relationship triple.

[0058] In this embodiment, the text embedding vector h is n Decode and then get the entity's start position (starting position) and end position (ending position) to identify all possible head entities. The head entity recognition layer uses the following calculation formula:

[0059]

[0060] in, and Respectively represent the input sequence h n The probability of the start position and end position of the i-th entity in the text. If the probability exceeds the preset threshold, the label value of the multi-level text feature is recorded as 1, otherwise it is 0; σ is the sigmoid activation function, ω start With ω end is the trainable weight, b start with b end represents the bias value; and x i =h n [i] represents the encoding of the i-th token in the input sequence. When there are multiple head entities in the text, the scope of the entity is determined by matching the closest starting and ending position tokens, and this matching method ensures the integrity of the entity.

[0061] The nearest matching principle is: get all and The nearest neighbor Start with 1 and The end with a value of 1 is regarded as a complete head entity. This matching method ensures the integrity of the entity and improves the accuracy of head entity recognition.

[0062] After identifying the head entity, joint recognition of the relationship and tail entities is performed. The structure of each joint recognition layer for relationship and tail entities is identical to that of the head entity recognition layer. Decoding the obj entity (tail entity) is similar to decoding the sub entity (head entity). The joint recognition sublayer for relationship and tail entities differs from the head entity recognition sublayer in that it incorporates a text embedding vector containing contextual semantic information into the input and also considers the head entity feature information extracted by the head entity recognition sublayer. Relationship modeling is performed as a function that maps the head entity to the tail entity.

[0063] The head entity and text embedding vectors are input into the relation and tail entity joint recognition sublayer for recognition, and all specific relations and tail entities of each head entity are obtained.

[0064] In this embodiment, the relationship and tail entity joint identification sub-layer is calculated using the following formula:

[0065]

[0066] in, and Respectively represent the input sequence h n The probability of the i-th entity being identified as the start position and the end position of the tail entity. If the probability exceeds the preset threshold, the tag value of the entity is recorded as 1, otherwise it is 0; r represents a specific relationship; represents the mean vector between the start and end positions of the k-th entity.

[0067] It should be noted that when the probability of start_o and end_o is 0 after binary judgment, it means that there is no corresponding obj entity under this specific relationship, that is, there is no triple of this relationship when sub is the head entity.

[0068] After the head entity and its corresponding specific relationship and tail entity are identified, the generated entity-relationship triples are combined and expressed as (head entity, specific relationship, tail entity).

[0069] Through entity extraction, we can more accurately understand the intention of the medical inquiry and provide important contextual information, which helps to deeply understand the semantic content of the text and improve the accuracy of subsequent reply texts.

[0070] Step S204: Contextually understand the entity relationship triples and the medical inquiry text through the first encoding sub-model to obtain a text-enhanced word vector containing contextual information, and input the text-enhanced word vector into the output layer.

[0071] The first encoding sub-model uses RoBERTa as the backbone network. In this embodiment, the first encoding sub-model includes a first vector embedding layer and a plurality of encoders connected in a stacked manner.

[0072] The step of performing contextual understanding on the entity relationship triples and the medical inquiry text by the first encoding sub-model to obtain a text-enhanced word vector containing contextual information includes:

[0073] The entity relationship triples and the medical inquiry text are vector-encoded by the first vector embedding layer to obtain entity text vectors, and the entity text vectors are input into multiple encoders;

[0074] Perform attention calculation on the entity text vector through the first multi-head attention layer to obtain the text attention distribution feature containing context information, and input the text attention distribution feature into the first feedforward neural network layer;

[0075] The text attention distribution features and entity text vectors are enhanced through the first feedforward neural network layer to obtain the text enhanced word vector.

[0076] The number of encoders can be set according to actual conditions. For example, a 12-layer stacked encoder can be used.

[0077] The first vector embedding layer is the BERT embedding layer, which performs position embedding, word embedding, and character embedding on the entity relationship triples and the medical inquiry text respectively to obtain the embedding vector, namely the entity text vector.

[0078] The entity text vector is input into multiple stacked encoders for feature extraction. The input of the first encoder is the entity text vector, and the input of subsequent encoders is the entity text vector and the output of the previous encoder.

[0079] In this embodiment, multiple encoders can be divided into feature extraction layers of different scales to perform feature extraction of different scales. Each encoder includes a first multi-head attention layer and a first feedforward neural network layer. Each first multi-head attention layer can implement an attention mechanism of the same scale or a multi-scale attention mechanism. Each head can focus on contextual information of different scales. For example, if the multi-head attention sublayer has 8 heads, that is, 8 self-attentions, then 4 heads focus on small scales, 2 heads focus on medium scales, and 2 heads focus on large scales. The self-attention of texts of different scales is calculated by different heads, and then the self-attention is merged to obtain the text attention distribution feature.

[0080] Specifically, the process of multi-scale attention calculation in each first multi-head attention layer is as follows:

[0081]

[0082] Among them, Q i =H i-1 W q ;K i =Hi-1 W k ; V i =H i-1 W v ;Q i represents the query vector of the i-th head, K i represents the key vector of the i-th head, V i Represents the value vector of the i-th head; H i represents the mask-self-attention output of the i-th head; d k Indicates the dimension of the key vector.

[0083] Merging the self-attention, the calculation formula for multi-head attention is as follows:

[0084] MultiHead=Concat(head1,head2,…,head A )W0;

[0085] Among them, Concat represents the matrix concatenation function; W0 represents the parameter matrix when compressing each self-attention.

[0086] The text attention distribution features and entity text vectors are input into the first feedforward neural network layer, and the text attention distribution features and entity text vectors are connected and enhanced through the first feedforward neural network layer to prevent insufficient fitting.

[0087] In some optional implementations, residual connections and layer normalization are performed after each first multi-head attention layer and the first feedforward neural network layer, which can help gradient flow and reduce degradation problems during training.

[0088] By implementing multi-head attention through the first encoding sub-model and transmitting this attention information between encoders, it is possible to capture deep features in text sentences, enrich the representation capability of features, improve the generalization ability of the model, and enable the model to understand the input text more comprehensively, thereby enhancing the model's understanding and processing capabilities of complex data structures.

[0089] Step S205 : querying the pre-built discourse corpus based on the entity relationship triples to obtain candidate reply texts, and inputting the candidate reply texts into the second encoding sub-model.

[0090] The conversation corpus includes common conversational phrases summarized by salespeople, frequently used phrases from physician input, and common quick-response phrases configured by physicians. These phrases are used to more effectively obtain information, provide consultation, or persuade patients to adopt specific treatments during doctor-patient communication. The conversational phrase database can include medical Q&A data, physician-patient Q&A conversation data, and medical knowledge graphs. For example, the database includes examples of conversations covering various scenarios, including opening remarks, question-asking methods, responses to patient concerns, emphasizing the risks of a disease, explaining the advantages of treatment options, and tips for scheduling appointments.

[0091] In this embodiment, the discourse corpus can be constructed by the following steps:

[0092] 1) Data collection: Obtain the original data of medical consultations, including historical consultation dialogue information and the role information corresponding to each sentence.

[0093] 2) Data preprocessing: Clean and format the collected data, including word segmentation, to adapt to subsequent processing procedures.

[0094] 3) Feature extraction: Analyze medical consultation data, extract key features such as word frequency and co-occurrence probability, and construct a word-symptom association index, which helps to characterize the characteristics of disease categories.

[0095] 4) Classification and labeling: Use deep learning algorithms, such as the BERT neural network model, to classify medical consultation data and label disease types.

[0096] 5) Constructing association matrix: Constructing the disease weight co-occurrence matrix and the disease type association co-occurrence matrix, which helps to classify text data more finely.

[0097] 6) Calculate the correction index: Calculate the corrected sentence-syndrome relevance index sequence based on the sentence-syndrome relevance index and the two-word correction index to improve the accuracy of classification.

[0098] 7) Corpus construction: Use a suitable data format (such as JSON) to store the annotated medical consultation data, and build a discourse corpus by combining common and personalized discourse.

[0099] 8) Continuous Updates: Regularly update the corpus, add new case data, and continuously optimize the script prediction library based on feedback and evaluation results.

[0100] Based on the entity relationship triples, a search is performed in the discourse corpus to obtain candidate response texts. The candidate response texts are used to combine with the consultation text to generate more accurate and more appropriate response texts for the consultation scenario.

[0101] Step S206: extract semantic features from the candidate reply text through the second encoding sub-model to obtain a text semantic vector, and input the text semantic vector into the output layer.

[0102] In this embodiment, the second encoding sub-model is used to extract features from the candidate reply text, capture the contextual information of the words in the context, and obtain a text semantic vector containing semantic information.

[0103] In some optional implementations, the second encoding sub-model uses the SimCSE model of contrastive learning as its skeleton, and the second encoding sub-model includes a second vector embedding layer and multiple encoder layers, each encoder layer includes a second multi-head attention layer and a second feedforward neural network layer.

[0104] The step of extracting semantic features from the candidate reply text using the second encoding sub-model to obtain a text semantic vector includes:

[0105] Encode the candidate reply text through the second vector embedding layer to obtain the text sentence vector, and input the text sentence vector into multiple encoder layers;

[0106] The second multi-head attention layer performs contextual understanding on the text sentence vector to obtain the text attention representation, and the text attention representation and text sentence vector are input into the second feedforward neural network layer;

[0107] The text attention representation and text sentence vector are calculated through the second feedforward neural network layer to obtain the text semantic vector.

[0108] The number of encoder layers can be set according to actual conditions. For example, an encoder layer consisting of 12 stacked layers can be used.

[0109] The second vector embedding layer is used to perform position embedding, word embedding, and character embedding on the candidate reply text to obtain the text sentence vector.

[0110] The text sentence vector is input into multiple stacked encoder layers for attention calculation, where the input of the first encoder layer is the text sentence vector, and the input of the subsequent encoder layers is the text sentence vector and the output of the previous encoder layer.

[0111] In this embodiment, the calculation process of the second multi-head attention layer is the same as that of the first multi-head attention layer, and will not be repeated here.

[0112] The text attention representation and the text sentence vector are input into the second feedforward neural network layer, and the connection between the text attention representation and the text sentence vector is enhanced through the second feedforward neural network layer to prevent insufficient fitting.

[0113] In some optional implementations, residual connections and layer normalization are performed after each second multi-head attention layer and second feedforward neural network layer, which can help gradient flow and reduce degradation problems during training.

[0114] By extracting features from candidate reply texts through the second encoding sub-model, it is possible to capture the contextual information of the text in the context, enrich the representation capabilities of the features, improve the quality of text vector representation, effectively shorten the distance between similar sentences, and increase the distance between dissimilar sentences. This can more accurately match relevant semantic information and improve retrieval accuracy.

[0115] Step S207: Calculate the text enhancement word vector and text semantic vector through the output layer to obtain reply words recommendation.

[0116] Specifically, the cosine similarity between the text enhancement word vector and the text semantic vector is calculated through the output layer; based on the cosine similarity, a preset number of candidate reply texts are screened out and output as reply wording recommendations.

[0117] Calculate the cosine similarity between the text enhancement word vector and the text semantic vector, sort them from high to low according to the cosine similarity, and recommend the candidate reply texts corresponding to the top N text semantic vectors as reply words, where N is a positive integer.

[0118] In this embodiment, combining the conversation information with the reply text can improve the matching of the reply script recommendation with the medical inquiry text, and at the same time, improve the professionalism and accuracy of the reply script recommendation.

[0119] It should be emphasized that in order to further ensure the privacy and security of the reply script recommendations, the above reply script recommendations can also be stored in a blockchain node.

[0120] The blockchain referred to in this application is a new application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0121] In some optional implementations, the output layer may also include a fully connected layer and a softmax layer. The fully connected layer extracts high-level features from the text-enhanced word vectors and text semantic vectors, converts these features into a latent representation of the reply text space, and then converts them into a probability distribution through the softmax layer, so that each possible reply text has a probability score. Combining cosine similarity and probability scores, we can obtain reply wording recommendations.

[0122] This application generates reply script recommendations through a trained reply script recommendation model, which can shorten the reasoning response time and improve response efficiency; entity extraction is performed through the entity extraction layer, which can enhance the model's semantic understanding and intention understanding of the medical inquiry text; the first encoding sub-model performs contextual understanding of entity relationship triples and medical inquiry texts to obtain text-enhanced word vectors containing contextual information, further enhancing the model's understanding of text semantics; the second encoding sub-model processes the obtained candidate reply texts, which can combine the obtained reply script recommendations with the current medical inquiry text and related medical entity expressions, thereby obtaining more accurate and effective replies that contain professional terms, thereby improving the efficiency and accuracy of intelligent medical consultation.

[0123] In some optional implementations, before the step of inputting the medical inquiry text into the trained response recommendation model, the method further includes:

[0124] Obtain a medical consultation dialogue dataset, which includes medical consultation text samples and corresponding response speech samples;

[0125] Inputting the medical inquiry text sample into a pre-built neural network model, the pre-built neural network model includes an initial embedding layer, an initial entity extraction layer, an initial first encoding sub-model, an initial second encoding sub-model and an initial output layer;

[0126] The initial embedding layer encodes the medical consultation text sample into a vector to obtain the sample embedding vector;

[0127] Entity extraction is performed on the sample embedding vector through the entity extraction layer to obtain a sample entity triple, and the sample entity triple and the medical inquiry text sample are input into the initial first encoding sub-model;

[0128] The initial first encoding sub-model performs contextual understanding on the sample entity triples and the medical inquiry text samples to obtain sample enhanced word vectors containing contextual information;

[0129] Input the reply speech sample into the initial second encoding sub-model, encode the reply speech sample through the initial second encoding sub-model to obtain the sample semantic vector;

[0130] The output layer calculates the sample enhanced word vector and sample semantic vector, and outputs the predicted reply words;

[0131] Calculate the loss between the predicted reply and the reply sample according to the preset loss function;

[0132] The model parameters of the neural network model are adjusted based on the loss value. When the iteration end condition is met, the final model parameters are obtained, and a reply script recommendation model is generated based on the final model parameters.

[0133] The medical consultation dialogue dataset can be obtained in the following ways:

[0134] 1) Chinese Medical Question and Answer Dataset: Contains question and answer pairs from different medical departments, such as andrology, internal medicine, obstetrics and gynecology, oncology, pediatrics, and surgery, totaling 792,099 data in CSV file format.

[0135] 2) MedDialog (Chinese) doctor-patient dialogue dataset: contains 1.1 million dialogues between doctors and patients and 4 million utterances.

[0136] 3) Medical Conversation Analysis Dataset: This dataset collects real online doctor-patient conversations and performs multi-level manual annotation, including information such as named entities, conversation intent, symptom labels, and medical reports.

[0137] The patient consultation conversation dataset is fed into a pre-built neural network model for training to obtain predicted responses. The loss between the predicted responses and the sample responses is calculated. Pre-set loss functions such as cross-entropy loss and sequence generation loss are used. Model parameters are adjusted based on the loss value, and training is iterated until the model converges. Convergence can be achieved by maintaining no significant change in the loss value or by reaching a preset number of iterations. This results in a trained response recommendation model.

[0138] In this embodiment, the reply speech recommendation model has two branches, one branch is the first coding sub-model, and the other branch is the second coding sub-model. The first coding sub-model is used to characterize conversation information, and the second coding sub-model is used to characterize reply speech. Combining the two can improve the efficiency and accuracy of reply speech generation.

[0139] In this embodiment, the use of historical medical consultation dialogue data sets can easily construct training samples, reducing the cost and risk of training sample processing. The reply words are highly dependent on the collected historical data, and have stronger controllability and emergency repair capabilities. Moreover, because the reply words are derived from actual conversations, they are more in line with the doctor-patient conversation scenario, effectively reducing the risk of "hallucinations" and improving the quality and accuracy of the reply words.

[0140] In some optional implementations, in order to achieve doctor personalization, doctor-related features for personalized characterization of doctors can be added during the model training process, so that the doctor's reply script recommendations generated by the system are highly consistent with the doctor's personal habits and actual scenarios, thereby improving the doctor's usage experience and the doctor's adoption rate.

[0141] In some optional implementations of this embodiment, before the step of inputting the reply speech sample into the initial second encoding sub-model, the method further includes:

[0142] Construct positive samples and negative samples of the reply speech samples, and input the positive samples and negative samples into the second encoding sub-model.

[0143] The second encoding sub-model uses the SimCSE model. SimCSE is a simple yet efficient contrastive learning algorithm that, given an input, predicts the input itself against a target. Its core concept is to use Dropout as noise. Dropout randomly turns parameters on and off within the network structure, causing local changes in a vector. By performing contrastive learning on the vectors before and after the change, it generates a large number of vectors that are similar but not identical to the original vector.

[0144] During training, the SimCSE model randomly selects two sentences and performs dropout on one of them to obtain an enhanced version. The enhanced version and the original sentence are then fed into the model as positive pairs for training. Simultaneously, the model also feeds the other enhanced version and the original sentence as negative pairs for training.

[0145] Specifically, the BERT model is used to encode the reply speech sample. Dropout is performed during the encoding process to generate a dropout mask sample. The dropout mask sample and the reply speech sample are then used as a pair of positive samples. It should be understood that each dropout operation randomly generates a different dropout mask. Therefore, although the two samples have the same content, the resulting representation vectors after encoding will be different.

[0146] Within a batch, all samples other than the positive sample pair for the current reply are considered negative. This is because in a randomly sampled batch, different samples are typically unrelated, or at least not semantically closely related. Therefore, they can be used as negative samples for contrastive learning, helping the model learn to distinguish between different text representations. A batch is a collection of text samples that are simultaneously input to the model during training.

[0147] In this way, the SimCSE model can effectively learn how to distinguish different sentences and make similar sentences closer in the embedding space and dissimilar sentences farther away in the embedding space.

[0148] This application constructs positive and negative samples so that the model can capture the complex features and patterns in text data, improve feature expression capabilities, and better generalize to unseen text data, thereby improving the understanding of complex semantics of the text.

[0149] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.

[0150] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0151] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware via computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above-described method embodiments. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0152] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0153] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a device for recommending a reply to a medical question. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0154] like Figure 3As shown, the device 300 for recommending medical consultation replying techniques in this embodiment includes: an acquisition module 301, an embedding module 302, an entity extraction module 303, a first encoding module 304, a query module 305, a second encoding module 306, and an output module 307.

[0155] The acquisition module 301 is used to receive the medical inquiry text and input the medical inquiry text into the trained reply speech recommendation model, wherein the reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model and an output layer;

[0156] The embedding module 302 is used to perform vector encoding on the medical inquiry text through the embedding layer to obtain a text embedding vector, and input the text embedding vector into the entity extraction layer;

[0157] The entity extraction module 303 is used to perform entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples, and input the entity relationship triples and the medical inquiry text into the first encoding sub-model;

[0158] The first encoding module 304 is configured to perform contextual understanding on the entity relationship triples and the medical inquiry text through the first encoding sub-model, obtain a text-enhanced word vector containing contextual information, and input the text-enhanced word vector into the output layer;

[0159] The query module 305 is configured to query the pre-built discourse corpus based on the entity relationship triples to obtain candidate reply texts, and input the candidate reply texts into the second encoding sub-model;

[0160] The second encoding module 306 is used to extract semantic features from the candidate reply text through the second encoding sub-model to obtain a text semantic vector, and input the text semantic vector into the output layer;

[0161] The output module 307 is used to calculate the text enhancement word vector and the text semantic vector through the output layer to obtain reply speech recommendations.

[0162] It should be emphasized that in order to further ensure the privacy and security of the reply script recommendations, the above reply script recommendations can also be stored in a blockchain node.

[0163] Based on the above-mentioned medical consultation reply script recommendation device 300, reply script recommendations are generated through the trained reply script recommendation model, which can shorten the reasoning response time and improve the response efficiency; entity extraction is performed through the entity extraction layer, which can enhance the model's semantic understanding and intention understanding of the medical consultation text; the first encoding sub-model performs contextual understanding of the entity relationship triples and the medical consultation text to obtain text enhanced word vectors containing contextual information, further enhancing the model's semantic understanding of the text; the second encoding sub-model processes the obtained candidate reply text, which can enable the obtained reply script recommendation to be combined with the current medical consultation text and related medical entity expressions, thereby obtaining a more accurate and effective reply containing professional terminology, thereby improving the efficiency and accuracy of intelligent medical consultation.

[0164] In some optional implementations, the entity extraction layer includes a head entity recognition sublayer and a relationship and tail entity joint recognition sublayer, and the entity extraction module 303 includes:

[0165] A head entity recognition submodule, configured to input the text embedding vector into the head entity recognition sublayer for recognition and output all head entities;

[0166] a relation and tail entity recognition submodule, configured to input the head entity and the text embedding vector into the relation and tail entity joint recognition sublayer for recognition, and obtain all specific relations and tail entities corresponding to each head entity;

[0167] The combination submodule is used to combine the head entity, the specific relationship and the tail entity to obtain an entity relationship triple.

[0168] Through entity extraction, we can more accurately understand the intention of the medical inquiry and provide important contextual information, which helps to deeply understand the semantic content of the text and improve the accuracy of subsequent reply texts.

[0169] In some optional implementations, the first encoding sub-model includes a first vector embedding layer and a plurality of stacked encoders, each of the encoders includes a first multi-head attention layer and a first feedforward neural network layer, and the first encoding module 304 includes:

[0170] A first vector embedding submodule is configured to perform vector encoding on the entity relationship triples and the medical inquiry text through the first vector embedding layer to obtain entity text vectors, and input the entity text vectors into the plurality of encoders;

[0171] A first attention submodule is configured to perform attention calculation on the entity text vector through the first multi-head attention layer to obtain a text attention distribution feature containing context information, and input the text attention distribution feature into the first feedforward neural network layer;

[0172] The first feedforward neural submodule is used to perform enhanced calculation on the text attention distribution feature and the entity text vector through the first feedforward neural network layer to obtain a text enhanced word vector.

[0173] By implementing multi-head attention through the first encoding sub-model and transmitting this attention information between encoders, it is possible to capture deep features in text sentences, enrich the representation capability of features, improve the generalization ability of the model, and enable the model to understand the input text more comprehensively, thereby enhancing the model's understanding and processing capabilities of complex data structures.

[0174] In some optional implementations, the second encoding sub-model includes a second vector embedding layer and multiple encoder layers, each of the encoder layers includes a second multi-head attention layer and a second feedforward neural network layer, and the second encoding module 306 includes:

[0175] A second vector embedding submodule, configured to encode the candidate reply text through the second vector embedding layer to obtain a text sentence vector, and input the text sentence vector into the multiple encoder layers;

[0176] A second attention submodule is configured to perform contextual understanding on the text sentence vector through the second multi-head attention layer to obtain a text attention representation, and input the text attention representation and the text sentence vector into the second feedforward neural network layer;

[0177] The second feedforward neural submodule is used to calculate the text attention representation and the text sentence vector through the second feedforward neural network layer to obtain a text semantic vector.

[0178] By extracting features from candidate reply texts through the second encoding sub-model, it is possible to capture the contextual information of the text in the context, enrich the representation capabilities of the features, improve the quality of text vector representation, effectively shorten the distance between similar sentences, and increase the distance between dissimilar sentences. This can more accurately match relevant semantic information and improve retrieval accuracy.

[0179] In some optional implementations, the output module 307 includes:

[0180] A calculation submodule, configured to calculate the cosine similarity between the text enhancement word vector and the text semantic vector through the output layer;

[0181] The output submodule is used to screen out a preset number of candidate reply texts based on the cosine similarity and output them as reply wording recommendations.

[0182] By combining conversation information with reply text, the matching between reply script recommendations and consultation text can be improved, while at the same time, the professionalism and accuracy of reply script recommendations can be improved.

[0183] In some optional implementations, the apparatus 300 for recommending reply techniques to a medical consultation may further include a training module for:

[0184] Obtaining a medical consultation dialogue dataset, wherein the medical consultation dialogue dataset includes medical consultation text samples and corresponding reply speech samples;

[0185] Inputting the medical inquiry text sample into the pre-built neural network model, wherein the pre-built neural network model includes an initial embedding layer, an initial entity extraction layer, an initial first encoding sub-model, an initial second encoding sub-model and an initial output layer;

[0186] Performing vector encoding on the medical inquiry text sample through the initial embedding layer to obtain a sample embedding vector;

[0187] Performing entity extraction on the sample embedding vector through the entity extraction layer to obtain a sample entity triple, and inputting the sample entity triple and the medical inquiry text sample into the initial first encoding sub-model;

[0188] Performing contextual understanding on the sample entity triples and the medical inquiry text sample through the initial first encoding sub-model to obtain a sample enhanced word vector containing contextual information;

[0189] Inputting the reply speech sample into the initial second encoding sub-model, encoding the reply speech sample through the initial second encoding sub-model to obtain a sample semantic vector;

[0190] Calculating the sample enhanced word vector and the sample semantic vector through the output layer, and outputting the predicted reply words;

[0191] Calculate the loss value between the predicted reply speech and the reply speech sample according to a preset loss function;

[0192] The model parameters of the neural network model are adjusted based on the loss value. When the iteration end condition is met, the final model parameters are obtained, and a reply speech recommendation model is generated based on the final model parameters.

[0193] Using historical medical consultation dialogue datasets makes it easy to construct training samples, reducing the cost and risk of training sample processing. Response scripts rely heavily on collected historical data, offering greater controllability and emergency repair capabilities. Furthermore, since response scripts are derived from actual conversations, they are more closely aligned with doctor-patient dialogue scenarios, effectively reducing the risk of "hallucinations" and improving the quality and accuracy of response scripts.

[0194] In some optional implementations of this embodiment, the training module further includes a sample construction submodule for constructing positive samples and negative samples of the reply speech samples, and inputting the positive samples and the negative samples into the second encoding submodel.

[0195] By constructing positive and negative samples, the model can capture the complex features and patterns in text data, improve feature expression capabilities, and better generalize to unseen text data, thereby improving the understanding of complex semantics of the text.

[0196] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0197] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with a memory 41, a processor 42, and a network interface 43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.

[0198] The computer device may be a desktop computer, notebook computer, PDA, cloud server, etc. The computer device may interact with the user via a keyboard, mouse, remote control, touchpad, or voice control device.

[0199] The memory 41 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for the method of recommending a consultation reply technique. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0200] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to execute computer-readable instructions or process data stored in the memory 41, such as executing computer-readable instructions for the method for recommending a consultation response.

[0201] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0202] Generating reply script recommendations through a trained reply script recommendation model can shorten the inference response time and improve response efficiency; extracting entities through the entity extraction layer can enhance the model's semantic understanding and intent understanding of the inquiry text; using the first encoding sub-model to perform contextual understanding of entity relationship triples and inquiry text, text-enhanced word vectors containing contextual information are obtained, further enhancing the model's understanding of text semantics; processing the obtained candidate reply text through the second encoding sub-model can enable the obtained reply script recommendations to be combined with the current inquiry text and related medical entity expressions, thereby obtaining more accurate and effective replies that contain professional terminology, thereby improving the efficiency and accuracy of intelligent consultation.

[0203] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the above-mentioned method for recommending consultation response techniques.

[0204] Generating reply script recommendations through a trained reply script recommendation model can shorten the inference response time and improve response efficiency; extracting entities through the entity extraction layer can enhance the model's semantic understanding and intent understanding of the inquiry text; using the first encoding sub-model to perform contextual understanding of entity relationship triples and inquiry text, text-enhanced word vectors containing contextual information are obtained, further enhancing the model's understanding of text semantics; processing the obtained candidate reply text through the second encoding sub-model can enable the obtained reply script recommendations to be combined with the current inquiry text and related medical entity expressions, thereby obtaining more accurate and effective replies that contain professional terminology, thereby improving the efficiency and accuracy of intelligent consultation.

[0205] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0206] Obviously, the embodiments described above are only some of the embodiments of the present application, rather than all of the embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present application specification and the accompanying drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present application.

Claims

1. A method for recommending reply words to medical consultation, characterized in that: The steps include: Receiving a medical inquiry text, and inputting the medical inquiry text into a trained reply speech recommendation model, wherein the reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model, and an output layer; Performing vector encoding on the medical inquiry text through the embedding layer to obtain a text embedding vector, and inputting the text embedding vector into the entity extraction layer; Performing entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples, and inputting the entity relationship triples and the medical inquiry text into the first encoding sub-model; The first encoding sub-model performs contextual understanding on the entity relationship triples and the medical consultation text to obtain a text-enhanced word vector containing contextual information, and inputs the text-enhanced word vector into the output layer; the first encoding sub-model includes a first vector embedding layer and a plurality of stacked encoders, each of which includes a first multi-head attention layer and a first feedforward neural network layer; Querying a pre-built discourse corpus based on the entity relationship triples to obtain candidate reply texts, and inputting the candidate reply texts into the second encoding sub-model; Performing semantic feature extraction on the candidate reply text through the second encoding sub-model to obtain a text semantic vector, and inputting the text semantic vector into the output layer; the second encoding sub-model includes a second vector embedding layer and multiple encoder layers, each of the encoder layers includes a second multi-head attention layer and a second feedforward neural network layer; The text enhancement word vector and the text semantic vector are calculated by the output layer to obtain a reply word recommendation; The step of performing contextual understanding on the entity relationship triples and the medical inquiry text by using the first encoding sub-model to obtain a text-enhanced word vector containing contextual information includes: Performing vector encoding on the entity relationship triples and the medical inquiry text through the first vector embedding layer to obtain entity text vectors, and inputting the entity text vectors into the plurality of encoders; Performing attention calculation on the entity text vector through the first multi-head attention layer to obtain a text attention distribution feature containing context information, and inputting the text attention distribution feature into the first feedforward neural network layer; Performing an enhanced calculation on the text attention distribution feature and the entity text vector through the first feedforward neural network layer to obtain a text enhanced word vector; The step of extracting semantic features from the candidate reply text using the second encoding sub-model to obtain a text semantic vector includes: Encoding the candidate reply text through the second vector embedding layer to obtain a text sentence vector, and inputting the text sentence vector into the multiple encoder layers; Performing contextual understanding on the text sentence vector through the second multi-head attention layer to obtain a text attention representation, and inputting the text attention representation and the text sentence vector into the second feedforward neural network layer; The text attention representation and the text sentence vector are calculated through the second feedforward neural network layer to obtain a text semantic vector.

2. The method for recommending reply words to a medical consultation according to claim 1, characterized in that: The entity extraction layer includes a head entity recognition sublayer and a relationship and tail entity joint recognition sublayer; the step of performing entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples includes: Input the text embedding vector into the head entity recognition sublayer for recognition, and output all head entities; Inputting the head entity and the text embedding vector into the relation and tail entity joint recognition sublayer for recognition, thereby obtaining all specific relations and tail entities corresponding to each head entity; The head entity, the specific relationship and the tail entity are combined to obtain an entity relationship triple.

3. The method for recommending reply words to a medical consultation according to claim 1, characterized in that: The step of calculating the text enhancement word vector and the text semantic vector through the output layer to obtain a reply speech recommendation includes: Calculating the cosine similarity between the text enhancement word vector and the text semantic vector through the output layer; Based on the cosine similarity, a preset number of candidate reply texts are screened out and output as reply speech recommendations.

4. The method for recommending reply words to a medical consultation according to claim 1, wherein: Before the step of inputting the medical inquiry text into the trained response recommendation model, the method further includes: Obtaining a medical consultation dialogue dataset, wherein the medical consultation dialogue dataset includes medical consultation text samples and corresponding reply speech samples; Inputting the medical inquiry text sample into a pre-built neural network model, wherein the pre-built neural network model includes an initial embedding layer, an initial entity extraction layer, an initial first encoding sub-model, an initial second encoding sub-model, and an initial output layer; Performing vector encoding on the medical inquiry text sample through the initial embedding layer to obtain a sample embedding vector; Performing entity extraction on the sample embedding vector through the entity extraction layer to obtain a sample entity triple, and inputting the sample entity triple and the medical inquiry text sample into the initial first encoding sub-model; Performing contextual understanding on the sample entity triples and the medical inquiry text sample through the initial first encoding sub-model to obtain a sample enhanced word vector containing contextual information; Inputting the reply speech sample into the initial second encoding sub-model, encoding the reply speech sample through the initial second encoding sub-model to obtain a sample semantic vector; Calculating the sample enhanced word vector and the sample semantic vector through the output layer, and outputting the predicted reply words; Calculate the loss value between the predicted reply speech and the reply speech sample according to a preset loss function; The model parameters of the neural network model are adjusted based on the loss value. When the iteration end condition is met, the final model parameters are obtained, and a reply speech recommendation model is generated based on the final model parameters.

5. The method for recommending reply words to a medical consultation according to claim 4, characterized in that: Before the step of inputting the reply speech sample into the second encoding sub-model, the method further includes: Construct positive samples and negative samples of the reply speech sample, and input the positive samples and the negative samples into the second encoding sub-model.

6. A device for recommending replying words to a medical consultation, characterized in that: include: An acquisition module is configured to receive a medical inquiry text and input the medical inquiry text into a trained reply speech recommendation model, wherein the reply speech recommendation model includes an embedding layer, an entity extraction layer, a first encoding sub-model, a second encoding sub-model, and an output layer; An embedding module, configured to perform vector encoding on the medical inquiry text through the embedding layer to obtain a text embedding vector, and input the text embedding vector into the entity extraction layer; an entity extraction module, configured to perform entity extraction on the text embedding vector through the entity extraction layer to obtain entity relationship triples, and input the entity relationship triples and the medical inquiry text into the first encoding sub-model; a first encoding module, configured to perform contextual understanding on the entity relationship triples and the medical inquiry text through the first encoding sub-model, obtain a text-enhanced word vector containing contextual information, and input the text-enhanced word vector into the output layer; the first encoding sub-model includes a first vector embedding layer and a plurality of stacked encoders, each of the encoders including a first multi-head attention layer and a first feedforward neural network layer; a query module, configured to query a pre-built discourse corpus based on the entity relationship triples to obtain candidate reply texts, and input the candidate reply texts into the second encoding sub-model; a second encoding module, configured to extract semantic features from the candidate reply text using the second encoding sub-model to obtain a text semantic vector, and input the text semantic vector into the output layer; the second encoding sub-model includes a second vector embedding layer and multiple encoder layers, each of the encoder layers includes a second multi-head attention layer and a second feedforward neural network layer; An output module, configured to calculate the text enhancement word vector and the text semantic vector through the output layer to obtain a reply word recommendation; The first encoding module includes: A first vector embedding submodule is configured to perform vector encoding on the entity relationship triples and the medical inquiry text through the first vector embedding layer to obtain entity text vectors, and input the entity text vectors into the plurality of encoders; A first attention submodule is configured to perform attention calculation on the entity text vector through the first multi-head attention layer to obtain a text attention distribution feature containing context information, and input the text attention distribution feature into the first feedforward neural network layer; A first feedforward neural submodule, configured to perform an enhanced calculation on the text attention distribution feature and the entity text vector through the first feedforward neural network layer to obtain a text enhanced word vector; The second encoding module includes: A second vector embedding submodule, configured to encode the candidate reply text through the second vector embedding layer to obtain a text sentence vector, and input the text sentence vector into the multiple encoder layers; A second attention submodule is configured to perform contextual understanding on the text sentence vector through the second multi-head attention layer to obtain a text attention representation, and input the text attention representation and the text sentence vector into the second feedforward neural network layer; The second feedforward neural submodule is used to calculate the text attention representation and the text sentence vector through the second feedforward neural network layer to obtain a text semantic vector.

7. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the method for recommending medical consultation reply techniques as described in any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the method for recommending medical consultation response techniques according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Intelligent inquiry method and device based on semantic comprehension, storage medium and server

    CN111274365A

  • Data processing method and device, equipment, storage medium and computer program product

    CN116108164A