An intelligent interactive question-answering system based on natural language processing

CN122925560APending Publication Date: 2026-10-16ULEARNING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611189005.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0003]本发明目的在于提供一种基于自然语言处理的智能交互问答系统,以解决现有技术中单一粒度语义理解导致意图解析不精细,以及静态知识检索无法适应动态对话语境的问题

Benefits of technology

通过构建多粒度语义解析模块,对用户当前轮次的自然语言查询文本执行分层次语义解析,结合依存句法分析、短语结构抽取和语义角色标注,从词级、短语级至句子级逐层提取精细化语义特征,生成多粒度语义表示。该技术手段使系统不再依赖单一粒度的向量编码,而是同步捕捉词汇本身的语义、短语内部的结构化组成关系以及句子整体的陈述意图,从而为后续的语义匹配和推理提供层次完整的信息基础,在应对句式复杂或修饰嵌套密集的查询时,显著提升对用户真实意图的解析准确度。通过构建动态知识图谱构建模块,将多粒度语义表示与基于对话历史编码生成的历史上下文向量相结合,并以拼接得到的综合查询向量为动态线索,在预设知识库中执行实体相似度计算与关系三元组抽取。这种动态抽取方式改变了传统脱离语境的静态知识检索模式,使得所构建的局部知识子图中的实体和关系不仅与当前查询语句相关,还与前文对话形成的语义背景保持高度一致,从而在推理阶段之前有效滤除与当前语境无关的噪声知识,让后续图推理过程能够在紧凑且高相关度的知识范围内进行,兼顾了推理深度的需求与计算资源的合理消耗。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122925560A_ABST
    Figure CN122925560A_ABST
Patent Text Reader

Abstract

The application discloses an intelligent interactive question and answer system based on natural language processing and belongs to the technical field of natural language processing. The system comprises a user input text receiving module, which acquires natural language query text of the current round of a user; a multi-granularity semantic analysis module, which performs hierarchical semantic analysis of words, phrases and sentences on the query text; a dialogue history coding module, which performs time sequence coding on the multi-round dialogue history to generate a history context vector; a dynamic knowledge graph construction module, which dynamically extracts entities and relations from a knowledge base based on multi-granularity semantic representation and the history context vector to construct a local knowledge subgraph; a heterogeneous graph reasoning module, which performs heterogeneous fusion of the local knowledge subgraph and the multi-granularity semantic representation and generates a reasoning path vector through multi-hop reasoning of a graph attention network; and an answer generation module, which decodes the reasoning path vector to generate a natural language answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, specifically to an intelligent interactive question-and-answer system based on natural language processing. Background Technology

[0002] Existing intelligent question-answering systems face numerous challenges in handling complex natural language queries. Questions posed by users in conversational interactions are often characterized by rich semantic layers and strong contextual dependencies, requiring the system to accurately understand user intent and provide precise answers. Current technologies often employ single-granularity representation methods for semantic understanding of user queries, encoding the entire sentence into a fixed-length vector or focusing only on word-level matching. This coarse-grained semantic processing approach struggles to capture the hierarchical structural information between different linguistic units in the user query, resulting in insufficient refinement in the analysis of fine-grained semantics, phrase modification relationships, and the overall sentence intent. Furthermore, in terms of integrating external knowledge, traditional solutions typically rely on keyword matching or fixed templates to retrieve information from knowledge bases, lacking the ability to dynamically perceive the dialogue context and deep semantics. This static retrieval mechanism cannot dynamically adjust the scope of knowledge extraction based on the current dialogue context, easily introducing a large number of noisy entities and irrelevant relationships, affecting the accuracy and efficiency of reasoning. How to achieve deep analysis of multi-layered semantics in user input during question-answering and accurately construct a knowledge reasoning structure closely related to the current query within a dynamically changing dialogue context is a pressing problem in this field. Summary of the Invention

[0003] The purpose of this invention is to provide an intelligent interactive question-answering system based on natural language processing, in order to solve the problems of imprecise intent parsing caused by single-granularity semantic understanding in the prior art, and the inability of static knowledge retrieval to adapt to dynamic dialogue context.

[0004] To achieve the above objectives, the present invention provides the following technical solution: The present invention provides an intelligent interactive question-answering system based on natural language processing. This system significantly improves the accuracy of answers and the coherence of interaction in complex question-answering scenarios through the deep integration of multi-granularity semantic understanding and dynamic knowledge reasoning. The system includes a user input text receiving module, a multi-granularity semantic parsing module, a dialogue history encoding module, a dynamic knowledge graph construction module, a heterogeneous graph reasoning module, and an answer generation module.

[0005] The user input text receiving module acquires the natural language query text for the current user round, providing raw input for subsequent processing. The multi-granularity semantic parsing module performs hierarchical semantic parsing on the natural language query text, generating multi-granularity semantic representations at the word, phrase, and sentence levels. This captures query intent from different levels of abstraction, enhancing the joint understanding of fine-grained and overall semantics. Preferably, this module performs dependency parsing on the query text, obtaining a syntactic dependency tree, and extracting phrase structures from the syntactic dependency tree, extracting noun phrases, verb phrases, and prepositional phrases. Simultaneously, it performs semantic role labeling on the query text, identifying predicates and their arguments. Based on this, word-level semantic vectors, phrase-level semantic vectors, and sentence-level semantic vectors are generated based on the syntactic dependency tree, phrase structure, and semantic role labeling results. This ensures that the semantic representation includes both syntactic structure information and semantic role information, facilitating accurate positioning in downstream knowledge retrieval and reasoning. Furthermore, for word-level semantics, a pre-trained word embedding model is used to map each word into a word-level semantic vector; for phrase-level semantics, the word-level semantic vectors of each word in the extracted phrase structure are averaged or attention pooled to obtain phrase-level semantic vectors; for sentence-level semantics, the entire query text is input into a sentence encoder to obtain sentence-level semantic vectors, thereby constructing a hierarchical and complete semantic expression.

[0006] The dialogue history encoding module performs temporal encoding on multi-turn dialogue history to generate a historical context vector, enabling the system to maintain dialogue continuity and understand referential resolution. This module acquires the user query and system response text from multiple turns prior to the current turn, vectorizes each turn's dialogue text, and obtains a dialogue turn vector sequence. This sequence is then input into a bidirectional long short-term memory network for temporal dependency modeling, outputting the hidden state at each time step. The hidden states are then aggregated with attention weights to generate the historical context vector. Through bidirectional temporal modeling and an attention mechanism, this module can highlight key information relevant to the current query in the historical dialogue and suppress interference from irrelevant historical content. Preferably, the dialogue turn vector sequence is positionally encoded to add temporal positional information. The positionally encoded sequence is then input into a forward LSTM and a backward LSTM to obtain forward and backward hidden state sequences. The forward and backward hidden states at corresponding time steps are concatenated to obtain bidirectional hidden states. Finally, the bidirectional hidden states are weighted with time-step attention to generate a more accurate historical context vector.

[0007] The dynamic knowledge graph construction module, based on multi-granularity semantic representation and historical context vectors, dynamically extracts relevant entities and relationships from a pre-defined knowledge base to construct a local knowledge subgraph for the current round. This avoids blind searching of the entire knowledge graph, improving the efficiency and accuracy of knowledge retrieval. The module concatenates the multi-granularity semantic representation with the historical context vector to obtain a comprehensive query vector. It then calculates the similarity between the comprehensive query vector and entity embeddings in the knowledge base, filtering out candidate entity sets with similarity exceeding a threshold. Finally, it extracts relation triples associated with the comprehensive query vector from the candidate entity set, forming a local knowledge subgraph. By concatenating semantic representation and historical context, the comprehensive query vector simultaneously carries the fine semantics of the current query and the historical context of the dialogue, making the extracted subgraph highly relevant to the user's dialogue state. Preferably, the module also performs entity disambiguation on the candidate entity set to eliminate ambiguity between entities with the same name and scores the confidence of the extracted relation triples, filtering out low-confidence triples, thereby further improving the quality and credibility of the constructed local knowledge subgraph.

[0008] The heterogeneous graph reasoning module heterogeneously fuses local knowledge subgraphs with multi-granularity semantic representations. It performs multi-hop reasoning through a graph attention network to generate reasoning path vectors, enabling deep interaction and reasoning between textual semantics and knowledge structure. This module maps word-level, phrase-level, and sentence-level semantic vectors from the multi-granularity semantic representations to graph node features. Entity nodes and relation nodes in the local knowledge subgraph are aligned with these graph node features to construct a heterogeneous graph. A graph attention network is applied to this heterogeneous graph, using a multi-head attention mechanism to calculate attention coefficients between nodes and update node representations. After multi-hop propagation, the graph node representations are pooled to generate reasoning path vectors. This heterogeneous fusion mechanism allows textual semantic information to effectively guide the reasoning direction in the knowledge graph, while the structural information of the knowledge graph supplements and corrects the understanding of textual semantics, thus solving the problem of insufficient information from a single modality. Preferably, during multi-hop inference, a maximum number of inference hops is set. In each hop, attention weights are calculated using the current node representation and neighbor node representations, and neighbor information is aggregated to update the node representation. The updated node representation is then joined with the initial node representation using a residual connection. After completing all hops, the final node representation is subjected to global average pooling to obtain the inference path vector. The residual connection design helps with gradient propagation and multi-hop information preservation, ensuring that key information is effectively retained even in long-distance inference paths.

[0009] The answer generation module decodes the reasoning path vector to generate a natural language answer, ultimately presenting the reasoning result to the user in fluent natural language. This module fuses the reasoning path vector with the historical context vector to obtain a fused vector, which is then input into a Transformer-based decoder to generate the answer text word by word. During the generation process, a copying mechanism is used to select entity words from the local knowledge subgraph, while a general vocabulary is generated using a generative vocabulary list. This mechanism ensures that the generated answer accurately references entity information from the knowledge graph while maintaining the flexibility and naturalness of the language expression, significantly reducing entity generation errors and awkward language.

[0010] Through the collaborative work of the above modules, the question-answering system provided by this invention can perform multi-level semantic analysis of user queries, dynamically construct local knowledge subgraphs in combination with the dialogue history context, and generate knowledge-enhanced answers by using heterogeneous graph attention reasoning, thereby significantly improving the factual accuracy and information completeness of the answers while maintaining the coherence of the dialogue.

[0011] The technical effects and advantages provided by the present invention in the above technical solution are as follows: By constructing a multi-granularity semantic parsing module, hierarchical semantic parsing is performed on the natural language query text of the user's current round. Combining dependency parsing, phrase structure extraction, and semantic role labeling, refined semantic features are extracted layer by layer from the word level, phrase level, to the sentence level, generating a multi-granularity semantic representation. This technique allows the system to move beyond single-granularity vector encoding, simultaneously capturing the semantics of words themselves, the structured relationships within phrases, and the overall declarative intent of sentences. This provides a complete information foundation for subsequent semantic matching and reasoning, significantly improving the accuracy of parsing the user's true intent when dealing with queries with complex sentence structures or dense nested modifications. By constructing a dynamic knowledge graph construction module, the multi-granularity semantic representation is combined with historical context vectors generated based on dialogue history encoding. Using the concatenated comprehensive query vector as dynamic clues, entity similarity calculation and relation triple extraction are performed in a pre-set knowledge base. This dynamic extraction method changes the traditional static knowledge retrieval mode that is detached from context. It makes the entities and relations in the constructed local knowledge subgraph not only relevant to the current query statement, but also highly consistent with the semantic background formed by the previous dialogue. This effectively filters out noisy knowledge that is irrelevant to the current context before the reasoning stage, allowing the subsequent graph reasoning process to be carried out within a compact and highly relevant knowledge range, taking into account both the need for reasoning depth and the reasonable consumption of computing resources. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.

[0013] Figure 1 This is a schematic diagram of the structure of an intelligent interactive question-answering system based on natural language processing; Figure 2 This is a flowchart of multi-granularity semantic parsing; Figure 3 This is a flowchart of the dialogue history coding process; Figure 4 It is a flowchart for answer generation that integrates gating and replication mechanisms. Detailed Implementation

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

[0015] See Figure 1 This invention provides an intelligent interactive question-answering system based on natural language processing, comprising: a user input text receiving module, a multi-granularity semantic parsing module, a dialogue history encoding module, a dynamic knowledge graph construction module, a heterogeneous graph reasoning module, and an answer generation module. The user input text receiving module acquires the user's natural language query text for the current round. The multi-granularity semantic parsing module performs hierarchical semantic parsing on the user's natural language query text for the current round, generating multi-granularity semantic representations including word-level, phrase-level, and sentence-level representations. The dialogue history encoding module performs temporal encoding on the multi-round dialogue history, generating a historical context vector. The dynamic knowledge graph construction module dynamically extracts relevant entities and relationships from a preset knowledge base based on the multi-granularity semantic representations and the historical context vectors, constructing a local knowledge subgraph for the current round. The heterogeneous graph reasoning module heterogeneously fuses the local knowledge subgraph with the multi-granularity semantic representations, performs multi-hop reasoning through a graph attention network, and generates a reasoning path vector. The answer generation module decodes the reasoning path vector to generate a natural language answer.

[0016] Example 1:

[0017] In specific implementation, please refer to Figure 2The multi-granularity semantic parsing module performs hierarchical semantic parsing of the user's current round of natural language query text, including dependency parsing, phrase structure extraction, semantic role labeling, and multi-granularity semantic vector generation.

[0018] During dependency parsing, the user's current natural language query text is input into a neural network dependency parser based on a dual affine attention mechanism. The dependency parser comprises an embedding layer, a bidirectional long short-term memory (LSTM) encoding layer, and a dual affine classification layer. The embedding layer maps each word in the text to a vector. The LSM encoding layer extracts the context representation of each word. The dual affine classification layer calculates the scores for dependency arcs and dependency relationship types between any two words, and uses a maximum spanning tree algorithm to decode the complete syntactic dependency tree. Nodes in the syntactic dependency tree are words, directed edges represent dependency relationships between words, and edge labels indicate the relationship type.

[0019] A transformation-based neural network phrase structure analyzer is implemented for phrase structure extraction. The phrase structure analyzer constructs a shift-reduction stack from the word sequence of the syntactic dependency tree. An LSTM-based state encoder encodes the contents of the stack and buffer, and a multilayer perceptron predicts the next operation, such as SHIFT or REDUCE, and the reduced phrase label. This process is repeated until a complete phrase structure tree is constructed. From this tree, sets of noun phrases, verb phrases, and prepositional phrases are extracted. Each noun phrase consists of consecutive words, as do the verb and prepositional phrases.

[0020] Semantic role labeling employs a sequence labeling model based on BiLSTM-CRF. The word sequence of the user's current natural language query text is taken as input, and character-level information is encoded through a word embedding layer and a character convolutional neural network. This encoded information is then concatenated and fed into a two-layer bidirectional long short-term memory network to obtain the contextual representation of each word. A Conditional Random Field (CRF) is then applied to the top layer of the BiLSTM for sequence labeling. The BIO labeling system is used to identify predicates and their corresponding argument boundaries and role types, outputting semantic role labeling results, including predicates and their associated arguments such as agent, patient, time, and location.

[0021] When generating word-level semantic vectors, a pre-trained word embedding model is used to map each word to a word-level semantic vector. The pre-trained word embedding model employs the Transformer-based bidirectional encoder representation model BERT, consisting of 12 stacked Transformer encoder layers. Each layer contains a multi-head self-attention sublayer and a feedforward fully connected sublayer, with a hidden dimension of 768 and 12 self-attention heads. BERT is pre-trained on a large-scale general corpus through masked language modeling and next-sentence prediction tasks. When the user inputs the natural language query text for the current round, a [CLS] marker is added at the beginning of the text, and a [SEP] marker is added at the end. The word segmenter divides the text into word fragments. BERT outputs a 768-dimensional context representation vector for each word fragment. For a complete word segmented into multiple word fragments, the vector of the first word fragment is taken as the word-level semantic vector, and then... Indicates the first Word-level semantic vectors of each word.

[0022] When generating phrase-level semantic vectors, for each phrase extracted from the phrase structure, the word-level semantic vectors of all words within that phrase are average-pooled to obtain the phrase-level semantic vector. The average pooling calculation method is as follows:

[0023] in, A phrase-level semantic vector representing a phrase. This represents the set of words contained in the current phrase. Represents a set The number of Chinese words Represents a set The Middle The word-level semantic vectors of each word are obtained. The above operations are performed on all noun phrases, verb phrases, and prepositional phrases to obtain a set of phrase-level semantic vectors.

[0024] When generating sentence-level semantic vectors, the entire natural language query text of the user's current round is input into the sentence encoder. The sentence encoder also uses the BERT model, taking the final hidden state vector corresponding to the [CLS] marker position of the model as the sentence-level semantic vector. This 768-dimensional vector integrates the semantic information of the entire sentence.

[0025] Word-level semantic vectors, phrase-level semantic vectors, and sentence-level semantic vectors together constitute a multi-granularity semantic representation, which is output to the dynamic knowledge graph construction module and the heterogeneous graph reasoning module.

[0026] Example 2:

[0027] In specific implementation, please refer to Figure 3The dialogue history encoding module acquires the user query text and system response text from multiple rounds prior to the current round. It concatenates the user query text and system response text from each round into a dialogue round text sequence, and these concatenations form a dialogue sequence set. The number of rounds acquired is set to 5, meaning the most recent 5 rounds of dialogue content are retained. When the historical dialogue has fewer than 5 rounds, blank round placeholders are added to the beginning of the sequence; these placeholders are indicated by the special marker [PAD].

[0028] When vectorizing the dialogue text for each round, the BERT bidirectional encoder model based on Transformers is used as the text encoder. The BERT model consists of 12 stacked Transformer encoder layers, each containing a multi-head self-attention sublayer and a feedforward fully connected sublayer, with a hidden dimension of 768 and 12 self-attention heads. The BERT model is pre-trained on a general corpus through masked language modeling and next-sentence prediction tasks. For each round of dialogue text, a [CLS] marker is added at the beginning of the text and a [SEP] marker is added at the end. The word segmenter divides the text into word fragments, and the BERT model outputs a 768-dimensional context representation vector for each word fragment. The final hidden state vector corresponding to the [CLS] marker position is taken as the round representation vector for this round of dialogue. The round representation vectors of each round are arranged in chronological order to obtain the dialogue round vector sequence, with each round vector having a dimension of 768.

[0029] When performing positional encoding on the dialogue turn vector sequence, sine and cosine functions are used to generate the positional encoding vector. The dimension of the positional encoding vector is the same as the dimension of the turn representation vector, which is 768 dimensions. For the nth turn in the sequence... The position, the position encoding vector of the position peacekeeping The dimensions are generated by calculating the sine and cosine functions, respectively, where This is the dimension index, with values ​​ranging from 0 to 383. The turn representation vector in the dialogue turn vector sequence is added element-wise to the corresponding position encoding vector to obtain the turn representation vector sequence with added temporal position information.

[0030] The position-encoded round representation vector sequence is input into a bidirectional long short-term memory (LSTM) network for temporal dependency modeling. The bidirectional LSTM network consists of a forward LSTM layer and a backward LSTM layer. Both the forward LSTM and backward LSTM layers contain 256 hidden units, and both layers are single-layer structures. The forward LSTM layer processes the round representation vector sequence in chronological order from earliest to latest, obtaining the forward hidden state sequence. Indicates the first The forward hidden state has a dimension of 256 and is processed by the backward LSTM layer in ascending order of time to obtain the backward hidden state sequence. Indicates the first The backward hidden state at each time step has a dimension of 256. The gating mechanism within the LSTM unit uses the Sigmoid activation function and element-wise multiplication to filter information.

[0031] By concatenating the forward and backward hidden states at the corresponding time steps, we obtain the bidirectional hidden state for each time step. Two-way hidden state at each time step The dimension is 512, and it is composed of... and They are concatenated along the feature dimension. The bidirectional hidden states at all time steps constitute a bidirectional hidden state sequence.

[0032] When performing time-step attention-weighted aggregation on the bidirectional hidden state sequence, an attention mechanism based on learnable parameters is adopted. An attention scoring vector is introduced. The dimension is 512, and it is randomly initialized and updated through training. For the ... Two-way hidden state at each time step Attention scores are calculated through linear transformations and nonlinear activations. These scores are then Softmax normalized to obtain attention weights. These attention weights are then used to weight and sum the bidirectional hidden state sequences to generate a historical context vector. The calculation method for the weighted aggregation of attention is as follows:

[0033] in, This represents the historical context vector, with a dimension of 512. This represents the total number of dialogue rounds, with a value of 5. Indicates the first A two-way hidden state at each time step. This represents a trainable weight matrix with dimension . . This represents a trainable bias vector with a dimension of 512. This represents a trainable attention scoring vector with a dimension of 512. This represents the hyperbolic tangent activation function. Indicates the first The attention weights at each time step are in the range of (0,1), and the sum of the attention weights at all time steps is 1. , and The parameter values ​​are obtained during model training through backpropagation and updates using the Adam optimizer, with the initial learning rate of the Adam optimizer set to 0.001. Historical context vector. Output to the dynamic knowledge graph construction module and the answer generation module.

[0034] Example 3:

[0035] In its implementation, the dynamic knowledge graph construction module receives the multi-granular semantic representation output by the multi-granular semantic parsing module and the historical context vector output by the dialogue history encoding module. The multi-granular semantic representation includes a set of word-level semantic vectors, a set of phrase-level semantic vectors, and a sentence-level semantic vector. The historical context vector has a dimension of 512.

[0036] When generating the comprehensive query vector, the multi-granularity semantic representation is concatenated with the historical context vector. Sentence-level semantic vectors are extracted from the multi-granularity semantic representation; these vectors have a dimension of 768. The sentence-level semantic vectors are then concatenated with the historical context vectors along the feature dimension to obtain a comprehensive query vector with a dimension of 1280. This comprehensive query vector integrates the global semantic information of the current query round and the temporal context information of the dialogue history.

[0037] The pre-defined knowledge base uses a structured knowledge graph, where entities are stored as entity embedding vectors. These vectors are obtained through pre-training the TransE knowledge graph embedding model, with a dimension of 512. The TransE model models the relation triples (head entity, relation, tail entity) in the knowledge graph as a translation transformation where the sum of the head entity embedding vector and the relation embedding vector is approximately equal to the tail entity embedding vector. The loss function uses a marginal ranking loss. After training, all entities receive a 512-dimensional embedding vector.

[0038] When calculating the similarity between the comprehensive query vector and the entity embeddings in the knowledge base, a trainable linear projection matrix is ​​introduced to linearly map the comprehensive query vector from 1280 dimensions to 512 dimensions, resulting in the projected query vector. The projected query vector is calculated as follows:

[0039] in, This represents the projection query vector, with a dimension of 512. Let represent a trainable linear projection matrix with dimension . . This represents the comprehensive query vector, with a dimension of 1280. Linear projection matrix. The parameter values ​​are updated through backpropagation during the model training phase.

[0040] Projected query vector For each query, the cosine similarity between the projected query vector and the embedding vector of each entity in the knowledge base is calculated. The threshold for cosine similarity is set to 0.65. When the cosine similarity between the projected query vector and an entity embedding vector is greater than or equal to 0.65, the corresponding entity is included in the candidate entity set. The threshold of 0.65 is based on the optimal balance between precision and recall determined through grid search on the validation set.

[0041] When performing entity disambiguation on the candidate entity set, a graph context-based entity disambiguation model is employed. This model is a graph attention network structure, consisting of two stacked graph attention layers, each containing four attention heads with a hidden dimension of 256. Each entity in the candidate entity set is treated as a node, and a subgraph is constructed using its one-hop neighbors in the knowledge graph as context nodes. Each entity node in the subgraph is input with its pre-trained entity embedding vector, and neighbor information is aggregated through the graph attention layer to update the context-aware representation of the entity node. The updated entity node representation is used to determine the semantic relevance of entities within the context represented by the comprehensive query vector, eliminating ambiguity between entities with the same name and retaining semantically related entities. The candidate entity set after disambiguation is free of ambiguous entity nodes.

[0042] When extracting relation triples associated with the projected query vector from the disambiguated candidate entity set, each entity in the candidate entity set is traversed, and all relation triples in which that entity participates are retrieved from the knowledge graph. For each retrieved relation triple, the head entity embedding vector, relation embedding vector, and tail entity embedding vector are concatenated, and a confidence score is calculated using a multilayer perceptron. The multilayer perceptron contains two fully connected layers: the first fully connected layer has an input dimension of 1536 and an output dimension of 512, using the ReLU activation function; the second fully connected layer has an input dimension of 512 and an output dimension of 1, using the Sigmoid activation function. The output value represents the confidence score of the triple, ranging from (0,1). The confidence score threshold is set to 0.5; triples with a confidence score greater than 0.5 are retained, while low-confidence triples with a score less than or equal to 0.5 are filtered out. The retained relation triples and their contained entities and relations together form a local knowledge subgraph. The local knowledge subgraph is represented by a graph data structure, containing a set of entity nodes and a set of relation edges, and is output to the heterogeneous graph reasoning module.

[0043] Example 4:

[0044] In its implementation, the heterogeneous graph reasoning module receives the multi-granular semantic representation output by the multi-granular semantic parsing module and the local knowledge subgraph output by the dynamic knowledge graph construction module. The multi-granular semantic representation includes a set of word-level semantic vectors, a set of phrase-level semantic vectors, and a sentence-level semantic vector. Each vector in the word-level semantic vector set has a dimension of 768, each vector in the phrase-level semantic vector set has a dimension of 768, and each sentence-level semantic vector has a dimension of 768. The local knowledge subgraph includes a set of entity nodes and a set of relation edges. Entity nodes are accompanied by pre-trained entity embedding vectors with a dimension of 512, and relation edges are accompanied by relation type labels.

[0045] When mapping word-level, phrase-level, and sentence-level semantic vectors in multi-granularity semantic representation to graph node features, three independent trainable linear projection matrices are used. The word-level linear projection matrix has a dimension of 512×768, linearly mapping each 768-dimensional word-level semantic vector to a 512-dimensional word-level graph node feature. The phrase-level linear projection matrix has a dimension of 512×768, linearly mapping each 768-dimensional phrase-level semantic vector to a 512-dimensional phrase-level graph node feature. The sentence-level linear projection matrix has a dimension of 512×768, linearly mapping each 768-dimensional sentence-level semantic vector to a 512-dimensional sentence-level graph node feature. The parameter values ​​of the three linear projection matrices are updated through backpropagation during the model training phase.

[0046] When constructing a heterogeneous graph by aligning entity nodes and relation nodes in the local knowledge subgraph with graph node features, the heterogeneous graph contains three types of nodes: semantic nodes, entity nodes, and relation nodes. Semantic nodes consist of word-level, phrase-level, and sentence-level graph node features. The initial representation vector of each semantic node is the corresponding graph node feature, with a dimension of 512. Entity nodes consist of entity nodes in the local knowledge subgraph. The initial representation vector of each entity node is a pre-trained entity embedding vector, with a dimension of 512. Relation nodes consist of relation edges in the local knowledge subgraph. The initial representation vector of each relation node is a randomly initialized relation embedding vector, with a dimension of 512, and the relation embedding vector is updated through training. There are no edges connecting semantic nodes to each other. Edges between semantic nodes and entity nodes are established based on the overlap between the word-level semantic vector and the entity name; an undirected edge is established when the overlap character length exceeds 2. Edges between semantic nodes and relation nodes are established based on the overlap between the phrase-level semantic vector and the relation name; similarly, an undirected edge is established when the overlap character length exceeds 2. The edges between entity nodes and relation nodes are established based on the triple structure in the local knowledge subgraph. When the head entity is connected to the tail entity through a relation, directed edges are established between the entity node and the relation node, and between the relation node and the entity node, respectively.

[0047] When applying a graph attention network to a heterogeneous graph, the graph attention network consists of two stacked heterogeneous attention layers. Each heterogeneous attention layer contains four attention heads with a hidden dimension of 128. The outputs of the two heterogeneous attention layers are fused by element-wise averaging. The heterogeneous attention layers distinguish between different types of neighbor nodes when calculating attention coefficients, calculating attention weights separately for each type.

[0048] The maximum number of inference hops is set to 3, meaning that the multi-hop inference process is completed through 3 hops. The basis for setting the maximum number of inference hops to 3 is that the size of the local knowledge subgraph is usually within three hops to cover the required knowledge associations. In each hop of inference, when calculating attention weights using the current node representation and neighboring node representations, for each node... and nodes First, a linear transformation is performed on the node representations. Then, the transformed results are concatenated and used to calculate attention coefficients through a single-layer feedforward network. Finally, the attention coefficients are normalized using Softmax to obtain the attention weights. The node representation update method in each hop of inference is as follows:

[0049] in, Represents a node In the Jump to the updated node representation vector The value range is from 0 to 2. This indicates the number of attention heads, with a value of 4. This indicates a vector concatenation operation. This represents the ELU activation function. Represents a node The set of neighbor nodes includes three types of neighbors: semantic nodes, entity nodes, and relation nodes. Indicates the first In the jump reasoning, the first Each attention node For nodes The attention weights are calculated by normalizing the attention coefficients using Softmax. The value range is (0,1). Indicates the first In the jump reasoning, the first Each attention head corresponds to a trainable weight matrix with dimension [ ]. , The dimension represented by the input node. Represents a node In the The node representation vector before the jump update. For the initial jump... , This is the initial representation vector for each node.

[0050] After updating the node representation for each hop, a residual join is performed between the updated node representation and the initial node representation. The specific method for the residual join is as follows: for each node... , and update its node representation Representation of the initial node Element-wise addition is performed to obtain the node representation after residual connection. Residual connection helps to prevent the initial semantic information from being diluted during deep propagation in the network.

[0051] After completing the 3-hop propagation, global average pooling is performed on the final node representations of all nodes to obtain the inference path vector. Global average pooling is calculated by averaging the final node representation vectors of all nodes along the node dimension, resulting in a 512-dimensional inference path vector. The inference path vector is then output to the answer generation module.

[0052] Example 5:

[0053] In specific implementation, please refer to Figure 4 The answer generation module receives the reasoning path vector output by the heterogeneous graph reasoning module, the historical context vector output by the dialogue history encoding module, and the local knowledge subgraph output by the dynamic knowledge graph construction module. The reasoning path vector has a dimension of 512, the historical context vector has a dimension of 512, and the local knowledge subgraph contains a set of entity nodes and a set of relation edges. The entity nodes are accompanied by entity name text.

[0054] When fusing the inference path vector and the historical context vector, a gated fusion mechanism is employed. This mechanism includes a trainable gate vector to control the contribution ratio of the two vectors during the fusion process. The fusion vector is calculated as follows:

[0055] in, This represents the fusion vector, with a dimension of 512. This represents the reasoning path vector, with a dimension of 512. This represents the historical context vector, with a dimension of 512. This indicates element-wise multiplication. This represents the gated weight vector, with a dimension of 512, where each dimension takes values ​​ranging from (0,1). Gated Weight Vector The calculation method is as follows ,in and Denotes a trainable weight matrix, with dimensions 1. , This represents a trainable bias vector with dimension 512. This represents the Sigmoid activation function. , and The parameter values ​​are obtained during the model training phase through backpropagation and Adam optimizer updates, with the initial learning rate of the Adam optimizer set to 0.001.

[0056] When the fused vector is input into the Transformer-based decoder, the decoder consists of six stacked decoder layers. Each decoder layer contains a masked multi-head self-attention sublayer, an encoder-decoder cross-attention sublayer, and a feedforward fully connected sublayer. The masked multi-head self-attention sublayer has 8 attention heads and a hidden dimension of 512. During self-attention computation, a mask is applied to positions after the current time step, ensuring that the decoding process only focuses on already generated words. The encoder-decoder cross-attention sublayer also has 8 attention heads. The query vector comes from the output of the previous decoder sublayer, and the key and value vectors come from the encoder within the answer generation module. The encoder hidden state sequence is obtained through encoding. The hidden dimension of the feedforward fully connected sublayer is 2048, and the ReLU activation function is used. Each sublayer is followed by a residual connection and a layer normalization operation. The input to the decoder is a right-shifted one-bit reference answer text sequence during the training phase, and word-by-word generation starts from the start marker [BOS] during the inference phase.

[0057] The process of generating the answer text word by word is as follows: At each generation time step, the currently generated word sequence is input into a Transformer-based decoder, and the decoder outputs the hidden state vector for the current time step. The hidden state vector has a dimension of 512. The hidden state vector is mapped to the generated vocabulary space through a linear projection layer, and the weight matrix of the linear projection layer has a dimension of 512. ,in This represents the size of the generated vocabulary, which consists of the 50,000 most frequent words from the training corpus. The mapping result is then normalized using Softmax to obtain the probability distribution over the generated vocabulary.

[0058] During the generation process, a copying mechanism is used to select entity words from the local knowledge subgraph. This mechanism introduces a trainable switch probability value to allocate generation probabilities between the generated vocabulary and the entity words in the local knowledge subgraph. The switch probability value is calculated by concatenating the hidden state vector of the decoder at the current time step with the context vector, passing it through a fully connected layer and a sigmoid activation function, and outputting a scalar probability value. The fully connected layer has an input dimension of 1024 and an output dimension of 1. The context vector is obtained by weighted summation of the encoder's hidden state sequence using an encoder-decoder cross-attention sublayer.

[0059] The entity vocabulary set for the local knowledge subgraph is constructed as follows: traverse all entity nodes in the local knowledge subgraph, extract the entity name text of each entity node, process it through a word segmenter to obtain an entity vocabulary list, and then remove duplicates to form the entity vocabulary set. Each word in the entity vocabulary set corresponds to an embedding vector, which is used to calculate the attention score with the decoder's hidden state vector.

[0060] The final generation probability distribution at each time step is a weighted sum of the generation vocabulary probability distribution and the copying vocabulary probability distribution. The switch probability value controls the weight of the generation vocabulary, and 1 minus the switch probability value controls the weight of the copying vocabulary. The probability of the copying vocabulary is obtained by pooling the decoder's cross-attention weights across the entity vocabulary set. The word with the highest probability in the final generation probability distribution is selected as the output word for the current time step. When the output word is the end marker [EOS] or the number of generated words reaches the maximum length limit of 50, the generation process terminates, and the output words from all time steps are concatenated sequentially to form the natural language answer text.

[0061] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. An intelligent interactive question-and-answer system based on natural language processing, characterized in that, include: The user input text receiving module is used to obtain the natural language query text of the user in the current round; The multi-granularity semantic parsing module performs hierarchical semantic parsing on the natural language query text of the user in the current round, generating multi-granularity semantic representations including word-level, phrase-level, and sentence-level; The dialogue history encoding module performs temporal encoding on multi-turn dialogue history to generate a historical context vector. The dynamic knowledge graph construction module, based on the multi-granularity semantic representation and the historical context vector, dynamically extracts relevant entities and relationships from the preset knowledge base to construct the local knowledge subgraph for the current round; The heterogeneous graph reasoning module heterogeneously fuses the local knowledge subgraph with the multi-granularity semantic representation, performs multi-hop reasoning through a graph attention network, and generates a reasoning path vector. The answer generation module decodes the reasoning path vector to generate a natural language answer.

2. The intelligent interactive question-and-answer system based on natural language processing according to claim 1, characterized in that, The multi-granularity semantic parsing module performs hierarchical semantic parsing on the natural language query text of the user's current round, including: Dependency parsing is performed on the natural language query text of the user in the current round to obtain a syntactic dependency tree; Phrase structure extraction is performed on the syntactic dependency tree to extract noun phrases, verb phrases, and prepositional phrases; Semantic role labeling is performed on the natural language query text of the user in the current round to identify predicates and their arguments; Based on the syntactic dependency tree, phrase structure, and semantic role labeling results, word-level semantic vectors, phrase-level semantic vectors, and sentence-level semantic vectors are generated as the multi-granularity semantic representation.

3. The intelligent interactive question-and-answer system based on natural language processing according to claim 1, characterized in that, The dialogue history encoding module performs time-series encoding on multi-turn dialogue history, including: Retrieve the text of user queries and system responses from previous rounds prior to the current round; The dialogue text for each round is vectorized to obtain a sequence of dialogue round vectors. The dialogue turn vector sequence is input into a bidirectional long short-term memory network to perform temporal dependency modeling and output the hidden state at each time step. The hidden states are then aggregated using attention weighting to generate the historical context vector.

4. The intelligent interactive question-and-answer system based on natural language processing according to claim 1, characterized in that, The dynamic knowledge graph construction module dynamically extracts relevant entities and relationships from a preset knowledge base based on the multi-granularity semantic representation and the historical context vector, including: The multi-granular semantic representation is concatenated with the historical context vector to obtain the comprehensive query vector; The similarity between the comprehensive query vector and the entity embeddings in the knowledge base is calculated, and a set of candidate entities with similarity exceeding a threshold is selected. Extract relational triples associated with the comprehensive query vector from the candidate entity set to form the local knowledge subgraph.

5. The intelligent interactive question-and-answer system based on natural language processing according to claim 1, characterized in that, The heterogeneous graph reasoning module heterogeneously fuses the local knowledge subgraph with the multi-granularity semantic representation, including: The word-level, phrase-level, and sentence-level semantic vectors in the multi-granularity semantic representation are respectively mapped to graph node features; Align the entity nodes and relation nodes in the local knowledge subgraph with the graph node features to construct a heterogeneous graph; A graph attention network is applied to the heterogeneous graph, and the attention coefficients between nodes are calculated through a multi-head attention mechanism to update the node representation. After multi-hop propagation, the graph node representations are pooled to generate the inference path vector.

6. The intelligent interactive question-and-answer system based on natural language processing according to claim 1, characterized in that, The answer generation module decodes the reasoning path vector, including: The reasoning path vector is fused with the historical context vector to obtain a fused vector; The fused vector is input into a Transformer-based decoder to generate the answer text word by word; During the generation process, entity words are selected from the local knowledge subgraph using a copying mechanism, and a general vocabulary is generated using a generated vocabulary list.

7. The intelligent interactive question-and-answer system based on natural language processing according to claim 5, characterized in that, The heterogeneous graph reasoning module performs multi-hop reasoning through a graph attention network, including: Set the maximum number of inference jumps; In each hop of inference, attention weights are calculated using the current node representation and neighbor node representations, and neighbor information is aggregated to update the node representation; Perform a residual join between the updated node representation and the initial node representation; After completing all hops, global average pooling is performed on the final node representation to obtain the inference path vector.

8. The intelligent interactive question-and-answer system based on natural language processing according to claim 4, characterized in that, The dynamic knowledge graph construction module dynamically extracts relevant entities and relationships from a preset knowledge base, and also includes: The candidate entity set is subjected to entity disambiguation processing to eliminate ambiguity between entities with the same name; The extracted relation triples are scored with confidence, and low-confidence triples are filtered out.

9. The intelligent interactive question-and-answer system based on natural language processing according to claim 2, characterized in that, The multi-granularity semantic parsing module generates word-level, phrase-level, and sentence-level semantic vectors, including: For the word level, a pre-trained word embedding model is used to map each word into a word-level semantic vector; For phrase level, the word-level semantic vectors within each phrase in the phrase structure are averaged or attention pooled to obtain phrase-level semantic vectors. At the sentence level, the entire natural language query text of the user's current round is input into the sentence encoder to obtain the sentence-level semantic vector.

10. The intelligent interactive question-and-answer system based on natural language processing according to claim 3, characterized in that, The dialogue history encoding module inputs the dialogue turn vector sequence into a bidirectional long short-term memory network, including: The dialogue turn vector sequence is position-encoded and temporal position information is added; The position-encoded sequence is input into the forward LSTM and the backward LSTM to obtain the forward hidden state sequence and the backward hidden state sequence, respectively. By concatenating the forward hidden state and the backward hidden state at the corresponding time step, we obtain the bidirectional hidden state at each time step. The bidirectional hidden state is subjected to time-step attention weighting to generate the historical context vector.