Multi-field text-oriented hierarchical semantic understanding and intelligent question and answer generation method
Through the combination of multi-domain text classification pre-trained model and graph attention network, the cross-domain recognition and deep semantic understanding problems of intelligent question-answer system in multi-domain text processing are solved, achieving more accurate and comprehensive question-and-answer effects.
Patent Information
- Application Number
- CN202510595989.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing intelligent question-and-answer system lacks cross-domain recognition capabilities in multi-domain text processing, making it difficult to understand complex semantics and deep-level information, resulting in insufficient accuracy and completeness of question-and-answer.
A multi-domain text classification pre-trained model is used for domain recognition, combined with a two-way long and short-term memory neural network and a graph attention network for hierarchical semantic understanding, and refine knowledge paths through multi-hop reasoning methods to generate high-quality question-and-answer results.
It improves the cross-domain understanding ability and question-and-answer accuracy of the intelligent question-and-answer system, generates more comprehensive and in-depth answers, and improves the user interaction experience.
Smart Images

Figure CN120494098A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to text understanding technology, and in particular to a hierarchical semantic understanding and intelligent question-answering generation method for multi-domain texts. Background Art
[0002] In the field of natural language processing, intelligent question-answering systems aim to use computers to automatically understand user questions and provide accurate and relevant answers. With the development of artificial intelligence technology, intelligent question-answering systems have been widely used in a variety of fields, including customer service consultation, medical diagnosis, and educational guidance. Traditional intelligent question-answering systems are typically based on keyword matching or simple template methods, which have difficulty understanding complex semantics and processing professional knowledge from multiple fields. In recent years, advances in deep learning technology have led to significant development of neural network-based question-answering systems. In particular, the use of pre-trained language models has significantly improved the system's ability to understand natural language. At the same time, knowledge graphs, as an important representation of structured knowledge, provide rich knowledge support for intelligent question-answering systems.
[0003] However, existing technologies still have obvious shortcomings in intelligent question answering of multi-domain texts: Existing question-answering systems are usually designed for a single field and lack effective cross-domain recognition and processing mechanisms. They find it difficult to accurately understand and distinguish questions from different professional fields, resulting in a significant decrease in accuracy when processing cross-domain texts.
[0004] Traditional question-answering systems have limited ability to understand the semantics of complex texts, especially the lack of comprehensive grasp of the contextual dependencies and hierarchical semantic structures of long texts. They are unable to effectively capture the deep semantic information in the text, which affects the quality of question answering.
[0005] Existing knowledge reasoning methods often use simple path search or single jump mechanisms, which are difficult to handle complex problems that require multi-step reasoning. They lack attention mechanisms for entities and relationships in knowledge graphs, making it difficult to find the most relevant knowledge paths when dealing with complex problems, affecting the accuracy and completeness of the answers. Summary of the Invention
[0006] The embodiments of the present invention provide a hierarchical semantic understanding and intelligent question-answering generation method for multi-domain texts, which can solve the problems in the prior art.
[0007] According to a first aspect of the embodiments of the present invention, Provides hierarchical semantic understanding and intelligent question-answering generation methods for multi-domain texts, including: Receive the text to be processed input by the user and perform preprocessing to obtain the preprocessed text; A multi-domain text classification pre-training model is used to perform domain identification on the preprocessed text, and a multi-round iterative domain segmentation mechanism is constructed to obtain a target domain identifier corresponding to the preprocessed text. According to the target domain identifier, the corresponding domain knowledge graph is called from a preset multi-domain knowledge graph library; Constructing a hierarchical semantic understanding model based on a bidirectional long short-term memory neural network, wherein the hierarchical semantic understanding model uses a block memory mechanism to divide and calculate overlapping subsequences of an input sequence, inputting the preprocessed text into the hierarchical semantic understanding model, and obtaining a hierarchical semantic representation of the preprocessed text; A multi-hop reasoning method based on a graph attention network is used to perform knowledge reasoning on the domain knowledge graph. Each hop of reasoning includes entity attention calculation and relationship attention calculation, and the knowledge path related to the hierarchical semantic representation is gradually refined through multi-hop iteration. Based on the hierarchical semantic representation and the knowledge path, the hierarchical semantic representation and the knowledge path are input into a pre-trained question-answer generation model, and a bidirectional decoding strategy is used to decode the input information in sequence and reverse order to generate corresponding question-answer pairs; The question-answer pair is returned to the user as an output result of the intelligent question answering.
[0008] A multi-domain text classification pre-training model is used to perform domain identification on the preprocessed text, and a multi-round iterative domain segmentation mechanism is constructed to obtain a target domain identifier corresponding to the preprocessed text. According to the target domain identifier, the corresponding domain knowledge graph is called from a preset multi-domain knowledge graph library, including: Performing word segmentation on the preprocessed text, using a word segmentation method that combines forward maximum matching based on a domain dictionary library and rule recognition based on a word segmentation rule library to obtain a text sequence after word segmentation; Constructing a multi-domain text classification pre-training model, setting a multi-layer bidirectional encoder in the multi-domain text classification pre-training model to extract features of the text sequence after word segmentation, aligning and encoding entities in the text sequence after word segmentation with entities in a preset multi-domain knowledge graph to obtain entity encoding vectors, and obtaining domain prediction probabilities based on the entity encoding vectors and features of the text sequence after word segmentation; Inputting the segmented text sequence into the multi-domain text classification pre-training model, constructing a multi-round iterative domain segmentation mechanism based on the domain prediction probability, combining the current domain prediction probability with the preset domain knowledge rules in each iteration, performing hierarchical domain division on the preprocessed text, and updating the domain prediction probability after each iteration, iterating according to a preset number of iterations to obtain a final target domain identification; According to the target domain identifier, relevant domain knowledge graphs are retrieved from the preset multi-domain knowledge graph library, similarity calculation and weight assignment are performed on the retrieved multiple domain knowledge graphs, and the knowledge graph with the highest similarity weight is determined as the target domain knowledge graph.
[0009] Construct a multi-domain text classification pre-training model, set a multi-layer bidirectional encoder in the multi-domain text classification pre-training model to extract the features of the text sequence after word segmentation, align and encode the entities in the text sequence after word segmentation with the entities in a preset multi-domain knowledge graph to obtain entity encoding vectors, and obtain domain prediction probabilities based on the entity encoding vectors and the features of the text sequence after word segmentation, including: Constructing a multi-domain text classification pre-training model, and inputting the segmented text sequence into the multi-domain text classification pre-training model; A multi-layer bidirectional encoder is set in the multi-domain text classification pre-training model, the text sequence after word segmentation is input into the multi-layer bidirectional encoder, and a local attention sublayer and a global attention sublayer are respectively constructed in each layer of the encoder, the local attention sublayer calculates local text features based on a sliding window, and the global attention sublayer captures long-range dependencies, the local text features are adaptively fused with the global dependency features, and a multi-scale feature vector of the text sequence after word segmentation is extracted; Constructing a cross-modal entity alignment network, projecting entities in the segmented text sequence and entities in a preset multi-domain knowledge graph into a shared semantic space, constructing a multi-head interactive attention mechanism in the shared semantic space, calculating an entity semantic matching matrix based on the multi-head interactive attention mechanism, inputting the entity semantic matching matrix into a graph neural network for message passing, fusing the local structural information of the entity with the global semantic information, and generating a context-aware entity encoding vector; The entity encoding vector and the multi-scale feature vector are interactively fused at multiple levels to obtain a domain prediction probability.
[0010] A hierarchical semantic understanding model is constructed based on a bidirectional long short-term memory neural network. The hierarchical semantic understanding model uses a block memory mechanism to divide and calculate overlapping subsequences of an input sequence. The preprocessed text is input into the hierarchical semantic understanding model to obtain a hierarchical semantic representation of the preprocessed text, including: Constructing a hierarchical semantic understanding model, setting a character-level bidirectional long short-term memory neural network in the hierarchical semantic understanding model, wherein the character-level bidirectional long short-term memory neural network adopts a block memory mechanism to divide the input sequence into multiple overlapping subsequence blocks, and each subsequence block is set with an independent memory unit group; Calculating the attention weight distribution of the character sequence in the subsequence block in the memory unit group to generate an intra-block feature representation, inputting the intra-block feature representation into the cross-block attention network, calculating the cross-block feature representation, and obtaining character-level semantic features; Constructing a dynamic feature pyramid based on the character-level semantic features, wherein the dynamic feature pyramid calculates a convolution kernel parameter matrix according to statistical information of the input features and performs feature transformation on the character-level semantic features; Calculating a feature correlation matrix using a selective gating mechanism in the dynamic feature pyramid, and generating a multi-granularity character representation based on the feature correlation matrix; The multi-granularity character representation is fused with the pre-trained word vector, inputted into a word-level bidirectional long short-term memory neural network, and word-level semantic features are calculated through a progressive attention mechanism; Inputting the word-level semantic features into a sentence-level bidirectional long-short-term memory neural network, and calculating the sentence-level semantic features using a hierarchical bidirectional information transfer mechanism; A multi-level feature fusion network is constructed, the character-level semantic features, the word-level semantic features and the sentence-level semantic features are input into the multi-level feature fusion network, and a hierarchical semantic representation is calculated.
[0011] A multi-hop reasoning method based on a graph attention network is used to perform knowledge reasoning on the domain knowledge graph. Each hop of reasoning includes entity attention calculation and relationship attention calculation. The knowledge path related to the hierarchical semantic representation is gradually refined through multi-hop iteration, including: Constructing a hierarchical heterogeneous structure for the domain knowledge graph, extracting a multi-granularity entity node feature matrix and a relationship edge feature matrix from the hierarchical heterogeneous structure, and mapping the hierarchical semantic representation into a query vector using a bidirectional neural network; Constructing a graph attention network, inputting the multi-granularity entity node feature matrix, the relationship edge feature matrix, and the query vector into the graph attention network, and obtaining enhanced entity representation vectors and relationship representation vectors through multi-layer graph convolution operations and residual connections; Constructing a multi-hop reasoning module in the graph attention network, the multi-hop reasoning module calculating entity attention weights according to the query vector and the enhanced entity representation vector, calculating relationship attention weights according to the query vector and the enhanced entity representation vector, and combining a current state with a historical state according to the entity attention weights and the relationship attention weights to obtain a multi-hop state representation; Inputting the multi-hop state representation into an interactive matching network, wherein the interactive matching network constructs a fine-grained interaction matrix to calculate a multi-level similarity representation between the multi-hop state representation and the query vector; Constructing a hierarchical path scoring model based on the multi-level similarity representation, wherein the hierarchical path scoring model uses a hierarchical attention mechanism to adaptively score candidate knowledge paths; A knowledge path related to the hierarchical semantic representation is selected from the hierarchical heterogeneous structure according to the adaptive scoring.
[0012] A multi-hop reasoning module is constructed in the graph attention network, wherein the multi-hop reasoning module calculates entity attention weights according to the query vector and the enhanced entity representation vector, calculates relationship attention weights according to the query vector and the enhanced relationship representation vector, and combines the current state with the historical state according to the entity attention weights and the relationship attention weights to obtain a multi-hop state representation, including: Inputting the query vector into a multi-head feature projection network, wherein the multi-head feature projection network transforms the query vector using different projection matrices to generate a multi-view query representation; Adaptively generating feature transformation parameters according to the multi-view query representation, and conditionally transforming the entity representation vector and the relationship representation vector based on the feature transformation parameters to generate an enhanced entity representation vector and an enhanced relationship representation vector; Constructing a multi-hop reasoning module, and providing a query-aware attention calculation unit in the multi-hop reasoning module, wherein the query-aware attention calculation unit performs a tensor decomposition operation on the query vector, the enhanced entity representation vector, and the enhanced relationship representation vector, respectively, to construct a multi-view initial weight matrix; Constructing a deep attention conversion network in the multi-hop reasoning module, the deep attention conversion network performs multi-layer feature transformation and information aggregation on the multi-view initial weight matrix, and generates entity attention weights and relationship attention weights from the transformed features through a self-calibration mechanism; A recursive state update unit is provided in the multi-hop reasoning module. The recursive state update unit uses an adaptive gating network to combine the entity attention weight and the relationship attention weight with historical reasoning information to generate a multi-hop state representation.
[0013] Based on the hierarchical semantic representation and the knowledge path, the hierarchical semantic representation and the knowledge path are input into a pre-trained question-answer generation model, and a bidirectional decoding strategy is used to decode the input information sequentially and in reverse order to generate corresponding question-answer pairs, including: The hierarchical semantic representation is input into the multi-layer feature transformation network, and the semantic feature vector is obtained through residual connection and nonlinear mapping; The knowledge path is input into the heterogeneous graph neural network, and the node and edge features are transferred to obtain a structured path representation. The structured path representation is passed through a multi-head attention mechanism to obtain a path feature vector; Inputting the semantic feature vector and the path feature vector into a pre-trained question-answer generation model, setting a bidirectional decoding strategy in the pre-trained question-answer generation model, sequentially decoding the semantic feature vectors through a forward decoding unit, and dynamically calculating the attention weight distribution and updating the decoding state in each decoding step to generate a question sequence; The path feature vector is reverse-decoded in the pre-trained question-answer generation model, and during the decoding process, memory retrieval and state update are performed based on the historical decoding information stored in the memory matrix to generate an answer sequence; Constructing a multi-granularity alignment calculation module to generate an alignment matrix, inputting the alignment matrix into a deep neural network to obtain a state update vector, and adjusting the hidden layer states of the forward decoding unit and the reverse decoding unit according to the state update vector to obtain an updated hidden layer state; Multiple rounds of interactive correction are initiated based on the updated hidden layer state, and question reconstruction and answer reconstruction are performed alternately in each round of correction to generate question-answer pairs.
[0014] According to a second aspect of the embodiments of the present invention, An electronic device is provided, comprising: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0015] According to a third aspect of the embodiments of the present invention, A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method described above is implemented.
[0016] The beneficial effects of this application are as follows: By constructing a multi-round iterative domain segmentation mechanism and a hierarchical semantic understanding model based on a bidirectional long short-term memory neural network, the present invention can more accurately identify the domain to which the text belongs and understand the deep semantics of the text, thereby improving the understanding accuracy of the intelligent question-answering system.
[0017] This paper adopts a multi-hop reasoning method based on graph attention network to perform knowledge reasoning on the domain knowledge graph. Through the calculation of entity attention and relationship attention, it can effectively refine the knowledge paths related to semantic representation, enhance the knowledge reasoning ability of the question-answering system, and make the answers more comprehensive and in-depth.
[0018] The present invention combines hierarchical semantic representation and knowledge paths, and through a pre-trained question-answer generation model and a bidirectional decoding strategy, can generate high-quality question-answer pairs, improve the fluency and accuracy of question-answer generation, and provide users with a more intelligent and natural interactive experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A flowchart of a method for hierarchical semantic understanding and intelligent question-answer generation for multi-domain texts according to an embodiment of the present invention; Figure 2 This is a workflow diagram of a multi-domain text classification pre-training model according to an embodiment of the present invention; Figure 3 The overall structure and data flow diagram of the hierarchical semantic understanding model of the embodiment of the present invention Figure 4 This is a multi-hop reasoning calculation flow chart of an embodiment of the present invention; Figure 5 This is a comparison chart of the accuracy of the question-answering generation model of an embodiment of the present invention on different data sets. DETAILED DESCRIPTION
[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0021] The following specific embodiments are used to describe the technical solution of the present invention in detail. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0022] Figure 1 This is a flow chart of a method for hierarchical semantic understanding and intelligent question-answer generation for multi-domain texts according to an embodiment of the present invention. Figure 1 As shown, the method includes: Receive the text to be processed input by the user and perform preprocessing to obtain the preprocessed text; A multi-domain text classification pre-training model is used to perform domain identification on the preprocessed text, and a multi-round iterative domain segmentation mechanism is constructed to obtain a target domain identifier corresponding to the preprocessed text. According to the target domain identifier, the corresponding domain knowledge graph is called from a preset multi-domain knowledge graph library; Constructing a hierarchical semantic understanding model based on a bidirectional long short-term memory neural network, wherein the hierarchical semantic understanding model uses a block memory mechanism to divide and calculate overlapping subsequences of an input sequence, inputting the preprocessed text into the hierarchical semantic understanding model, and obtaining a hierarchical semantic representation of the preprocessed text; A multi-hop reasoning method based on a graph attention network is used to perform knowledge reasoning on the domain knowledge graph. Each hop of reasoning includes entity attention calculation and relationship attention calculation, and the knowledge path related to the hierarchical semantic representation is gradually refined through multi-hop iteration. Based on the hierarchical semantic representation and the knowledge path, the hierarchical semantic representation and the knowledge path are input into a pre-trained question-answer generation model, and a bidirectional decoding strategy is used to decode the input information in sequence and reverse order to generate corresponding question-answer pairs; The question-answer pair is returned to the user as an output result of the intelligent question answering.
[0023] In an optional embodiment, a multi-domain text classification pre-training model is used to perform domain identification on the preprocessed text, and a multi-round iterative domain segmentation mechanism is constructed to obtain a target domain identifier corresponding to the preprocessed text. According to the target domain identifier, the corresponding domain knowledge graph is called from a preset multi-domain knowledge graph library, including: Performing word segmentation on the preprocessed text, using a word segmentation method that combines forward maximum matching based on a domain dictionary library and rule recognition based on a word segmentation rule library to obtain a text sequence after word segmentation; Constructing a multi-domain text classification pre-training model, setting a multi-layer bidirectional encoder in the multi-domain text classification pre-training model to extract features of the text sequence after word segmentation, aligning and encoding entities in the text sequence after word segmentation with entities in a preset multi-domain knowledge graph to obtain entity encoding vectors, and obtaining domain prediction probabilities based on the entity encoding vectors and features of the text sequence after word segmentation; Inputting the segmented text sequence into the multi-domain text classification pre-training model, constructing a multi-round iterative domain segmentation mechanism based on the domain prediction probability, combining the current domain prediction probability with the preset domain knowledge rules in each iteration, performing hierarchical domain division on the preprocessed text, and updating the domain prediction probability after each iteration, iterating according to a preset number of iterations to obtain a final target domain identification; According to the target domain identifier, relevant domain knowledge graphs are retrieved from the preset multi-domain knowledge graph library, similarity calculation and weight assignment are performed on the retrieved multiple domain knowledge graphs, and the knowledge graph with the highest similarity weight is determined as the target domain knowledge graph.
[0024] Preprocess the input text, including removing special characters, standardizing punctuation, and removing stop words. For example, the input text "What's the weather like today? Will it rain?" is preprocessed into "What's the weather like today? Will it rain?"
[0025] This approach combines forward maximum matching based on a domain lexicon with rule recognition based on a word segmentation rule library. Specifically, a domain lexicon containing multiple domain-specific terms is first constructed. For example, in the medical field, terms such as "CT scan" and "blood routine test" are included; in the weather field, terms such as "precipitation" and "air pressure" are included. Then, based on the forward maximum matching principle, starting from the left side of the text, a search is performed to find a text segment that matches the longest term in the domain lexicon. Simultaneously, the word segmentation rule library is applied to identify text in specific formats, such as formatted expressions like dates and times. For example, the preprocessed text "What's the weather like today? Will it rain?" is segmented to obtain the word sequence ["today", "weather", "how", "will", "will", "will not", "rain"].
[0026] A pre-trained model for multi-domain text classification was constructed, which uses a multi-layer bidirectional encoder structure to extract text features. Specifically, the segmented text sequence is first input into a pre-trained word embedding model, which maps each word into a fixed-dimensional vector representation. For example, "weather" is mapped into a 300-dimensional vector. Next, the word embedding sequence is input into a multi-layer bidirectional encoder. Each encoder layer consists of two neural networks, one forward and one backward, which capture the context of the text and output context-sensitive feature representations. For example, for a text sequence of six words, after passing through the bidirectional encoder, six 768-dimensional feature vectors are obtained.
[0027] Entities are aligned and encoded with the knowledge graph, identifying possible entities such as "weather" and "rain" from the word sequence. These entities are then aligned with entities in the pre-defined multi-domain knowledge graph. For example, "weather" and "rain" have corresponding nodes in the weather domain knowledge graph. This alignment is achieved by matching entity names and calculating entity attribute similarity. For each identified entity, its structural and semantic information in the knowledge graph is extracted to generate an entity encoding vector. For example, the entity encoding vector for "weather" includes its category information in the knowledge graph (such as meteorological phenomena) and its associated relationships (such as its relationship with temperature and humidity).
[0028] The text features are integrated with the entity encoding vector to calculate the domain prediction probability. In specific implementations, the text features are average-pooled or attention-pooled to obtain a global representation of the text. This global representation is then concatenated with the entity encoding vector. The prediction probability for each domain is calculated using a fully connected layer and a softmax function. For example, for an input text, the probability for the weather domain might be 0.85, the probability for the medical domain 0.05, and the probability for the tourism domain 0.10.
[0029] Based on domain prediction probabilities, a multi-round iterative domain segmentation mechanism is constructed. In the first iteration, the domain prediction probabilities are used to preliminarily determine the broad domain to which the text belongs. For example, the input text is initially categorized into the broad category of "weather." In the second iteration, the "weather" category is segmented using pre-set domain knowledge rules, such as "weather forecast," "meteorological disasters," and "climate change," into sub-domains such as "weather forecast." Domain knowledge rules include keyword matching rules (e.g., the keyword "rain" tends to favor the "weather forecast" sub-domain) and contextual rules (e.g., question format tends to favor the query sub-domain). After each iteration, the domain prediction probabilities are updated based on the segmentation results. For example, the segmentation results may yield a probability of 0.75 for the "weather forecast" sub-domain, 0.20 for the "meteorological disasters" sub-domain, and 0.05 for the "climate change" sub-domain. After completing the pre-set number of iterations (typically 2-3), the target domain is finally identified as "weather forecast."
[0030] Based on the identified target domain identifier, relevant domain knowledge graphs are retrieved from the pre-set multi-domain knowledge graph library. For example, for the "weather forecast" domain, relevant graphs such as the weather forecast knowledge graph and the meteorological knowledge graph are retrieved. Similarity calculations are performed on the multiple retrieved knowledge graphs, and weights are assigned. Similarity calculations are based on factors such as the matching degree between entities appearing in the text and entities in the knowledge graph, and the relevance of the text topic to topics covered by the knowledge graph. For example, for text containing the entities "rain" and "weather," the similarity with the weather forecast knowledge graph is 0.92, and the similarity with the meteorological knowledge graph is 0.78. Based on the similarity, weights are assigned, and the weather forecast knowledge graph is determined to be the target domain knowledge graph.
[0031] This method accurately identifies the domain to which a text belongs and calls upon the corresponding domain knowledge graph, providing knowledge support for subsequent text comprehension and intelligent question-answering. Experiments have shown that this method achieves an accuracy rate of 92.5% on multi-domain text classification tasks, an 8.3 percentage point improvement over traditional methods.
[0032] In an optional embodiment, a multi-domain text classification pre-training model is constructed, a multi-layer bidirectional encoder is set in the multi-domain text classification pre-training model to extract features of the text sequence after word segmentation, entities in the text sequence after word segmentation are aligned and encoded with entities in a preset multi-domain knowledge graph to obtain entity encoding vectors, and domain prediction probabilities are obtained based on the entity encoding vectors and the features of the text sequence after word segmentation, including: Constructing a multi-domain text classification pre-training model, and inputting the segmented text sequence into the multi-domain text classification pre-training model; A multi-layer bidirectional encoder is set in the multi-domain text classification pre-training model, the text sequence after word segmentation is input into the multi-layer bidirectional encoder, and a local attention sublayer and a global attention sublayer are respectively constructed in each layer of the encoder, the local attention sublayer calculates local text features based on a sliding window, and the global attention sublayer captures long-range dependencies, the local text features are adaptively fused with the global dependency features, and a multi-scale feature vector of the text sequence after word segmentation is extracted; Constructing a cross-modal entity alignment network, projecting entities in the segmented text sequence and entities in a preset multi-domain knowledge graph into a shared semantic space, constructing a multi-head interactive attention mechanism in the shared semantic space, calculating an entity semantic matching matrix based on the multi-head interactive attention mechanism, inputting the entity semantic matching matrix into a graph neural network for message passing, fusing the local structural information of the entity with the global semantic information, and generating a context-aware entity encoding vector; The entity encoding vector and the multi-scale feature vector are interactively fused at multiple levels to obtain a domain prediction probability.
[0033] A multi-domain text classification pre-training model was constructed and the segmented text sequences were fed into the model. A 12-layer bidirectional encoder was set up in the model, and each encoder layer contained two sub-layers: a local attention sub-layer and a global attention sub-layer.
[0034] In the local attention sublayer, a sliding window mechanism is used to calculate local text features. Specifically, the window size is set to 5, with a step size of 1. A self-attention score is calculated for the word-meta sequence within each window. For example, for the above segmented sequence, the first window contains ["this", "model", "mobile phone", "of", "camera"]. The attention weights between these five words are calculated to obtain local text features. For each word-meta within the window, the attention score with other words in the window is calculated based on word-meta similarity. This score is then normalized to generate an attention weight. The attention weight is then weighted and summed with the feature vector of the corresponding word-meta to obtain the local feature vector.
[0035] In the global attention sublayer, global self-attention is calculated for the entire sequence to capture long-range dependencies. For example, although the words "mobile phone" and "pixel" are distant, they are semantically related, and the global attention mechanism captures this relationship. Specifically, the attention score of each word in the sequence is calculated relative to all other words to generate a global attention weight matrix. This matrix is then multiplied by the word feature vector to obtain the global feature vector.
[0036] A gating mechanism is used to adaptively fuse local and global feature vectors. The gating value is calculated through a nonlinear transformation of local and global features and ranges from 0 to 1. When local information is more important, the gating value is closer to 1; when global information is more critical, the gating value is closer to 0. The fused feature vectors are fed through a feedforward neural network and residual connections to produce the output of each layer, namely the multi-scale feature vector.
[0037] Identify entities from the segmented text sequence. For example, identify "mobile phone" and "camera" as entities. Then, search for these entities in a pre-defined multi-domain knowledge graph. Suppose the knowledge graph contains entities and relationships in multiple domains, such as electronics, healthcare, and finance. "mobile phone" and "camera" belong to the electronics domain.
[0038] Entities identified in the text and entities in the knowledge graph are projected into a shared semantic space of the same dimension (e.g., 768) through independent encoders. Within this space, an eight-head interactive attention mechanism is constructed, with each attention head responsible for capturing a specific type of semantic relationship. An entity-semantic matching matrix is generated by calculating attention scores between text entities and knowledge graph entities.
[0039] For example, the text entity "mobile phone" is matched with entities such as "smartphone," "mobile phone case," and "mobile phone screen" in the knowledge graph to obtain the corresponding matching score. The dimension of the matching matrix is the number of text entities multiplied by the number of knowledge graph entities.
[0040] The entity semantic matching matrix is input into a graph neural network for message passing. Specifically, a graph convolutional network is used to aggregate information from each entity node's first-order neighboring nodes. For example, the "phone" node aggregates information from related nodes such as "camera," "screen," and "battery." Through three layers of graph convolution operations, the entity's local structural information is gradually integrated with its global semantic information, ultimately generating a context-aware entity encoding vector.
[0041] The entity encoding vector is interactively fused with multi-scale feature vectors at multiple levels. A cross-attention mechanism is used to calculate the attention weights between the entity encoding vector and the text feature vector, followed by weighted fusion. The fused feature vector is mapped to the domain label space through a fully connected layer, and the softmax function is applied to obtain the domain prediction probability.
[0042] For example, for the input text "This phone's camera has high pixels", after the above processing, the domain prediction probabilities may be: 0.85 for the electronics domain, 0.10 for the photography domain, and 0.05 for other domains, thus correctly classifying the text into the electronics domain.
[0043] Figure 2 This is a workflow diagram of the multi-domain text classification pre-training model according to an embodiment of the present invention: This figure illustrates a complete flow chart for text processing and prediction. The process begins with the "segmented text sequence" at the top, which is processed by a multi-layer bidirectional encoder. The encoder consists of two key components: a local attention layer and a global attention layer, which are integrated through an adaptive feature fusion mechanism. The system consists of two main branches: the left branch generates multi-scale feature vectors, and the right branch generates entity encoding vectors using a cross-modal entity alignment network. The outputs of these two branches are integrated in a multi-layer interactive fusion module, ultimately outputting a domain prediction probability. The entire architecture utilizes a multi-layer attention mechanism and cross-modal alignment technology, enhancing the model's understanding of text and prediction accuracy through multiple feature fusion and interactions. Notably, the dashed lines in the figure indicate additional information flow paths, indicating the system's feedback mechanism for optimizing prediction results. This design reflects the model's complexity and advanced capabilities, enabling it to better handle multi-domain text classification tasks.
[0044] In an optional embodiment, a hierarchical semantic understanding model is constructed based on a bidirectional long short-term memory neural network. The hierarchical semantic understanding model uses a block memory mechanism to divide and calculate overlapping subsequences of an input sequence. The preprocessed text is input into the hierarchical semantic understanding model to obtain a hierarchical semantic representation of the preprocessed text, including: Constructing a hierarchical semantic understanding model, setting a character-level bidirectional long short-term memory neural network in the hierarchical semantic understanding model, wherein the character-level bidirectional long short-term memory neural network adopts a block memory mechanism to divide the input sequence into multiple overlapping subsequence blocks, and each subsequence block is set with an independent memory unit group; Calculating the attention weight distribution of the character sequence in the subsequence block in the memory unit group to generate an intra-block feature representation, inputting the intra-block feature representation into the cross-block attention network, calculating the cross-block feature representation, and obtaining character-level semantic features; Constructing a dynamic feature pyramid based on the character-level semantic features, wherein the dynamic feature pyramid calculates a convolution kernel parameter matrix according to statistical information of the input features and performs feature transformation on the character-level semantic features; Calculating a feature correlation matrix using a selective gating mechanism in the dynamic feature pyramid, and generating a multi-granularity character representation based on the feature correlation matrix; The multi-granularity character representation is fused with the pre-trained word vector, inputted into a word-level bidirectional long short-term memory neural network, and word-level semantic features are calculated through a progressive attention mechanism; Inputting the word-level semantic features into a sentence-level bidirectional long-short-term memory neural network, and calculating the sentence-level semantic features using a hierarchical bidirectional information transfer mechanism; A multi-level feature fusion network is constructed, the character-level semantic features, the word-level semantic features and the sentence-level semantic features are input into the multi-level feature fusion network, and a hierarchical semantic representation is calculated.
[0045] The construction of the hierarchical semantic understanding model begins with the configuration of a character-level bidirectional long short-term memory neural network. In this network, the input text sequence is divided into multiple overlapping subsequence blocks. Each overlapping subsequence block has an independent memory cell group, which consists of an input gate, a forget gate, an output gate, and a memory cell. The flow of information is controlled by adjusting the parameter values of these gate structures.
[0046] When calculating the attention weight distribution for the character sequence within a subsequence block in the memory cell group, an attention score is calculated for each character position. The attention weight distribution is generated by calculating the association of each character with other characters. These weights are then used to generate intra-block feature representations. The original feature vector of each character is multiplied by the corresponding attention weight and the sum is calculated. These intra-block feature representations are input into the cross-block attention network, which calculates the attention relationship between different subsequence blocks and generates character-level semantic features that take into account contextual information.
[0047] A dynamic feature pyramid is constructed based on character-level semantic features. This pyramid calculates the convolution kernel parameter matrix based on the statistical information of the input features. Specifically, the mean and standard deviation of the character-level semantic features are calculated, and these statistics are used as the basis for generating convolution kernel parameters of different scales. For example, for a character-level semantic feature with a dimension of 256, convolution kernels of sizes 3×3, 5×5, and 7×7 can be generated, with the number of channels of the convolution kernel being 64, 32, and 16, respectively. These convolution kernels perform feature transformations on the character-level semantic features to generate multi-scale feature maps.
[0048] In the dynamic feature pyramid, a selective gating mechanism is used to calculate the feature correlation matrix. This mechanism controls the flow of information from features at different scales by setting gating units. Based on the multi-scale feature maps generated in the previous example, correlation scores between feature maps are calculated to generate a correlation matrix. Features with higher correlations are given greater weights, while features with lower correlations are given smaller weights, thus generating a multi-granular character representation.
[0049] The multi-granularity character representation is fused with pre-trained word vectors using concatenation and linear transformation. These fused features are fed into a word-level bidirectional long short-term memory neural network, where word-level semantic features are calculated using a progressive attention mechanism.
[0050] The implementation method of the progressive attention mechanism is to consider the influence of the previous and next words for each word position in the sequence, and this influence decreases as the distance increases.
[0051] When word-level semantic features are input into a sentence-level bidirectional long short-term memory neural network, a layered bidirectional information transfer mechanism is used to calculate sentence-level semantic features. This mechanism establishes forward and reverse information flow at each layer of the network, with the hidden state of the previous layer serving as the input to the next layer. For example, in a three-layer network, the output of the first layer undergoes forward and reverse transfers to produce a two-dimensional feature matrix. The second layer then extracts higher-level features based on this matrix, and the third layer ultimately generates sentence-level semantic features.
[0052] A multi-level feature fusion network is constructed, and character-level, word-level, and sentence-level semantic features are input into the network to calculate a hierarchical semantic representation. The fusion network uses an attention mechanism to weight and sum the three levels of features. For example, for a sample, the calculated weight of the character-level feature is 0.2, the weight of the word-level feature is 0.3, and the weight of the sentence-level feature is 0.5. The final hierarchical semantic representation is generated based on these weights.
[0053] Tests on various corpora demonstrate that this hierarchical semantic understanding model is highly effective in processing complex text. For example, in the Chinese news classification task, compared to a model using only a single-level feature set, this model achieved a 3.5 percentage point improvement in accuracy and a 2.8 percentage point improvement in F1 score. In the English sentiment analysis task, accuracy improved by 2.9 percentage points and F1 score by 2.5 percentage points. This demonstrates that the fusion of multi-level features can effectively capture the deep semantic information of a text.
[0054] Figure 3 The overall structure and data flow diagram of the hierarchical semantic understanding model of the embodiment of the present invention are as follows: This diagram depicts a complex text semantic processing pipeline. Starting with preprocessed text, it is first processed by a character-level bidirectional long short-term memory (LSTM) neural network. In this layer, a block-based memory mechanism is used to partition the input sequence into overlapping subsequences, dividing the text into subsequence block 1, subsequence block 2, and so on to subsequence block n. These subsequences undergo attention weight distribution calculation and cross-block attention network processing to obtain character-level semantic features. The processing then splits into two parallel branches: the left branch is a dynamic feature pyramid processing pipeline, including convolution kernel parameter matrix calculation and selective gating mechanism, ultimately generating multi-granular character representations; the right branch is a word-level bidirectional long short-term memory (LSTM) neural network processing pipeline, which incorporates pretrained word embeddings and a progressive attention mechanism to output word-level semantic features. Finally, the outputs of these two branches are integrated in a multi-level feature fusion network, achieving multi-layered semantic understanding from the character to the word level. This entire design embodies the application of deep learning in natural language processing. Through multi-level and multi-angle feature extraction and fusion, it improves the accuracy and completeness of text understanding.
[0055] Existing text semantic understanding models suffer from three major problems: first, single-level feature extraction fails to fully capture the semantic information of text; second, sequence processing with a fixed window size struggles to adapt to texts of varying lengths; and third, there is a lack of effective multi-level feature fusion mechanisms. Existing technologies typically employ a single word vector representation or simple convolutional network feature extraction, failing to fully utilize multi-level information such as characters, words, and sentences.
[0056] The improvement scheme proposed in this application starts from the following aspects: first, a block memory mechanism is introduced to adapt to text inputs of different lengths through overlapping subsequence division; second, a dynamic feature pyramid is constructed to adaptively generate convolution kernel parameters based on the statistical information of the input features; third, a progressive attention mechanism and a hierarchical bidirectional information transfer mechanism are designed to enhance the model's ability to understand the context; fourth, a multi-level feature fusion network is established to effectively integrate semantic information at the three levels of characters, words and sentences.
[0057] In an optional embodiment, a multi-hop reasoning method based on a graph attention network is used to perform knowledge reasoning on the domain knowledge graph, wherein each hop reasoning includes entity attention calculation and relationship attention calculation, and the knowledge path related to the hierarchical semantic representation is gradually refined through a multi-hop iterative approach, including: Constructing a hierarchical heterogeneous structure for the domain knowledge graph, extracting a multi-granularity entity node feature matrix and a relationship edge feature matrix from the hierarchical heterogeneous structure, and mapping the hierarchical semantic representation into a query vector using a bidirectional neural network; Constructing a graph attention network, inputting the multi-granularity entity node feature matrix, the relationship edge feature matrix, and the query vector into the graph attention network, and obtaining enhanced entity representation vectors and relationship representation vectors through multi-layer graph convolution operations and residual connections; Constructing a multi-hop reasoning module in the graph attention network, the multi-hop reasoning module calculating entity attention weights according to the query vector and the enhanced entity representation vector, calculating relationship attention weights according to the query vector and the enhanced entity representation vector, and combining a current state with a historical state according to the entity attention weights and the relationship attention weights to obtain a multi-hop state representation; Inputting the multi-hop state representation into an interactive matching network, wherein the interactive matching network constructs a fine-grained interaction matrix to calculate a multi-level similarity representation between the multi-hop state representation and the query vector; Constructing a hierarchical path scoring model based on the multi-level similarity representation, wherein the hierarchical path scoring model uses a hierarchical attention mechanism to adaptively score candidate knowledge paths; A knowledge path related to the hierarchical semantic representation is selected from the hierarchical heterogeneous structure according to the adaptive scoring.
[0058] A hierarchical heterogeneous structure is constructed for the domain knowledge graph. Specifically, the knowledge graph is divided into a concept layer, an instance layer, and an attribute layer. The concept layer contains category nodes, such as "disease" and "symptoms"; the instance layer contains specific entity nodes, such as "diabetes" and "headache"; and the attribute layer contains attribute nodes, such as "morbidity" and "treatment methods." Multi-granularity entity node feature matrices and relationship edge feature matrices are extracted from this hierarchical heterogeneous structure. For example, for the medical domain knowledge graph, the extracted entity node matrix has a dimension of [10000, 128], representing 10,000 entity nodes, each with a feature dimension of 128; the relationship edge feature matrix has a dimension of [500, 64], representing 500 relationship types, each with a feature dimension of 64.
[0059] A bidirectional neural network is used to map the hierarchical semantic representation to a query vector. Specifically, the user query text "What are the common symptoms of diabetes?" is first encoded into an initial vector representation with a dimension of
[768] using the BERT model. This is then further processed using a bidirectional LSTM network to obtain a hierarchical semantic representation. Finally, a fully connected layer is used to map the query vector to a dimension of
[128] , consistent with the knowledge graph entity dimension.
[0060] A graph attention network is constructed, which receives as input a multi-granular entity node feature matrix, a relationship edge feature matrix, and a query vector. Enhanced entity and relationship representation vectors are obtained through two layers of graph convolution operations and residual connections. The first layer of graph convolution aggregates node features, while the second layer further extracts high-order features. The output of each layer of graph convolution is added to the original features through residual connections to prevent the vanishing gradient problem in deep network training. For example, the entity representation output by the first layer of graph convolution has a dimension of [10000, 128]. After the second layer of graph convolution, the enhanced entity representation vector still has the dimension [10000, 128]. Similarly, the enhanced relationship representation vector has the dimension [500, 64].
[0061] A multi-hop reasoning module is constructed within the graph attention network. This module first calculates entity attention weights based on the query vector and the enhanced entity representation vectors. Specifically, for the query "common symptoms of diabetes," the similarity between the query vector and the representations of each entity node is calculated to obtain the entity attention distribution. For example, the attention weight for the "diabetes" node is 0.75, and the attention weight for the "hypertension" node is 0.05. Relationship attention weights are then calculated based on the query vector and the enhanced entity representation vectors. For example, the attention weight for the "cause" relationship is 0.6, and the weight for the "treatment" relationship is 0.1. Finally, based on the entity and relationship attention weights, the current state is combined with the historical state to obtain a multi-hop state representation. For example, after the first hop of reasoning, the state representation is biased towards the "diabetes" entity node and the "cause" relationship; after the second hop of reasoning, the state representation is further biased towards symptom nodes such as "thirst" and "polyuria."
[0062] The multi-hop state representation is fed into an interactive matching network, and a fine-grained interaction matrix is constructed to calculate the multi-level similarity representation between the multi-hop state representation and the query vector. Specifically, an interaction matrix of dimension [128, 128] is constructed, where each element in the matrix represents the degree of match between the state representation and the corresponding dimension of the query vector. Row and column pooling operations are performed on the interaction matrix to obtain row vectors
[128] and column vectors
[128] , which capture the matching information from query to state and state to query, respectively. These vectors are concatenated and passed through a multi-layer perceptron to obtain a multi-level similarity representation with dimension
[256] .
[0063] A hierarchical path scoring model is constructed based on multi-level similarity representations. This model uses a hierarchical attention mechanism to adaptively score candidate knowledge paths. For medical question-answering scenarios, a three-tier scoring mechanism is implemented: concept-level scoring focuses on the semantic type matching of the path, such as a symptom node with a weight of 0.8; instance-level scoring focuses on the relevance of specific entities, such as a "thirst" node with a score of 0.85; and attribute-level scoring focuses on the matching of attribute information, such as a "commonness" attribute with a score of 0.7. The final path score is derived by combining these three scoring layers.
[0064] Based on adaptive scoring, knowledge paths related to the hierarchical semantic representation are selected from the hierarchical heterogeneous structure. For example, for the query "common symptoms of diabetes," the highest-scoring paths are selected, such as "diabetes-cause-thirst" (score 0.92), "diabetes-cause-polyuria" (score 0.89), and "diabetes-cause-weight loss" (score 0.85).
[0065] In an optional embodiment, a multi-hop reasoning module is constructed in the graph attention network, wherein the multi-hop reasoning module calculates entity attention weights based on the query vector and the enhanced entity representation vector, calculates relationship attention weights based on the query vector and the enhanced relationship representation vector, and combines the current state with the historical state according to the entity attention weights and the relationship attention weights to obtain a multi-hop state representation, including: Inputting the query vector into a multi-head feature projection network, wherein the multi-head feature projection network transforms the query vector using different projection matrices to generate a multi-view query representation; Adaptively generating feature transformation parameters according to the multi-view query representation, and conditionally transforming the entity representation vector and the relationship representation vector based on the feature transformation parameters to generate an enhanced entity representation vector and an enhanced relationship representation vector; Constructing a multi-hop reasoning module, and providing a query-aware attention calculation unit in the multi-hop reasoning module, wherein the query-aware attention calculation unit performs a tensor decomposition operation on the query vector, the enhanced entity representation vector, and the enhanced relationship representation vector, respectively, to construct a multi-view initial weight matrix; Constructing a deep attention conversion network in the multi-hop reasoning module, the deep attention conversion network performs multi-layer feature transformation and information aggregation on the multi-view initial weight matrix, and generates entity attention weights and relationship attention weights from the transformed features through a self-calibration mechanism; A recursive state update unit is provided in the multi-hop reasoning module. The recursive state update unit uses an adaptive gating network to combine the entity attention weight and the relationship attention weight with historical reasoning information to generate a multi-hop state representation.
[0066] The query vector is input into the multi-head feature projection network for processing. This network uses different projection matrices to transform the query vector and generate multi-view query representations. In specific implementation, assume the dimension of the query vector is 256, and 4 projection heads are set. Each projection head uses a 64×256 projection matrix to transform the query vector. For example, for the query vector Q = [0.3, 0.5, 0.2,..., 0.4], it is transformed through 4 different projection matrices W1, W2, W3, W4 to obtain 4 query representations Q1, Q2, Q3, Q4 of different views, and the dimension of each view representation is 64.
[0067] Generate feature transformation parameters adaptively based on the multi-view query representations. This process is implemented through a parameter generation network, which receives the multi-view query representations as input and outputs the parameters for conditional transformation. Specifically, after concatenating the multi-view query representations Q1, Q2, Q3, Q4, they are passed through a two-layer fully connected network. The middle layer is set with 128 neurons and uses the ReLU activation function, and the output layer generates the transformation parameters γ and β. For example, for the entity "person", the generated γ = [1.2, 0.8,..., 1.1], and β = [0.1, -0.2,..., 0.3]; for the relationship "friend", the generated γ = [0.9, 1.3,..., 1.0], and β = [-0.1, 0.2,..., 0.1].
[0068] Perform conditional transformation on the entity representation vector and the relationship representation vector based on the generated feature transformation parameters to generate enhanced representation vectors. The calculation method of the conditional transformation is: enhanced representation = original representation × γ + β. For example, perform conditional transformation on the original representation vector [0.5, 0.3,..., 0.7] of the entity "person" with the above generated γ and β parameters to obtain the enhanced entity representation vector [0.7, 0.04,..., 1.07].
[0069] In the multi-hop reasoning module, set a query-aware attention calculation unit. This unit performs tensor decomposition operations on the query vector with the enhanced entity representation vector and the enhanced relationship representation vector respectively to construct a multi-view initial weight matrix. In specific implementation, perform dot product operations on the query representation of each view with the enhanced entity representation vector to obtain the initial entity weights; similarly, perform dot product operations on the query representation of each view with the enhanced relationship representation vector to obtain the initial relationship weights. For example, for the enhanced entity "person" representation vector, the initial attention weights calculated with the query view Q1 are 0.45, with Q2 are 0.38, with Q3 are 0.52, and with Q4 are 0.41.
[0070] A deep attention transformation network is constructed within the multi-hop reasoning module to perform multi-layer feature transformation and information aggregation on the multi-view initial weight matrix. This network consists of three convolutional layers, each containing 16 3×3 convolution kernels. ReLU activation is used in between, and a global average pooling layer is used for feature aggregation. After this transformation, the initial weights for the entity "person" ([0.45, 0.38, 0.52, 0.41]) are transformed to [0.48, 0.40, 0.50, 0.42].
[0071] The final attention weights are generated through a self-calibration mechanism. The self-calibration mechanism first applies the Softmax function to normalize the converted weights, and then introduces a residual connection structure to perform a weighted combination of the normalized weights and the initial weights. For example, for the entity "person", the normalized weights are: [0.26,0.22,0.27,0.23]; After combining with the initial weight, the final entity attention weight is: [0.35,0.30,0.40,0.32].
[0072] A recursive state update unit is implemented in the multi-hop reasoning module. An adaptive gating network is used to combine entity and relationship attention weights with historical reasoning information to generate a multi-hop state representation. The adaptive gating network consists of two gating units: an update gate and a reset gate. The update gate controls the extent to which new information is accepted, while the reset gate controls the extent to which historical information is retained.
[0073] In the specific implementation, assuming that the historical state vector at time t is H_t=[0.4,0.6,...,0.3], the entity attention weight is: E_t=[0.35,0.30,0.40,0.32], The relation attention weight is: R_t=[0.28,0.32,0.25,0.35].
[0074] Calculate the candidate state C_t=[0.42,0.58,...,0.35], which is obtained by concatenating E_t and R_t and passing them through a fully connected network.
[0075] Calculate the update gate Z_t=[0.7,0.6,...,0.8] and the reset gate U_t=[0.3,0.4,...,0.2]. Both gates are obtained by concatenating H_t, E_t, and R_t and passing them through their respective fully connected layers and using the Sigmoid function.
[0076] The new state representation is calculated according to the formula H_{t+1}=Z_t⊙C_t+(1-Z_t)⊙(U_t⊙H_t), where ⊙ represents element-wise multiplication. For example, the calculated state representation at time t+1 is: H_{t+1}=[0.41,0.57,...,0.34].
[0077] This multi-hop reasoning method can effectively capture the complex relationships between entities in the graph attention network, improve the model's ability to understand complex problems through multi-step reasoning, and demonstrate excellent performance in tasks such as knowledge graph question answering and social network analysis.
[0078] Figure 4 This is a multi-hop reasoning calculation flow chart of an embodiment of the present invention: The figure illustrates a complex multi-hop reasoning computational process. The query vector is input into a multi-head feature projection network and transformed using different projection matrices to generate a multi-view query representation. The entity and relationship representation vectors are then conditionally transformed based on the feature transformation parameters to generate enhanced entity and relationship representation vectors. A query-aware attention computation unit is then implemented within the multi-hop reasoning module. This unit performs tensor decomposition on the query vector and the enhanced entity and relationship representation vectors, constructing an initial multi-view weight matrix. A deep attention transformation network then performs multi-layer feature transformation and information aggregation, and the transformed features are then used to generate entity and relationship attention weights using a self-controlled criterion. Finally, an adaptive gating network is used within the progressive state update unit to combine the entity and relationship attention weights with historical reasoning information to generate a multi-hop state representation. This design enables a complex knowledge reasoning process through the superposition of multi-level feature transformation and attention mechanisms.
[0079] In an optional embodiment, based on the hierarchical semantic representation and the knowledge path, the hierarchical semantic representation and the knowledge path are input into a pre-trained question-answer generation model, and a bidirectional decoding strategy is used to decode the input information sequentially and in reverse order to generate corresponding question-answer pairs, including: The hierarchical semantic representation is input into the multi-layer feature transformation network, and the semantic feature vector is obtained through residual connection and nonlinear mapping; The knowledge path is input into the heterogeneous graph neural network, and the node and edge features are transferred to obtain a structured path representation. The structured path representation is passed through a multi-head attention mechanism to obtain a path feature vector; Inputting the semantic feature vector and the path feature vector into a pre-trained question-answer generation model, setting a bidirectional decoding strategy in the pre-trained question-answer generation model, sequentially decoding the semantic feature vectors through a forward decoding unit, and dynamically calculating the attention weight distribution and updating the decoding state in each decoding step to generate a question sequence; The path feature vector is reverse-decoded in the pre-trained question-answer generation model, and during the decoding process, memory retrieval and state update are performed based on the historical decoding information stored in the memory matrix to generate an answer sequence; Constructing a multi-granularity alignment calculation module to generate an alignment matrix, inputting the alignment matrix into a deep neural network to obtain a state update vector, and adjusting the hidden layer states of the forward decoding unit and the reverse decoding unit according to the state update vector to obtain an updated hidden layer state; Multiple rounds of interactive correction are initiated based on the updated hidden layer state, and question reconstruction and answer reconstruction are performed alternately in each round of correction to generate question-answer pairs.
[0080] The hierarchical semantic representation is input into a multi-layer feature transformation network, where a semantic feature vector is obtained through residual connections and nonlinear mapping. Specifically, the hierarchical semantic representation includes features at the word level, syntax level, and document level, and the features at each level are processed by the corresponding feature extraction module. For word-level features, a pre-trained word embedding model (such as Word2Vec or BERT) is used to convert the text into a word vector with a dimension of 768. For syntax-level features, dependency parsing is used to obtain grammatical relationships, construct a syntax tree, and extract features through a tree-structured encoder. For document-level features, a bidirectional long short-term memory network (BiLSTM) or a Transformer encoder is used to capture long-range dependencies.
[0081] The feature transformation network consists of four fully connected layers, with 1024, 512, 256, and 128 neurons in each layer, respectively. Reinforced Luminance (ReLU) activation functions are used. Residual connections are introduced between each layer, summing the input and output of the current layer before passing it to the next layer, effectively alleviating the vanishing gradient problem. The resulting 128-dimensional semantic feature vector is obtained. For example, for the input text "Application of Artificial Intelligence in Medical Diagnosis," after processing, a semantic feature vector containing the topic, intent, and key points is obtained.
[0082] The knowledge path is input into a heterogeneous graph neural network, which transfers information between node and edge features to obtain a structured path representation. A knowledge path consists of entity nodes and relationship edges in the knowledge graph, such as "artificial intelligence - application - medical diagnosis - assistance - disease identification." The heterogeneous graph neural network distinguishes between different types of nodes and edges, designing a specific transformation matrix for each type.
[0083] For each node, information about its neighboring nodes is collected and transformed using a corresponding transformation matrix based on the edge type. This information is then aggregated and used to update the current node representation. This process is repeated three times to achieve multi-hop information transfer. An 8-head attention mechanism is applied to the processed path representation, with each attention head having a dimension of 64. The importance weights between different nodes are calculated and fused to produce a 512-dimensional path feature vector.
[0084] Input the semantic feature vector and path feature vector into a pre-trained question-answer generation model and set a bidirectional decoding strategy. The pre-trained model is based on the T5 or BART architecture, has approximately 110M parameters, and is pre-trained on 10 million question-answer pairs.
[0085] The forward decoding unit sequentially decodes the semantic feature vectors to generate a sequence of questions. Specifically, at each decoding step, the attention distribution between the current decoding state and the encoder output is calculated. The attention weights are calculated by performing a dot product similarity calculation and then normalized using softmax. Highly weighted areas indicate the focus of the current decoding step. For example, when generating the question "How is artificial intelligence applied in the field of medical diagnosis?", the decoder will focus on the key concepts of "artificial intelligence," "medical diagnosis," and "application."
[0086] In the pre-trained model, the path feature vectors are reverse-decoded to generate the answer sequence. Reverse decoding starts at the end of the answer and builds up the complete answer. During the decoding process, a 256-dimensional memory matrix is used to store historical decoding information. A memory retrieval mechanism retrieves relevant historical information to assist in updating the current state. Each cell in the memory matrix stores a vector representing the characteristics of the previous decoding state.
[0087] To enhance the consistency between questions and answers, a multi-granularity alignment calculation module was constructed to generate an alignment matrix. Alignment calculations were performed at three granularities: word, phrase, and sentence. Word-level alignment was achieved by calculating the cosine similarity of word vectors; phrase-level alignment extracted n-gram features and calculated similarity using a sliding window; and sentence-level alignment compared the semantic representations of the complete question and answer. The alignment matrix has dimensions of question length × answer length, with each element ranging from 0 to 1, indicating the degree of alignment at the corresponding position.
[0088] The alignment matrix is processed by a deep neural network consisting of three fully connected layers, with 512, 256, and 128 neurons in each layer, to generate a state update vector. This vector is used to adjust the hidden states of the forward and backward decoding units to ensure semantic consistency between the question and the answer. For example, if the question is "How can AI help doctors diagnose diseases?" the answer should focus on the specific technologies and methods used in AI-assisted diagnosis.
[0089] Based on the updated hidden layer state, multiple rounds of interactive revision are initiated, alternating between question and answer reconstruction in each round. Three rounds of interactive revision are performed, with each round first revising the question representation based on the current answer state, and then revising the answer content based on the updated question representation. The interactive revision process uses a gated update mechanism, achieving information fusion by calculating the weighted sum of the candidate state and the original state. The weight parameters are learned by the neural network.
[0090] Through the above steps, this method can generate semantically coherent and content-related question-answer pairs, such as the question "What are the advantages of artificial intelligence in medical diagnosis?" and the answer "Artificial intelligence has advantages in medical diagnosis, such as processing large amounts of data, identifying hidden patterns, improving diagnostic accuracy, and reducing misdiagnosis rates, which can assist doctors in making more accurate clinical decisions."
[0091] Figure 5 This is a comparison chart of the accuracy of the question-answering generation model on different data sets according to an embodiment of the present invention: This figure compares the accuracy of different question-answering models on seven datasets. Four models are compared: our solution, Seq2Seq+Attention, BART, and T5. The horizontal axis represents the datasets (SQuAD, HotpotQA, NaturalQA, TriviaQA, NewsQA, BioASQ, and DROP), and the vertical axis represents the accuracy percentage. In terms of performance, our solution achieved the best results on all datasets, consistently achieving accuracy above 80%, with a peak of 83.7% on the TriviaQA dataset. The T5 model performed second overall, with accuracy fluctuating between 76.9% and 80.3%. The BART model ranked third, with accuracy ranging from 73.1% to 76.2%. The Seq2Seq+Attention model performed the worst, with accuracy mostly ranging from 62.6% to 65.1%. Of particular note, this technical solution maintains stable high performance on datasets such as HotpotQA (81.4%) and NaturalQA (82.6%), demonstrating its strong generalization and robustness. These experimental results fully demonstrate the superiority and practical value of this technical solution in multi-domain question answering tasks.
[0092] According to a second aspect of the embodiments of the present invention, An electronic device is provided, comprising: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0093] According to a third aspect of the embodiments of the present invention, A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method described above is implemented.
[0094] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.
[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A hierarchical semantic understanding and intelligent question-answering method for multi-domain texts, characterized by: include: Receive the text to be processed input by the user and perform preprocessing to obtain the preprocessed text; A multi-domain text classification pre-training model is used to perform domain identification on the preprocessed text, and a multi-round iterative domain segmentation mechanism is constructed to obtain a target domain identifier corresponding to the preprocessed text. According to the target domain identifier, the corresponding domain knowledge graph is called from a preset multi-domain knowledge graph library; Constructing a hierarchical semantic understanding model based on a bidirectional long short-term memory neural network, wherein the hierarchical semantic understanding model uses a block memory mechanism to divide and calculate overlapping subsequences of an input sequence, inputting the preprocessed text into the hierarchical semantic understanding model, and obtaining a hierarchical semantic representation of the preprocessed text; A multi-hop reasoning method based on a graph attention network is used to perform knowledge reasoning on the domain knowledge graph. Each hop of reasoning includes entity attention calculation and relationship attention calculation, and the knowledge path related to the hierarchical semantic representation is gradually refined through multi-hop iteration. Based on the hierarchical semantic representation and the knowledge path, the hierarchical semantic representation and the knowledge path are input into a pre-trained question-answer generation model, and a bidirectional decoding strategy is used to decode the input information in sequence and reverse order to generate corresponding question-answer pairs; The question-answer pair is returned to the user as an output result of the intelligent question answering.
2. The method according to claim 1, characterized in that A multi-domain text classification pre-training model is used to perform domain identification on the preprocessed text, and a multi-round iterative domain segmentation mechanism is constructed to obtain a target domain identifier corresponding to the preprocessed text. According to the target domain identifier, the corresponding domain knowledge graph is called from a preset multi-domain knowledge graph library, including: Performing word segmentation on the preprocessed text, using a word segmentation method that combines forward maximum matching based on a domain dictionary library and rule recognition based on a word segmentation rule library to obtain a text sequence after word segmentation; Constructing a multi-domain text classification pre-training model, setting a multi-layer bidirectional encoder in the multi-domain text classification pre-training model to extract features of the text sequence after word segmentation, aligning and encoding entities in the text sequence after word segmentation with entities in a preset multi-domain knowledge graph to obtain entity encoding vectors, and obtaining domain prediction probabilities based on the entity encoding vectors and features of the text sequence after word segmentation; Inputting the segmented text sequence into the multi-domain text classification pre-training model, constructing a multi-round iterative domain segmentation mechanism based on the domain prediction probability, combining the current domain prediction probability with the preset domain knowledge rules in each iteration, performing hierarchical domain division on the preprocessed text, and updating the domain prediction probability after each iteration, iterating according to a preset number of iterations to obtain a final target domain identification; According to the target domain identifier, relevant domain knowledge graphs are retrieved from the preset multi-domain knowledge graph library, similarity calculation and weight assignment are performed on the retrieved multiple domain knowledge graphs, and the knowledge graph with the highest similarity weight is determined as the target domain knowledge graph.
3. The method according to claim 2, characterized in that Construct a multi-domain text classification pre-training model, set a multi-layer bidirectional encoder in the multi-domain text classification pre-training model to extract the features of the text sequence after word segmentation, align and encode the entities in the text sequence after word segmentation with the entities in a preset multi-domain knowledge graph to obtain entity encoding vectors, and obtain domain prediction probabilities based on the entity encoding vectors and the features of the text sequence after word segmentation, including: Constructing a multi-domain text classification pre-training model, and inputting the segmented text sequence into the multi-domain text classification pre-training model; A multi-layer bidirectional encoder is set in the multi-domain text classification pre-training model, the text sequence after word segmentation is input into the multi-layer bidirectional encoder, and a local attention sublayer and a global attention sublayer are respectively constructed in each layer of the encoder, the local attention sublayer calculates local text features based on a sliding window, and the global attention sublayer captures long-range dependencies, the local text features are adaptively fused with the global dependency features, and a multi-scale feature vector of the text sequence after word segmentation is extracted; Constructing a cross-modal entity alignment network, projecting entities in the segmented text sequence and entities in a preset multi-domain knowledge graph into a shared semantic space, constructing a multi-head interactive attention mechanism in the shared semantic space, calculating an entity semantic matching matrix based on the multi-head interactive attention mechanism, inputting the entity semantic matching matrix into a graph neural network for message passing, fusing the local structural information of the entity with the global semantic information, and generating a context-aware entity encoding vector; The entity encoding vector and the multi-scale feature vector are interactively fused at multiple levels to obtain a domain prediction probability.
4. The method according to claim 1, wherein A hierarchical semantic understanding model is constructed based on a bidirectional long short-term memory neural network. The hierarchical semantic understanding model uses a block memory mechanism to divide and calculate overlapping subsequences of an input sequence. The preprocessed text is input into the hierarchical semantic understanding model to obtain a hierarchical semantic representation of the preprocessed text, including: Constructing a hierarchical semantic understanding model, setting a character-level bidirectional long short-term memory neural network in the hierarchical semantic understanding model, wherein the character-level bidirectional long short-term memory neural network adopts a block memory mechanism to divide the input sequence into multiple overlapping subsequence blocks, and each subsequence block is set with an independent memory unit group; Calculating the attention weight distribution of the character sequence in the subsequence block in the memory unit group to generate an intra-block feature representation, inputting the intra-block feature representation into the cross-block attention network, calculating the cross-block feature representation, and obtaining character-level semantic features; Constructing a dynamic feature pyramid based on the character-level semantic features, wherein the dynamic feature pyramid calculates a convolution kernel parameter matrix according to statistical information of the input features and performs feature transformation on the character-level semantic features; Calculating a feature correlation matrix using a selective gating mechanism in the dynamic feature pyramid, and generating a multi-granularity character representation based on the feature correlation matrix; The multi-granularity character representation is fused with the pre-trained word vector, inputted into a word-level bidirectional long short-term memory neural network, and word-level semantic features are calculated through a progressive attention mechanism; Inputting the word-level semantic features into a sentence-level bidirectional long-short-term memory neural network, and calculating the sentence-level semantic features using a hierarchical bidirectional information transfer mechanism; A multi-level feature fusion network is constructed, the character-level semantic features, the word-level semantic features and the sentence-level semantic features are input into the multi-level feature fusion network, and a hierarchical semantic representation is calculated.
5. The method according to claim 1, characterized in that A multi-hop reasoning method based on a graph attention network is used to perform knowledge reasoning on the domain knowledge graph. Each hop of reasoning includes entity attention calculation and relationship attention calculation. The knowledge path related to the hierarchical semantic representation is gradually refined through multi-hop iteration, including: Constructing a hierarchical heterogeneous structure for the domain knowledge graph, extracting a multi-granularity entity node feature matrix and a relationship edge feature matrix from the hierarchical heterogeneous structure, and mapping the hierarchical semantic representation into a query vector using a bidirectional neural network; Constructing a graph attention network, inputting the multi-granularity entity node feature matrix, the relationship edge feature matrix, and the query vector into the graph attention network, and obtaining enhanced entity representation vectors and relationship representation vectors through multi-layer graph convolution operations and residual connections; Constructing a multi-hop reasoning module in the graph attention network, the multi-hop reasoning module calculating entity attention weights according to the query vector and the enhanced entity representation vector, calculating relationship attention weights according to the query vector and the enhanced entity representation vector, and combining a current state with a historical state according to the entity attention weights and the relationship attention weights to obtain a multi-hop state representation; Inputting the multi-hop state representation into an interactive matching network, wherein the interactive matching network constructs a fine-grained interaction matrix to calculate a multi-level similarity representation between the multi-hop state representation and the query vector; Constructing a hierarchical path scoring model based on the multi-level similarity representation, wherein the hierarchical path scoring model uses a hierarchical attention mechanism to adaptively score candidate knowledge paths; A knowledge path related to the hierarchical semantic representation is selected from the hierarchical heterogeneous structure according to the adaptive scoring.
6. The method according to claim 5, characterized in that A multi-hop reasoning module is constructed in the graph attention network, wherein the multi-hop reasoning module calculates entity attention weights according to the query vector and the enhanced entity representation vector, calculates relationship attention weights according to the query vector and the enhanced relationship representation vector, and combines the current state with the historical state according to the entity attention weights and the relationship attention weights to obtain a multi-hop state representation, including: Inputting the query vector into a multi-head feature projection network, wherein the multi-head feature projection network transforms the query vector using different projection matrices to generate a multi-view query representation; Adaptively generating feature transformation parameters according to the multi-view query representation, and conditionally transforming the entity representation vector and the relationship representation vector based on the feature transformation parameters to generate an enhanced entity representation vector and an enhanced relationship representation vector; Constructing a multi-hop reasoning module, and providing a query-aware attention calculation unit in the multi-hop reasoning module, wherein the query-aware attention calculation unit performs a tensor decomposition operation on the query vector, the enhanced entity representation vector, and the enhanced relationship representation vector, respectively, to construct a multi-view initial weight matrix; Constructing a deep attention conversion network in the multi-hop reasoning module, the deep attention conversion network performs multi-layer feature transformation and information aggregation on the multi-view initial weight matrix, and generates entity attention weights and relationship attention weights from the transformed features through a self-calibration mechanism; A recursive state update unit is provided in the multi-hop reasoning module. The recursive state update unit uses an adaptive gating network to combine the entity attention weight and the relationship attention weight with historical reasoning information to generate a multi-hop state representation.
7. The method according to claim 1, characterized in that Based on the hierarchical semantic representation and the knowledge path, the hierarchical semantic representation and the knowledge path are input into a pre-trained question-answer generation model, and a bidirectional decoding strategy is used to decode the input information sequentially and in reverse order to generate corresponding question-answer pairs, including: The hierarchical semantic representation is input into the multi-layer feature transformation network, and the semantic feature vector is obtained through residual connection and nonlinear mapping; The knowledge path is input into the heterogeneous graph neural network, and the node and edge features are transferred to obtain a structured path representation. The structured path representation is passed through a multi-head attention mechanism to obtain a path feature vector; Inputting the semantic feature vector and the path feature vector into a pre-trained question-answer generation model, setting a bidirectional decoding strategy in the pre-trained question-answer generation model, sequentially decoding the semantic feature vectors through a forward decoding unit, and dynamically calculating the attention weight distribution and updating the decoding state in each decoding step to generate a question sequence; The path feature vector is reverse-decoded in the pre-trained question-answer generation model, and during the decoding process, memory retrieval and state update are performed based on the historical decoding information stored in the memory matrix to generate an answer sequence; Constructing a multi-granularity alignment calculation module to generate an alignment matrix, inputting the alignment matrix into a deep neural network to obtain a state update vector, and adjusting the hidden layer states of the forward decoding unit and the reverse decoding unit according to the state update vector to obtain an updated hidden layer state; Multiple rounds of interactive correction are initiated based on the updated hidden layer state, and question reconstruction and answer reconstruction are performed alternately in each round of correction to generate question-answer pairs.
8. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Structural semantic flow modeling-based interpretable text question and answer method and system
CN121365742A
A knowledge graph multi-hop question answering method fusing a large model and a graph convolution network
CN122452794A