A medical inquiry intention recognition method, device, equipment and medium

By combining the BERT model in the medical field with a large language model, and dynamically adjusting the fusion weights of local and global semantic features, the problem of low accuracy of a single BERT model in medical consultation is solved, and more efficient intent recognition is achieved.

CN122433752APending Publication Date: 2026-07-21GUANGZHOU FANGZHOU INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGZHOU FANGZHOU INFORMATION TECHNOLOGY CO LTD
Filing Date
2026-04-20
Publication Date
2026-07-21

Smart Images

  • Figure CN122433752A_ABST
    Figure CN122433752A_ABST
Patent Text Reader

Abstract

The application discloses a medical inquiry intention recognition method, device, equipment and medium, by introducing a feature vector representing the complexity of the text to dynamically control the fusion weight of the local semantic feature (from the medical field BERT model) and the global semantic feature (from the large language model), the problem that the prior art cannot adaptively adjust the model focus according to the characteristics of the inquiry text is solved. When the text is complex, the system automatically gives a higher weight to the large language model which is better at processing complex semantics and long dependencies to grasp the global intention; when the text is simple, the medical field BERT model which is more efficient in calculation and accurate in local understanding is more focused. This dynamic weighting fusion mechanism effectively combines the precise understanding ability of the special-purpose model in the field and the advantages of the general large model in processing complex texts and macro context, significantly improving the accuracy of medical inquiry intention recognition in various complexity text scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to intelligent medical technology, and more particularly to a method, apparatus, device, and medium for recognizing medical consultation intent. Background Technology

[0002] In intelligent medical question-and-answer and triage systems, accurately identifying the patient's intent in natural language consultation is a key prerequisite for achieving efficient human-computer interaction, precise triage, and automation of subsequent medical processes.

[0003] In existing technologies, the task of medical consultation intent recognition mainly relies on a single pre-trained language model (such as the BERT model based on the Transformer architecture) for intent classification. These models, pre-trained on general corpora, can capture local semantic features in text well and have a good understanding ability for short texts with clear structure and direct expression.

[0004] However, the single BERT model has the following technical limitations when faced with complex and ever-changing medical consultation texts: 1. Insufficient understanding of medical terminology: Despite fine-tuning, the general BERT model still lacks the ability to understand the deep semantic relationships of high-density, highly specialized medical terms, and is prone to misclassifying consultation texts containing similar words but with different intentions.

[0005] 2. Limited ability to grasp the global semantics of complex text: When the consultation text contains complex syntactic structures (such as multiple nested clauses) and long-distance contextual dependencies (such as the problem of referential resolution: "My mother has a headache and she has not slept well these past two days"), a single model is difficult to effectively capture the macro-intention that runs through the whole text, resulting in a decrease in recognition accuracy.

[0006] 3. Lack of adaptive mechanisms for text complexity: Existing solutions employ fixed feature extraction and fusion strategies for all input texts, failing to dynamically adjust the processing focus based on the complexity of the text itself (such as sentence length, number of terms, and grammatical complexity). Applying the same processing model to both simple questions and complex, lengthy descriptions is clearly inefficient and inaccurate. Summary of the Invention

[0007] This invention provides a method, apparatus, device, and medium for medical consultation intent recognition, in order to solve the problem that a single model in the prior art cannot simultaneously take into account the accuracy of local semantic understanding and the ability to grasp global semantics, and cannot adapt to the text complexity for adjustment, thereby achieving more accurate medical consultation intent recognition.

[0008] In a first aspect, the present invention provides a method for recognizing medical consultation intent, comprising: Obtain the consultation text entered by the user; The first local semantic features are extracted from the consultation text using the BERT model in the medical field. The first global semantic feature is extracted from the consultation text using a large language model; Extract the first feature vector representing the text complexity from the consultation text; The first feature vector is mapped to the first dynamic weight of the first local semantic feature and the second dynamic weight of the first global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1; The first local semantic feature and the first global semantic feature are weighted and fused using the first dynamic weight and the second dynamic weight to obtain the first fused feature; The first fused feature is mapped to the intent category space of medical consultation intent recognition to predict the user's consultation intent.

[0009] Optionally, mapping the first feature vector to a first dynamic weight of the first local semantic feature and a second dynamic weight of the first global semantic feature includes: The first feature vector is input into a fully connected layer for mapping, and the first feature vector is mapped into 2-dimensional logits; Normalizing the 2D logits yields the first dynamic weight of the first local semantic feature and the second dynamic weight of the first global semantic feature.

[0010] Optionally, the first feature vector representing text complexity includes the sentence length dimension, the medical term density dimension, the syntax tree depth dimension, and the context dependency length dimension; Extracting a first feature vector representing the text complexity from the consultation text includes: The consultation text is segmented into sentences; The clauses are segmented into words, and the total number of words in all clauses is counted. The average sentence length is obtained by calculating the quotient of the total number of word segments and the number of sentences. The average sentence length is normalized by using the maximum and minimum sentence lengths in the medical corpus to obtain the sentence length dimension of the first feature vector.

[0011] Optionally, a first feature vector representing the text complexity is extracted from the consultation text, including: The consultation text is segmented into words to obtain the total number of words in the consultation text; Identify medical terms from the segmented words and count the total number of the medical terms; The ratio of the total number of medical terms to the total number of word segments is calculated to obtain the medical term density dimension of the first feature vector.

[0012] Optionally, a first feature vector representing the text complexity is extracted from the consultation text, including: The consultation text is segmented into sentences; The sentence is parsed syntactically to obtain the dependency syntax tree of the sentence, with ROOT as the root and word segments as nodes; The depth of the dependency syntax tree is determined by counting the number of nodes on the longest path from the root of the dependency syntax tree to any leaf node. Calculate the average depth of the dependency syntax tree for all clauses to obtain the average syntax tree depth; The quotient of the average syntactic tree depth and the maximum syntactic tree depth recorded in the medical corpus is calculated to obtain the syntactic tree depth dimension of the first feature vector.

[0013] Optionally, a first feature vector representing the text complexity is extracted from the consultation text, including: The consultation text is subjected to referential resolution, and different referential words in the consultation text that refer to the same entity are divided into the same referential chain; In the same chain of reference, for each pronoun, the number of sentences between the pronoun and its antecedent is calculated as the reference distance of the pronoun; Calculate the average referential distance of all pronouns as the average referential distance; The context-dependent length dimension of the first feature vector is obtained by calculating the quotient of the average referential distance and the maximum referential distance recorded in the medical corpus.

[0014] Optionally, before obtaining the user-inputted consultation text, the medical consultation intent recognition method further includes: Obtain a training dataset, which contains multiple consultation text samples and consultation intent labels corresponding to each consultation text sample; The second local semantic features are extracted from the consultation text samples using the BERT model in the medical field. A second global semantic feature is extracted from the consultation text sample using a large language model; Extract a second feature vector representing the text complexity from the consultation text sample; The second feature vector of the consultation text sample is input into a trainable gating network, and the gating network outputs the first dynamic weight of the second local semantic feature and the second dynamic weight of the second global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1. The second local semantic feature and the second global semantic feature are weighted and fused using the first dynamic weight and the second dynamic weight to obtain the second fused feature; The second fusion feature is input into the intent classification layer to obtain the prediction result of the consultation text sample; The loss function value is calculated based on the prediction results of the consultation text sample and the consultation intent label of the consultation text sample; The parameters of the gating network and the intent classification layer are updated end-to-end through the backpropagation algorithm, so that the trained gating network outputs a larger second dynamic weight for consultation text samples with high text complexity and a larger first dynamic weight for consultation text samples with low text complexity.

[0015] Secondly, the present invention also provides a medical consultation intent recognition device, comprising: The consultation text acquisition module is used to acquire the consultation text input by the user; The local feature extraction module is used to extract local semantic features from the consultation text using the BERT model in the medical field. A global feature extraction module is used to extract global semantic features from the consultation text using a large language model; The feature vector extraction module is used to extract feature vectors representing the complexity of the text from the consultation text; The weight generation module is used to map the feature vector to a first dynamic weight of the local semantic feature and a second dynamic weight of the global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1. The feature fusion module is used to weight and fuse the local semantic features and the global semantic features using the first dynamic weight and the second dynamic weight to obtain fused features; The consultation intent prediction module is used to map the fused features to the intent category space of medical consultation intent recognition, and predict the user's consultation intent.

[0016] Thirdly, the present invention also provides an electronic device, comprising: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the medical consultation intent recognition method as described in the first aspect of the present invention.

[0017] Fourthly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that, when the program is executed by a processor, it implements the medical consultation intent recognition method as described in the first aspect of the present invention.

[0018] The medical consultation intent recognition method provided by this invention dynamically adjusts the fusion weights of local semantic features (from a medical domain BERT model) and global semantic features (from a large language model) by introducing feature vectors representing text complexity. This solves the problem that existing technologies cannot adaptively adjust the model's emphasis based on the characteristics of the consultation text itself. When the text is complex, the system automatically assigns higher weights to the large language model, which is better at handling complex semantics and long dependencies, to grasp the global intent; when the text is simple, it places more emphasis on the computationally efficient and locally accurate medical domain BERT model. This dynamic weighted fusion mechanism effectively combines the domain-specific model's accurate understanding capabilities with the general large model's advantages in handling complex text and macro-context, significantly improving the accuracy of medical consultation intent recognition in various text complexity scenarios.

[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.

[0021] Figure 1 A flowchart of a medical consultation intent recognition method provided by the present invention; Figure 2 This invention provides a network architecture diagram for a medical consultation intent recognition model. Figure 3 This is a schematic diagram of the structure of a medical consultation intent recognition device provided by the present invention; Figure 4 This is a schematic diagram of the structure of an electronic device provided by the present invention.

[0022] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0025] Figure 1 This is a flowchart illustrating a medical consultation intent recognition method provided by the present invention. This embodiment is applicable to scenarios where the medical intent of a user is automatically recognized based on natural language consultation text input by the user. This method can be executed by the medical consultation intent recognition device provided by the present invention. This device can be implemented in software and / or hardware, and is typically configured in an electronic device, such as... Figure 1 As shown, this medical consultation intent recognition method includes the following steps: S101. Obtain the consultation text input by the user.

[0026] In this embodiment of the invention, the consultation text input by the user refers to natural language text obtained by the user through keyboard input or speech recognition conversion in the dialogue interface of an intelligent consultation system, medical consultation application, or webpage. For example, "I've been feeling dizzy and nauseous for the past two days, what's wrong?" or "I'd like to book an appointment with a cardiology specialist tomorrow morning," etc.

[0027] S102. Use the BERT model in the medical field to extract the first local semantic features from the consultation text.

[0028] Figure 2 The network architecture diagram of a medical consultation intent recognition model provided by the present invention is as follows: Figure 2 As shown, Figure 2As shown, the medical domain's BERT (Bidirectional Encoder Representations from Transformers) model is used to extract local semantic features (Vbert) from the consultation text (Qtext), referred to as the first local semantic features. The BERT model is a pre-trained language model based on Transformers. This invention uses a medical domain BERT model, which is further pre-trained or fine-tuned using large-scale medical domain corpora (such as medical literature, electronic medical records, and medical encyclopedias) on top of a general BERT model (such as BERT-base). Therefore, it has a stronger semantic representation ability for medical terminology, symptom descriptions, and drug names.

[0029] For example, the acquired consultation text (Qtext) is tokenized and then input into a pre-trained BERT model for the medical domain. This model uses its multi-layer Transformer encoder to perform deep bidirectional encoding on the text sequence, ultimately outputting a feature vector that represents the overall local semantic information of the input text. Typically, the vector corresponding to the [CLS] tokens output by the model can be taken as a local semantic feature to represent fine-grained, local structural and semantic information in the text. This includes: word meaning and context-dependent meaning: the precise semantics of each word in its local context (usually several adjacent words or a short phrase), such as the different meanings of "cell" in "red blood cell" and "cell wall"; part-of-speech, morphology, and phrase structure: such as the identification of nouns and verbs, and local syntactic combinations such as noun phrases and verb phrases; local dependencies: the modification relationships, subject-predicate relationships, and verb-object relationships between adjacent words, such as the adjective-noun dependency in "severe headache"; terms and entity boundaries: the BERT model can capture the start and end positions of medical terms, as well as the constraints of local context on terms, through self-attention.

[0030] S103. Use a large language model to extract the first global semantic features from the consultation text.

[0031] In this embodiment of the invention, a Large Language Model (LLM) is used to extract global semantic features Vllm from the consultation text Qtext, referred to as the first global semantic feature. Here, a Large Language Model refers to an autoregressive language model (such as the GPT series, Llama, Qwen3 series, etc.) trained on a massive general-purpose corpus with a huge number of parameters (typically in the billions to trillions). Compared to the BERT model, the Large Language Model has a deeper network structure and stronger long sequence modeling capabilities, excelling at understanding complex contextual relationships, performing logical reasoning, and capturing the macro-themes and intentions of the text.

[0032] For example, the consultation text (Qtext) is input as a prompt into the large language model. The large language model performs forward propagation over the entire text sequence using a causal attention mechanism. The output of the last hidden state, corresponding to the end of the text or a special extraction marker, can be projected into a high-dimensional vector as a global semantic feature. This feature can better summarize the global intent and contextual dependencies of the consultation text, including: the overall theme and core intent: for example, even if sentences describe multiple symptoms in a consultation text, LLM can still summarize the overall intent as "possibly a cardiovascular disease consultation"; and long-distance semantic dependencies: causal relationships, conditional relationships, and adversative relationships spanning multiple sentences. For example, “The patient had surgery three years ago and is now experiencing fever”—LLM can link the potential connection between “surgical history” and “fever”; implicit common sense or medical knowledge: using knowledge learned in pre-training to fill in background information not explicitly stated in the text, such as “fasting blood glucose 7.0” which may imply “diabetes”; text structure and logical flow: understanding the order between paragraphs, the relationship between general and specific points, question and answer structure, etc., rather than just the relationship between individual words; abstraction and generalized representation: mapping texts of different lengths and expressions to a fixed-dimensional semantic space, facilitating classification or generation tasks.

[0033] S104. Extract the first feature vector representing the text complexity from the consultation text.

[0034] In this embodiment of the invention, text complexity is a key indicator for measuring the ease of understanding medical consultation text. Unlike existing technologies that treat all texts equally, this embodiment introduces a multi-dimensional feature vector C to quantify and evaluate text complexity. In an optional embodiment of the invention, the feature vector C characterizing text complexity includes at least the following dimensions: sentence length dimension, medical terminology density dimension, syntactic tree depth dimension, and context dependency length dimension. By quantifying these dimensions, the structural and semantic complexity of the medical consultation text can be comprehensively characterized from different perspectives.

[0035] In some embodiments of the present invention, such as Figure 2 As shown, a feature extraction layer is used to extract feature vectors representing text complexity. The extraction process is as follows: S1041. Extract sentence length dimension features.

[0036] Sentence length is one of the fundamental metrics for measuring text complexity. Sentences that are too long or too short can affect the accuracy of intent recognition. The specific steps are as follows: 1. Segment the consultation text using Qtext. For example, sentence segmenters such as nltk or spacy can be used to segment sentences based on punctuation marks such as periods, question marks, and exclamation marks.

[0037] 2. Perform word segmentation on each clause and count the total number of words in all clauses. For example, jieba (word-level) can be used for Chinese, and tools such as nltk.tokenize.word_tokenize can be used for English.

[0038] 3. Calculate the quotient of the total number of word segments and the number of sentences to obtain the average sentence length.

[0039] 4. To eliminate scale differences caused by different corpora, the average sentence length is normalized using the maximum and minimum sentence lengths from the medical corpus, resulting in the sentence length dimension of the feature vector. The normalization formula is, for example: (average sentence length - minimum length) / (maximum length - minimum length).

[0040] S1042. Extract the density dimension features of medical terminology.

[0041] The density of medical terminology reflects the professionalism and information content of a text. High-density medical terminology usually means that the text is more difficult to understand and requires the assistance of global semantic information. The specific steps are as follows: 1. Perform word segmentation on the consultation text Qtext to obtain the total number of words in the consultation text.

[0042] 2. Based on a pre-built medical terminology database (e.g., a terminology table integrating terms such as SNOMED CT, ICD-11, MedDRA, etc.), medical terms are identified and marked from word segmentation using dictionary matching, and the total number of medical terms is counted.

[0043] 3. Calculate the quotient of the total number of medical terms and the total number of word segments to obtain the medical term density dimension of the feature vector. This value is a floating-point number between 0 and 1.

[0044] S1043. Extract the deep dimension features of the syntax tree.

[0045] The depth of the syntax tree reflects the complexity of the grammatical structure of the statement. The deeper the tree, the more nested modifiers and clauses there are, and the more difficult it is to understand. The specific steps are as follows: 1. Segment the consultation text (Qtext).

[0046] 2. Perform syntactic parsing on each clause (e.g., using Stanford CoreNLP, HanLP, or other natural language processing tools) to obtain the dependency syntax tree of the clause. The dependency syntax tree has ROOT as the root node and the word segment as other nodes.

[0047] 3. For each dependency syntax tree, count the number of nodes on the longest path from the root node (ROOT) to any leaf node, and use this number of nodes as the depth of the dependency syntax tree.

[0048] 4. Calculate the average depth of the dependency syntactic tree for all clauses to obtain the average syntactic tree depth.

[0049] 5. Calculate the quotient of the average syntax tree depth and the maximum syntax tree depth recorded in the medical corpus to obtain the syntax tree depth dimension of the feature vector. This value is also a value normalized to the interval [0, 1].

[0050] S1044. Extract context-dependent length dimension features.

[0051] Context dependency length, especially when measured by the distance of reference resolution, reflects the complexity of how information in a text is related across sentences. The greater the dependency distance, the more difficult it is to understand the macro-logical meaning of the text. The specific steps are as follows: 1. Perform coreference resolution on the consultation text Qtext, and group different pronouns in the consultation text that refer to the same entity (such as "my mother" or "she") into the same coreference chain.

[0052] 2. In the same chain of reference, for each pronoun other than its antecedent (the entity reference that appears for the first time), calculate the number of sentences that separate the pronoun from its antecedent. This number is used as the referential distance of the pronoun.

[0053] 3. Calculate the average referential distance of all pronouns as the average referential distance.

[0054] 4. Calculate the quotient of the average referential distance and the maximum referential distance recorded in the medical corpus to obtain the context-dependent length dimension of the feature vector, thereby normalizing the value to the interval [0, 1].

[0055] Through feature extraction from one or more dimensions, a multi-dimensional feature vector representing the complexity of the text can be formed. For example, a four-dimensional vector [Llen, Dterm, Dsyn, Ldep]. This vector comprehensively and objectively describes the complexity of the consultation text, providing a precise basis for the subsequent generation of dynamic weights.

[0056] S105. Map the first feature vector to the first dynamic weight of the first local semantic feature and the second dynamic weight of the first global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1.

[0057] In this embodiment of the invention, the first feature vector is mapped to a first dynamic weight of the first local semantic feature and a second dynamic weight of the first global semantic feature, and the sum of the first dynamic weight and the second dynamic weight is 1.

[0058] For example, such as Figure 2As shown, this step uses a lightweight gating network (e.g., one or more fully connected layers) to generate weights. As an optional embodiment, the mapping process includes: inputting the feature vector C into the fully connected layer for mapping, transforming the feature vector into 2-dimensional logits; subsequently, normalizing the 2-dimensional logits using the Softmax function to obtain two weight values ​​ranging from (0, 1) and summing to 1, namely the first dynamic weight α of the local semantic feature Vbert and the second dynamic weight β of the global semantic feature Vllm. Specifically, the mathematical formula is expressed as: in, This is the weight matrix of the gated network, which is also the mapping matrix in the fully connected layer. This is the bias term for the gated network.

[0059] The core of this dynamic weight is that when the feature vector represents a high level of text complexity (e.g., long sentences, many terms, complex syntactic structures), the network will learn and output a higher second dynamic weight β, making subsequent fusion more focused on global semantic features; conversely, when the text is simple, it will output a higher first dynamic weight α.

[0060] S106. The first local semantic feature and the first global semantic feature are weighted and fused using the first dynamic weight and the second dynamic weight to obtain the first fused feature.

[0061] In this embodiment of the invention, the first local semantic feature Vbert and the first global semantic feature Vllm are weighted and fused using the first dynamic weight α and the second dynamic weight β to obtain the fused feature Vfused, which is called the first fused feature.

[0062] For example, such as Figure 2 As shown, in the feature fusion layer, the first local semantic feature Vbert and the first global semantic feature Vllm are weighted and fused using the first dynamic weight α and the second dynamic weight β. The calculation formula for the fused feature is as follows: Through this adaptive dynamic weighting, the fusion feature Vfused can optimally combine the advantages of the two models based on the complexity of the text.

[0063] S107. Map the first fusion feature to the intent category space of medical consultation intent recognition to predict the user's consultation intent.

[0064] In this embodiment of the invention, the first fused feature is mapped to the intent category space of medical consultation intent recognition to predict the user's consultation intent. For example... Figure 2As shown, in this embodiment of the invention, the fused feature Vfused obtained in step S160 is input into the intent classification layer. This intent classification layer typically consists of a fully connected layer followed by a Softmax activation function, and its output dimension is equal to the number of predefined medical consultation intent categories (e.g., including N categories such as "consultation", "prescription", "report interpretation", "appointment", and "transfer to human agent"). The Softmax function outputs a probability value p for each intent category, and the category with the highest probability is selected as the final predicted user's consultation intent.

[0065] The medical consultation intent recognition method provided by this invention dynamically adjusts the fusion weights of local semantic features (from a medical domain BERT model) and global semantic features (from a large language model) by introducing feature vectors representing text complexity. This solves the problem that existing technologies cannot adaptively adjust the model's emphasis based on the characteristics of the consultation text itself. When the text is complex, the system automatically assigns higher weights to the large language model, which is better at handling complex semantics and long dependencies, to grasp the global intent; when the text is simple, it places more emphasis on the computationally efficient and locally accurate medical domain BERT model. This dynamic weighted fusion mechanism effectively combines the domain-specific model's accurate understanding capabilities with the general large model's advantages in handling complex text and macro-context, significantly improving the accuracy of medical consultation intent recognition in various text complexity scenarios.

[0066] In some embodiments of the present invention, the medical consultation intent recognition model can be pre-trained before applying the medical consultation intent recognition method of the present invention. The specific training process is as follows: S201. Obtain the training dataset. The training dataset contains multiple consultation text samples and consultation intent labels corresponding to each consultation text sample.

[0067] In this embodiment of the invention, a batch of consultation text samples labeled with intent categories and covering different levels of complexity are obtained as a training dataset. The dataset must contain various texts ranging from extremely simple to extremely complex; otherwise, the model cannot learn to adjust weights according to complexity.

[0068] S202. Use the BERT model in the medical field to extract second local semantic features from the consultation text samples.

[0069] The extraction process of this local semantic feature is similar to that of the local semantic feature extraction process in the aforementioned embodiments, and will not be described again here.

[0070] S203. Use a large language model to extract the second global semantic features from the consultation text samples.

[0071] The extraction process of the global semantic features is similar to that of the global semantic features extraction process in the aforementioned embodiments, and will not be described again here.

[0072] S204. Extract the second feature vector representing the text complexity from the consultation text sample.

[0073] The feature vector extraction process is similar to the feature vector extraction process in the aforementioned embodiments, and will not be described again here.

[0074] S205. Input the second feature vector of the consultation text sample into a trainable gating network. The gating network outputs the first dynamic weight of the second local semantic feature and the second dynamic weight of the second global semantic feature. The sum of the first dynamic weight and the second dynamic weight is 1.

[0075] In this embodiment of the invention, the second feature vector of the consultation text sample is input into a trainable gating network. The gating network outputs the first dynamic weight of the second local semantic feature and the second dynamic weight of the second global semantic feature, and the sum of the first dynamic weight and the second dynamic weight is 1. The results and processing of the gating network have been described in detail in the foregoing embodiments, and will not be repeated here.

[0076] In an optional embodiment of the present invention, the feature vector C characterizing text complexity includes at least the following dimensions: sentence length dimension, medical terminology density dimension, syntax tree depth dimension, and context dependency length dimension. By quantifying these dimensions, the structural and semantic complexity of the consultation text can be comprehensively characterized from different perspectives.

[0077] S206. The second local semantic feature and the second global semantic feature are weighted and fused using the first dynamic weight and the second dynamic weight to obtain the second fused feature.

[0078] S207. Input the second fusion feature into the intent classification layer to obtain the prediction result of the consultation text sample.

[0079] In this embodiment of the invention, the second fused feature is input into the intent classification layer, which typically consists of a fully connected layer followed by a Softmax activation function. Its output dimension is equal to the predefined number of medical consultation intent categories. The Softmax function outputs the probability value for each intent category, and the category with the highest probability is selected as the prediction result for the consultation text sample.

[0080] S208. Calculate the loss function value based on the prediction results of the consultation text samples and the consultation intent labels of the consultation text samples.

[0081] In this embodiment of the invention, the standard cross-entropy loss function is used to calculate the loss function value, and the calculation formula is as follows: in, It is a true intent label. It is the second fusion feature. It is the probability value of a positive sample output by the intention classification layer.

[0082] S209. Through the backpropagation algorithm, the parameters of the gating network and the parameters of the intent classification layer are updated end-to-end, so that the trained gating network outputs a larger second dynamic weight for consultation text samples with high text complexity and a larger first dynamic weight for consultation text samples with low text complexity.

[0083] Calculate the gradient of the loss function value with respect to all trainable parameters, including the weight matrix in the gated network. Bias terms The parameters of the intent classification layer, as well as the partially unfrozen parameters of BERT and LLM, are then updated based on the gradients. This process is repeated across the entire training set until the loss function value is less than a threshold.

[0084] During training, the gating network's training process is entirely driven by the classification loss. It does not require the first dynamic weights. The second dynamic weight β is designed with additional constraints. It only requires providing labeled data covering different complexities, and the gradient will naturally guide the model to learn: BERT is often used for simple diagnostic texts (first dynamic weight β). For complex medical texts, LLM (with a large second dynamic weight β) is often used to maximize classification accuracy. This is precisely the advantage of the dynamic weight mechanism—adaptive, task-oriented, and end-to-end learning.

[0085] For low-complexity text samples with short sentences, no technical terms, low syntactic depth, and no cross-sentence referencing, such as "headache," if the gating network incorrectly assigns a large second dynamic weight β, the fused vector... LLM is dominated by global semantics. However, LLM may introduce unnecessary abstractions or noise into very short texts, making it difficult for the intent classification layer to distinguish correctly, thus increasing the loss. If a large first dynamic weight is given... (Use BERT frequently). BERT's local features can accurately capture the semantics of the word "headache," resulting in high classification accuracy and lower loss. Gradient updates will drive... This allows for a larger first dynamic weight output when the text complexity is low. And a smaller second dynamic weight β.

[0086] For texts with high complexity, such as long sentences, numerous terms ("hypertension and diabetes", "heart failure", "chest tightness and shortness of breath"), deep syntactic nesting, and cross-sentence references ("patient...the patient..."), if the gating network incorrectly assigns a large first dynamic weight... BERT, limited by local context windows and shallow interactions, struggles to integrate cues scattered across different sentences (such as the causal relationship between medical history and current symptoms), leading to classification errors and increased loss. With a larger second dynamic weight β, LLM can model complex dependencies across sentences and understand medical associations between terms, thus achieving accurate classification and reducing loss. Gradient updates drive... This results in a larger second dynamic weight β and a smaller first dynamic weight when the text complexity is high. .

[0087] Figure 3 This is a schematic diagram of the structure of a medical consultation intent recognition device provided by the present invention, as shown below. Figure 3 As shown, the medical consultation intent recognition device includes: The consultation text acquisition module 101 is used to acquire the consultation text input by the user; Local feature extraction module 102 is used to extract local semantic features from the consultation text using the BERT model in the medical field; The global feature extraction module 103 is used to extract global semantic features from the consultation text using a large language model; Feature vector extraction module 104 is used to extract feature vectors representing text complexity from the consultation text; The weight generation module 105 is used to map the feature vector to a first dynamic weight of the local semantic feature and a second dynamic weight of the global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1. Feature fusion module 106 is used to weight and fuse the local semantic features and the global semantic features using the first dynamic weight and the second dynamic weight to obtain fused features; The consultation intent prediction module 107 is used to map the fused features to the intent category space of medical consultation intent recognition, and predict the user's consultation intent.

[0088] In some embodiments of the present invention, the weight generation module 105 includes: The first mapping submodule is used to input the first feature vector into the fully connected layer for mapping, and to map the first feature vector into 2-dimensional logits; The first normalization submodule is used to normalize the 2-dimensional logits to obtain the first dynamic weight of the first local semantic feature and the second dynamic weight of the first global semantic feature.

[0089] In some embodiments of the present invention, the first feature vector characterizing text complexity includes sentence length dimension, medical terminology density dimension, syntax tree depth dimension, and context dependency length dimension. The feature vector extraction module 104 includes: The first sentence segmentation module is used to segment the consultation text into sentences; The first word segmentation submodule is used to segment the sentences and count the total number of words in all sentences; The average sentence length calculation submodule is used to calculate the quotient of the total number of word segments and the number of sentences to obtain the average sentence length; The second normalization submodule is used to normalize the average sentence length by using the maximum and minimum sentence lengths in the medical corpus to obtain the sentence length dimension of the first feature vector.

[0090] In some embodiments of the present invention, the feature vector extraction module 104 includes: The second word segmentation submodule is used to segment the consultation text into words to obtain the total number of words in the consultation text; The terminology recognition submodule is used to identify medical terms from the word segmentation and count the total number of medical terms. The terminology density calculation submodule is used to calculate the quotient of the total number of medical terms and the total number of word segments to obtain the medical terminology density dimension of the first feature vector.

[0091] In some embodiments of the present invention, the feature vector extraction module 104 includes: The second sentence segmentation module is used to segment the consultation text into sentences; The syntactic parsing submodule is used to perform syntactic parsing on the sentence to obtain the dependency syntax tree of the sentence, wherein the dependency syntax tree is rooted at ROOT and the word segment is a node; The depth statistics submodule is used to count the number of nodes on the longest path from the root of the dependency syntax tree to any leaf node, which is taken as the depth of the dependency syntax tree. The average depth calculation submodule is used to calculate the average depth of the dependency syntax tree of all clauses, and obtain the average syntax tree depth. The syntax tree depth calculation submodule is used to calculate the quotient of the average syntax tree depth and the maximum syntax tree depth recorded in the medical corpus to obtain the syntax tree depth dimension of the first feature vector.

[0092] In some embodiments of the present invention, the feature vector extraction module 104 includes: The submodule for resolving pronouns is used to resolve pronouns in the consultation text, and to divide different pronouns in the consultation text that refer to the same entity into the same pronoun chain; The submodule for calculating the reference distance is used to calculate the number of sentences between the reference word and its antecedent as the reference distance of the reference word for each reference word in the same reference chain. The average distance calculation submodule is used to calculate the average of the referential distances of all pronouns as the average referential distance; The dependency length calculation submodule is used to calculate the quotient of the average referential distance and the maximum referential distance recorded in the medical corpus to obtain the context dependency length dimension of the first feature vector.

[0093] In some embodiments of the present invention, the medical consultation intent recognition device further includes: The dataset acquisition module is used to acquire a training dataset before acquiring the user-input consultation text. The training dataset contains multiple consultation text samples and consultation intent labels corresponding to each consultation text sample. The first extraction module is used to extract second local semantic features from the consultation text sample using the BERT model in the medical field; The second extraction module is used to extract second global semantic features from the consultation text sample using a large language model; The third extraction module is used to extract a second feature vector representing the text complexity from the consultation text sample; The weight output module is used to input the second feature vector of the consultation text sample into a trainable gating network. The gating network outputs the first dynamic weight of the second local semantic feature and the second dynamic weight of the second global semantic feature. The sum of the first dynamic weight and the second dynamic weight is 1. The weighted fusion module is used to weight and fuse the second local semantic feature and the second global semantic feature using the first dynamic weight and the second dynamic weight to obtain the second fused feature; The structure prediction module is used to input the second fused feature into the intent classification layer to obtain the prediction result of the consultation text sample; The loss calculation module is used to calculate the loss function value based on the prediction result of the consultation text sample and the consultation intent label of the consultation text sample; The parameter update module is used to update the parameters of the gating network and the parameters of the intent classification layer end-to-end through the backpropagation algorithm, so that the trained gating network outputs a larger second dynamic weight for consultation text samples with high text complexity and a larger first dynamic weight for consultation text samples with low text complexity.

[0094] The aforementioned medical consultation intent recognition device can execute the medical consultation intent recognition method provided in the foregoing embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the medical consultation intent recognition method.

[0095] Figure 4 This is a schematic diagram of an electronic device provided by the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0096] like Figure 4 As shown, the electronic device includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer programs stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0097] Multiple components in the electronic device are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, optical disk, etc.; and a communication unit 19, such as a network card, modem, wireless transceiver, etc. The communication unit 19 allows the electronic device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0098] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as medical consultation intent recognition methods.

[0099] In some embodiments, the medical consultation intent recognition method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on an electronic device via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the medical consultation intent recognition method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the medical consultation intent recognition method by any other suitable means (e.g., by means of firmware).

[0100] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0101] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0102] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0103] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0104] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0105] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0106] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the medical consultation intent recognition method provided in any embodiment of this application.

[0107] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0108] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0109] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for recognizing intent during medical consultation, characterized in that, include: Obtain the consultation text entered by the user; The first local semantic features are extracted from the consultation text using the BERT model in the medical field. The first global semantic feature is extracted from the consultation text using a large language model; Extract the first feature vector representing the text complexity from the consultation text; The first feature vector is mapped to the first dynamic weight of the first local semantic feature and the second dynamic weight of the first global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1; The first local semantic feature and the first global semantic feature are weighted and fused using the first dynamic weight and the second dynamic weight to obtain the first fused feature; The first fused feature is mapped to the intent category space of medical consultation intent recognition to predict the user's consultation intent.

2. The medical consultation intent recognition method according to claim 1, characterized in that, Mapping the first feature vector to a first dynamic weight of the first local semantic feature and a second dynamic weight of the first global semantic feature includes: The first feature vector is input into a fully connected layer for mapping, and the first feature vector is mapped into 2-dimensional logits; Normalizing the 2D logits yields the first dynamic weight of the first local semantic feature and the second dynamic weight of the first global semantic feature.

3. The medical consultation intent recognition method according to claim 1, characterized in that, The first feature vector representing text complexity includes sentence length dimension, medical terminology density dimension, syntax tree depth dimension, and context dependency length dimension; Extracting a first feature vector representing the text complexity from the consultation text includes: The consultation text is segmented into sentences; The clauses are segmented into words, and the total number of words in all clauses is counted. The average sentence length is obtained by calculating the quotient of the total number of word segments and the number of sentences. The average sentence length is normalized by using the maximum and minimum sentence lengths in the medical corpus to obtain the sentence length dimension of the first feature vector.

4. The medical consultation intent recognition method according to claim 3, characterized in that, Extracting a first feature vector representing text complexity from the consultation text also includes: The consultation text is segmented into words to obtain the total number of words in the consultation text; Identify medical terms from the segmented words and count the total number of the medical terms; The ratio of the total number of medical terms to the total number of word segments is calculated to obtain the medical term density dimension of the first feature vector.

5. The medical consultation intent recognition method according to claim 3, characterized in that, Extracting a first feature vector representing text complexity from the consultation text also includes: The consultation text is segmented into sentences; The sentence is parsed syntactically to obtain the dependency syntax tree of the sentence, with ROOT as the root and word segments as nodes; The depth of the dependency syntax tree is determined by counting the number of nodes on the longest path from the root of the dependency syntax tree to any leaf node. Calculate the average depth of the dependency syntax tree for all clauses to obtain the average syntax tree depth; The quotient of the average syntactic tree depth and the maximum syntactic tree depth recorded in the medical corpus is calculated to obtain the syntactic tree depth dimension of the first feature vector.

6. The medical consultation intent recognition method according to claim 3, characterized in that, Extracting a first feature vector representing text complexity from the consultation text also includes: The consultation text is subjected to referential resolution, and different referential words in the consultation text that refer to the same entity are divided into the same referential chain; In the same chain of reference, for each pronoun, the number of sentences between the pronoun and its antecedent is calculated as the reference distance of the pronoun; Calculate the average referential distance of all pronouns as the average referential distance; The context-dependent length dimension of the first feature vector is obtained by calculating the quotient of the average referential distance and the maximum referential distance recorded in the medical corpus.

7. The medical consultation intent recognition method according to any one of claims 1-6, characterized in that, Before obtaining the user's input consultation text, the process also includes: Obtain a training dataset, which contains multiple consultation text samples and consultation intent labels corresponding to each consultation text sample; The second local semantic features are extracted from the consultation text samples using the BERT model in the medical field. A second global semantic feature is extracted from the consultation text sample using a large language model; Extract a second feature vector representing the text complexity from the consultation text sample; The second feature vector of the consultation text sample is input into a trainable gating network, and the gating network outputs the first dynamic weight of the second local semantic feature and the second dynamic weight of the second global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1. The second local semantic feature and the second global semantic feature are weighted and fused using the first dynamic weight and the second dynamic weight to obtain the second fused feature; The second fusion feature is input into the intent classification layer to obtain the prediction result of the consultation text sample; The loss function value is calculated based on the prediction results of the consultation text sample and the consultation intent label of the consultation text sample; The parameters of the gating network and the intent classification layer are updated end-to-end through the backpropagation algorithm, so that the trained gating network outputs a larger second dynamic weight for consultation text samples with high text complexity and a larger first dynamic weight for consultation text samples with low text complexity.

8. A medical consultation intent recognition device, characterized in that, include: The consultation text acquisition module is used to acquire the consultation text input by the user; The local feature extraction module is used to extract local semantic features from the consultation text using the BERT model in the medical field. A global feature extraction module is used to extract global semantic features from the consultation text using a large language model; The feature vector extraction module is used to extract feature vectors representing the complexity of the text from the consultation text; The weight generation module is used to map the feature vector to a first dynamic weight of the local semantic feature and a second dynamic weight of the global semantic feature, wherein the sum of the first dynamic weight and the second dynamic weight is 1. The feature fusion module is used to weight and fuse the local semantic features and the global semantic features using the first dynamic weight and the second dynamic weight to obtain fused features; The consultation intent prediction module is used to map the fused features to the intent category space of medical consultation intent recognition, and predict the user's consultation intent.

9. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the medical consultation intent recognition method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the medical consultation intent recognition method as described in any one of claims 1-7.