A Smart Question Answering Method for Slope Documents that Integrates Knowledge Graphs and Large Language Models
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-10
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]本发明的目的在于提供一种融合知识图谱与大语言模型的边坡文档智能问答方法,以解决传统方法专业查询意图理解不足以及通用模型专业领域知识不可靠的问题
[0100] (1) To address the shortcomings of traditional retrieval methods in understanding the professional query intent of slope engineering and the unreliability of general large language models in answering questions in professional fields, this invention integrates knowledge graphs and large language models to collaboratively apply the structured knowledge and textual semantics of slope documents to question answering. The method first constructs a professional knowledge graph from slope professional documents that reflects the hierarchical reference of standard provisions and parameter constraint relationships. This unifies the survey parameters, standard requirements, and construction experience that were originally scattered in multiple heterogeneous documents into a knowledge network that can be used for system reasoning, fundamentally solving the limitation of pure semantic retrieval in capturing the precise logical dependencies between provisions. During the question answering process, the system can understand the professional query intent implied in the user's dialogue context and automatically connect seemingly scattered but logically closely related provisions. By combining text paragraphs and data records, the system overcomes the contextual fragmentation problem caused by text segmentation in traditional block retrieval, while ensuring rapid location of the most relevant key information in complex knowledge relationships. Subsequently, the structured knowledge in the graph is deeply integrated with the semantics of the original document, so that the information on which the generated answer is based has both logical completeness and expressive integrity. This not only supplements the preconditions and applicable conditions that pure vector retrieval may miss, but also fully preserves the details in the original document. The final generated answer strictly anchors to the authoritative knowledge in the graph in terms of engineering specifications and parameter values, fundamentally suppressing the illusionary risk of general models generating false content out of thin air. The output results are significantly improved in terms of professional accuracy and traceability, providing reliable support for knowledge-intensive decision-making in slope engineering investigation, design and maintenance.
Smart Images

Figure CN122572684A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of geotechnical engineering information technology, specifically involving an intelligent question-answering method for slope documents that integrates knowledge graphs and large language models. Background Technology
[0002] In the process of slope engineering investigation, design, construction, and long-term maintenance, a large number of professional documents have been accumulated, including geological investigation reports, slope design specifications, support structure construction plans, monitoring data records, and maintenance manuals. The geotechnical parameters, hydrogeological conditions, constraints between specification clauses, and engineering experience recorded in these documents are crucial bases for subsequent engineering safety assessments and maintenance decisions. In practice, engineering technicians face not only information retrieval challenges when consulting these documents, but also the challenge of integrating professional knowledge and logical reasoning. For example, when designers need to determine a support scheme for a specific slope section, they must simultaneously compare the stratigraphic description and shear strength indicators in the investigation report, the safety factor requirements in the design specifications, and the treatment measures of previous construction schemes under similar geological conditions. These contents are scattered across documents of different formats and sources, and there are clear levels of reference and applicable conditions between the specification clauses. Designers often need to spend a considerable amount of time repeatedly reviewing multiple documents, manually extracting information, and cross-checking, and it is easy to overlook key constraints or reference relationships due to negligence during the entire process.
[0003] Currently, the commonly used technical solution in engineering practice is to deploy traditional document retrieval systems based on keyword matching. After a user enters several keywords into the search box, the system scans the document collection and returns a list of fragments containing those words. Such systems can quickly locate the chapters mentioning the phrase, but they cannot distinguish whether the returned content is the main text of a specification, a clause explanation, or a construction record, nor can they answer natural language questions that require understanding and reasoning, such as "Based on the parameters of this survey report, what type of support should be selected for this slope?" Users must read each returned fragment one by one, extracting and synthesizing the scattered information themselves. In complex query scenarios with multiple intersecting factors, this working mode is time-consuming, and the results are highly dependent on the user's own professional level and the completeness of manual correlation. In addition, when users need to follow up on the results of the previous query or refine the conditions, traditional retrieval systems cannot retain the dialogue context, and each interaction starts anew, which cannot support the progressive and exploratory information acquisition process commonly found in engineering analysis.
[0004] With the development of large language models, their strong natural language understanding and text generation capabilities have provided new possibilities for building intelligent question-answering systems. However, directly applying general-purpose large language models to the field of slope engineering can lead to a significant illusion problem. The model may generate fluent but inconsistent content that deviates from actual standard values or contains logical inconsistencies for questions involving specific specification parameters or engineering criteria. In scenarios with high relevance to engineering safety, such inaccurate information poses a risk. To mitigate this problem, retrieval-enhanced generation technology has been introduced. The general process involves first dividing professional documents into text blocks of fixed length, then using an embedding model to convert each text block into a vector and storing it in a database. When a user asks a question, the question is also vectorized, and the most relevant text blocks are retrieved based on semantic similarity. These text blocks, along with the question, are then fed into the large language model, which is then constrained to generate an answer based on the retrieved context. However, this approach still has certain limitations when dealing with specialized slope engineering documents. There are references and hierarchical relationships among the clauses of the slope protection code, and the structured correspondence between parameters and applicable conditions in the table is also quite strict. Pure semantic vector retrieval is difficult to capture such precise logical constraints. Often, the retrieved text blocks are semantically similar but do not contain the specific clauses necessary to answer the question, or the original mutually referencing clause paragraphs are broken up during the block segmentation process, resulting in incomplete contextual information input to the model, which ultimately affects the accuracy of the answer. Summary of the Invention
[0005] The purpose of this invention is to provide an intelligent question-answering method for slope documents that integrates knowledge graphs and large language models, so as to solve the problems of insufficient understanding of professional query intent in traditional methods and unreliable professional domain knowledge in general models.
[0006] To achieve the above objectives, the technical solution of the present invention is as follows:
[0007] A method for intelligent question answering of slope documents that integrates knowledge graphs and large language models includes the following steps:
[0008] S1: Collect slope engineering document data containing tabular data and preprocess it to obtain preprocessed slope engineering document data, preprocessed document structure information, and table structure perception data; at the same time, collect user's historical dialogue round text data and user's current question text data.
[0009] S2: Based on the preprocessed document structure information, the chapter-level structure embedding matrix and the paragraph-level structure embedding matrix are calculated sequentially and fused into a document structure-aware embedding matrix. The semantic structure representation of the table is obtained through intra-column attention interaction and column-level sequence aggregation. The document structure-aware embedding matrix and the semantic structure representation of the table are aligned with multi-source features to obtain a fused document structure knowledge matrix. Entities and relationships are then extracted based on the fused document structure knowledge matrix to construct a slope engineering knowledge graph.
[0010] S3: Based on the initial embedding of entity nodes in the slope engineering knowledge graph, combined with the text data of the user's historical dialogue rounds and the text data of the user's current question, the embedding representation of the entity nodes activated by the context is calculated in sequence. Context-guided path reasoning is performed on the knowledge graph to generate multi-hop reasoning attention trajectories. Then, through adaptive threshold path dynamic pruning and reasoning chain reconstruction, dynamic knowledge reasoning paths are obtained.
[0011] S4: Based on the dynamic knowledge reasoning path, determine the anchor entity and the target entity, extract local knowledge subgraphs from the slope engineering knowledge graph and aggregate them into a knowledge flow structured representation. At the same time, encode the preprocessed slope engineering document data into a text flow semantic representation, and then fuse the knowledge flow structured representation and the text flow semantic representation to obtain enhanced generative context features.
[0012] S5: Based on the enhanced generation context features, a preliminary answer is generated through Transformer decoding to generate a vocabulary probability distribution. Then, beam search decoding and length normalization reordering are used to select the candidate sequence with the highest score as the final answer text.
[0013] Furthermore, the specific process of step S1 is as follows:
[0014] S11: Collect slope engineering document data containing tabular data. The data type is text document, including survey report documents, design specification documents, construction plan documents, and monitoring record documents. Use regular expressions to clean the slope engineering document data to remove page numbers, headers, and footers. Then remove stop words based on the stop word list to obtain preprocessed slope engineering document data.
[0015] S12: For the preprocessed slope engineering document data, the document structure is parsed using a document layout analysis method, and the preprocessed document structure information in JSON format is output, including the chapter tree hierarchy, chapter title text, paragraph start and end indexes, and table area bounding box coordinates.
[0016] S13: Based on the coordinates of the bounding boxes of the table areas in the preprocessed document structure information, extract the text of the table areas from the preprocessed slope engineering document data, and reconstruct the text of the table areas into structured table data corresponding to the rows and columns based on the cell coordinates to obtain table structure-aware data.
[0017] S14: Collect text data of the user's historical dialogue rounds and the text data of the user's current question.
[0018] Furthermore, the specific process of step S2 is as follows:
[0019] S21: Calculate the document structure-aware embedding matrix based on the preprocessed document structure information. The calculation method is as follows:
[0020] ,
[0021] ,
[0022] ,
[0023] in, Embedding matrices for chapter-level structures, For layer normalization operation, For graph convolutional networks, This is the adjacency matrix corresponding to the hierarchical relationship of the chapter tree. This is the edge weight matrix. These are the initial features for each chapter node. This is the offset matrix for the relative positions between chapters. It is a bidirectional gated loop unit. Embedding matrices for paragraph-level structures, This serves as the initial semantic representation of the paragraph text sequence. For document structure-aware embedding matrices, for Encoder, ⊕ represents dimension concatenation operation, ⊙ represents element-wise addition, and ⊙ represents Hadamard product.
[0024] The method for constructing the adjacency matrix corresponding to the chapter tree hierarchy includes: based on the chapter tree hierarchy in the preprocessed document structure information, taking each chapter title as a node; if chapter i is the parent node of chapter j, then... If chapter i and chapter j are adjacent sibling nodes under the same parent node, then At the same time, add a self-loop to each node. =1, set the rest of the positions to 0, and obtain a binary adjacency matrix, where N is the total number of chapter nodes, and i and j are the first index and the second index, respectively;
[0025] The method for constructing the initial features of the chapter nodes includes: inputting the chapter title text from the preprocessed document structure information into the pre-trained language model, extracting the hidden state of the last output layer of the pre-trained language model, and taking the vector corresponding to the [CLS] label as the initial feature of a single node of the chapter node; if the chapter has no independent title text, then taking the mean pooling vector of all paragraph texts within the scope of the chapter after being encoded by the pre-trained language model as a substitute; concatenating the initial features of a single node of all nodes in the chapter to obtain the initial features of each chapter node;
[0026] The method for constructing the relative position offset matrix between chapters includes: based on the chapter tree hierarchy in the preprocessed document structure information, sequentially numbering each chapter node according to the preorder traversal to obtain the chapter node code, extracting the level depth of each chapter node in the tree, with the root node depth=0, then the relative position offset between chapter i and chapter j is... ,in and These are the first position weight parameters and the second position weight parameters, respectively. These are the chapter node codes for the i-th and j-th chapter nodes, respectively. Let be the level depths of the i-th and j-th chapter nodes, respectively; then combine the node numbers according to the level depth values as row and column positions to obtain the relative position offset matrix between chapters;
[0027] The method for constructing the initial semantic representation of the paragraph text sequence includes: extracting each paragraph text from the preprocessed slope engineering document data according to the paragraph start and end index in the preprocessed document structure information, inputting each paragraph text into the pre-trained language model, extracting the hidden state sequence of all tokens in the last layer to obtain the initial semantic representation of a single paragraph, and concatenating all the initial semantic representations of a single paragraph to obtain the initial semantic representation of the paragraph text sequence.
[0028] S22: Based on the document structure-aware embedding matrix and table structure-aware data, attention interaction and aggregation are performed to obtain the semantic structure representation of the table. The calculation method is as follows:
[0029] ,
[0030] ,
[0031] ,
[0032] in, For cell feature matrices enhanced with in-column attention, As a multi-head attention mechanism, Embedding features for table cells For attention masking, This is a matrix of offset masks for relative positions within a column. The table features are those resulting from column-level aggregation. For gated loop unit, This is an operation that flattens a matrix into a sequence in column order. For the semantic structure representation of the table, To be aware of the embedding matrix from the document structure The submatrix extracted from the table area;
[0033] The method for constructing the feature embedding of the table cell includes: inputting the text content of each cell in the table structure-aware data into the BERT pre-trained language model, taking the vector corresponding to the [CLS] label as the feature embedding of the cell, and arranging the feature embeddings of all cells in row and column order to obtain the feature embedding of the table cell.
[0034] The method for constructing the relative position offset mask matrix within the column includes: parsing the total number of rows and columns of the target table based on the coordinates of the table area bounding box in the preprocessed document structure information, and assigning a unique cell number to each cell in the target table according to the traversal order of row first and column second;
[0035] Construct an initial mask matrix, wherein the total number of rows and columns of the initial mask matrix are equal to the total number of cells in the target table;
[0036] For any two cells in the same column of the target table, iterate through and calculate the difference in row index between the first cell and the second cell, and assign the difference in row index to the corresponding element in the initial mask matrix; the row and column indices of the corresponding element are: the cell number of the first cell and the cell number of the second cell, respectively.
[0037] For any two cells in the target table that do not belong to the same column, negative infinity is assigned to the corresponding element in the initial mask matrix; the row and column indices of the corresponding element are: the cell number of the first cell and the cell number of the second cell, respectively.
[0038] After traversing all cell pairs and assigning values, the relative position offset mask matrix within the column is obtained.
[0039] S23: Align the document structure-aware embedding matrix with the table semantic structure representation using multi-source features to generate a fused document structure knowledge matrix. The calculation method is as follows:
[0040] ,
[0041] ,
[0042] ,
[0043] ,
[0044] ,
[0045] in, The semantic structure of the table is represented by a vector after mean pooling. To broadcast the pooling vector to Matrix of equal length, To perform mean pooling along the dimensions of table cells, To copy the vector along the sequence dimension Second-rate, It is the sum of the chapter length and the paragraph sequence length; For dual-stream gated fusion weight matrix, It is the Sigmoid activation function. The weight matrix for the gated transformation. This is the gated bias vector. As a preliminary fusion feature, It is a matrix of all ones. To integrate the document structure knowledge matrix, It is a feedforward fully connected network;
[0046] S24: Based on the knowledge matrix of the fused document structure, extract entities and relationships, and construct a knowledge graph for slope engineering. The calculation method is as follows:
[0047] ,
[0048] ,
[0049] ,
[0050] ,
[0051] in, For entity label emission score matrix, For entity classification weight matrix, For GELU activation function, The hidden layer transformation weight matrix is... This is the hidden layer bias vector. For entity classification bias vector, For entity boundary label sequence, For conditional random fields, Let be the probability tensor of the relationship triplet. For the relation classification weight matrix, , They are respectively The candidate head entity feature vector and candidate tail entity feature vector are extracted based on the entity boundary label sequence. For relation classification bias vectors For slope engineering knowledge graph This is a triplet constructor that selects head and tail entities that simultaneously satisfy the condition that the entity boundary labels are valid and the relationship probability is greater than a preset threshold, based on the entity boundary label sequence and the relationship probability, to form a set of relation triplets.
[0052] Furthermore, the specific process of step S3 is as follows:
[0053] S31: Based on the initial embedding of entity nodes in the slope engineering knowledge graph, and combined with the historical dialogue text received by the system and the current user question, the context-activated entity node embedding representation is obtained. The calculation method is as follows:
[0054] ,
[0055] ,
[0056] ,
[0057] ,
[0058] ,
[0059] in, To hide the user's historical conversations. The user's current problem is hidden. For BERT pre-trained language models, For embedding layer, For user's historical dialogue rounds text data, The text data representing the user's current question. To fuse semantic vectors for context, To broadcast the pooling vector to The matrix after the row, For mean pooling, The number of entities in the slope engineering knowledge graph. The context-gated activation value. For the gated weight matrix, This is the initial embedding of entity nodes in the slope engineering knowledge graph. This is the first projection weight matrix. Embedded representations for entity nodes activated in the context. This is the second projection weight matrix;
[0060] The calculation method for the initial embedding of entity nodes in the slope engineering knowledge graph includes: assigning an embedding vector to each entity node in the slope engineering knowledge graph through an embedding layer, randomly initializing and updating it during training to obtain the initial embedding of entity nodes in the slope engineering knowledge graph.
[0061] S32: Based on the context-activated entity node embedding representation, perform context-guided path reasoning on the knowledge graph to generate a multi-hop reasoning attention trajectory, calculated as follows:
[0062] ,
[0063] ,
[0064] ,
[0065] ,
[0066] in, Choose a mask for the anchor node. To select the top score The operation is performed on each element, where k is the selection threshold. For the Softmax function, It is a multilayer perceptron. For graph attention networks, For the initial ripple diffusion node attention features, For the first Ripple diffusion node attention features of the layer For the first The ripple diffusion node attention feature of the layer, where layer is the index of the graph attention network layer number. For the first The graph attention weight matrix of the layer. This is the adjacency matrix of the knowledge graph for slope engineering. For multi-hop reasoning attention trajectory, They are respectively the 1st, ..., the 1st Ripple diffusion node attention features of the layer The total number of floors;
[0067] The method for constructing the adjacency matrix of the slope engineering knowledge graph includes: for the set of relation triples in the slope engineering knowledge graph, using entity nodes as row and column indices, if there is any relation edge between entity i and entity j, then... At the same time, add a self-loop to each node. Set the remaining positions to 0 to obtain the adjacency matrix of the slope engineering knowledge graph;
[0068] S33: Perform adaptive threshold path dynamic pruning and inference chain reconstruction on multi-hop inference attention trajectories, eliminate redundant paths with attention weights below the dynamic threshold, and generate dynamic knowledge inference paths. The calculation method is as follows:
[0069] ,
[0070] ,
[0071] ,
[0072] in, For adaptive pruning threshold, For mean pooling operation, It is a one-dimensional convolutional layer. This is the threshold scaling factor. For binary pruning masks, For indicator functions, This is a dynamic knowledge reasoning path.
[0073] Furthermore, the specific process of step S4 is as follows:
[0074] S41: For dynamic knowledge reasoning paths, utilize the non-zero nodes retained after filtering by binary pruning mask in the attention features of each layer's ripple diffusion nodes, and sequentially search for valid nodes in each layer from the first layer to the last layer according to the layer index. The valid nodes in the first layer are used as anchor entities, and the valid nodes in the last layer are used as target entities.
[0075] S42: Based on the anchor entities and target entities contained in the dynamic knowledge reasoning path, extract a local knowledge subgraph centered on the anchor entity with a radius of no more than three hops from the slope engineering knowledge graph. Obtain the initial embedding vector of each entity node in the subgraph through embedding layer retrieval, then aggregate neighborhood information through mean pooling, and fuse it with the concatenated vector of the anchor-target entity pair to obtain the structured representation of the knowledge flow. The calculation method is as follows:
[0076] ,
[0077] ,
[0078] ,
[0079] in, This is the initial set of embedding vectors obtained from the embedding layer for each entity node in the local knowledge subgraph. For a set of entity nodes in a local knowledge subgraph, For embedded layer retrieval operations, The entity embedding matrix after subgraph pooling. For mean pooling operation, The embedding vector for the node corresponding to the anchor entity. Embed vectors for the nodes corresponding to the target entity. Transform the weight matrix for the knowledge flow. For a structured representation of knowledge flow;
[0080] The extraction methods for the node embedding vectors corresponding to the anchor entity and the target entity include: locating the index position of the anchor entity and the target entity from the entity node set of the local knowledge subgraph based on the determined anchor entity and target entity, and then... Retrieve the corresponding row vector by index, and obtain the following results: and ;
[0081] S43: Based on the preprocessed slope engineering document data, the text sequence is converted into word embedding vectors through an embedding layer, and then the semantic features of the document are extracted through encoding to obtain the semantic representation of the text stream. The calculation method is as follows:
[0082] ,
[0083] ,
[0084] in, For the preprocessed slope engineering document data, For text embedding vectors, For Transformer encoders, For semantic representation of text streams;
[0085] S44: Based on the knowledge flow structured representation and the text flow semantic representation, a dual-stream fusion is performed to obtain enhanced generative context features. The calculation method is as follows:
[0086] ,
[0087] ,
[0088] ,
[0089] ,
[0090] in, This represents the aligned representation of a text stream mapped to a knowledge space. For broadcast operation, This represents the pooled and broadcast knowledge flow. For preprocessed slope engineering document data Length, For dual-stream gating weights, This is to enhance the generation of contextual features.
[0091] Furthermore, the specific process of step S5 is as follows:
[0092] S51: Based on the enhanced generation context features, decode to generate a preliminary answer, and obtain the vocabulary probability distribution corresponding to the preliminary answer text sequence. The calculation method is as follows:
[0093] ,
[0094] in, To provide a preliminary answer to the vocabulary probability distribution corresponding to the text sequence, For Transformer decoder, To answer the starting marker;
[0095] S52: Based on the vocabulary probability distribution corresponding to the initial response text sequence, multiple candidate response sequences are generated using beam search decoding. A length-normalized logarithm probability score is calculated for each candidate sequence, and the candidate sequence with the highest score is selected as the final response text. The calculation method is as follows:
[0096] ,
[0097] ,
[0098] in, Let B be the set of candidate answer sequences obtained by the beam search. For the beam search decoding operation, B is the beam width, and α is the length penalty coefficient. For the final answer text, This refers to the operation that retrieves the element corresponding to the maximum value.
[0099] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0100] (1) To address the shortcomings of traditional retrieval methods in understanding the professional query intent of slope engineering and the unreliability of general large language models in answering questions in professional fields, this invention integrates knowledge graphs and large language models to collaboratively apply the structured knowledge and textual semantics of slope documents to question answering. The method first constructs a professional knowledge graph from slope professional documents that reflects the hierarchical reference of standard provisions and parameter constraint relationships. This unifies the survey parameters, standard requirements, and construction experience that were originally scattered in multiple heterogeneous documents into a knowledge network that can be used for system reasoning, fundamentally solving the limitation of pure semantic retrieval in capturing the precise logical dependencies between provisions. During the question answering process, the system can understand the professional query intent implied in the user's dialogue context and automatically connect seemingly scattered but logically closely related provisions. By combining text paragraphs and data records, the system overcomes the contextual fragmentation problem caused by text segmentation in traditional block retrieval, while ensuring rapid location of the most relevant key information in complex knowledge relationships. Subsequently, the structured knowledge in the graph is deeply integrated with the semantics of the original document, so that the information on which the generated answer is based has both logical completeness and expressive integrity. This not only supplements the preconditions and applicable conditions that pure vector retrieval may miss, but also fully preserves the details in the original document. The final generated answer strictly anchors to the authoritative knowledge in the graph in terms of engineering specifications and parameter values, fundamentally suppressing the illusionary risk of general models generating false content out of thin air. The output results are significantly improved in terms of professional accuracy and traceability, providing reliable support for knowledge-intensive decision-making in slope engineering investigation, design and maintenance.
[0101] (2) In response to the problem that traditional retrieval or simple block-segmentation methods treat all kinds of slope documents as flat text and cannot distinguish the hierarchical inclusion relationship of chapters and the structured coupling relationship of parameters-conditions-conclusions, this invention systematically restores the hierarchical reference relationship between the sections of the specification clauses and the vertical change law of table parameters. This makes the survey parameters, specification requirements and construction experience that were originally scattered in multiple heterogeneous documents unified into a knowledge network that can be used for reasoning. This solves the limitation that pure semantic retrieval is difficult to capture the precise logical dependencies between clauses. The knowledge graph constructed transforms the implicit engineering judgment logic distributed between various parts of the document into explicit structured associations. This enables the complete causal reasoning chain to be quickly located in subsequent tasks such as engineering scheme retrieval, specification compliance verification and design parameter tracing, rather than just returning isolated text fragments. This improves the efficiency and credibility of slope engineering knowledge acquisition.
[0102] (3) To address the challenges of uncertain reasoning radius and path divergence noise in engineering question answering—the length of the reasoning path from survey parameters to support scheme depends on the complexity of the specific problem and is difficult to pre-determine, and each entity node in the knowledge graph connects to a large number of neighbors, and full diffusion will introduce weakly related entities to interfere with reasoning judgment—this invention injects the user's dialogue context and current question intent into the reasoning process of the knowledge graph, so that the system can understand the professional query intent implied behind the user's question and automatically focus on the relevant knowledge area, avoiding the problem of divergent results caused by blind search without direction guidance; the final output reasoning path is presented in the form of an interpretable explicit node sequence, which is a complete derivation chain from survey parameters to support scheme and then to construction key points, so that engineers can trace the reasoning basis of the answer and verify the rationality of each link, overcoming the inherent defects of traditional methods that output black box results and return answers based solely on semantic similarity without providing logical support.
[0103] (4) This invention forms a system that complements structured constraints and semantic richness by integrating knowledge flow structured representation, text flow semantic representation and dual-flow adaptive fusion. On the one hand, the reasoning links in the graph provide a mapping between parameters and conclusions, so that the answer is anchored to authoritative knowledge in numerical judgment and normative reference. On the other hand, the complete contextual information of the original text is preserved and supplemented into the generation process, avoiding the omission of key limiting conditions due to information compression. The two work together adaptively according to the needs of the answer content. When it involves the judgment of clear parameter thresholds, the structured constraints are given priority to ensure the accuracy of the criteria. When it involves the scope of application of the scheme or the preconditions, the original text context is fully used to ensure the integrity of the information. In the end, the generated answer has both logical rigor and expression integrity in different types of engineering question and answer scenarios, suppressing the illusion risk of the general model generating false content out of thin air. Attached Figure Description
[0104] Figure 1An interface diagram of the intelligent question-and-answer system for slope documentation provided by this invention;
[0105] Figure 2 This is a diagram of the knowledge graph reasoning link interface provided by the present invention. Detailed Implementation
[0106] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings.
[0107] A method for intelligent question answering of slope documents that integrates knowledge graphs and large language models includes the following steps:
[0108] S1: Collect slope engineering document data and preprocess it to obtain preprocessed slope engineering document data, preprocessed document structure information, and table structure perception data; simultaneously collect user's historical dialogue round text data and user's current question text data; the specific process is as follows:
[0109] S11: Collect slope engineering document data containing tabular data. The data type is text document, including survey report documents, design specification documents, construction plan documents, and monitoring record documents. Use regular expressions to clean the slope engineering document data to remove page numbers, headers, and footers. Then remove stop words based on the stop word list to obtain preprocessed slope engineering document data.
[0110] S12: For the preprocessed slope engineering document data, the document structure is parsed using a document layout analysis method, and the preprocessed document structure information in JSON format is output, including the chapter tree hierarchy, chapter title text, paragraph start and end indexes, and table area bounding box coordinates.
[0111] S13: Based on the coordinates of the bounding boxes of the table areas in the preprocessed document structure information, extract the text of the table areas from the preprocessed slope engineering document data, and reconstruct the text of the table areas into structured table data corresponding to the rows and columns based on the cell coordinates to obtain table structure-aware data.
[0112] S14: Collect text data of the user's historical dialogue rounds and the text data of the user's current question;
[0113] S2: Based on the preprocessed document structure information, the chapter-level structure embedding matrix and the paragraph-level structure embedding matrix are calculated sequentially and fused into a document structure-aware embedding matrix. The semantic structure representation of the table is obtained through intra-column attention interaction and column-level sequence aggregation. The document structure-aware embedding matrix and the table semantic structure representation are aligned with multi-source features to obtain a fused document structure knowledge matrix. Entities and relationships are then extracted based on the fused document structure knowledge matrix to construct a slope engineering knowledge graph. The specific process is as follows:
[0114] S21: Calculate the document structure-aware embedding matrix based on the preprocessed document structure information. The calculation method is as follows:
[0115] ,
[0116] ,
[0117] ,
[0118] in, Embedding matrices for chapter-level structures, For layer normalization operation, For graph convolutional networks, This is the adjacency matrix corresponding to the hierarchical relationship of the chapter tree. This is the edge weight matrix. These are the initial features for each chapter node. This is the offset matrix for the relative positions between chapters. It is a bidirectional gated loop unit. Embedding matrices for paragraph-level structures, This serves as the initial semantic representation of the paragraph text sequence. For document structure-aware embedding matrices, for Encoder, ⊕ represents dimension concatenation operation, ⊙ represents element-wise addition, and ⊙ represents Hadamard product.
[0119] The method for constructing the adjacency matrix corresponding to the chapter tree hierarchy includes: based on the chapter tree hierarchy in the preprocessed document structure information, taking each chapter title as a node; if chapter i is the parent node of chapter j, then... If chapter i and chapter j are adjacent sibling nodes under the same parent node, then At the same time, add a self-loop to each node. =1, set the rest of the positions to 0, and obtain a binary adjacency matrix, where N is the total number of chapter nodes, and i and j are the first chapter index and the second chapter index, respectively;
[0120] The method for constructing the initial features of the chapter nodes includes: inputting the chapter title text from the preprocessed document structure information into the BERT pre-trained language model, extracting the hidden state of the last layer, and taking the vector corresponding to the [CLS] label as the initial feature of a single node for that chapter node; if a chapter does not have an independent title text, then taking the mean pooling vector of all paragraph texts within the scope of the chapter after being encoded by the BERT pre-trained language model as a substitute; concatenating the initial features of the single nodes of all chapter nodes to obtain the initial features of each chapter node;
[0121] The method for constructing the relative position offset matrix between chapters includes: based on the chapter tree hierarchy in the preprocessed document structure information, sequentially numbering each chapter node according to the preorder traversal to obtain the chapter node code, extracting the level depth of each chapter node in the tree, with the root node depth=0, then the relative position offset between chapter i and chapter j is... ,in and These are the first position weight parameters and the second position weight parameters, respectively. These are the chapter node codes for the i-th and j-th chapter nodes, respectively. These are the level depths of the i-th and j-th chapter nodes, respectively; then, by combining them according to the node numbers, we obtain the relative position offset matrix between chapters;
[0122] The method for constructing the initial semantic representation of the paragraph text sequence includes: extracting each paragraph text from the preprocessed slope engineering document data according to the paragraph start and end index in the preprocessed document structure information, inputting each paragraph text into the BERT pre-trained language model, extracting the hidden state sequence of all tokens in the last layer to obtain the initial semantic representation of a single paragraph, and concatenating all the initial semantic representations of a single paragraph to obtain the initial semantic representation of the paragraph text sequence.
[0123] S22: Based on the document structure-aware embedding matrix and table structure-aware data, attention interaction and aggregation are performed to obtain the semantic structure representation of the table. The calculation method is as follows:
[0124] ,
[0125] ,
[0126] ,
[0127] in, For cell feature matrices enhanced with in-column attention, As a multi-head attention mechanism, Embedding features for table cells This is a matrix of offset masks for relative positions within a column. The table features are those resulting from column-level aggregation. For gated loop unit, This is an operation that flattens a matrix into a sequence in column order. For the semantic structure representation of the table, To be aware of the embedding matrix from the document structure The submatrix extracted from the table area;
[0128] The method for constructing the feature embedding of the table cell includes: inputting the text content of each cell in the table structure-aware data into the BERT pre-trained language model, taking the vector corresponding to the [CLS] label as the feature embedding of the cell, and arranging the feature embeddings of all cells in row and column order to obtain the feature embedding of the table cell.
[0129] The method for constructing the relative position offset mask matrix within the column includes: parsing the total number of rows and columns of the target table based on the coordinates of the table area bounding box in the preprocessed document structure information, and assigning a unique cell number to each cell in the target table according to the traversal order of row first and column second;
[0130] Construct an initial mask matrix, wherein the total number of rows and columns of the initial mask matrix are equal to the total number of cells in the target table;
[0131] For any two cells in the same column of the target table, iterate through and calculate the difference in row index between the first cell and the second cell, and assign the difference in row index to the corresponding element in the initial mask matrix; the row and column indices of the corresponding element are: the cell number of the first cell and the cell number of the second cell, respectively.
[0132] For any two cells in the target table that do not belong to the same column, negative infinity is assigned to the corresponding element in the initial mask matrix; the row and column indices of the corresponding element are: the cell number of the first cell and the cell number of the second cell, respectively.
[0133] After traversing all cell pairs and assigning values, the relative position offset mask matrix within the column is obtained.
[0134] S23: Align the document structure-aware embedding matrix with the table semantic structure representation using multi-source features to generate a fused document structure knowledge matrix. The calculation method is as follows:
[0135] ,
[0136] ,
[0137] ,
[0138] ,
[0139] ,
[0140] in, The semantic structure of the table is represented by a vector after mean pooling. To broadcast the pooling vector to Matrix of equal length, To perform mean pooling along the dimensions of table cells, To copy the vector along the sequence dimension Second-rate, It is the sum of the chapter length and the paragraph sequence length; For dual-stream gated fusion weight matrix, It is the Sigmoid activation function. The weight matrix for the gated transformation. This is the gated bias vector. As a preliminary fusion feature, It is a matrix of all ones. To integrate the document structure knowledge matrix, It is a feedforward fully connected network;
[0141] S24: Based on the knowledge matrix of the fused document structure, extract entities and relationships, and construct a knowledge graph for slope engineering. The calculation method is as follows:
[0142] ,
[0143] ,
[0144] ,
[0145] ,
[0146] in, For entity label emission score matrix, For entity classification weight matrix, For GELU activation function, The hidden layer transformation weight matrix is... This is the hidden layer bias vector. For entity classification bias vector, For entity boundary label sequence, For conditional random fields, Let be the probability tensor of the relationship triplet. For the relation classification weight matrix, , They are respectively The candidate head entity feature vector and candidate tail entity feature vector are extracted based on the entity boundary label sequence. For relation classification bias vectors For slope engineering knowledge graph This is a triplet constructor that selects head and tail entities that simultaneously satisfy the condition that the entity boundary labels are valid and the relationship probability is greater than a preset threshold, based on the entity boundary label sequence and the relationship probability, to form a set of relation triplets.
[0147] It is worth noting that slope engineering documents come from diverse sources and exhibit strong structural heterogeneity—survey reports primarily consist of stratigraphic descriptions and parameter tables, design specifications focus on hierarchical relationships of clause references, and construction plans emphasize process descriptions. Traditional retrieval or simple block-segmentation methods treat all types of documents as flat text, failing to distinguish between three heterogeneous information structures: First, the chapter-level inclusion relationship; ignoring this level will result in the retrieved context lacking upper-level constraints; second, the structured coupling relationship between parameters, conditions, and conclusions. For example, a set of geotechnical parameters in a survey report table, such as cohesion and internal friction angle, might be mapped to a safety factor threshold through specification clauses, and then the threshold would determine the support type. This logical link is easily broken during text block segmentation.
[0148] To address the aforementioned challenges, this invention presents a progressively layered technical solution, encompassing document structure perception, table semantic understanding, multi-source feature alignment, and knowledge graph construction. At the document structure perception level, the invention first constructs an adjacency matrix and a relative positional bias matrix between chapters based on the inherent hierarchical structure of the slope engineering design specifications. In the adjacency matrix, the edges connecting parent nodes to child nodes and the self-loop connections of nodes provide a topological path for information propagation in the graph convolutional network. When the graph convolutional network performs multi-layer information aggregation on the graph defined by the adjacency matrix, the feature vector of a specific article's section node will progressively integrate the semantic information of its parent node, grandparent node, and even the root node. This ensures that the chapter-level structure embedded in the model-encoded vector contains not only the technical content of the article itself but also the progressively ascending normative basis and principle constraints, accurately reproducing the "general provisions" in actual engineering. The system establishes a hierarchical reference relationship between "sub-item clauses" and "sub-item clauses constraining specific clauses." Simultaneously, a bidirectional gated loop unit encodes each sentence along the sequence of paragraphs within each chapter, capturing the contextual dependencies between textual expressions within paragraphs. For example, lithological descriptions of the same stratum in an exploration report often span multiple consecutive paragraphs. The bidirectional gated loop unit can connect the strata description information scattered in adjacent paragraphs at the feature level, avoiding interruptions to the complete semantics of the same geological object due to paragraph segmentation. Based on this, the Transformer encoder uses a self-attention mechanism to perform cross-dimensional information interaction and integration of chapter-level structural embedding and paragraph-level semantic embedding. The output document structure-aware embedding matrix enables the model to understand each text while simultaneously carrying its hierarchical position within the chapter and its contextual semantics, avoiding the perception of each clause in the design specifications or each paragraph in the exploration report as isolated text fragments.
[0149] At the level of semantic understanding of tables, this invention addresses the structural characteristics of parameter tables in exploration reports—parameter values in the same column (such as cohesion values corresponding to different strata depths within the same column) have vertical comparability and trend correlation in a physical sense, while different columns belong to different physical dimensions—by designing an intra-column attention mechanism. Specifically, through an intra-column relative position bias mask matrix, minimal attention weights are assigned to cell pairs that do not belong to the same column in multi-head attention, so that when the model calculates the interaction between table cells, its attention is mainly focused on cells within the same column, thereby enabling it to perceive the numerical variation pattern and distribution range of a parameter in a certain column from top to bottom. For example, when a column in an exploration report table records cohesion values corresponding to different depth segments from shallow to deep, the column… Inner attention enables the model to capture the numerical trend of the parameter as the depth increases, and then associate this change pattern with the design parameter selection logic of the corresponding depth segment, instead of mixing and calculating all cells in the table indiscriminately. Subsequently, the table features are aggregated column by column in column priority order through gated loop units, so that the vertical change information of each column is compressed into a time step in the sequence, generating a semantic structure representation of the table. This representation is then residually interacted and fused with the corresponding sub-region of the table in the document structure-aware embedding matrix, so that the parameter values scattered in different rows of the table and the normative constraints scattered in the document text can establish semantic association through the shared feature space, thereby alleviating the parameter-condition-conclusion link breakage problem caused by text segmentation to a certain extent.
[0150] At the multi-source feature alignment level, this invention uses a dual-stream gated fusion mechanism as its core, integrating the document structure-aware embedding matrix and the table semantic structure representation across modalities in an adaptive manner. The gate weights are jointly determined by the two source features after nonlinear transformation. In different document types and different document regions, the gate weights can adaptively adjust the contribution ratio of document text features and table parameter features. For example, in the paragraph-dense descriptive areas of a survey report, the gate weights of document text features can adaptively account for a higher proportion, while in the parameter table-dense data areas, the gate weights of table features can adaptively account for a higher proportion. This allows the fused document structure knowledge matrix to more evenly express the semantic complementarity of different modal information in the same document. Dual-stream gated fusion is not a simple concatenation or equal-weighted summation, but rather dynamically determines the degree of fusion between the text modality and the table modality based on the feature distribution at the current encoding position. This allows the engineering conditions described in the chapter text and the specific parameters given in the table to form a coupled duality in a unified embedding space, providing higher information density feature inputs for subsequent entity recognition and relation extraction.
[0151] At the knowledge graph construction level, this invention is based on a fused document structure knowledge matrix. It uses a conditional random field (CRF) to label entity boundaries at each location. The CRF utilizes label transfer constraints between adjacent locations, which can improve the sequence consistency of entity boundary labeling to a certain extent and reduce entity boundary breakage or nesting errors caused by single-point label prediction bias. After obtaining entity boundary labels, feature vectors of candidate head entities and candidate tail entities are extracted from the fused document structure knowledge matrix. The probability of success of various relationships between them is calculated through relationship classification, and effective relationship triples are selected based on preset thresholds. Finally, a slope engineering knowledge graph is constructed. This knowledge graph unifies the engineering judgment logic, which was originally implicitly distributed in multiple heterogeneous documents—such as a design specification clause making a support selection based on a specific data row in a survey report parameter table, or a technical clause referenced in a construction plan pointing to a specific entry in another specification—into explicit entity nodes and relationship edges. This provides structured knowledge support for downstream tasks such as engineering scheme retrieval, specification compliance verification, and design parameter tracing.
[0152] Existing technologies typically perform text segmentation and vector retrieval on all types of documents related to slope engineering. Essentially, they treat documents as flat, unstructured text sequences, failing to distinguish between chapter titles and body paragraphs—leading to retrieved text fragments that may lack the higher-level normative constraints of their respective chapters. Furthermore, they do not specifically model the physical relationships between values within table parameter columns—resulting in the vertical variation patterns of parameter values in the same column of the survey report being scattered across different text blocks during segmentation, losing the numerical context between parameters. In contrast, this invention uses graph convolutional networks and adjacency matrices to encode the hierarchical relationship of chapters in a tree structure, enabling the semantic embedding of each clause to carry a progressively upward normative constraint. According to the data, the numerical coupling between parameters in the same column of a table is captured by in-column attention, so that the table parameter representation retains the vertical trend and distribution characteristics of the same physical quantity. Adaptive semantic alignment between document text and table parameters is achieved through dual-stream gating fusion, so that parameters and clause constraints are coupled in a unified embedding space. Cross-document logical edges are explicitly incorporated into the knowledge graph through entity-relation extraction. Finally, the implicit chapter-level constraints, parameter-threshold mapping links and cross-document citation relationships in multi-source heterogeneous documents of slope engineering are transformed into queryable and reasonable structured knowledge representations, which improves the structured organization of multi-source heterogeneous engineering documents and the semantic integrity of downstream tasks.
[0153] S3: Based on the initial embedding of entity nodes in the slope engineering knowledge graph, combined with the user's historical dialogue rounds text data and the user's current question text data, the context-activated entity node embedding representation is calculated sequentially. Context-guided path reasoning is then performed on the knowledge graph to generate multi-hop reasoning attention trajectories. Finally, through adaptive threshold path dynamic pruning and reasoning chain reconstruction, a dynamic knowledge reasoning path is obtained. The specific process is as follows:
[0154] S31: Based on the initial embedding of entity nodes in the slope engineering knowledge graph, and combined with the historical dialogue text received by the system and the current user question, the context-activated entity node embedding representation is obtained. The calculation method is as follows:
[0155] ,
[0156] ,
[0157] ,
[0158] ,
[0159] ,
[0160] in, To hide the user's historical conversations. The user's current problem is hidden. For BERT pre-trained language models, For embedding layer, For user's historical dialogue rounds text data, The text data representing the user's current question. To fuse semantic vectors for context, To broadcast the pooling vector to The matrix after the row, The number of entities in the slope engineering knowledge graph. The context-gated activation value. For the gated weight matrix, This is the initial embedding of entity nodes in the slope engineering knowledge graph. This is the first projection weight matrix. Embedded representations for entity nodes activated in the context. This is the second projection weight matrix;
[0161] The calculation method for the initial embedding of entity nodes in the slope engineering knowledge graph includes: assigning an embedding vector to each entity node in the slope engineering knowledge graph through an embedding layer, randomly initializing and updating it during training to obtain the initial embedding of entity nodes in the slope engineering knowledge graph.
[0162] S32: Based on the context-activated entity node embedding representation, perform context-guided path reasoning on the knowledge graph to generate a multi-hop reasoning attention trajectory, calculated as follows:
[0163] ,
[0164] ,
[0165] ,
[0166] ,
[0167] in, Choose a mask for the anchor node. To select the top score The operation is performed on each element, where k is the selection threshold. For the Softmax function, It is a multilayer perceptron. For graph attention networks, For the initial ripple diffusion node attention features, For the first Ripple diffusion node attention features of the layer For the first The ripple diffusion node attention feature of the layer, where layer is the index of the graph attention network layer number. For the first The graph attention weight matrix of the layer. This is the adjacency matrix of the knowledge graph for slope engineering. For multi-hop reasoning attention trajectory, These are the attention features of the ripple diffusion nodes in layers 1, ..., and L, respectively, where L is the total number of layers.
[0168] The method for constructing the adjacency matrix of the slope engineering knowledge graph includes: for the set of relation triples in the slope engineering knowledge graph, using entity nodes as row and column indices, if there is any relation edge between entity i and entity j, then... At the same time, add a self-loop to each node. Set the remaining positions to 0 to obtain the adjacency matrix of the slope engineering knowledge graph;
[0169] S33: Perform adaptive threshold path dynamic pruning and inference chain reconstruction on multi-hop inference attention trajectories, eliminate redundant paths with attention weights below the dynamic threshold, and generate dynamic knowledge inference paths. The calculation method is as follows:
[0170] ,
[0171] ,
[0172] ,
[0173] in, For adaptive pruning threshold, For mean pooling operation, It is a one-dimensional convolutional layer. For learnable threshold scaling factor, For binary pruning masks, For indicator functions, This is a dynamic knowledge reasoning path.
[0174] It is necessary to further explain that slope engineering question-and-answer processes in practice exhibit progressive and multi-hop causal reasoning characteristics. Users often start with "What are the soil and rock conditions of a certain slope section?", followed by "Which type of support is suitable for these conditions?", and then confirm "The structural requirements and monitoring points for this type of support." These questions appear independent on the surface, but in reality, there is a causal reasoning relationship from survey parameters to support schemes and then to structural details. However, each question involves different entity node regions in the knowledge graph, requiring the model to cross multiple relational edges during the reasoning process. Traditional question-and-answer methods based on keyword matching or single-hop retrieval face two core challenges: First, the reasoning radius is uncertain, starting from survey parameters... The path from parameters to support schemes may take a two-hop path from parameters to specifications to schemes, or it may take more intermediate judgment nodes from parameters to failure modes to safety factors to specifications to schemes. The path length depends on the complexity of the specific problem and the engineering background. Fixed-step reasoning strategies are difficult to adapt to this flexibility requirement. Secondly, there is path divergence and noise. Each entity node in the knowledge graph is often connected to a large number of neighboring nodes. For example, a certain type of geotechnical parameter node may have specification-related edges with multiple support type nodes, but not all associations are related to the specific geological conditions of the current slope. Full diffusion will introduce weakly related entities such as scheme nodes of the same type but with different geological conditions, which will interfere with the reasoning judgment.
[0175] To address the aforementioned challenges, this invention establishes a question-driven multi-hop reasoning system, encompassing contextual semantic injection, ripple-like path exploration, and adaptive pruning and reconstruction. At the contextual semantic injection level, the invention first encodes the user's historical dialogue text and the current question text using BERT pre-trained language models. Then, through a multi-head attention mechanism, the model interacts with the current question's hidden state as the query and the historical dialogue's hidden state as the key. This allows the model to extract contextual clues related to the current question from historical dialogues—for example, if a user has previously inquired about the geotechnical parameters of a slope section, and the current question asks about the support type, the model automatically associates the previously confirmed parameter information with the current question through attention interaction, generating a contextual fusion semantic vector. Subsequently, this contextual fusion semantic vector is pooled and broadcast to all entity nodes in the knowledge graph, and contextual gating activation values are calculated to gate the... The method injects dialogue context information into the initial embedding of each entity node, resulting in context-activated entity node embeddings. The gating mechanism here does not indiscriminately write context information into all entity nodes, but rather adaptively determines the injection strength based on the relevance of each entity node's own characteristics to the context semantics. Entity nodes related to the current question and historical dialogue semantics (such as geotechnical parameter nodes and specification clause nodes corresponding to the current slope section) receive higher activation strength, while irrelevant entity nodes (such as parameter nodes of other engineering projects) are only slightly affected. This design allows entity nodes in the knowledge graph to carry the semantic bias of the current question-and-answer scenario before inference begins, providing an initial search direction related to the question for subsequent path exploration, avoiding blind searching from all entity nodes without directional guidance.
[0176] At the ripple-like path exploration level, this invention first performs multilayer perceptron scoring and selection on the embedded representations of context-activated entity nodes, identifying a small number of anchor nodes that best match the semantics of the current question as the starting point for inference—these anchor nodes are usually entities directly mentioned in the user's current question or confirmed in historical dialogues, such as the geotechnical parameter node of a certain slope section; subsequently, using the anchor nodes as wave sources, attention signals are diffused outward layer by layer along the adjacency matrix of the knowledge graph through a graph attention network; the first layer of the graph attention network starts from the anchor nodes and diffuses attention along relation edges to direct neighbor nodes (such as from geotechnical parameter nodes to associated specification clause nodes and failure mode nodes); the second layer of the graph attention network continues to diffuse outward from the nodes activated in the previous layer (such as from specification clause nodes to support type nodes and safety factor threshold nodes), and so on, expanding layer by layer, each Each layer adds the attention features of the current layer's ripple diffusion nodes to the residuals of the previous layer and passes them to the next layer, forming a multi-hop inference attention trajectory radiating outward from the anchor point. The residual connection serves to preserve the information of intermediate nodes explored in each hop, preventing the gradual loss of the inference contribution of near-hop nodes as the number of graph attention network layers increases during deep diffusion. This ensures that the final multi-hop inference attention trajectory simultaneously covers the attention distribution of both directly related near-hop nodes and indirectly derived far-hop nodes. Furthermore, the graph attention network does not treat all neighbors equally during each hop diffusion. Instead, the attention weights dynamically allocate propagation intensity based on the semantic matching degree between the current node's features and those of its neighbors. This results in neighbors semantically relevant to the current problem receiving higher attention propagation weights, which to some extent suppresses diffusion in directions unrelated to the problem, thereby controlling the scope and direction of ripple diffusion.
[0177] At the adaptive pruning and inference chain reconstruction level, this invention performs one-dimensional convolutional smoothing and mean pooling on the attention distribution of each layer in the multi-hop inference attention trajectory, and then multiplies it by a learnable threshold scaling factor to calculate an adaptive pruning threshold that dynamically changes with the current input. This design introduces a threshold scaling factor instead of a fixed cutoff value because different problems have different inference complexities—simple problems (such as directly finding the canonical threshold of a parameter) may only require a few high-attention paths to answer, and the threshold can be adaptively higher to simplify the paths; while complex problems (such as integrating multi-source parameter derivation support schemes) need to retain more inference branches, and the threshold can be adaptively lower to retain more intermediate derivation steps. Subsequently, after performing multilayer perceptron scoring and Softmax normalization on the attention trajectories of each layer, the adaptive pruning threshold is calculated using the index... The function resets attention weights below the adaptive pruning threshold to zero and retains those above the threshold, generating a binary pruning mask to dynamically eliminate redundant paths. For example, when reasoning from geotechnical parameter nodes to support scheme nodes, support scheme paths that are inconsistent with the current slope geological condition type are pruned due to their low attention scores, retaining only reasoning branches that match geological conditions and conform to specifications. Finally, the gated loop unit encodes the pruned reasoning path sequence, integrating the retained multi-hop path node information into a coherent dynamic knowledge reasoning path. This path presents a complete causal derivation chain from exploration parameters to support schemes to structural key points in the form of an explicit node sequence, providing interpretable reasoning basis for downstream answer generation, rather than just outputting a black-box answer result.
[0178] Existing technologies typically employ question-answering methods based on text retrieval or fixed-step graph reasoning. The former matches keywords to the user's current question in a document database and returns relevant paragraphs, but it cannot perform multi-hop derivation along the relational edges of the knowledge graph. When faced with progressive questions such as "deriving a support scheme from geotechnical parameters," which requires traversing multiple intermediate decision nodes, the fragmented text returned by the retrieval is difficult to connect into a complete causal chain. The latter, while supporting multi-step reasoning on the graph, usually uses a fixed number of hops or a full neighbor diffusion strategy. A fixed number of hops cannot adapt to the differences in reasoning depth between different questions—too few hops will miss key intermediate nodes, while too many hops will introduce noise. On the other hand, full neighbor diffusion aggregates all neighbor node information indiscriminately in each hop, resulting in weakly correlated facts unrelated to the current slope geological conditions. In contrast, this invention adaptively injects semantic information from historical dialogues and the current problem into knowledge graph entity nodes through context gating, providing a contextualized initial search direction for reasoning. It explores from anchor nodes hop-by-hop using a graph attention network in a ripple-like diffusion manner, with attention weights dynamically allocated based on semantic matching, ensuring the diffusion process is guided by the problem's semantics rather than purely topologically driven. Adaptive threshold pruning eliminates redundant paths with attention below a dynamic threshold, and gated recurrent units reconstruct the remaining paths into coherent reasoning chains. Ultimately, among multiple possible reasoning paths, it can more accurately identify the reasoning chain that constitutes an actual causal relationship with the current engineering problem, improving the accuracy of multi-hop reasoning paths and the causal logic completeness of downstream responses.
[0179] S4: Based on the dynamic knowledge reasoning path, anchor entities and target entities are determined. Local knowledge subgraphs are extracted from the slope engineering knowledge graph and aggregated into a knowledge flow structured representation. Simultaneously, the preprocessed slope engineering document data is encoded into a text flow semantic representation. Then, the knowledge flow structured representation and the text flow semantic representation are fused to obtain enhanced generative context features. The specific process is as follows:
[0180] S41: For dynamic knowledge reasoning paths, utilize the non-zero nodes retained after filtering by binary pruning mask in the attention features of each layer's ripple diffusion nodes, and sequentially search for valid nodes in each layer from the first layer to the last layer according to the layer index. The valid nodes in the first layer are used as anchor entities, and the valid nodes in the last layer are used as target entities.
[0181] S42: Based on the anchor entities and target entities contained in the dynamic knowledge reasoning path, extract a local knowledge subgraph centered on the anchor entity with a radius of no more than three hops from the slope engineering knowledge graph. Obtain the initial embedding vector of each entity node in the subgraph through embedding layer retrieval, then aggregate neighborhood information through mean pooling, and fuse it with the concatenated vector of the anchor-target entity pair to obtain the structured representation of the knowledge flow. The calculation method is as follows:
[0182] ,
[0183] ,
[0184] ,
[0185] in, This is the initial set of embedding vectors obtained from the embedding layer for each entity node in the local knowledge subgraph. For a set of entity nodes in a local knowledge subgraph, For embedded layer retrieval operations, The entity embedding matrix after subgraph pooling. For mean pooling operation, The embedding vector for the node corresponding to the anchor entity. Embed vectors for the nodes corresponding to the target entity. Transform the weight matrix for the knowledge flow. For a structured representation of knowledge flow;
[0186] The extraction methods for the node embedding vectors corresponding to the anchor entity and the target entity include: locating the index position of the anchor entity and the target entity from the entity node set of the local knowledge subgraph based on the determined anchor entity and target entity, and then... Retrieve the corresponding row vector by index, and obtain the following results: and ;
[0187] S43: Based on the preprocessed slope engineering document data, the text sequence is converted into word embedding vectors through an embedding layer, and then the semantic features of the document are extracted through encoding to obtain the semantic representation of the text stream. The calculation method is as follows:
[0188] ,
[0189] ,
[0190] in, For the preprocessed slope engineering document data, For text embedding vectors, For Transformer encoders, For semantic representation of text streams;
[0191] S44: Based on the knowledge flow structured representation and the text flow semantic representation, a dual-stream fusion is performed to obtain enhanced generative context features. The calculation method is as follows:
[0192] ,
[0193] ,
[0194] ,
[0195] ,
[0196] in, This represents the aligned representation of a text stream mapped to a knowledge space. For broadcast operation, This represents the pooled and broadcast knowledge flow. The length of the text sequence. For dual-stream gating weights, This is to enhance the generation of contextual features.
[0197] It is necessary to further explain that knowledge graphs and original document text each have complementary advantages and inherent limitations in engineering question answering. After being constructed through entity-relation extraction, knowledge graphs can provide structured parameter-condition-conclusion mappings—such as engineering criterion chains like "if the safety factor is not lower than a certain threshold, a gentler slope is allowed." However, due to the information compression in the form of triples, limiting information such as applicable conditions, assumptions, and terminological context in the original text is inevitably lost. For example, in a design code clause, a provision stating "a certain value of geotechnical parameters maps to a certain support scheme" is extracted as a relation triple, and the accompanying statement "this provision applies to homogeneous soil slopes; for mixed geotechnical slopes, further justification is required" is lost. One key constraint is stripped away. If the support scheme recommendation is given based solely on the triplet while ignoring the limitation of the applicable range of lithology, it may lead to the incorrect application of the criteria for homogeneous soil slopes in the case of mixed soil and rock slopes, resulting in inferences based on incomplete information. On the other hand, although the original document text retains the complete contextual description and constraints, the logic of the engineering criteria is presented in narrative language. The technical basis for the support selection in the survey report is often scattered in multiple paragraphs. There is a lack of explicit structured connection between parameter values, standard references and scheme conclusions. When the model directly relies on the text to generate answers, it is easily interfered with by differences in expression style or contextual noise, making it difficult to accurately extract the strict correspondence between parameters and thresholds.
[0198] To address the aforementioned challenges, this invention constructs a structured representation of knowledge flow, extracts semantic representation from text flow, and achieves adaptive fusion of the two flows, forming a fusion system that complements structured constraints and semantic richness. At the level of constructing the structured representation of knowledge flow, this invention first extracts effective nodes from the dynamic knowledge reasoning path as anchor entities and effective nodes from the last layer as target entities—these effective nodes are non-zero nodes retained after binary pruning and masking, and have been verified in previous reasoning to be causally related to the current problem. Subsequently, a local knowledge subgraph with a radius of no more than three hops is extracted from the slope engineering knowledge graph centered on the anchor entity. Initial embedding vectors are obtained for each entity node in the graph through embedding layer retrieval, and then the structural information of the subgraph's neighborhood is aggregated through mean pooling. This is then fused with the features obtained after concatenation transformation of the anchor entity embedding vector and the target entity embedding vector. A structured representation of the knowledge flow is obtained. This structured representation contains three aspects of information: the direct semantic association between the anchor entity and the target entity, the structural context information of the anchor's neighboring nodes in the local subgraph, and the relative positional relationship of the target entity in the subgraph. Taking the slope engineering scenario as an example, when the anchor entity is a certain geotechnical parameter node and the target entity is a certain support scheme node, the structured representation of the knowledge flow not only encodes the features of these two types of entities themselves, but also aggregates the neighborhood information of intermediate judgment nodes such as the standard clause nodes and safety factor threshold nodes between the two in the local subgraph. This allows the complete intermediate logical links in the reasoning link from the exploration parameters through the standard criteria to the support scheme to be structurally preserved in the knowledge flow representation, rather than just retaining the isolated embedding vectors of the first and last entities. This provides a structural skeleton for the reasoning link in the subsequent fusion process.
[0199] At the level of text flow semantic representation extraction, this invention first converts the text sequence into word embedding vectors through an embedding layer for the preprocessed slope engineering document data, and then uses the Transformer encoder to extract the contextual semantic features of the document layer by layer through a self-attention mechanism to obtain the text flow semantic representation. Since the Transformer encoder does not rely on a fixed local window, but instead uses self-attention to globally model the dependencies between any positions in the text, the text flow semantic representation can better preserve the narrative context across sentences or even paragraphs in the original text. For example, although the parameter description "the friction angle in this slope section is low" in the survey report and the subsequent conclusion "it is recommended to reduce the slope rate" are separated by several sentences, the text flow semantic representation can still establish a long-distance semantic association between the two at the feature level, so that the narrative engineering judgment logic in the original text is encoded as a whole in the form of continuous semantic vectors, rather than being truncated into short fragments that are unrelated to each other.
[0200] At the dual-stream adaptive fusion level, this invention first uses multi-head attention to perform cross-attention calculation with the semantic representation of the text stream as the query and the structured representation of the knowledge stream as the key, mapping the text stream to the knowledge space and generating an aligned representation from the text stream to the knowledge space. This alignment operation allows ambiguous narrative expressions in the text to obtain clearer semantic directions under the guidance of structured knowledge—for example, when the text mentions "slowing down the slope," cross-attention allows relevant features in the text stream to interactively align with the structured representations of the slowing down slope solution entity nodes in the knowledge stream, thereby establishing a correspondence between the descriptive solution expression in the original text and the solution definition in the graph, bridging the semantic gap between narrative language and structured knowledge. Subsequently, a multilayer perceptron concatenates and nonlinearly transforms the aligned text stream representation and the pooled broadcast knowledge stream representation, generating dual-stream gating weights through an activation function. The dual-stream gating weights adaptively determine the fusion ratio of the structured representation of the knowledge stream and the semantic representation of the text stream for each position in the text sequence—when... When the location involves explicit parameter threshold determination (such as "what safety factor is required to adopt a gentler slope"), the gating weight can adaptively assign higher fusion weight to the structured representation of the knowledge flow, prioritizing the use of precise parameter-threshold mapping relationships in the triples for constraining answers. When the location involves the scope of application or preconditions of a solution (such as "what geological conditions are suitable for a certain type of support"), the gating weight can adaptively assign higher fusion weight to the semantic representation of the text flow to capture rich limiting descriptions in the original text regarding lithological requirements, terrain limitations, etc. The enhanced generation context after gating fusion retains the structured engineering criterion chain in the knowledge graph and supplements the applicable conditions and exceptions not covered by the triples in the original text. This allows downstream answer generation to prioritize structured constraints to ensure accurate criteria when facing parameter threshold determination questions, and to fully refer to the original text context to ensure information completeness when facing scope of application questions. Thus, it can obtain more balanced and logically rigorous contextual support in different types of engineering question-and-answer scenarios.
[0201] Existing technologies for fusing knowledge graphs and text typically employ simple concatenation or fixed-ratio weighted fusion methods. Simple concatenation serializes the graph triples into text and directly concatenates them with the original text before feeding them into the generation model, without performing semantic alignment at the feature level. This results in the structured constraints of the graph and the narrative context of the text being expressed separately in the semantic space, lacking interaction. Consequently, the model struggles to dynamically adjust its dependence on the two information sources based on the question type when generating answers. While fixed-ratio weighted fusion fuses the two at the feature level, the fusion ratio is globally uniform and fails to perceive the differentiated needs for structured constraints and semantic richness across different document locations or question types—for example, in scenarios requiring precise threshold parameter determination or requiring complete context. Using scope descriptions to assign the same fusion weights to different scenarios makes it difficult to balance the advantages of both aspects. In contrast, this invention maps the text stream to the knowledge space for semantic alignment through cross-attention, establishing a correspondence between ambiguous narratives in the text and precise entities in the graph within a unified semantic space. By dynamically generating fusion weights based on the feature distribution of each location through a dual-stream gating mechanism, the fusion ratio can be adaptively adjusted according to different question types and text fragments—favoring the knowledge stream in contexts where parameter threshold judgment is the primary focus, and favoring the text stream in contexts where scope description is the primary focus. This achieves a more balanced complementary effect between the accuracy of structured constraints and the completeness of the text context, improving the credibility of the engineering question-answering system's answers in complex slope scenarios.
[0202] S5: Based on the enhanced generation context features, a preliminary answer is generated through Transformer decoding to produce a vocabulary probability distribution. Then, beam search decoding and length normalization reordering are used to select the candidate sequence with the highest score as the final answer text. The specific process is as follows:
[0203] S51: Based on the enhanced generation context features, decode to generate a preliminary answer, and obtain the vocabulary probability distribution corresponding to the preliminary answer text sequence. The calculation method is as follows:
[0204] ,
[0205] in, To provide a preliminary answer to the vocabulary probability distribution corresponding to the text sequence, For Transformer decoder, To answer the starting marker;
[0206] S52: Based on the vocabulary probability distribution corresponding to the initial response text sequence, multiple candidate response sequences are generated using beam search decoding. A length-normalized logarithm probability score is calculated for each candidate sequence, and the candidate sequence with the highest score is selected as the final response text. The calculation method is as follows:
[0207] ,
[0208] ,
[0209] in, Let B be the set of candidate answer sequences obtained by the beam search. For the beam search decoding operation, B is the beam width, and α is the length penalty coefficient. For the final answer text, This refers to the operation that retrieves the element corresponding to the maximum value.
[0210] Example 1
[0211] The BERT pre-trained language model used in this embodiment is the BERT-base-Chinese version, with a hidden layer dimension of 768, 12 Transformer layers, and 12 multi-head attention heads. The graph convolutional network has a 2-layer structure with 768 hidden units per layer. The bidirectional gated recurrent unit is set to 2 layers with 768 hidden units. The Transformer encoder and decoder both have a 6-layer structure, with 8 multi-head attention heads and 76 hidden units in each layer. 8. The number of hidden units in the feedforward network is set to 2048; the number of attention heads in all multi-head attention mechanisms is uniformly set to 8; the number of hidden units in the gated recurrent unit is set to 768; the number of layers in the graph attention network is set to 3, with 4 attention heads per layer and 768 hidden units; the multilayer perceptron adopts a 2-layer fully connected structure, with 256 hidden units and GELU activation function; the kernel size of the one-dimensional convolutional layer is set to 3, and the stride is set to 1; the number of hidden units in the feedforward fully connected network is set to 2048; entity boundary annotation uses conditional random fields for sequence decoding.
[0212] The embedding vector dimension of each embedding layer is uniformly set to 768, consistent with the BERT output dimension; the initial embedding vector dimension of entity nodes is set to 768, and is updated during training after random initialization; the feature dimensions of document structure-aware embedding matrix, table semantic structure representation, fused document structure knowledge matrix, context-activated entity node embedding representation, multi-hop inference attention trajectory, knowledge flow structured representation, text flow semantic representation, and enhanced generated context features are all maintained at 768; the number of anchor nodes is set to 5, and the number of ripple diffusion layers is set to 3; the beam width in beam search decoding is set to 5, and the length penalty coefficient is set to 0.6; the preset threshold for relation triple selection is set to 0.5;
[0213] The training adopts a phased strategy. The first phase pre-trains the knowledge graph construction-related parts, specifically corresponding to the document structure-aware embedding, table semantic structure representation, multi-source feature alignment, and entity and relation extraction parts covered in steps S21 to S24. The loss function in this phase consists of two parts summed with equal weights: the loss function for entity boundary labeling adopts the negative log-likelihood loss of conditional random fields, and the loss function for relation classification adopts the binary cross-entropy loss. The two are summed with equal weights as the total loss of the first phase.
[0214] In the second stage, after the first stage training converges, all parameters of the fixed knowledge graph construction part are no longer updated. Instead, the training focuses on the context-aware reasoning part (corresponding to steps S31 to S33) and the dual-stream fusion generation part (corresponding to steps S41 to S44 and S51 to S52). The loss function adopts the cross-entropy loss of the answer text, directly using the quality of the final generated answer text as the optimization objective, so that the selection of the reasoning path and the context fusion strategy are closely related to the actual effect of the question-answering task. The optimizer uniformly adopts AdamW, with the initial learning rate set to 3e-5 in the first stage and 1e-4 in the second stage, and the weight decay coefficient set to 0.01. The learning rate scheduling strategy adopts cosine annealing, supplemented by linear warm-up, with the warm-up steps set to 10% of the total training steps in each stage. The training batch size is set to 8, the maximum training rounds are set to 50, and an early stopping strategy is adopted based on the loss on the validation set, with an early stopping patience value set to 5 rounds.
[0215] The interface diagram of the intelligent question-and-answer system for slope documentation provided by this invention is shown below. Figure 1 As shown, for a highway slope, designers need to determine the support scheme for deep soil and rock masses based on the survey report. The survey report table shows: the section with a depth of 5 to 12 meters consists of strongly weathered mudstone with a cohesion of 18 kPa and an internal friction angle of 22 degrees; the section with a depth of 12 to 20 meters consists of moderately weathered mudstone interbedded with sandstone, with a cohesion of 12 kPa and an internal friction angle of 15 degrees. Article 5.2.3 of the design code stipulates that when the internal friction angle is not less than 20 degrees, a safety factor of 1.25 can be achieved to reduce the slope ratio; when the internal friction angle is less than 20 degrees... When the safety factor reaches 1.35, anchor cable support must be used; at the same time, the end of Article 5.2.3 states "applicable conditions for mixed rock and soil strata are detailed in Article 4.3.2", while Article 4.3.2 is located in another chapter of the specification, which stipulates that the safety factor for mixed rock and soil slopes or alternating soft and hard slopes should be increased by 0.1 based on Article 5.2.3; the user first asks "the soil and rock parameters in the 12 to 20 meter depth range of this section", and after the system replies, the user asks "what kind of support scheme should be used for this section";
[0216] The results of the traditional retrieval enhancement generation method: The traditional method divides the standard text into fixed-length blocks and builds a vector index. When a user asks a question, similar text blocks are retrieved and fed into a large language model to generate an answer. The system retrieves text fragments containing keywords such as "internal friction angle less than 20 degrees", "anchor cable support", and "safety factor 1.35". The generated answer is: "According to Article 5.2.3 of the standard, if the internal friction angle is 15 degrees or less than 20 degrees, anchor cable support should be used, and the safety factor should not be less than 1.35." This answer ignores two key pieces of information: First, Article 4.3.2, which is cited in the last sentence of Article 5.2.3, is located in another chapter and was divided into different blocks during text segmentation. Semantic retrieval did not include this cross-chapter citation relationship in the recall scope. Second, the lithological description of "moderately weathered mudstone interbedded with sandstone" in the exploration report table belongs to soft and hard interbedded strata, which meets the mixed rock and soil strata determination conditions of Article 4.3.2. However, the structured mapping link between the table parameters and the standard provisions is broken during the text segmentation process, resulting in the safety factor not being adjusted.
[0217] The knowledge graph of this invention, during its construction phase, captured the cross-chapter reference relationship between Article 5.2.3 and Article 4.3.2 through chapter-based hierarchical relationship encoding, and preserved the coupling relationship between the lithological description and parameter values of "moderately weathered mudstone interbedded with sandstone" through column attention in the table, such as... Figure 2 As shown; during the user's second round of follow-up questions, the system starts from the anchor point entity "internal friction angle 15 degrees" and, through ripple diffusion, infers step-by-step along the knowledge graph relationship edges: the first jump relates to the anchor cable support criterion and safety factor threshold of 1.35 in Article 5.2.3; the second jump traces through the cross-document reference edge to the additional conditions of mixed rock and soil strata in Article 4.3.2; simultaneously, from the lithological entity "mudstone interbedded with sandstone," it matches through the table parameter coupling edge to the soft and hard interlayer judgment condition in Article 4.3.2; the reasoning chain ultimately corrects the safety factor to 1.45; in the dual-stream fusion stage, the gating weight is applied to the relevant clauses. The position of the range determination is adaptively biased towards the original text semantics, so that the complete limiting description of the applicable conditions in the original text of Article 4.3.2 is preserved; the final generated answer is: "This section should be supported by anchor cables with a safety factor of not less than 1.45; the basis is: the friction angle in the 12 to 20 meter section is 15 degrees, and according to Article 5.2.3 of the specification, anchor cables should be used and the foundation safety factor is 1.35; the lithology of this section is moderately weathered mudstone interbedded with sandstone, which is a soft and hard interlayer. According to Article 4.3.2 of the specification, the safety factor should be increased by 0.1 on the base value, so the final safety factor is 1.45."
[0218] The above description is merely a specific embodiment of the present invention. Any feature disclosed in this specification may be replaced by other equivalent or similar features unless otherwise specified. All disclosed features, or steps in all methods or processes, may be combined in any way except for mutually exclusive features and / or steps.
Claims
1. A method for intelligent question answering of slope documents that integrates knowledge graphs and large language models, characterized in that, Includes the following steps: S1: Collect slope engineering document data containing tabular data and preprocess it to obtain preprocessed slope engineering document data, preprocessed document structure information, and table structure perception data; at the same time, collect user's historical dialogue round text data and user's current question text data. S2: Based on the preprocessed document structure information, the chapter-level structure embedding matrix and the paragraph-level structure embedding matrix are calculated sequentially and fused into a document structure-aware embedding matrix. The semantic structure representation of the table is obtained through intra-column attention interaction and column-level sequence aggregation. The document structure-aware embedding matrix and the semantic structure representation of the table are aligned with multi-source features to obtain a fused document structure knowledge matrix. Entities and relationships are then extracted based on the fused document structure knowledge matrix to construct a slope engineering knowledge graph. S3: Based on the initial embedding of entity nodes in the slope engineering knowledge graph, combined with the text data of the user's historical dialogue rounds and the text data of the user's current question, the embedding representation of the entity nodes activated by the context is calculated in sequence. Context-guided path reasoning is performed on the knowledge graph to generate multi-hop reasoning attention trajectories. Then, through adaptive threshold path dynamic pruning and reasoning chain reconstruction, dynamic knowledge reasoning paths are obtained. S4: Based on the dynamic knowledge reasoning path, determine the anchor entity and the target entity, extract local knowledge subgraphs from the slope engineering knowledge graph and aggregate them into a knowledge flow structured representation. At the same time, encode the preprocessed slope engineering document data into a text flow semantic representation, and then fuse the knowledge flow structured representation and the text flow semantic representation to obtain enhanced generative context features. S5: Based on the enhanced generation context features, a preliminary answer is generated through Transformer decoding to generate a vocabulary probability distribution. Then, beam search decoding and length normalization reordering are used to select the candidate sequence with the highest score as the final answer text.
2. The intelligent question-and-answer method for slope documents as described in claim 1, characterized in that, The specific process of step S1 is as follows: S11: Collect slope engineering document data containing tabular data. The data type is text document, including survey report documents, design specification documents, construction plan documents, and monitoring record documents; The slope engineering document data is cleaned using regular expressions to remove page numbers, headers, and footers, and then stop words are removed based on a stop word list to obtain the preprocessed slope engineering document data. S12: For the preprocessed slope engineering document data, the document structure is parsed using a document layout analysis method, and the preprocessed document structure information in JSON format is output, including the chapter tree hierarchy, chapter title text, paragraph start and end indexes, and table area bounding box coordinates. S13: Based on the coordinates of the bounding boxes of the table areas in the preprocessed document structure information, extract the text of the table areas from the preprocessed slope engineering document data, and reconstruct the text of the table areas into structured table data corresponding to the rows and columns based on the cell coordinates to obtain table structure-aware data. S14: Collect text data of the user's historical dialogue rounds and the text data of the user's current question.
3. The intelligent question-and-answer method for slope documents as described in claim 2, characterized in that, The specific process of step S2 is as follows: S21: Calculate the document structure-aware embedding matrix based on the preprocessed document structure information. The calculation method is as follows: , , , in, Embedding matrices for chapter-level structures, For layer normalization operation, For graph convolutional networks, This is the adjacency matrix corresponding to the hierarchical relationship of the chapter tree. This is the edge weight matrix. These are the initial features for each chapter node. This is the offset matrix for the relative positions between chapters. It is a bidirectional gated loop unit. Embedding matrices for paragraph-level structures, This serves as the initial semantic representation of the paragraph text sequence. For document structure-aware embedding matrices, for Encoder, ⊕ represents dimension concatenation operation, ⊙ represents element-wise addition, and ⊙ represents Hadamard product. S22: Based on the document structure-aware embedding matrix and table structure-aware data, attention interaction and aggregation are performed to obtain the semantic structure representation of the table. The calculation method is as follows: , , , in, For cell feature matrices enhanced with in-column attention, As a multi-head attention mechanism, Embedding features for table cells For attention masking, This is a matrix of offset masks for relative positions within a column. The table features are those resulting from column-level aggregation. For gated loop unit, This is an operation that flattens a matrix into a sequence in column order. For the semantic structure representation of the table, To be aware of the embedding matrix from the document structure The submatrix extracted from the table area; S23: Align the document structure-aware embedding matrix with the table semantic structure representation using multi-source features to generate a fused document structure knowledge matrix. The calculation method is as follows: , , , , , in, The semantic structure of the table is represented by a vector after mean pooling. To broadcast the pooling vector to Matrix of equal length, To perform mean pooling along the dimensions of table cells, To copy the vector along the sequence dimension Second-rate, It is the sum of the chapter length and the paragraph sequence length; For dual-stream gated fusion weight matrix, It is the Sigmoid activation function. The weight matrix for the gated transformation. This is the gated bias vector. As a preliminary fusion feature, It is a matrix of all 1s. To integrate the document structure knowledge matrix, It is a feedforward fully connected network; S24: Based on the knowledge matrix of the fused document structure, extract entities and relationships, and construct a knowledge graph for slope engineering. The calculation method is as follows: , , , , in, For entity label emission score matrix, For entity classification weight matrix, For GELU activation function, The hidden layer transformation weight matrix, This is the hidden layer bias vector. For entity classification bias vector, For entity boundary label sequence, For conditional random fields, Let be the probability tensor of the relation triplet. For the relation classification weight matrix, , They are respectively The candidate head entity feature vector and candidate tail entity feature vector are extracted based on the entity boundary label sequence. For relation classification bias vectors For slope engineering knowledge graph This is a triplet constructor that selects head and tail entities that simultaneously satisfy the condition that the entity boundary labels are valid and the relationship probability is greater than a preset threshold, based on the entity boundary label sequence and the relationship probability, to form a set of relation triplets.
4. The intelligent question-and-answer method for slope documents as described in claim 3, characterized in that, The method for constructing the adjacency matrix corresponding to the chapter tree hierarchy includes: based on the chapter tree hierarchy in the preprocessed document structure information, taking each chapter title as a node; if chapter i is the parent node of chapter j, then... If chapter i and chapter j are adjacent sibling nodes under the same parent node, then At the same time, add a self-loop to each node. =1, set the rest of the positions to 0, and obtain a binary adjacency matrix, where N is the total number of chapter nodes, and i and j are the first index and the second index, respectively; The method for constructing the initial features of the chapter nodes includes: inputting the chapter title text from the preprocessed document structure information into the pre-trained language model, extracting the hidden state of the last output layer of the pre-trained language model, and taking the vector corresponding to the [CLS] label as the initial feature of a single node of the chapter node; if the chapter has no independent title text, then taking the mean pooling vector of all paragraph texts within the scope of the chapter after being encoded by the pre-trained language model as a substitute; concatenating the initial features of a single node of all nodes in the chapter to obtain the initial features of each chapter node; The method for constructing the relative position offset matrix between chapters includes: based on the chapter tree hierarchy in the preprocessed document structure information, sequentially numbering each chapter node according to the preorder traversal to obtain the chapter node code, extracting the level depth of each chapter node in the tree, with the root node depth=0, then the relative position offset between chapter i and chapter j is... ,in and These are the first position weight parameters and the second position weight parameters, respectively. These are the chapter node codes for the i-th and j-th chapter nodes, respectively. Let be the level depths of the i-th and j-th chapter nodes, respectively; then combine the node numbers according to the level depth values as row and column positions to obtain the relative position offset matrix between chapters; The method for constructing the initial semantic representation of the paragraph text sequence includes: extracting each paragraph text from the preprocessed slope engineering document data according to the paragraph start and end index in the preprocessed document structure information, inputting each paragraph text into the pre-trained language model, extracting the hidden state sequence of all tokens in the last layer to obtain the initial semantic representation of a single paragraph, and concatenating all the initial semantic representations of the single paragraphs to obtain the initial semantic representation of the paragraph text sequence.
5. The intelligent question-and-answer method for slope documents as described in claim 3, characterized in that, The method for constructing the feature embedding of the table cell includes: inputting the text content of each cell in the table structure-aware data into the BERT pre-trained language model, taking the vector corresponding to the [CLS] label as the feature embedding of the cell, and arranging the feature embeddings of all cells in row and column order to obtain the feature embedding of the table cell. The method for constructing the relative position offset mask matrix within the column includes: parsing the total number of rows and columns of the target table based on the coordinates of the table area bounding box in the preprocessed document structure information, and assigning a unique cell number to each cell in the target table according to the traversal order of row first and column second. Construct an initial mask matrix, wherein the total number of rows and columns of the initial mask matrix are equal to the total number of cells in the target table; For any two cells in the same column of the target table, calculate the difference in row index between the first and second cells, and assign the row index difference to the corresponding element in the initial mask matrix; the row and column indices of the corresponding element are: the cell number of the first cell and the cell number of the second cell, respectively. For any two cells in the target table that do not belong to the same column, negative infinity is assigned to the corresponding element in the initial mask matrix; the row and column indices of the corresponding element are: the cell number of the first cell and the cell number of the second cell, respectively. After iterating through all cell pairs and assigning values, the relative position offset mask matrix within the column is obtained.
6. The intelligent question-and-answer method for slope documents as described in claim 3, characterized in that, The specific process of step S3 is as follows: S31: Based on the initial embedding of entity nodes in the slope engineering knowledge graph, and combined with the historical dialogue text received by the system and the current user question, the context-activated entity node embedding representation is obtained. The calculation method is as follows: , , , , , in, To hide the user's historical conversations. The user's current problem is hidden. For BERT pre-trained language models, For embedding layer, For user's historical dialogue rounds text data, The text data representing the user's current question. To fuse semantic vectors for context, To broadcast the pooling vector to The matrix after the row, For mean pooling, The number of entities in the slope engineering knowledge graph. The context-gated activation value. For the gated weight matrix, This is the initial embedding of entity nodes in the slope engineering knowledge graph. This is the first projection weight matrix. Embedded representations of entity nodes activated in the context. This is the second projection weight matrix; S32: Based on the context-activated entity node embedding representation, perform context-guided path reasoning on the knowledge graph to generate a multi-hop reasoning attention trajectory, calculated as follows: , , , , in, Choose a mask for the anchor node. To select the top score The operation is performed on each element, where k is the selection threshold. For the Softmax function, It is a multilayer perceptron. For graph attention networks, For the initial ripple diffusion node attention features, For the first Ripple diffusion node attention features of the layer For the first The ripple diffusion node attention feature of the layer, where layer is the index of the graph attention network layer number. For the first The graph attention weight matrix of the layer. This is the adjacency matrix of the knowledge graph for slope engineering. For multi-hop reasoning attention trajectory, They are respectively the 1st, ..., the 1st Ripple diffusion node attention features of the layer The total number of floors; S33: Perform adaptive threshold path dynamic pruning and inference chain reconstruction on multi-hop inference attention trajectories, eliminate redundant paths with attention weights below the dynamic threshold, and generate dynamic knowledge inference paths. The calculation method is as follows: , , , in, For adaptive pruning threshold, For mean pooling operation, It is a one-dimensional convolutional layer. This is the threshold scaling factor. For binary pruning masks, For indicator functions, This is a dynamic knowledge reasoning path.
7. The intelligent question-and-answer method for slope documents as described in claim 6, characterized in that, The calculation method for the initial embedding of entity nodes in the slope engineering knowledge graph described in S31 includes: assigning an embedding vector to each entity node in the slope engineering knowledge graph through an embedding layer, randomly initializing and updating it during training to obtain the initial embedding of entity nodes in the slope engineering knowledge graph. The method for constructing the adjacency matrix of the slope engineering knowledge graph described in S32 includes: for the set of relation triples in the slope engineering knowledge graph, using entity nodes as row and column indices, if there is any relation edge between entity i and entity j, then... At the same time, add a self-loop to each node. Set the remaining positions to 0 to obtain the adjacency matrix of the slope engineering knowledge graph.
8. The intelligent question-and-answer method for slope documents as described in claim 6, characterized in that, The specific process of step S4 is as follows: S41: For dynamic knowledge reasoning paths, utilize the non-zero nodes retained after filtering by binary pruning mask in the attention features of each layer's ripple diffusion nodes, and sequentially search for valid nodes in each layer from the first layer to the last layer according to the layer index. The valid nodes in the first layer are used as anchor entities, and the valid nodes in the last layer are used as target entities. S42: Based on the anchor entities and target entities contained in the dynamic knowledge reasoning path, extract a local knowledge subgraph centered on the anchor entity with a radius of no more than three hops from the slope engineering knowledge graph. Obtain the initial embedding vector of each entity node in the subgraph through embedding layer retrieval, then aggregate neighborhood information through mean pooling, and fuse it with the concatenated vector of the anchor-target entity pair to obtain the structured representation of the knowledge flow. The calculation method is as follows: , , , in, This is the initial set of embedding vectors obtained from the embedding layer for each entity node in the local knowledge subgraph. For a set of entity nodes in a local knowledge subgraph, For embedded layer retrieval operations, The entity embedding matrix after subgraph pooling. For mean pooling operation, The embedding vector for the node corresponding to the anchor entity. Embed vectors for the nodes corresponding to the target entity. Transform the weight matrix for the knowledge flow. For a structured representation of knowledge flow; The extraction methods for the node embedding vectors corresponding to the anchor entity and the target entity include: locating the index position of the anchor entity and the target entity from the entity node set of the local knowledge subgraph based on the determined anchor entity and target entity, and then... Retrieve the corresponding row vector by index, and obtain the results respectively. and ; S43: Based on the preprocessed slope engineering document data, the text sequence is converted into word embedding vectors through an embedding layer, and then the semantic features of the document are extracted through encoding to obtain the semantic representation of the text stream. The calculation method is as follows: , , in, For the preprocessed slope engineering document data, For text embedding vectors, For Transformer encoders, For semantic representation of text streams; S44: Based on the knowledge flow structured representation and the text flow semantic representation, a dual-stream fusion is performed to obtain enhanced generative context features. The calculation method is as follows: , , , , in, This represents the aligned representation of a text stream mapped to a knowledge space. For broadcast operation, This represents the pooled and broadcast knowledge flow. For preprocessed slope engineering document data Length, For dual-stream gating weights, This is to enhance the generation of contextual features.
9. The intelligent question-and-answer method for slope documents as described in claim 8, characterized in that, The specific process of step S5 is as follows: S51: Based on the enhanced generation context features, decode to generate a preliminary answer, and obtain the vocabulary probability distribution corresponding to the preliminary answer text sequence. The calculation method is as follows: , in, To provide a preliminary answer to the vocabulary probability distribution corresponding to the text sequence, For Transformer decoder, To answer the starting marker; S52: Based on the vocabulary probability distribution corresponding to the initial response text sequence, multiple candidate response sequences are generated using beam search decoding. A length-normalized logarithm probability score is calculated for each candidate sequence, and the candidate sequence with the highest score is selected as the final response text. The calculation method is as follows: , , in, Let B be the set of candidate answer sequences obtained by the beam search. For the beam search decoding operation, B is the beam width, and α is the length penalty coefficient. For the final answer text, This refers to the operation that retrieves the element corresponding to the maximum value.