A medical question and answer service method and system based on artificial intelligence

By introducing semantic role awareness and dynamic term popularity assessment mechanisms, combined with intent classification and adaptive question standardization processing, the problems of term standardization and semantic drift in medical question-answering systems are solved, improving the accuracy and stability of the system in spoken input and multi-turn dialogue.

CN122087068BActive Publication Date: 2026-07-24XIEHE HOSPITAL ATTACHED TO TONGJI MEDICAL COLLEGE HUAZHONG SCI & TECH UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIEHE HOSPITAL ATTACHED TO TONGJI MEDICAL COLLEGE HUAZHONG SCI & TECH UNIV
Filing Date
2026-04-23
Publication Date
2026-07-24

Smart Images

  • Figure CN122087068B_ABST
    Figure CN122087068B_ABST
Patent Text Reader

Abstract

The application provides a medical question and answer service method and system based on artificial intelligence, relates to the technical field of medical question and answer, and comprises the following steps: performing word segmentation and dependency syntax analysis on a medical inquiry text input by a user to form a multi-round dialogue context; splicing the current user input and the latest round of historical input in a historical dialogue queue to form a joint input sequence, inputting the joint input sequence into a pre-trained language model to obtain an intention classification result; calculating dynamic heat factors of each term, and sorting candidate standard terms in a standard term knowledge base according to the dynamic heat factors to obtain a candidate term sorting list; performing differential question standardization processing on the current user input according to the intention classification result; inputting the standardized question into a medical knowledge retrieval module to obtain a retrieval result and generate a medical question and answer response. The application can improve the term standardization accuracy of a medical question and answer system in a spoken input scene and the response stability of the medical question and answer system in a multi-round dialogue scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical question-and-answer technology, and in particular to a medical question-and-answer service method and system based on artificial intelligence. Background Technology

[0002] With the continuous development of internet healthcare, AI-based medical question-and-answer systems have been widely used to assist users in acquiring medical knowledge and guiding medical decisions. However, existing systems face two prominent problems in practical deployment: First, user input is often colloquial and ambiguous, such as using "always dizzy" instead of "dizzy" or "uncomfortable stomach" instead of "stomach ache," directly causing matching biases in the terminology standardization process and affecting the accuracy of knowledge retrieval. Second, in multi-turn dialogue scenarios, users frequently use pronouns or omit subjects, and if the system lacks an effective context management mechanism, it struggles to accurately understand the user's true intent, leading to semantic drift in question-and-answer responses and compromising system stability. These problems limit the practicality of medical question-and-answer systems in complex interactive scenarios.

[0003] To address the issue of multi-turn dialogue, Chinese patent application number 202011118109.7 discloses an intelligent question-answering method for multi-turn dialogue in the medical field. This method extracts entity and intent information from user input using a natural language understanding model. When it detects that the current turn's input is missing entity or intent information, it directly inherits the corresponding information from the previous turn and completes the current question using a sentence completion model, thereby achieving the transfer of multi-turn context. However, this method adopts a fixed information inheritance strategy, that is, it uses the entities and intents from the previous turn regardless of the situation, without distinguishing between two fundamentally different dialogue states: a change in user intent and a continuation of follow-up questions. This poses a risk of introducing incorrect historical context into the current question when the user switches topics, and the method also does not address the issue of dynamic standardization of medical terminology. Summary of the Invention

[0004] In view of this, the present invention provides a medical question-answering service method and system based on artificial intelligence. By introducing a dynamic term popularity evaluation mechanism based on semantic role awareness and an adaptive question standardization processing framework based on intent classification, combined with service quality evaluation based on path attribution and a two-parameter collaborative optimization closed loop, the method aims to improve the accuracy of term standardization in spoken language input scenarios and the response stability in multi-turn dialogue scenarios.

[0005] The technical solution of this invention is implemented as follows:

[0006] On one hand, the present invention provides a medical question-and-answer service method based on artificial intelligence, comprising:

[0007] S1. Perform word segmentation and dependency parsing on the medical inquiry text input by the user, extract medical terms and their semantic roles, and append the current input to the historical dialogue queue to form a multi-turn dialogue context;

[0008] S2. Concatenate the current user input with the most recent historical input in the historical dialogue queue to form a joint input sequence. Input the sequence into the pre-trained language model for joint encoding and classification to obtain the intent classification result.

[0009] S3. The historical frequency of each medical term is weighted by the semantic role weight of each term, and the dynamic heat factor of each term is calculated by the exponential smoothing method. The candidate standard terms in the standard term knowledge base are sorted based on the dynamic heat factor to obtain the candidate term ranking list.

[0010] S4. Based on the intent classification results, perform differential question standardization processing on the current user input:

[0011] If the intention is to jump, clear the history dialogue queue and directly use the current user's input as the standardized question;

[0012] If the intention is to ask a follow-up question, then the current user input is supplemented with subject completion or substitution resolution based on the context information in the historical dialogue queue, and the medical terms in the current user input are standardized and replaced according to the candidate term sorting list to obtain a standardized question.

[0013] S5. Input the standardized question into the medical knowledge retrieval module, obtain the retrieval results, and generate a medical question-and-answer response.

[0014] Preferably, the dynamic heat factor mentioned in step S3 Calculate using the following formula:

[0015] ;

[0016] Where t is the current time, For the target medical term whose popularity needs to be calculated, It is the j-th candidate term in the standard terminology knowledge base; For the user input in the k-th round of the dialogue; W is the length of the historical dialogue sliding window referenced for the heat calculation, in the number of dialogue rounds; For the term Semantic role weights in the k-th round of dialogue; For indicator functions, when Appeared in The value is 1 when the condition is met, and 0 otherwise. For smoothing coefficients; This represents the heat factor value of the term at the previous moment.

[0017] Preferably, the semantic role weight Three-level assignment based on the semantic role of the term in the sentence: when exist When the core medical entity is in the subject position, When a subordinate medical entity is in the object position or in a parallel structure, When it is a background medical entity modified by an adverbial phrase, .

[0018] Preferably, in step S4, if the intention is a follow-up question, then the current user input is supplemented with subject completion or substitution resolution based on the context information in the historical dialogue queue, specifically including:

[0019] Detect whether the current user input contains an indicator pronoun;

[0020] If the pronoun is present, the medical entity referred to by the pronoun is determined by the context information in the history dialogue queue, and the pronoun is replaced with an explicit statement of the corresponding entity.

[0021] If no demonstrative pronoun is present, the subject medical entity to which the current question refers is inferred from the context information in the history dialogue queue, and the inferred subject entity is added to the subject position of the question.

[0022] Preferably, the method further includes performing path attribution evaluation on the quality of the question-and-answer service in units of a preset evaluation period:

[0023] At the end of each evaluation period, for the pronoun resolution path and the subject completion path, the number of questions processed by each path during the current evaluation period, and the number of relevant results recalled when each question is directly retrieved from the original input, are counted respectively. The number of relevant results recalled by the search after standardizing and rewriting the question The semantic rewriting recall improvement rate for each path is calculated using the following formula:

[0024] ;

[0025] in, The recall improvement rate for semantic rewriting of path p;

[0026] Each path After historical percentile normalization, the normalized recall improvement rate of the proxy resolution path was obtained. Normalized recall improvement rate compared to subject completion path processing The path attribution comprehensive recall score is obtained by weighting the number of questions processed according to the path:

[0027] ;

[0028] in, , These represent the number of questions processed by the pronoun resolution path and the subject completion path within the current evaluation period, respectively.

[0029] Count the number of positive user feedbacks during the current evaluation period. Total number of feedback Calculate the original user satisfaction ;

[0030] The rewriting contribution coefficient is calculated based on the proportion of standardized questions for each path to the total number of questions within the current evaluation period. ,in The total number of results retrieved for standardized question retrieval across all rewritten paths. The total number of results retrieved by directly searching the original question under all rewritten paths. To prevent the smoothing constant from having a denominator of zero;

[0031] by right The contribution level was corrected by rewriting. ;

[0032] Calculate the overall quality confidence score:

[0033] ;

[0034] in, For intent classification accuracy, In order to identify security thresholds, This is an indicator function that indicates when the intent classification accuracy is below a safety threshold. The value is 1 if the condition is met, and 0 otherwise. The penalty coefficient for intentional misjudgment. The weight coefficients for each dimension satisfy... .

[0035] Preferably, it also includes according to For smoothing coefficient Perform two-parameter collaborative adaptive adjustment with the sliding window length W:

[0036] ;

[0037] ;

[0038] in, Preset service quality threshold; It is a symbolic function; They are respectively Adjustment step size with W; , These represent the value ranges of the two parameters;

[0039] The adjusted parameters are applied to the terminology dynamic heat factor calculation in step S3 in the next evaluation cycle.

[0040] Preferably, in step S2, the current user input is concatenated with the most recent historical input to form a joint input sequence, specifically in the following format:

[0041] ;

[0042] in, Input for the most recent user in the history dialogue queue; Input for the current user; For classification labeling; Sentence separator.

[0043] Preferably, the historical dialogue queue in step S1 is a sliding window queue with a maximum window size of N rounds. After each round of question and answer is completed, the user input and system response of the current round are appended to the end of the queue. When the queue length exceeds N, the earliest historical round is automatically deleted, so that the queue always maintains a historical record of no more than N rounds.

[0044] Preferably, in step S5, the medical knowledge retrieval module adopts a two-stage fusion retrieval method that combines vector semantic retrieval and keyword retrieval:

[0045] Based on the cosine similarity of the semantic vectors of standardized questions and knowledge base entries, the top K candidate entries with the highest similarity are recalled, where K is the preset upper limit of the number of entries to be recalled.

[0046] Perform exact matching and re-ranking of the K recalled candidate entries using standard terminology keywords, and take the candidate entry with the highest ranking after re-ranking as the search result.

[0047] In addition, the present invention also provides an artificial intelligence-based medical question-and-answer service system to implement the above-described method, the system comprising:

[0048] The text preprocessing module is used to perform word segmentation and dependency parsing on the medical inquiry text input by the user, extract medical terms and their semantic roles, and append the current input to the historical dialogue queue to form a multi-turn dialogue context;

[0049] The intent classification module is used to concatenate the current user input with the most recent historical input in the historical dialogue queue to form a joint input sequence, which is then input into a pre-trained language model for joint encoding and classification to obtain the intent classification result.

[0050] The terminology popularity calculation module is used to weight the historical frequency of each medical term by the semantic role weight of each term, calculate the dynamic popularity factor of each term using the exponential smoothing method, and sort the candidate standard terms in the standard terminology knowledge base based on the dynamic popularity factor to obtain a ranked list of candidate terms.

[0051] The question standardization module is used to perform differentiated question standardization processing on the current user input based on the intent classification results: if the intent is a jump, the historical dialogue queue is cleared and the current user input is directly used as the standardized question; if the intent is a follow-up question, the current user input is supplemented with subject completion or substitution resolution based on the context information in the historical dialogue queue, and the medical terms in the current user input are standardized and replaced according to the candidate term ranking list to obtain the standardized question.

[0052] The medical knowledge retrieval module is used to receive standardized questions, perform searches, and generate medical question-and-answer responses.

[0053] The present invention has the following advantages over the prior art:

[0054] (1) This invention assigns weights to medical terms in user input according to their semantic roles and dynamically calculates the popularity factor of each term by combining the exponential smoothing mechanism in the recent history window, so that the priority ranking of candidate terms in the terminology standardization process can be adaptively adjusted according to the changes in the dialogue scenario.

[0055] (2) The present invention concatenates the user’s multi-round input and inputs it into the pre-trained language model for intent classification, clearly distinguishes the two types of dialogue states: “follow-up question continuation” and “intent jump”, and clears the historical dialogue queue in time when the intent jumps, so as to avoid the semantic information of the previous rounds from interfering with the processing of the current question.

[0056] (3) This invention targets three typical scenarios: pronoun-containing questions, pronoun-free questions, and intention-jumping questions. It executes three differentiated processing paths: pronoun resolution and terminology standardization, subject completion and terminology standardization, and history clearing and direct standardization. This achieves targeted processing of question standardization for different input forms. Compared with a single completion strategy, it has a wider scenario coverage and finer-grained semantic repair capabilities.

[0057] (4) This invention designs a multi-dimensional service quality assessment model for path attribution, which integrates semantic rewriting recall improvement rate, intent recognition accuracy and user feedback attribution score into a quantifiable quality confidence index, and drives the collaborative adaptive adjustment of smoothing coefficient and historical window length in heat calculation, forming a data-driven system optimization closed loop, providing an objective evaluation basis for continuous optimization of the system in different clinical use scenarios. Attached Figure Description

[0058] 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 some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1 This is a flowchart of the method of the present invention;

[0060] Figure 2 This is a flowchart of the dynamic term popularity calculation for semantic role perception in this invention.

[0061] Figure 3 This is a flowchart of the adaptive question standardization three-path routing of the present invention;

[0062] Figure 4 This is a schematic diagram of the path attribution quality assessment and two-parameter adaptive closed loop of the present invention;

[0063] Figure 5 This is a system framework diagram of the present invention. Detailed Implementation

[0064] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the 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.

[0065] like Figure 1 As shown, this invention provides a medical question-and-answer service method based on artificial intelligence, comprising:

[0066] S1. Perform word segmentation and dependency parsing on the medical inquiry text input by the user, extract medical terms and their semantic roles, and append the current input to the historical dialogue queue to form a multi-turn dialogue context;

[0067] S2. Concatenate the current user input with the most recent historical input in the historical dialogue queue to form a joint input sequence. Input the sequence into the pre-trained language model for joint encoding and classification to obtain the intent classification result.

[0068] S3. The historical frequency of each medical term is weighted by the semantic role weight of each term, and the dynamic heat factor of each term is calculated by the exponential smoothing method. The candidate standard terms in the standard term knowledge base are sorted based on the dynamic heat factor to obtain the candidate term ranking list.

[0069] S4. Based on the intent classification results, perform differentiated question standardization processing on the current user input: if the intent is a jump, clear the historical dialogue queue and directly use the current user input as the standardized question; if the intent is a follow-up question, combine the context information in the historical dialogue queue to perform subject completion or substitution resolution on the current user input, and standardize and replace the medical terms in the current user input according to the candidate term ranking list to obtain the standardized question.

[0070] S5. Input the standardized question into the medical knowledge retrieval module, obtain the retrieval results, and generate a medical question-and-answer response.

[0071] In one embodiment of the present invention, step S1 includes:

[0072] After receiving the medical inquiry text input by the user, the system first performs word segmentation, dividing the continuous character sequence into a word sequence. Then, dependency parsing is performed on the segmentation results to obtain the grammatical dependencies between words in the sentence. Based on the dependency parsing results, the system further identifies and extracts medical terms from the text and determines their semantic role category according to their syntactic position in the sentence structure: core medical entities in the subject position are labeled as subject entities; subordinate medical entities in the object position or in parallel structures are labeled as subordinate entities; and background medical entities in adverbial modifiers are labeled as background entities. These three semantic role labels will serve as the weighting basis for the term popularity calculation in step S3. The above word segmentation and dependency parsing can be implemented using existing Chinese natural language processing toolkits, such as HanLP or spaCy Chinese models.

[0073] After preprocessing the current input, the system appends it to the history dialogue queue. Internally, the system maintains a sliding window-style history dialogue queue with a maximum window size of N rounds, where N is a configurable parameter. After each round of question-and-answer, the user input and system response for that round are appended to the end of the queue. When the queue length exceeds N, the oldest historical round is automatically deleted, ensuring the queue always maintains a history of no more than N rounds. This represents the most recent round of historical user input in the queue. When a subsequent step detects a change in user intent, the historical dialogue queue will be completely cleared and reset to prevent irrelevant semantic information from historical dialogues from interfering with the processing flow of the current round. The above preprocessing operations form a structured multi-turn dialogue context sequence, which serves as unified input data for subsequent processing modules.

[0074] In one embodiment of the present invention, step S2 includes:

[0075] The system categorizes user input by intent, determining whether the current input belongs to either an intent shift or a follow-up question, providing a routing basis for the subsequent question standardization process in step S4. It then retrieves the most recent round of historical user input from the historical dialogue queue. With the current user input The input sequence is constructed by concatenating the following standard format:

[0076] ;

[0077] in, Input for the most recent user in the history dialogue queue; Input for the current user; These are classification tags used to aggregate global semantic representations; The sentence-to-sentence delimiter is used to distinguish the boundary between historical sentences and the current input. The above joint input sequence is fed into the pre-trained language model. Through joint encoding of the content of the two rounds of dialogue, the model can fully capture the contextual semantic dependencies across sentences and output the intent classification result, which takes the value jump (intent jump) or follow (follow-up question), as the routing input for the question standardization process in step S4.

[0078] The aforementioned pre-trained language models can be BERT-base-Chinese or RoBERTa-wwm-ext-Chinese, fine-tuned on a medical dialogue dataset for intent classification. A binary linear layer is connected above the latent vector of the location, and the output jump / follow classification probability is given.

[0079] like Figure 2 As shown, in one embodiment of the present invention, step S3 includes:

[0080] Medical terminology is diverse, with the same medical concept existing in various forms such as colloquial names, scientific names, and abbreviations. Examples include "heart disease" and "coronary atherosclerotic heart disease," and "aspirin" and "acetylsalicylic acid." If the semantic role of a term in a sentence is not considered and its popularity is calculated directly based on historical cumulative frequency, terms frequently appearing in background modifiers (such as the background term "PD-L1 high expression" in the search term "drug recommendations for patients with high PD-L1 expression") will artificially inflate popularity, affecting the priority ranking of terminology standardization and replacement. Therefore, this step introduces a semantic role-aware exponential smoothing decay mechanism. The frequency of medical terms involved in recent conversations is weighted according to their semantic roles, and exponential smoothing is applied in conjunction with historical popularity to calculate the dynamic popularity factor of each term at the current moment. The specific calculation formula is as follows:

[0081] ;

[0082] Where t is the current time, Let i be the medical term to be evaluated; It is the j-th candidate term in the standard terminology knowledge base; Input text for the user in the k-th round of the conversation. This indicates that the most recent W rounds of dialogue are traversed; W is the length of the historical dialogue sliding window referenced for the heat calculation, in units of dialogue rounds, and is a configurable hyperparameter. For the term The semantic role weights in the k-th round of dialogue are determined by the dependency parsing results of step S1. For indicator functions, when the term Appearing in the kth round of user input The value is 1 when the condition is met, and 0 otherwise. To smooth the coefficients, the weighted frequency ratio within the recent window and the historical popularity are controlled. The trade-off between them; The numerator of the formula is the heat factor value of the term at the previous moment; the numerator of the formula is the term's heat factor value at the previous moment. The occurrence intensity of terms in nearly W rounds of dialogue is weighted by semantic role. The denominator is the sum of the weighted occurrence intensities of all candidate terms in the knowledge base within the same window. Dividing the two yields the term's occurrence intensity. The proportion of activity relative to all candidate terms.

[0083] Semantic role weight Three-level assignment based on the semantic role of the term in the sentence: when exist When the core medical entity is in the subject position, When a subordinate medical entity is in the object position or in a parallel structure, When it is a background medical entity modified by an adverbial phrase, The design basis for the three-level assignment is as follows: the main entity directly corresponds to the core query focus of the current session and has the strongest determining effect on the search results; the subordinate entity, as the attribute or parallel descriptive object of the main entity, has a certain session relevance; the background entity only appears as a modifier and has the weakest contribution to the core query focus, so assigning it a lower weight can effectively suppress its interference with the popularity ranking results.

[0084] In obtaining the dynamic heat factor of each term The system then matches these terms with a medical standard terminology knowledge base, sorting the candidate standard terms in descending order of popularity for use in step S4. The medical standard terminology knowledge base contains the standard scientific names, common colloquial names, common abbreviations, and their corresponding standardized forms for each medical concept. Candidate terms are dynamically weighted and sorted to ensure that the most active core entity terms in the current scenario are prioritized for matching in the process of dereferencing and question rewriting.

[0085] Compared to the static method of calculating popularity directly based on historical cumulative frequency, the semantic role perception mechanism can distinguish the primary and secondary status of terms in sentences, making the popularity factor more realistically reflect the activity level of terms in the current conversation focus, effectively avoiding the false inflation of popularity assessment results by high-frequency background terms, thereby improving the accuracy of priority ranking of standardized term replacement; the exponential smoothing mechanism further ensures that the popularity estimation has good trend stability and noise suppression capabilities in clinical scenarios of different departments and different periods.

[0086] like Figure 3 As shown, in one embodiment of the present invention, step S4 includes:

[0087] Based on the intent classification results of step S2, and combined with the dynamic term popularity factor calculated in step S3, The system performs adaptive question standardization processing on user input, transforming fragmented and colloquial raw input into semantically complete, terminologically standardized medical questions that can be efficiently matched by knowledge retrieval systems. The system routes input to three corresponding processing paths based on intent type, with the following routing rules:

[0088] ;

[0089] in, This is a follow-up question flag; a value of 1 indicates that the current input is a follow-up question. This is an intent transition flag; a value of 1 indicates that the current input has an intent transition. The indicator flag is set to indicate the presence of demonstrative pronouns. A value of 1 indicates that a demonstrative pronoun (such as "that," "this," "it," "should," etc.) is detected in the current input, while a value of 0 indicates that no demonstrative pronoun is present in the current input. O represents the standardized question output to the retrieval module. The three paths correspond to Path 1 (follow-up question containing demonstrative pronouns), Path 2 (intent jump), and Path 3 (follow-up question without demonstrative pronouns), respectively. The system synchronously records the number of questions processed by each path within each evaluation period. , ,Right now , (Path 2 does not rewrite the question and is not included in the rewrite quality assessment, so it is not counted separately), and is used for the path attribution quality assessment in step S6.

[0090] Path 1: When the intention is to ask follow-up questions ( And the current input contains an indicator pronoun ( When the input is displayed as "( )," it indicates that the user has omitted the specific entity name and is using a pronoun to refer to a medical entity that has appeared in the previous statement. The system first checks the current input. The system identifies demonstrative pronouns in the question and then determines the specific medical entity they refer to from the context information of the historical dialogue queue. The pronouns are then replaced with the explicit standard terminology of the corresponding entity, thus completing the coreference resolution. Coreference resolution can be implemented using a coreference resolution model based on a pre-trained language model (such as MacBERT or BERT-base-Chinese). The historical dialogue context is concatenated with the current question and input into the model, which predicts the antecedent position of the pronoun and extracts the corresponding entity name. After completing coreference resolution, the system uses the candidate terminology ranking list obtained in step S3 to replace colloquial or abbreviated medical terms in the question with their corresponding standard scientific names, resulting in a standardized question. During the replacement process, the candidate term list, sorted in descending order of popularity, is traversed. Each term is checked for colloquial variations or abbreviations within the question. If a match is found, it is replaced with the standard form. Terms with higher priority (greater popularity) are processed first, ensuring that core conversational entities are standardized first. This is based on the content of the last round of the historical dialogue. For the question "How effective is nivolumab in patients with high PD-L1 expression?", the current input is... Taking "What about the heart side effects?" as an example, after the process of eliminating pronouns and standardizing terminology, What are the incidence of cardiovascular adverse reactions and related medical recommendations for nivolumab in patients with PD-L1-high expressing gastric cancer? Perform knowledge retrieval.

[0091] Path 2: When the intention is a jump ( If the user has switched to a completely new topic, and the historical conversation content has no semantic connection with the current query, then the system clears the historical conversation queue cache maintained in step S1 and uses the current user input directly as the search query.

[0092] ;

[0093] in, That is, the input of the current user Clearing historical context effectively prevents irrelevant entities from past conversations from interfering with the current search and avoids decreased search accuracy caused by incorrect cross-topic associations. This is based on the content of the last round of the historical conversation. For the question "What dietary precautions should be taken after gastric cancer surgery?", the current input is... Taking "Can diabetics eat fruit?" as an example, the system detects a change in intent, clears the historical context, and directly uses... =Search for knowledge on "Can diabetics eat fruit?". Also, use the term popularity factor. Maintaining the current value without resetting it preserves the memory of historically high-frequency medical terms and avoids the cold start problem of popularity status after topic switching; if more thorough context isolation is required in actual deployment, the transition time can also be... Reset to the initial value of 0; this behavior is controlled by system deployment parameters as a configurable option.

[0094] Path 3: When the intention is to ask follow-up questions ( However, the current input does not contain demonstrative pronouns. When the question is incomplete, it indicates that the user omitted the subject or key entity name in their expression, resulting in an incomplete semantic statement that cannot be processed independently by the knowledge retrieval system without context. The system then uses the historical dialogue context... The text automatically identifies and extracts missing subject completion components. This is then concatenated with the current input to generate a semantically complete standard medical question. :

[0095] ;

[0096] in, In order to engage in dialogue with history The extracted subject completion fragment contains the missing subject entity information in the current question context; These are standard medical questions with complete semantics, ensuring that they can still be independently understood and processed by the retrieval system even when removed from their historical context. This is the incomplete question currently entered by the user. (Subject completion component) Extraction can be based on the context of the most recent W rounds in the historical dialogue queue, combined with dependency parsing results, using the subject entity (the subject position term with the highest popularity factor) as the completion component. This is based on the content of the last round of the historical dialogue. For the question "Does the NCCN guideline recommend first-line treatment for HER2-positive gastric cancer?", the current input is... Taking "What is the level of evidence?" as an example, the system extracts the subject completion component. back, What is the level of evidence for the NCCN guidelines recommending first-line treatment for HER2-positive gastric cancer? Perform knowledge retrieval.

[0097] This step uses a routing distribution mechanism to direct user input of different intent types to targeted standardized processing paths. While ensuring the independence of retrieval in scenarios with changing intents, it solves the problem of incomplete semantics in follow-up questions through two mechanisms: referential resolution and subject completion. Compared with a solution that does not distinguish between intent types and processes them uniformly, the differentiated routing strategy reduces the misintroduction of contextual information, enabling standardized questions to achieve higher retrieval matching accuracy under various user expression habits.

[0098] In one embodiment of the present invention, step S5 includes:

[0099] Based on the standardized question output from step S4 ( , or The system calls the medical knowledge base to perform a two-stage fusion retrieval, obtains the candidate knowledge entries most relevant to the semantics of the standardized question, and outputs a medical question-and-answer response in conjunction with the answer generation module.

[0100] In the first stage, the top K candidate items with the highest similarity are recalled based on the cosine similarity of the semantic vectors of the standardized questions and knowledge base items, where K is a preset upper limit for the number of items to be recalled. The semantic vectors can be obtained by inputting the standardized questions and knowledge base items into a sentence vector encoding model (such as a version of text2vec-base-chinese or BERT-base-Chinese that has been fine-tuned through contrastive learning). The vector representations of the knowledge base items are pre-calculated and a vector index (such as the FAISS index) is built in the offline stage. During online retrieval, only the standardized questions need to be encoded in real time and a nearest neighbor search needs to be performed to ensure response efficiency.

[0101] In the second stage, the K candidate entries recalled in the first stage are re-ranked using precise keyword matching of standard terms. The candidate entry with the highest ranking after re-ranking is taken as the final search result. This entry is then input into the answer generation module to generate a medical question-and-answer response in natural language and returned to the user. Precise keyword matching targets the standard terms in the standardized question after the replacement in step S4, performing precise string matching in the title and keyword fields of the candidate entries. Entries with a higher number of matches receive higher scores in the re-ranking. The knowledge base retrieval and answer generation techniques in this step can be implemented using existing search augmentation generation (RAG) frameworks or knowledge graph retrieval schemes. During the retrieval process, the system synchronously records the original inputs under each path (…). ) and standardized questions ( or The number of retrieved results for each search is denoted as . and ( (Corresponding path number), which is used for the sub-path quality assessment in step S6.

[0102] like Figure 4 As shown, in one embodiment of the present invention, step S6 includes:

[0103] Using a preset evaluation cycle as the unit, the quality of the question-and-answer service is evaluated by path attribution. Based on the evaluation results, the term popularity parameter in step S3 is adjusted by two parameters in a collaborative adaptive manner to form a closed-loop optimization mechanism.

[0104] First, calculate the recall improvement rate for semantic rewriting along different paths. At the end of each evaluation period, for the pronoun resolution path and the subject completion path, count the number of questions processed by each path during the current evaluation period, and the number of relevant results recalled when directly searching the original input for each question. The number of relevant results recalled by the search after standardizing and rewriting the question The semantic rewriting recall improvement rate for each path is calculated using the following formula:

[0105] ;

[0106] in, The recall improvement rate for semantic rewriting of path p; The number of relevant results recalled by the retrieval of path p after question standardization and rewriting. The value directly measures the actual contribution of the question standardization operation of the corresponding path in step S4 to the quality of knowledge retrieval recall. The larger the value, the more significant the improvement in retrieval performance of the question standardization of that path. Path 2 (intent jump to direct retrieval) does not perform question rewriting and does not participate in the recall improvement calculation.

[0107] Secondly, calculate the confidence score of the overall quality of the question-answering service for path attribution. . The evaluation comprehensively considers three dimensions of path attribution: question rewriting recall improvement, intent recognition accuracy, and explicit user feedback on rewritten attribution.

[0108] The first step is to robustly normalize the recall improvement rate for each path to eliminate the impact of outliers on the evaluation benchmark:

[0109] ;

[0110] in, The 90th percentile of the recall improvement rate of path p within the historical evaluation period is used as the normalization benchmark instead of the historical maximum value to avoid the systematic suppression of historical data after a few exceptionally good recall results raise the global benchmark. Let p be the recall improvement rate after path normalization. This indicates that the rewriting quality of the current cycle surpasses the historical 90th percentile level.

[0111] The second step is to calculate the normalized recall improvement rate of the two rewriting paths by weighting the number of questions processed in the current evaluation period for each path, and obtain the comprehensive recall score for path attribution:

[0112] ;

[0113] Since path 2 does not participate in recall boosting, the overall recall score can also be written as:

[0114] ;

[0115] in, ( The number of questions processed through path 1 (representing resolution and terminology standardization) within the current evaluation period; ( The number of questions processed through path 3 (subject completion) within the current evaluation period; This comprehensively reflects the weighted recall improvement level of the two rewriting paths; the path with a larger proportion of the number of paths is more effective in improving recall. The higher the weight of the influence, the more likely the evaluation results will match the actual service load distribution.

[0116] The third step is to process explicit user feedback. This involves counting the number of positive user feedback responses within the current evaluation period. Total number of feedback Calculate the original user satisfaction Since the original user satisfaction reflects the overall experience of the entire question-and-answer process (including the quality of the knowledge base and the quality of the generated answers), rather than simply measuring the quality contribution of standardized question rewriting, a rewriting contribution coefficient is introduced. right Perform attribution correction:

[0117] ;

[0118] ;

[0119] in, The total number of results retrieved for standardized question retrieval across all rewritten paths; The total number of results retrieved by directly searching the original question under all rewritten paths; This is a smoothing constant to prevent the denominator from being zero; To rewrite the contribution coefficient, which reflects the relative contribution of standardized question rewriting to the overall recall improvement, when... hour ,when Time (i.e., the number of recalled results after rewriting is lower than the number of direct searches of the original input) At this point, the contribution adjustment for user satisfaction will not be performed. Original values ​​participate directly calculate; The revised contribution level of user feedback items more accurately reflects the portion of user satisfaction derived from the standardized rewriting of questions.

[0120] Fourth, combining the above three dimensions, calculate the overall quality confidence score using the following formula. :

[0121] ;

[0122] in, The path attribution comprehensive recall score, This is the user feedback item after rewriting and correcting the contribution score. For each dimension's weight coefficients, satisfying It can be configured to prioritize each dimension based on the actual business scenario.

[0123] The surrogate estimate of the classification confidence of the intent classification module within the current evaluation period is defined as the mean of the softmax maximum class probabilities output by the intent classification model for all input questions within this period:

[0124] ;

[0125] Where N is the total number of input questions in the current evaluation period. Let i be the softmax output probability of the i-th input on the k-th intent label. This refers to the maximum confidence score of the classification for that input. This metric does not require external ground truth labels and can be automatically calculated online by the system. It is calculated when the classification model has a high degree of confidence in the overall judgment of the input in the current period. Approaching 1, when there are a large number of intention judgments with ambiguous boundaries or low confidence within the period. A significant decrease can effectively reflect the systematic stability of the intent classification module.

[0126] The intent recognition safety threshold is a configurable hyperparameter used to determine whether the overall confidence level of intent classification has dropped to the danger zone within the current evaluation period. For indicator functions, when Below the safety threshold The value is 1 if it is true, and 0 otherwise. The penalty coefficient for intentional misjudgment is denoted by , which is a configurable hyperparameter. At that time, the overall quality score is multiplied by the penalty factor. The design is based on the fact that in medical question-and-answer scenarios, misjudgment of intent (typically, misidentification of intent jump as follow-up question, resulting in the introduction of historical entities unrelated to the current question in the previous round into the current question for rewriting) has a systematic and transmissive effect on the quality of question and answer. Its negative impact is not linearly superimposed on the scores of each dimension, but rather acts on the overall quality score in the form of a multiplicative factor, which is more consistent with the impact mechanism of misjudgment of intent in actual scenarios. The overall quality confidence score for the current evaluation period; when the normalized recall improvement rate for each path... All did not exceed 1 (i.e., did not exceed the historical 90th percentile level) and When the value remains within [0,1] after δ correction, ;when hour A value exceeding 1 indicates that the current cycle rewrite quality surpasses historical benchmark levels.

[0127] Finally, based on the calculations for each evaluation period... and path-normalized recall improvement rate , This triggers the two-parameter collaborative adaptive adjustment of the terminology heat parameter in step S3. Smoothness coefficient The adjustment is based on the global quality confidence score. Compared with the preset service quality threshold The deviation between them is the driving signal, which is updated according to the following formula:

[0128] ;

[0129] in, A preset service quality threshold is used to determine whether the overall quality of the current question-and-answer service meets the expected level; For a sign function, when Time to take This indicates that the current heat estimate needs to be adjusted in a more sensitive direction, when Time to take This indicates that the current assessment of popularity is overly sensitive; for Adjusting the step size controls the magnitude of each update; To normalize the deviation amplitude, the adjustment amount is proportional to the relative magnitude of the quality deviation; For the truncation function, the updated Limited to a preset range This prevents parameters from drifting into invalid ranges.

[0130] The adjustment of the sliding window length W is in This will be done after the update is completed, and subject completion path normalization will be introduced to improve recall rate. As a path quality correction item:

[0131] ;

[0132] in, The adjustment step size for W; Subject completion path normalized recall improvement rate, i.e., the recall rate after historical percentile normalization. ; The item plays a role in suppressing path quality: when subject completion significantly improves path recall ( When the historical information utilization rate is already high, the adjustment range of W is compressed to avoid excessively shortening the window. The updated W is limited to a preset integer range. Inside. It should be noted that when... When it approaches 1, When the term approaches zero, the adjustment range of W is significantly compressed. In this situation, the system tends to maintain the current window length unchanged to avoid frequent adjustments that introduce instability when historical information utilization is effective. For multiple consecutive evaluation periods, the value is below the threshold. However, W cannot be effectively adjusted. The system can enable a guaranteed adjustment mechanism: set a minimum guaranteed value for the adjustment amount of W. Ensure that W occurs at least once in each evaluation cycle. Adjustments This is a configurable hyperparameter, with a default value of 1 (rounds).

[0133] In the above two formulas The update direction is opposite to that of W: when hour, Increase the value to accelerate the response speed of the popularity factor to recent conversations, while shortening W to reduce the interference of long-term history on the current popularity calculation; when hour, The parameter S1 is reduced to smooth historical fluctuations, while the parameter W is extended to incorporate semantic accumulation from more historical rounds. These two parameters work synergistically in step S3. The calculation will take effect at the start of the next evaluation cycle.

[0134] By introducing a dual-parameter collaborative adaptive adjustment mechanism, the term dynamic heat calculation in step S3 can continuously seek a dynamic balance between perceptual sensitivity and historical stability based on the feedback of actual question-and-answer quality, thus avoiding the overfitting or response lag problems that occur when static parameters frequently switch dialogue topics or focus on a single topic for a long time.

[0135] By combining the above steps, the AI-based medical question-answering service method proposed in this invention forms a complete processing chain, from front-end context management and intent classification, mid-stage dynamic terminology popularity modeling and differentiated question standardization, to back-end two-stage fusion retrieval. The dynamic popularity factor in step S3... Supported by a hierarchical system of semantic role weights, a refined characterization of the historical activity of medical terms is achieved. This guides step S4 in selecting appropriate rewriting paths for different types of semantic missing information in follow-up questions, improving the semantic integrity of standardized questions. Step S5's two-stage fusion retrieval, building upon vector semantic recall with precise keyword matching, reduces the risk of noise introduced by terminology rewriting. Step S6's path attribution quality assessment statistically analyzes recall improvement based on path splitting structures and synthesizes it in conjunction with user feedback satisfaction signals. This approach not only distinguishes the actual contributions of each standardized path but also remains sensitive to the overall user experience quality of the system, providing a driving signal with real-world differentiation for the coordinated adjustment of the two parameters. The core idea behind this improvement is to incorporate the semantic history information accumulated in multi-turn dialogues and real-time quality feedback into the same closed-loop control framework. This allows the system's ability to adapt to the dialogue context to gradually increase as the dialogue rounds progress, rather than relying on fixed preset parameters to maintain consistent performance across all scenarios.

[0136] like Figure 5 As shown, in one embodiment of the present invention, the present invention also provides an artificial intelligence-based medical question-and-answer service system, which is implemented collaboratively by a set of software functional modules. The modules are sequentially connected through data flow to form a complete end-to-end online service link.

[0137] The text preprocessing module is responsible for receiving medical inquiry texts submitted by users, performing preprocessing operations such as word segmentation, noise reduction, special symbol filtering, and low-quality character cleaning. After word segmentation, it performs shallow dependency parsing on the segmentation results to identify the semantic roles of each medical term in the sentence, including three categories: main entity, subordinate entity, and background entity. At the same time, it appends the current input to the history dialogue queue to maintain the sliding window-style multi-turn dialogue context.

[0138] The intent classification module receives the output of the text preprocessing module, concatenates the current user input with the most recent historical input in the historical dialogue queue according to a fixed format to form a joint input sequence, sends it to the pre-trained language model for joint encoding, and outputs the dialogue intent classification result for the current round, distinguishing between two types of intents: jump and follow-up question.

[0139] The terminology popularity calculation module uses semantic role weights to weight the historical frequency of each medical term within a sliding window, and employs an exponential smoothing method to update the dynamic popularity factor of each term online. Based on this, it sorts the candidate standard terms in the standard terminology knowledge base in real time and outputs a ranked list of candidate terms for use in subsequent question standardization steps.

[0140] The question standardization module receives the intent classification results and the candidate term ranking list. Based on the intent type, it performs differentiated standardization processing on the current user input: when the intent is a jump, the module clears the historical dialogue queue and directly outputs the current input as a standardized question; when the intent is a follow-up question, the module first checks whether the current input contains an indicator pronoun. If it does, it determines the medical entity referred to by the pronoun based on the queue context and completes the referential resolution. If it does not contain the pronoun, it infers the main medical entity based on the context and inserts it into the subject position of the question to complete the subject completion. Then, it performs standardized replacement on the medical terms in the question based on the candidate term ranking list and outputs the final standardized question.

[0141] The medical knowledge retrieval module receives standardized questions and performs the retrieval using a two-stage fusion approach combining vector semantic retrieval and keyword retrieval. First, it recalls the top K candidate entries with the highest semantic vector cosine similarity between the standardized questions and knowledge base entries. Then, it performs precise matching and re-ranking of the recalled candidate entries using standard terminology keywords. The module then takes the highest-ranking entry after re-ranking and inputs it into the answer generation submodule to generate a medical question-and-answer response in natural language and return it to the user. Simultaneously, this module records the number of retrieval results for the original input and standardized questions under each path during the retrieval process, which is then used by the quality assessment module.

[0142] The path attribution quality assessment module uses a preset assessment period as a unit. It comprehensively calculates the overall quality confidence score within the current assessment period based on three dimensions: semantic rewriting recall improvement rate, intent classification accuracy, and explicit user feedback on rewriting attribution. Using this score and the normalized recall improvement rate of each path as driving signals, it performs collaborative adaptive online adjustment of the smoothing coefficient α and sliding window length W in the terminology popularity calculation module, forming a closed-loop control link that covers retrieval quality monitoring, parameter feedback updates, and continuous service performance optimization.

[0143] The modules mentioned above can be deployed within the same service process, or they can be divided into independent microservice nodes according to their functions and run in combination through interface calls to adapt to the deployment needs of medical Q&A platforms of different sizes.

[0144] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A medical question-and-answer service method based on artificial intelligence, characterized in that, include: S1. Perform word segmentation and dependency parsing on the medical inquiry text input by the user, extract medical terms and their semantic roles, and append the current input to the historical dialogue queue to form a multi-turn dialogue context; S2. Concatenate the current user input with the most recent historical input in the historical dialogue queue to form a joint input sequence. Input the sequence into the pre-trained language model for joint encoding and classification to obtain the intent classification result. S3. The historical frequency of each medical term is weighted by the semantic role weight of each term, and the dynamic heat factor of each term is calculated by the exponential smoothing method. The candidate standard terms in the standard term knowledge base are sorted based on the dynamic heat factor to obtain the candidate term ranking list. The dynamic heat factor mentioned in step S3 Calculate using the following formula: ; Where t is the current time, For the target medical term whose popularity needs to be calculated, It is the j-th candidate term in the standard terminology knowledge base; For the user input in the k-th round of the dialogue; W is the length of the historical dialogue sliding window referenced for the heat calculation, in the number of dialogue rounds; For the term Semantic role weights in the k-th round of dialogue; For indicator functions, when Appeared in The value is 1 when the condition is met, and 0 otherwise. For smoothing coefficients; This represents the heat factor value of the term at the previous moment; S4. Based on the intent classification results, perform differential question standardization processing on the current user input: If the intention is to jump, clear the history dialogue queue and directly use the current user's input as the standardized question; If the intention is to ask a follow-up question, then the current user input is subject-completed or the pronoun is eliminated by combining the context information in the historical dialogue queue, and the medical terms in the current user input are standardized and replaced according to the candidate term sorting list to obtain a standardized question. S5. Input the standardized question into the medical knowledge retrieval module, obtain the retrieval results, and generate a medical question-and-answer response.

2. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 1, characterized in that, The semantic role weight Three-level assignment based on the semantic role of the term in the sentence: when exist When the core medical entity is in the subject position, When a subordinate medical entity is in the object position or in a parallel structure, When it is a background medical entity modified by an adverbial phrase, .

3. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 1, characterized in that, In step S4, if the intent is to ask a follow-up question, then the current user input is supplemented with subject completion or substitution resolution based on the context information in the historical dialogue queue, specifically including: Detect whether the current user input contains an indicator pronoun; If the pronoun is present, the medical entity referred to by the pronoun is determined by the context information in the history dialogue queue, and the pronoun is replaced with an explicit statement of the corresponding entity. If no demonstrative pronoun is present, the subject medical entity to which the current question refers is inferred from the context information in the history dialogue queue, and the inferred subject entity is added to the subject position of the question.

4. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 3, characterized in that, The method also includes path attribution evaluation of the question-and-answer service quality using a preset evaluation period: At the end of each evaluation period, for the pronoun resolution path and the subject completion path, the number of questions processed by each path during the current evaluation period, and the number of relevant results recalled when each question is directly retrieved from the original input, are counted respectively. The number of relevant results recalled by the search after standardizing and rewriting the question The semantic rewriting recall improvement rate for each path is calculated using the following formula: ; in, The recall improvement rate for semantic rewriting of path p; Each path After historical percentile normalization, the normalized recall improvement rate of the proxy resolution path was obtained. Normalized recall improvement rate compared to subject completion path processing The path attribution comprehensive recall score is obtained by weighting the number of questions processed according to the path: ; in, , These represent the number of questions processed by the pronoun resolution path and the subject completion path within the current evaluation period, respectively. Count the number of positive user feedbacks during the current evaluation period. Total number of feedback Calculate the original user satisfaction ; The rewriting contribution coefficient is calculated based on the proportion of standardized questions for each path to the total number of questions within the current evaluation period. ,in The total number of results retrieved for standardized question retrieval across all rewritten paths. This represents the total number of results retrieved by directly searching the original question across all rewritten paths. To prevent the smoothing constant from having a denominator of zero; by right The contribution level was corrected by rewriting. ; Calculate the overall quality confidence score: ; in, For intent classification accuracy, In order to identify the security threshold, This is an indicator function that indicates when the intent classification accuracy is below a safety threshold. The value is 1 if the condition is met, and 0 otherwise. The penalty coefficient is for intentional misjudgment. The weight coefficients for each dimension satisfy... .

5. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 4, characterized in that, Also includes the basis For smoothing coefficient Perform two-parameter collaborative adaptive adjustment with the sliding window length W: ; ; in, Preset service quality threshold; It is a symbolic function; They are respectively Adjustment step size with W; , These represent the value ranges of the two parameters; The adjusted parameters are applied to the terminology dynamic heat factor calculation in step S3 in the next evaluation cycle.

6. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 1, characterized in that, In step S2, the current user input is concatenated with the most recent historical input to form a joint input sequence, specifically in the following format: ; in, Input for the most recent user in the history dialogue queue; Input for the current user; For classification labeling; Sentence separator.

7. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 1, characterized in that, The historical dialogue queue mentioned in step S1 is a sliding window queue with a maximum window size of N rounds. After each round of question and answer is completed, the user input and system response of the current round are appended to the end of the queue. When the queue length exceeds N, the earliest historical round is automatically deleted, so that the queue always maintains a historical record of no more than N rounds.

8. The method for providing a medical question-and-answer service based on artificial intelligence according to claim 1, characterized in that, In step S5, the medical knowledge retrieval module employs a two-stage fusion retrieval method that combines vector semantic retrieval and keyword retrieval: Based on the cosine similarity of the semantic vectors of standardized questions and knowledge base entries, the top K candidate entries with the highest similarity are recalled, where K is the preset upper limit of the number of entries to be recalled. Perform exact matching and re-ranking of the K recalled candidate entries using standard terminology keywords, and take the candidate entry with the highest ranking after re-ranking as the search result.

9. A medical question-and-answer service system based on artificial intelligence, characterized in that, The system is used to implement the method according to any one of claims 1-8, the system comprising: The text preprocessing module is used to perform word segmentation and dependency parsing on the medical inquiry text input by the user, extract medical terms and their semantic roles, and append the current input to the historical dialogue queue to form a multi-turn dialogue context; The intent classification module is used to concatenate the current user input with the most recent historical input in the historical dialogue queue to form a joint input sequence, which is then input into a pre-trained language model for joint encoding and classification to obtain the intent classification result. The terminology popularity calculation module is used to weight the historical frequency of each medical term by the semantic role weight of each term, calculate the dynamic popularity factor of each term using the exponential smoothing method, and sort the candidate standard terms in the standard terminology knowledge base based on the dynamic popularity factor to obtain a ranked list of candidate terms. The question standardization module is used to perform differentiated question standardization processing on the current user input based on the intent classification results: if the intent is a jump, the historical dialogue queue is cleared and the current user input is directly used as the standardized question; if the intent is a follow-up question, the current user input is supplemented with subject completion or substitution resolution based on the context information in the historical dialogue queue, and the medical terms in the current user input are standardized and replaced according to the candidate term ranking list to obtain the standardized question. The medical knowledge retrieval module is used to receive standardized questions, perform searches, and generate medical question-and-answer responses.