Explainable text question answering method and system based on structural semantic flow modeling

By combining text knowledge graphs with streaming semantic modeling, semantic stream tags and multi-stream aggregation are constructed, solving the problem of insufficient interpretability in text question answering systems. This improves the interpretability and diagnostic accuracy of the model in medical question answering, allowing users to intuitively understand the model's reasoning process.

CN121365742BActive Publication Date: 2026-04-24QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +3
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)
Filing Date
2025-12-22
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Existing text-based question-answering systems lack interpretability and traceability, making it difficult to gain the trust of doctors and patients in high-risk scenarios such as healthcare. Furthermore, they lack multi-layer semantic aggregation capabilities, failing to effectively capture the dependencies between higher-order semantic units, thus limiting the system's reasoning and expression capabilities in complex medical question-answering tasks.

Method used

By injecting text knowledge graphs and streaming semantic modeling, semantic flow tags are constructed, multi-flow aggregation and cross-flow attention are performed to improve the interpretability and diagnostic accuracy of the model. Semantic flow aggregation and knowledge graph injection are designed, the semantic flow-to-semantic flow attention mechanism is optimized, cross-semantic unit dependency modeling is realized, and attention weights are visualized.

Benefits of technology

It achieves structural interpretability and observability of reasoning path in the model, improves the interpretability and diagnostic accuracy of the model in medical question answering, and enables users to intuitively understand the key semantic flow and its interaction relationships in the reasoning process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365742B_ABST
    Figure CN121365742B_ABST
Patent Text Reader

Abstract

The application provides an interpretable text question and answer method and system based on structural semantic flow modeling, relates to the fields of artificial intelligence and text question and answer technology, and comprises the following steps: obtaining an original token vector sequence from a question text to be answered; performing knowledge injection on the original token vector sequence to obtain an enhanced token vector sequence; performing semantic flow label identification on each token vector in the enhanced token vector sequence to obtain a token vector sequence with semantic flow labels; performing multi-flow aggregation and cross-flow attention on the token vector sequence with semantic flow labels to obtain a final flow-aware token vector sequence; and generating an answer and an inference path graph based on the final flow-aware token vector sequence through reasoning. The application combines text knowledge graph injection and flow-based semantic modeling, realizes the structuralized representation and reasoning of text, and improves the interpretability and diagnostic accuracy of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and text question answering, specifically to an interpretable text question answering method and system based on structural semantic flow modeling. Background Technology

[0002] With the development of large-scale pre-trained language models, the application of artificial intelligence technology in the field of natural language processing is becoming increasingly sophisticated, and text-based question answering systems are gradually becoming an important tool for intelligent medical assistance. Compared to traditional information retrieval methods, text-based question answering models can combine contextual semantics to provide users with more accurate and natural suggestions or explanations. However, while most current mainstream text-based question answering systems can generate answers of a certain quality, their interpretability is insufficient, making it difficult to meet the high requirements for model transparency and traceability in specific application scenarios.

[0003] Existing text-based question-answering systems generally face the critical problem of lacking interpretability mechanisms. Most existing models are based on black-box structures, which, while achieving high accuracy, struggle to explain how the model derives "answer suggestions" or "reasoning conclusions" from "question descriptions." For example, in high-risk medical scenarios, it is difficult to gain the trust of doctors and patients. Furthermore, they lack the ability to model the semantic structure of text. For instance, medical texts often implicitly contain a "symptom-examination-diagnosis-treatment" process structure, but existing methods mostly handle this at the token level, failing to effectively capture the dependencies between these higher-order semantic units (semantic flows). This results in a lack of clear boundaries in the reasoning chain, making it difficult to construct structured reasoning paths. In addition, traditional models lack the ability to aggregate multi-layered semantics, failing to abstract higher-level "medical intent flows" (such as "cause clue flows" and "diagnostic hypothesis flows") from low-level language fragments, limiting the system's reasoning and expression capabilities when facing complex medical question-answering tasks.

[0004] In recent years, although some studies have attempted to introduce knowledge graphs or interpretable modules to assist in modeling, most of them are post-interpretable and still face bottlenecks such as insufficient model interpretability and traceability, making it difficult to achieve a complete semantic tracking process "from language to reasoning to diagnosis". Summary of the Invention

[0005] To address the aforementioned issues, this invention proposes an interpretable text question answering method and system based on structured semantic flow modeling. By combining injected text knowledge graphs with streaming semantic modeling, it achieves structured representation and reasoning of text, thereby improving the interpretability and diagnostic accuracy of the model.

[0006] According to some embodiments, the present invention adopts the following technical solution:

[0007] Interpretable text question answering methods based on structural semantic flow modeling include:

[0008] Obtain the text of the question to be answered, and perform word segmentation and encoding on the question text to obtain the original token vector sequence;

[0009] Based on the knowledge graph, knowledge is injected into the entity tokens in the original token vector sequence to obtain an enhanced token vector sequence;

[0010] Semantic flow label recognition is performed on each token vector in the enhanced token vector sequence to obtain a token vector sequence with semantic flow labels;

[0011] Multi-stream aggregation and cross-stream attention are performed on the token vector sequence with semantic flow labels to obtain a semantically enhanced semantic flow-level vector sequence. The semantic flow-level vector sequence is then fused with the token vector sequence with semantic flow labels to obtain the final flow-aware token vector sequence.

[0012] Based on the final flow-aware token vector sequence, the answer and reasoning path graph are generated through reasoning.

[0013] According to some embodiments, the present invention adopts the following technical solution:

[0014] Interpretable text question answering systems based on structural semantic flow modeling include:

[0015] The question acquisition module is configured to: acquire the text of the question to be answered, and perform word segmentation and encoding on the question text to obtain the original token vector sequence;

[0016] The knowledge injection module is configured to inject knowledge into the entity tokens in the original token vector sequence based on the knowledge graph to obtain an enhanced token vector sequence; the tag recognition module is configured to perform semantic flow tag recognition on each token vector in the enhanced token vector sequence to obtain a token vector sequence with semantic flow tags.

[0017] The tag aggregation module is configured to perform multi-stream aggregation and cross-stream attention on the token vector sequence with semantic stream tags to obtain a semantically enhanced semantic stream-level vector sequence. The semantic stream-level vector sequence is then fused with the token vector sequence with semantic stream tags to obtain the final stream-aware token vector sequence.

[0018] The reasoning generation module is configured to generate answers and reasoning path graphs based on the final flow-aware token vector sequence.

[0019] According to some embodiments, the present invention adopts the following technical solution:

[0020] A computer program product includes a computer program that, when executed by a processor, implements the interpretable text question-answering method based on structured semantic flow modeling.

[0021] According to some embodiments, the present invention adopts the following technical solution:

[0022] A non-transitory computer-readable storage medium is provided for storing computer instructions, which, when executed by a processor, implement the interpretable text question-answering method based on structured semantic flow modeling.

[0023] According to some embodiments, the present invention adopts the following technical solution:

[0024] An electronic device includes a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to enable the electronic device to perform the interpretable text question answering method based on structural semantic flow modeling.

[0025] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0026] This invention constructs semantic flow tags to clearly divide semantic units in text, enabling the model to understand text content at the semantic level, providing a structured foundation for the reasoning process, and achieving structural interpretability.

[0027] This invention designs a semantic flow aggregation, which aggregates token-level semantic vectors into semantic flow-level vectors, enabling the model to model dependencies at the semantic flow unit level. This facilitates the demonstration of the influence and contribution between different semantic flows, thereby enhancing the interpretability of the prediction results.

[0028] This invention optimizes the semantic flow-to-semantic flow attention mechanism, enabling the model to calculate self-attention weights between different semantic flows to achieve dependency modeling across semantic units; and visualizes the attention weights, allowing users to intuitively understand the key semantic flows and their interactions that the model focuses on during inference, thereby improving the interpretability and observability of the model's inference path.

[0029] This invention designs a knowledge graph injection method that embeds professional knowledge (such as medicine) into token vectors and uses a visibility matrix to control the interaction between entities and text. This allows the model to clearly demonstrate the usage of knowledge entities during the reasoning process, further improving interpretability and reasoning transparency.

[0030] This invention designs a multi-granularity semantic modeling strategy, combining token-level and flow-level Transformer semantic features, enabling the model to explain decision-making criteria at multiple levels from local vocabulary to global semantic units, further improving the traceability and interpretability of downstream question-answering results.

[0031] This invention also visualizes attention weights, including the semantic flow-to-semantic flow attention matrix, which can show the degree of attention the model pays to each semantic flow when answering questions. Attached Figure Description

[0032] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0033] Figure 1 This is a flowchart of the method in Example 1.

[0034] Figure 2 This is a schematic diagram of tag aggregation in Example 1.

[0035] Figure 3 This is a flowchart of multi-stream aggregation and cross-stream attention in Example 1.

[0036] Figure 4 This is an example reasoning path for Example 1. Detailed Implementation

[0037] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0038] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0039] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0040] Example 1

[0041] One embodiment of the present invention provides an interpretable text question answering method based on structured semantic flow modeling. By combining the injection of text knowledge graphs with semantic flow modeling, it achieves structured representation and reasoning of text, improving the interpretability and diagnostic accuracy of the model. Taking medical question answering as an example, ... Figure 1 As shown, it includes:

[0042] Step 1: Obtain the text of the question to be answered, and perform word segmentation and encoding on the question text to obtain the original token vector sequence;

[0043] Furthermore, firstly, the question text is segmented using BERT tokenizer to obtain an original token sequence containing multiple tokens. Then, each token is represented as a vector through encoding, ultimately resulting in an original token vector sequence.

[0044] Specifically, the input question text is first segmented and encoded to obtain a vectorized representation that the model can process. The input text undergoes necessary standardization processes, including removing extra spaces, standardizing punctuation, and converting between full-width and half-width characters, to ensure consistent text formatting for subsequent segmentation. Then, the BERT tokenizer is used to segment the standardized text into multiple tokens, each token potentially being a complete word or a subword. Through tokenization, the input text is converted into a sequence of original tokens, which preserves the original word order, providing a foundation for subsequent contextual modeling.

[0045] Next, the token sequence obtained from word segmentation is mapped to tokenIDs. Each token is looked up at its corresponding index in the BERT pre-trained vocabulary, converting the symbolic token into a numerical form to generate a tokenID sequence. This step is crucial for mapping text from a symbolic space to a numerical space that the model can process, providing input for the embedding layer.

[0046] After obtaining the tokenID sequence, each tokenID is mapped to a fixed-dimensional vector representation through the BERT embedding layer. Each vector is typically 768-dimensional or has other preset dimensions. These vectors constitute the original token vector sequence, representing the preliminary semantic information of each token in the text. To enhance the token vectors' context-awareness, the original token vector sequence is input into the BERT Transformer encoder. Positional encoding is added to the encoder, and contextual information is modeled through a multi-layer multi-head self-attention mechanism. After encoder processing, each token vector not only retains its own semantic information but also incorporates the contextual semantics of other tokens in the text, thus forming a context-enhanced original token vector sequence. (It should be noted that the multi-head attention modeling at this stage is only used to generate basic context-aware representations and belongs to the preliminary encoding processing stage, without involving subsequent knowledge enhancement or semantic flow-level interaction modeling.)

[0047] Finally, after the above operations such as word segmentation, token ID mapping, vector embedding and context encoding, the resulting original token vector sequence contains both the basic semantic information of each token and the textual context relationship, providing a complete and processable vectorized basic representation for subsequent knowledge graph injection, semantic stream tag recognition and stream-level semantic modeling.

[0048] Step 2: Based on the knowledge graph, inject knowledge into the entity tokens in the original token vector sequence to obtain a knowledge graph-injected enhanced token vector sequence;

[0049] Furthermore, the knowledge injection specifically refers to:

[0050] Perform entity recognition on each token vector in the original token vector sequence, match it with entities existing in the knowledge graph, and obtain a vector representation associated with the knowledge graph;

[0051] The token vectors are fused with the corresponding knowledge graph vector representations to obtain an enhanced token vector sequence.

[0052] Specifically, firstly, the original token vector sequence output in the first step... Medical entity recognition is performed by using a Named Entity Recognition (NER) model to detect tokens corresponding to entities in the medical knowledge graph within the input text. For example, when the input question contains words such as "hypertension," "blood sugar," and "CT scan," these tokens are labeled as medical entities.

[0053] Before performing vector retrieval matching, the entities in the knowledge graph need to be vectorized and encoded. Specifically, each entity node in the knowledge graph is mapped to a vector representation, and a pre-trained language model in the medical field is used to encode the entities and their relationships into the same semantic space as the token vector, ensuring semantic alignment for subsequent similarity calculations and fusion operations.

[0054] Secondly, a knowledge graph retrieval is performed on the identified medical entity tokens. The retrieval consists of two stages: first, string-based alias matching is performed to find entity nodes in the knowledge graph that are completely identical to or synonymous with the token text; if no match is found or there is ambiguity, a vector similarity-based retrieval method is further employed to match the token vectors. Similarity calculations (using cosine similarity) are performed with the pre-trained vectors of all entities in the knowledge graph, and the top K entities with the highest scores are selected as the candidate node set. .

[0055] Subsequently, the candidate entity node vectors are weighted and aggregated to obtain a comprehensive knowledge representation of the token. Specifically, this is calculated based on the similarity scores between the token vector and each candidate entity vector. The weights are obtained through softmax normalization. Then, using these weights, a weighted sum is calculated on the entity vectors to obtain the knowledge vector representation of the token, as shown in the following formula:

[0056]

[0057] in, This represents the knowledge graph vector representation of the i-th token. This represents the embedding vector of the j-th candidate entity that the token may correspond to in the knowledge graph; This refers to the attention weights applied to candidate entities. If the knowledge vector dimension differs from the token vector dimension, a linear mapping layer is used. Perform dimensional alignment.

[0058] Finally, a gating fusion mechanism is used to integrate knowledge vectors. Compared with the original token vector The gating mechanism first calculates a control signal to perform the fusion. This determines the fusion ratio between knowledge information and original semantic information. The knowledge enhancement vector of the token after knowledge graph injection is calculated by combining the knowledge entity vector.

[0059]

[0060] in, This indicates that the token vector Its corresponding knowledge vector Concatenate the vectors to obtain a new extended vector; It is a trainable linear transformation matrix used to learn how to fuse token semantics with knowledge graph information; It is the bias term; ReLU() is the activation function used to introduce non-linear features and prevent gradient vanishing, which then generates the enhanced token representation:

[0061]

[0062] in Representing the control signal, it is a learnable fusion weight coefficient, ranging from 0 to 1, used to balance the weights of the original semantics and knowledge information. When the size is large, the model tends to preserve the semantics of the text. When the size is smaller, the model relies more on supplementary information from the knowledge graph; Represents a knowledge enhancement vector; This represents the final enhanced token vector, which integrates contextual semantics and knowledge graph information, and becomes the input for subsequent modules (such as Flow structure modeling or inference layers).

[0063] Through this mechanism, the model can adaptively learn the strength of knowledge injection in different contexts, thereby introducing effective medical knowledge without disrupting the original semantic structure. After knowledge injection and fusion of all medical entity tokens, an enhanced token vector sequence is obtained. It simultaneously contains textual context semantics and knowledge graph structure information, providing a more complete semantic foundation and interpretability support for subsequent semantic flow modeling.

[0064] Step 3: Perform semantic flow category identification on each token vector in the enhanced token vector sequence, predict the semantic flow category to which each token belongs, and output a token vector sequence with semantic flow labels;

[0065] Furthermore, the semantic stream category identification specifically includes:

[0066] By using a pre-trained Transformer, multi-head self-attention is applied to the enhanced token vector sequence to obtain a context-dependent semantic vector for each token vector.

[0067] Using a multi-layer feedforward classification head, the semantic flow category of each token semantic vector is predicted.

[0068] Specifically, firstly, the enhanced token vector sequence The input is fed into the Transformer encoder. The core of this encoder is a multi-head self-attention mechanism, which performs global interaction modeling on all tokens in the sequence at the knowledge semantic layer. This ensures that the representation vector of each token not only retains its own linguistic and knowledge features but also incorporates the knowledge semantic information of other tokens in the sequence. For example, "chest tightness" and "elevated body temperature" may be related in the knowledge graph. Through this stage of interaction, the model can learn the semantic consistency that both belong to the same semantic flow (symptom flow).

[0069] After processing by the encoder, a sequence of context-enhanced knowledge semantic vectors is obtained. ,

[0070] in, It is a high-dimensional vector that contains not only the linguistic semantics of the token, but also integrates knowledge graph information and contextual relationships, providing complete features for semantic flow classification.

[0071] Then, each vector The input is fed into the semantic stream classification module for prediction. The classification module consists of a linear mapping layer and a softmax layer, which map the high-dimensional vector to the semantic stream category space, as shown in the following formulas:

[0072]

[0073]

[0074] in, This represents the mapped score vector; The vector representing the i-th token; This represents the classification weight matrix, where each row corresponds to a weight vector for a category, used to map token vectors to the category space; C is the number of semantic stream categories (e.g., symptom stream, examination stream, diagnosis stream, treatment stream, etc.). This represents the bias vector, used to adjust the output of the linear mapping; Let represent the category probability vector of the i-th token; `softmax()` represents the normalization function, which normalizes the input vector by performing an exponential operation on each element. Finally, the category with the highest value is taken as the predicted label, as shown in the following formula:

[0075]

[0076] in, Labels indicating predictions; This represents the probability that the i-th token belongs to the k-th semantic stream.

[0077] During training, the model optimizes the joint parameters of the Transformer encoding and classification layers by minimizing the cross-entropy loss function, ensuring that the prediction results are consistent with the manually labeled semantic flow tags. After training, the model can automatically identify the semantic flow category for each token in the input text during the inference phase, which can be formally represented as... This yields a sequence of token vectors with semantic flow labels, providing a precise labeling basis for subsequent semantic flow aggregation and cross-flow attention modeling. A sequence of token vectors with semantic flow labels means that each token vector corresponds to a semantic flow label.

[0078] Step 4: Perform multi-stream aggregation and cross-stream attention modeling on the token vector sequence with semantic flow labels to obtain a semantic flow-level vector sequence. Then, fuse the semantic flow-level vector sequence with the token vector sequence with semantic flow labels to obtain the final flow-aware token vector sequence.

[0079] Furthermore, the multi-stream aggregation and cross-stream attention modeling specifically includes:

[0080] Based on the semantic flow tags, the token vectors belonging to the same semantic flow category in the token vector sequence with semantic flow tags are aggregated to generate the corresponding semantic flow level vector, thereby obtaining the overall representation of each semantic flow unit;

[0081] By using cross-stream attention interaction, the associations between different semantic stream units are modeled to obtain a semantic stream-level vector sequence;

[0082] Each token vector output from step three is associated with the flow level vector of its respective flow. The residuals are summed and fused to generate the final flow-aware token representation.

[0083] Specifically, such as Figure 2 , Figure 3 As shown, after completing the semantic flow tag recognition, a token vector sequence with semantic flow tags has been obtained. First, based on the tag recognition results, the enhanced token vector sequence is grouped according to the tag category. For example, all token vectors labeled "symptoms" form a set. The set consists of all token vectors labeled "check". And so on. For each type of semantic flow The system aggregates its internal token representations to obtain a semantic stream-level representation vector. In this way, the input text is structured into several semantic flow units, each containing words or subwords with similar semantic functions. To ensure that the flow representation more accurately reflects the important semantics within the flow, an attention-weighted aggregation method is used for computation:

[0084]

[0085] in, represents the importance weight of the i-th token within its semantic flow k; w represents the learnable parameter vector, which projects the token vector and maps the token features to a scalar score. This represents the augmented vector representation of the i-th token; This represents the set of indices of tokens within the k-th semantic stream, i.e., the indices of all tokens belonging to the same semantic stream; This means that the projected scalar score is exponentially calculated to ensure that the weights are positive, which facilitates subsequent normalization. Representing the same semantic stream The vector of the j-th token within.

[0086] Next, the model performs a weighted sum of all token vectors within the same semantic stream to obtain the stream-level vector:

[0087]

[0088] in, The final aggregate vector representation of the k-th semantic stream, also known as the stream-level vector, is the weighted average vector of all tokens within the semantic stream, representing the overall semantic features of the semantic stream. This indicates the in-stream weight of the token; The vector representing the i-th token; This represents the set of indices of the k-th semantic stream tokens. In this way, the model can automatically focus on the tokens that are most semantically critical, thus forming a semantically focused and structurally complete stream-level representation.

[0089] After obtaining the initial representation of all semantic streams Subsequently, the system further models the interaction relationships between different semantic flows. In medical texts, there are often logical connections between semantic flows; for example, the "symptom flow" often guides the "examination flow," while the "diagnosis flow" determines the "treatment flow." To capture these cross-flow dependencies, the system employs a flow-to-flow attention mechanism to model and fuse information between flows.

[0090] In this mechanism, all flow level vectors are first assembled into a matrix. And obtain the query matrix through linear mapping. Key matrix Sum matrix ,in This is a trainable parameter matrix. Next, the correlation between different semantic streams is calculated using an attention mechanism:

[0091]

[0092] Where d is the scaling factor for the vector dimension. This is the semantic flow vector after cross-flow attention update.

[0093] After cross-flow attention modeling, the updated flow-level vector sequence is obtained. These representations not only integrate important features from their respective semantic streams, but also contain related information from other semantic streams, thus forming a structured, high-level semantic expression.

[0094] Next, each enhanced token vector is paired with the flow level vector of its respective flow. Residual summation and fusion are performed to generate the final flow-aware token vector. :

[0095]

[0096] in, This indicates the final fused stream level vector. The token; This represents the token vector after semantic stream label recognition. In this way, each token vector retains its own fine-grained semantics while also containing structured semantic information from stream-level aggregation and cross-stream interactions, providing sufficient local and global information for generating global reasoning representations and answers.

[0097] Step 5: Based on the final flow-aware token vector sequence, generate the answer and reasoning path through inference.

[0098] Furthermore, the generation of the answer is specifically as follows:

[0099] The question text is encoded to obtain a question vector;

[0100] Calculate the attention weights between the question vector and each sequence of flow-aware token vectors;

[0101] The final global inference representation is obtained by weighting and aggregating all stream-aware token vector sequences using attention weights.

[0102] The global inference representation is input into the decoder, which then outputs the final answer.

[0103] Specifically, the question text is first encoded to obtain a question vector q, which is used to represent the overall semantic features of the question. The encoding method uses the same Transformer encoder as the previous token encoding, so that the question vector and the stream-aware token vector are in the same semantic space. This vector is used to represent the global semantics of the question, which facilitates interaction with the stream-aware token representation.

[0104] Next, the question vector q will be compared with all flow-aware token vectors. Perform the interaction and calculate the attention weight of each token to the question. :

[0105]

[0106] This step can be viewed as the question vector "querying" the relevance of the token vector at the token level, thus obtaining the importance of each token to the final answer.

[0107] Subsequently, a global inference vector is generated by weighting and summing all flow-aware token vectors using attention weights. :

[0108]

[0109] This global inference vector integrates the fine-grained semantic information of each token and the structured information of its stream, and is directly input into the decoder or generative model to generate the final answer.

[0110] The decoder here employs a Transformer decoder, a linear prediction layer, or other modules suitable for text generation to generate text answers or classification results based on task requirements. During the generation process, the decoder utilizes global inference vectors. This guides the output at each step, ensuring that the answer is highly relevant to the question and the flow-aware token information.

[0111] The reasoning path is as follows:

[0112] During inference, the model records and integrates intermediate information calculated by previous modules to generate an interpretable inference path. Specifically: Step three, semantic flow recognition, obtains the category label for each token, recording the mapping relationship between token and semantic flow; Step four, multi-flow aggregation and cross-flow attention calculation, yields the flow-level vector and inter-semantic flow attention weights, recording the semantic flow... Semantic flow dependencies; in step two, knowledge graph injection, each token is bound to a knowledge graph entity, which can record the mapping from token to knowledge node; the attention weights between the question vector and the flow-aware token vector can record the importance distribution of the token to the question; by organizing this information, a complete [structure] is formed. Figure 4 The reasoning path is shown.

[0113] To facilitate an intuitive understanding of the model's decision-making process, the intermediate information recorded during inference can be visualized, revealing the model's focus and reasoning logic when generating answers. Simultaneously, attention weights can be visually displayed using heatmaps to reflect the model's dependence on different tokens or semantic flows when generating answers. This visualization-based understanding of model decisions improves the traceability and interpretability of the results.

[0114] Example 2

[0115] One embodiment of the present invention provides an interpretable text question-answering system based on structural semantic flow modeling, comprising:

[0116] The question acquisition module is configured to: acquire the text of the question to be answered, and perform word segmentation and encoding on the question text to obtain the original token vector sequence;

[0117] The knowledge injection module is configured to inject knowledge into the entity tokens in the original token vector sequence based on the knowledge graph to obtain an enhanced token vector sequence; the tag recognition module is configured to perform semantic flow tag recognition on each token vector in the enhanced token vector sequence to obtain a token vector sequence with semantic flow tags.

[0118] The tag aggregation module is configured to perform multi-stream aggregation and cross-stream attention on the token vector sequence with semantic stream tags to obtain a semantically enhanced semantic stream-level vector sequence. The semantic stream-level vector sequence is then fused with the token vector sequence with semantic stream tags to obtain the final stream-aware token vector sequence.

[0119] The reasoning generation module is configured to generate answers and reasoning path graphs based on the final flow-aware token vector sequence.

[0120] Example 3

[0121] One embodiment of the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the interpretable text question-answering method based on structural semantic flow modeling.

[0122] Example 4

[0123] In one embodiment of the present invention, a non-transitory computer-readable storage medium is provided for storing computer instructions, which, when executed by a processor, implement the interpretable text question-answering method based on structural semantic flow modeling.

[0124] Example 5

[0125] One embodiment of the present invention provides an electronic device, including: a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to enable the electronic device to perform the interpretable text question answering method based on structural semantic flow modeling.

[0126] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0127] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0128] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.

Claims

1. An interpretable text question-answering method based on structural semantic flow modeling, characterized in that, include: Based on the knowledge graph, knowledge is injected into the entity tokens in the original token vector sequence to obtain an enhanced token vector sequence; Semantic flow label recognition is performed on each token vector in the enhanced token vector sequence to obtain a token vector sequence with semantic flow labels; Multi-stream aggregation and cross-stream attention are performed on the token vector sequence with semantic flow labels to obtain a semantically enhanced semantic flow-level vector sequence. The semantic flow-level vector sequence is then fused with the token vector sequence with semantic flow labels to obtain the final flow-aware token vector sequence. Based on the final flow-aware token vector sequence, an answer and a reasoning path graph are generated through inference; the generation of the answer specifically involves: The question text is encoded to obtain a question vector; Calculate the attention weights between the problem vector and each stream representation in the stream-level representation; The final global inference representation is obtained by weighting and converging the flow-level representations using attention weights. The global inference representation is input into the decoder to output the final answer; The generation of the reasoning path graph is specifically as follows: Semantic stream label recognition obtains the semantic stream label for each token, and records the mapping relationship between token and semantic stream label; The flow-level vectors and semantic flow attention weights obtained from multi-flow aggregation and cross-flow attention calculations record the semantic flow. Dependencies in semantic flow; In knowledge graph injection, the mapping between token and knowledge node is recorded through the knowledge graph entity bound to each token; Attention weights between the question vector and the flow-aware token vector are used to record the importance distribution of tokens to the question; By organizing this information, a complete reasoning path can be formed.

2. The interpretable text question answering method based on structural semantic flow modeling as described in claim 1, characterized in that, The knowledge injection specifically refers to: Perform entity recognition operation on each entity token in the original token vector sequence, match it with the entities existing in the knowledge graph, and obtain the vector representation associated with the knowledge graph; The token vectors are fused with the corresponding knowledge graph vector representations to obtain an enhanced token vector sequence.

3. The interpretable text question answering method based on structural semantic flow modeling as described in claim 1, characterized in that, The semantic stream tag recognition specifically includes: By using a pre-trained Transformer, multi-head self-attention is applied to the enhanced token vector sequence to obtain a context-dependent semantic vector for each token vector. Using a multi-layer feedforward classification head, predict the semantic flow label for each token semantic vector.

4. The interpretable text question answering method based on structural semantic flow modeling as described in claim 1, characterized in that, The multi-stream aggregation and cross-stream attention are specifically as follows: Based on the semantic flow tags, the semantic vectors of tokens belonging to the same semantic flow tags are aggregated into a single flow-level representation; By using cross-stream attention interaction, the association between different semantic streams is modeled to obtain a semantically enhanced semantic stream-level vector sequence.

5. An interpretable text question-answering system based on structural semantic flow modeling, characterized in that, include: The question acquisition module is configured to: acquire the text of the question to be answered, and perform word segmentation and encoding on the question text to obtain the original token vector sequence; The knowledge injection module is configured to inject knowledge into the entity tokens in the original token vector sequence based on the knowledge graph to obtain an enhanced token vector sequence; the tag recognition module is configured to perform semantic flow tag recognition on each token vector in the enhanced token vector sequence to obtain a token vector sequence with semantic flow tags. The tag aggregation module is configured to perform multi-stream aggregation and cross-stream attention on the token vector sequence with semantic stream tags to obtain a semantically enhanced semantic stream-level vector sequence. The semantic stream-level vector sequence is then fused with the token vector sequence with semantic stream tags to obtain the final stream-aware token vector sequence. The reasoning generation module is configured to: generate answers and reasoning path graphs based on the final flow-aware token vector sequence; the generation of the answers specifically involves: The question text is encoded to obtain a question vector; Calculate the attention weights between the problem vector and each stream representation in the stream-level representation; The final global inference representation is obtained by weighting and converging the flow-level representations using attention weights. The global inference representation is input into the decoder to output the final answer; The generation of the reasoning path graph is specifically as follows: Semantic stream label recognition obtains the semantic stream label for each token, and records the mapping relationship between token and semantic stream label; The flow-level vectors and semantic flow attention weights obtained from multi-flow aggregation and cross-flow attention calculations record the semantic flow. Dependencies in semantic flow; In knowledge graph injection, the mapping between token and knowledge node is recorded through the knowledge graph entity bound to each token; Attention weights between the question vector and the flow-aware token vector are used to record the importance distribution of tokens to the question; By organizing this information, a complete reasoning path can be formed.

6. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the interpretable text question answering method based on structural semantic flow modeling as described in any one of claims 1-4.

7. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium is used to store computer instructions, which, when executed by a processor, implement the interpretable text question-answering method based on structural semantic flow modeling as described in any one of claims 1-4.

8. An electronic device, characterized in that, include: The device includes a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to enable the electronic device to perform an interpretable text question answering method based on structural semantic flow modeling as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Auxiliary medical management method and system based on natural questions and answers and knowledge graph

    CN118568228A

  • Data intelligent question and answer method and system fusing domain knowledge

    CN118779438A