Hierarchical weighted RAG intelligent question and answer processing method and system for financial regulation scene
By employing a hierarchical weighted RAG intelligent question-answering method, the problems of collaborative processing of multi-source heterogeneous data and management of regulatory versions in financial regulatory scenarios are solved, enabling efficient and accurate financial regulatory consultation and compliance support.
Patent Information
- Application Number
- CN202611271653.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-27
AI Technical Summary
Existing RAG technology struggles to effectively process multi-source heterogeneous data in financial and regulatory scenarios, balance retrieval accuracy with contextual integrity, and cannot dynamically manage regulatory versions, leading to generation errors or compliance risks.
The hierarchical weighted RAG intelligent question-answering processing method is adopted. Through the differentiated processing of multi-source heterogeneous financial documents in blocks, the full life cycle version traceability management and query intent identification and diversion, combined with the parent-child hierarchical block strategy and the full life cycle version traceability system, multi-source data collaborative processing and accurate matching of regulatory versions are achieved.
It significantly improves the accuracy and rigor of responses to financial regulatory consultations, reduces generation errors and compliance risks, and achieves full-process traceability from generation to update, adapting to the complex scenarios of different versions of financial regulations.
Smart Images

Figure CN123178546A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of interdisciplinary technology of finance and artificial intelligence, and in particular to a hierarchical weighted RAG intelligent question-answering method and system for financial regulatory scenarios. Background Technology
[0002] While Large Language Models (LLMs, such as the GPT series and BERT), have demonstrated powerful capabilities in natural language understanding and generation, they suffer from the "illusion" problem when handling long text generation and domain knowledge updates. This is particularly true when training data does not cover specific domain knowledge (such as financial regulations), leading to the generation of erroneous or outdated information. TF-IDF and BM25-based word frequency retrieval methods, while capable of recalling information through keyword matching, lack semantic understanding capabilities (such as contextual differences in financial terminology and logical relationships in regulatory provisions). Deep learning-based vector retrieval (such as Dense Passage Retrieval, DPR) maps text to semantic vectors through pre-trained models and utilizes metrics like cosine similarity to improve retrieval accuracy, laying the foundation for Retrieval-Augmented Generation (RAG) retrieval techniques.
[0003] Early RAG frameworks were based on a two-stage "retrieval-generation" model: In 2020, ColBERT first encoded queries and documents into dense vectors and combined retrieval and generation; in the same year, Lewis et al. proposed a prototype RAG system that clarified the pipeline architecture, and experiments proved that retrieving external knowledge could reduce the illusion rate of LLM. In subsequent architectural optimizations, the retrieval module evolved into a hybrid retrieval combining vector retrieval and semantic matching (such as the Anserini+DPR combination proposed by Zheng et al. in 2021), and the generation module used the retrieved documents as contextual input to the LLM and fused knowledge with attention mechanisms (such as the T5-IR model in 2021). In addition, breakthroughs in key technologies have continued to drive the performance improvement of RAG: the ANCE model in 2020 used BERT and other technologies to re-rank the retrieval results to improve document relevance; the TAPAS model in 2021 guided the LLM to more accurately utilize external knowledge through prompt templates. Currently, RAG technology has expanded from the text domain to the non-text data domain (such as CLIP-RAG in 2023, which enables the generation of image-text associations), and has been implemented in vertical fields such as healthcare (such as PubMed-RAG in 2022) and law (such as Lex-RAG in 2023), effectively reducing the illusion rate through domain corpora and dedicated search strategies.
[0004] However, the industry-specific nature of finance and the specialized nature of financial regulations present the following unique challenges when applying RAG technology, making it difficult to directly adapt to specific scenario requirements:
[0005] 1. Challenges in coordinating multi-source heterogeneous data: Financial enterprises need to process various types of data, such as regulatory documents, industry standards, and internal regulations. Different data sources differ in terms of authority, timeliness, and scope of application, which can lead to coordination challenges and data confusion or mismatch of information priorities.
[0006] 2. The challenge of balancing search accuracy and completeness: In Search Augmentation (RAG) systems, there is always a core contradiction that is difficult to reconcile between search accuracy and contextual completeness. This contradiction is particularly prominent in the scenario of financial and regulatory consulting. Since the consulting results are directly related to the quality of compliance control and risk prevention of enterprise business, compared with the tasks of ordinary RAG technical support, financial and regulatory consulting puts forward more stringent dual requirements for the accuracy and completeness of the response content.
[0007] 3. Complexity of Dynamic Management of Regulatory Versions: Financial regulations are characterized by high-frequency iterations. When replacing old versions with new ones, factors such as the timing of business transactions and the scope of the regulations must be comprehensively considered. This requires the RAG system not only to establish a real-time updated regulatory database, but also to build a comprehensive version tracing and cross-referencing mechanism to ensure that the most appropriate clause version can be accurately matched during queries.
[0008] The aforementioned challenges directly restrict the effectiveness of general RAG technology in financial and regulatory scenarios. Therefore, there is an urgent need to develop a dedicated RAG solution that addresses the unique pain points of financial and regulatory scenarios and meets the needs of financial and regulatory consulting. Summary of the Invention
[0009] To address the challenges of traditional technologies in financial and regulatory scenarios, such as the inability to collaboratively process multi-source heterogeneous data, the inability to balance retrieval accuracy and contextual completeness, and the lack of dynamic management and precise matching of financial and regulatory versions, this invention proposes a hierarchical weighted RAG intelligent question-answering method for financial and regulatory scenarios. This method significantly improves the efficiency of collaborative processing of multi-source data through a hierarchical data processing mechanism, and significantly reduces the risk of model generation errors or incomplete information through a parent-child hierarchical block strategy. It can adapt to the extremely high requirements of accuracy and rigor in financial and regulatory consultations, and relies on a full lifecycle version traceability system to achieve full traceability from generation to update. This method is better suited to the complex scenarios of regulatory version applications in the financial field, avoiding compliance risks caused by version misuse. This invention also relates to a hierarchical weighted RAG intelligent question-answering system for financial and regulatory scenarios.
[0010] The technical solution of the present invention is as follows:
[0011] A hierarchical weighted RAG intelligent question-answering method for financial regulatory scenarios is characterized by the following steps:
[0012] The steps for differentiated processing of multi-source heterogeneous financial documents are as follows: A collection of multi-source heterogeneous financial documents, including regulatory documents, industry standard documents, and internal corporate regulations, is collected. Metadata, including title, effective date, and expiration date, is extracted from each document in the collection. Differentiated segmentation strategies are configured for different document categories: a parent-child hierarchical segmentation strategy is used for regulatory documents and internal corporate financial regulations, while a fixed-length segmentation strategy is used for industry standard documents. The parent-child hierarchical segmentation strategy involves generating a root node from the extracted metadata, using chapters in the document as parent nodes, and items under each chapter as child nodes, thus forming a root-parent-child three-level tree index structure. Parent nodes in this three-level tree index structure are used to generate parent blocks, and child nodes are used to generate child blocks. Each block obtained from the segmentation process is converted into a semantic vector using a vectorization model and stored according to different document categories in their respective hierarchical knowledge bases within the vector database.
[0013] Full lifecycle version traceability management steps: Based on the title of the metadata, identify multiple versions of documents with the same title; for the multiple versions of documents with the same title, construct a doubly linked list with the root node corresponding to each version of the document as the carrier, establish the inheritance and revision relationship between the old and new versions through the doubly linked list, combine the effective time and expiration time in the metadata of the document to form a traceable full lifecycle version chain, and store the full lifecycle version chain in a vector database;
[0014] Query intent identification and triage steps: Receive the query text input by the user, and identify the query intent of the query text through a large language model; if the query intent is identified as a legal retrieval, proceed to the legal retrieval step; if the query intent is identified as a legal comparison, proceed to the legal comparison step.
[0015] Regulatory retrieval steps: Based on the retrieval rules of various hierarchical knowledge bases, combined with the business scenario and time dimension carried by the query text, the full lifecycle version chain is invoked to match the target version document with the appropriate timeliness. First, a retrieval is performed on the sub-blocks of the root-parent-child three-layer tree index structure. Then, based on the association relationship of this root-parent-child three-layer tree index structure, the corresponding parent block and root node block are retrieved back, generating the first recall block set corresponding to the query text in each hierarchical knowledge base. Weights are configured for each hierarchical knowledge base, and all first recall block sets are weighted and fused according to the weights to obtain the second recall block set. Using a re-ranking model, the semantic relevance of the second recall block set to the query text is sorted to obtain the ranking result. The contents of the root node block, parent block, and child block in the ranking result are concatenated to form prompt words, which are input into the large language model. The large language model outputs the enhanced question-answering retrieval result corresponding to the query text.
[0016] The regulatory comparison process is as follows: The query text is parsed using a function call function of the large language model to determine the target regulatory title required for the query text. The latest version document corresponding to the target regulatory title is then searched in the vector database. The entire lifecycle version chain is traversed through the root node bound to the latest version document to obtain historical version documents of the target regulatory title. The various levels of blocks corresponding to the historical version documents and the latest version documents are used as a recall block set. The contents of the root node block, parent block, and child block in the recall block set are extracted and concatenated to form a prompt word, which is then input into the large language model. The large language model outputs the comparison results of the revision differences between the old and new regulatory entries corresponding to the query text.
[0017] Preferably, the full lifecycle version traceability management step further includes: when new document metadata is extracted, based on the title of the metadata, counting the number of documents with multiple versions having the same title in the vector database; if there is only one existing document with the same title as the current document in the vector database, then establishing the inheritance and revision relationship between the existing document and the new document's old and new versions through the doubly linked list, forming the traceable full lifecycle version chain and storing it in the vector database; if there are multiple existing documents with the same title as the current document in the vector database, then maintaining the inheritance and revision relationship between the new document's old and new versions in the full lifecycle version chain corresponding to each document with the same title.
[0018] Preferably, in the multi-source heterogeneous financial document segmentation differentiation processing step, the fixed-length segmentation strategy includes: starting from the beginning of the document, extracting text by a preset number of characters as the first segment; then starting from the end of the extracted text segment, generating the second segment by a preset number of characters, and so on, until the end of the document, ultimately obtaining multiple segments.
[0019] Preferably, in the regulatory retrieval step, the process of generating the first recall chunk set corresponding to the query text in each of the three hierarchical knowledge bases specifically includes applying differentiated retrieval rules for the three types of hierarchical knowledge bases:
[0020] For the hierarchical knowledge base corresponding to the industry standard documents, according to the industry standard retrieval rules, the sub-blocks of the root-parent-child three-level tree index structure are first retrieved, and the corresponding parent block and root node block are retrieved back according to the association relationship of the root-parent-child three-level tree index structure. The industry standard information related to the query text is recalled to form the first recall block set corresponding to the hierarchical knowledge base.
[0021] For the hierarchical knowledge base corresponding to the enterprise internal policy documents, based on the enterprise internal regulations retrieval rules, the retrieval is first performed on the sub-blocks of the root-parent-child three-level tree index structure, and the corresponding parent block and root node block are obtained by backtracking according to the association relationship of the root-parent-child three-level tree index structure. Combining the business scenario and time dimension of the query text, the target version of the enterprise internal regulations document that is adapted to the business scenario and time dimension is matched through the doubly linked list, and the enterprise internal regulations information related to the query text is recalled from the matched enterprise internal regulations document to form the first recall block set corresponding to the hierarchical knowledge base;
[0022] For the hierarchical knowledge base corresponding to the aforementioned regulatory documents, based on the financial legal provisions retrieval rules, the search is first performed on the sub-blocks of the root-parent-child three-level tree index structure. Then, the corresponding parent block and root node block are obtained by backtracking according to the association relationship of the root-parent-child three-level tree index structure. Combining the business scenario and time dimension of the query text, the target version of the financial legal provisions document that is adapted to the business scenario and time dimension is matched through the doubly linked list. The financial legal provisions information related to the query text is recalled from the matched financial legal provisions document, forming the first recall block set corresponding to the hierarchical knowledge base.
[0023] Preferably, the industry standard retrieval rule includes: converting the query text into a vector representation using a vectorization model; calculating the cosine similarity between the vector representation of the query text converted into a vector representation and all vector representations in the hierarchical knowledge base corresponding to the industry standard document; and selecting the blocks corresponding to the vector representations with a cosine similarity greater than a preset cosine similarity threshold as industry standard information related to the query text.
[0024] Preferably, the internal enterprise regulation retrieval rules include: converting the query text into a vector representation using a vectorization model; calculating the cosine similarity between the vector representation of the query text and the vector representations of all child nodes in the hierarchical knowledge base corresponding to the internal enterprise regulation documents; selecting child nodes corresponding to vector representations with a cosine similarity greater than a preset cosine similarity threshold; obtaining the parent node corresponding to each child node based on the selected child node using the root-parent-child three-layer tree index structure; obtaining the root node corresponding to each parent node based on the obtained parent node; determining the root node corresponding to the most appropriate version of the internal enterprise regulation document based on the full lifecycle version chain corresponding to each root node, as well as the business scenario and time dimension of the query text; and determining the parent node and child node based on the root node; and recalling the internal enterprise regulation document information corresponding to the finally determined root node, parent node, and child node as internal enterprise regulation information related to the query text.
[0025] Preferably, the financial legal regulations retrieval rules include: converting the query text into a vector representation using a vectorization model; calculating the cosine similarity between the vector representation of the query text and the vector representations of all child nodes in the hierarchical knowledge base corresponding to the regulatory documents; selecting child nodes corresponding to vector representations with a cosine similarity greater than a preset cosine similarity threshold; obtaining the parent node corresponding to each child node based on the selected child node using the root-parent-child three-layer tree index structure; obtaining the root node corresponding to each parent node based on the obtained parent node; determining the root node corresponding to the most appropriate version of the regulatory document based on the full lifecycle version chain corresponding to each root node, as well as the business scenario and time dimension of the query text; and determining the parent node and child node based on the root node; and recalling the regulatory document information corresponding to the finally determined root node, parent node, and child node as financial legal regulations information related to the query text.
[0026] Preferably, in the regulatory retrieval step, the weighted fusion of all first recall block sets according to the weights to obtain a second recall block set specifically includes:
[0027] Based on the weights of various hierarchical knowledge bases and the preset recall threshold, the recall quantity corresponding to each hierarchical knowledge base is calculated. For the first recall block set corresponding to each hierarchical knowledge base, the blocks in the first recall block set are sorted according to their relevance to the query text, and the top 10 blocks in the first recall block set with the highest relevance to the query text are selected to obtain the second recall block set.
[0028] A hierarchical weighted RAG intelligent question-answering system for financial regulatory scenarios is characterized by comprising a multi-source heterogeneous financial document segmentation and differentiation processing module, a full lifecycle version traceability management module, a query intent recognition and diversion module, a regulatory retrieval module, and a regulatory comparison module. The multi-source heterogeneous financial document segmentation and differentiation processing module, the full lifecycle version traceability management module, and the query intent recognition and diversion module are sequentially connected. The query intent recognition and diversion module is also connected to the regulatory retrieval module and the regulatory comparison module.
[0029] The multi-source heterogeneous financial document segmentation differentiation processing module is used to collect a multi-source heterogeneous financial document set including regulatory documents, industry standard documents, and internal enterprise policy documents. It extracts metadata from each document in the multi-source heterogeneous financial document set, including title, effective date, and expiration date, and configures differentiated segmentation strategies for different categories of documents in the multi-source heterogeneous financial document set: a parent-child hierarchical segmentation strategy is used for regulatory documents and internal enterprise financial policy documents, while a fixed-length segmentation strategy is used for industry standard documents. The parent-child hierarchical segmentation strategy involves generating a root node from the extracted metadata, using chapters in the document as parent nodes, and items under the chapters as child nodes, thus forming a root-parent-child three-level tree index structure. Parent nodes in the root-parent-child three-level tree index structure are used to generate parent blocks, and child nodes are used to generate child blocks. A vectorization model is used to convert each segmentation result into a semantic vector, which is then classified and stored in its corresponding hierarchical knowledge base in the vector database according to different document categories.
[0030] The full lifecycle version traceability management module: Based on the title of the metadata, it identifies multiple versions of documents with the same title; for the multiple versions of documents with the same title, it constructs a doubly linked list with the root node corresponding to each version of the document as the carrier, establishes the inheritance and revision relationship between the old and new versions through the doubly linked list, and forms a traceable full lifecycle version chain by combining the effective time and expiration time in the metadata of the document, and stores the full lifecycle version chain in the vector database;
[0031] The query intent recognition and routing module is used to receive query text input by the user, and to identify the query intent of the query text through a large language model; if the query intent is identified as a legal retrieval, it will jump to the legal retrieval module; if the query intent is identified as a legal comparison, it will jump to the legal comparison module.
[0032] The regulatory retrieval module: Based on the retrieval rules of various hierarchical knowledge bases, and combined with the business scenario and time dimension carried by the query text, it calls the full lifecycle version chain to match the target version document with the appropriate timeliness. First, it performs retrieval based on the sub-blocks of the root-parent-child three-layer tree index structure, and then backtracks to obtain the corresponding parent block and root node block according to the association relationship of this three-layer tree index structure, generating the first recall block set corresponding to the query text in each hierarchical knowledge base. Weights are configured for each hierarchical knowledge base, and all first recall block sets are weighted and fused according to the weights to obtain the second recall block set. Using a re-ranking model, the semantic relevance of the second recall block set to the query text is sorted to obtain the ranking result. The contents of the root node block, parent block, and child block in the ranking result are concatenated to form prompt words, which are input into the large language model. The large language model then outputs the enhanced question-answering retrieval result corresponding to the query text.
[0033] The regulatory comparison module parses the query text using a function call function of the large language model, determines the target regulatory title required by the query text, and searches for the latest version document corresponding to the target regulatory title in the vector database; it traverses the entire lifecycle version chain through the root node bound to the latest version document to obtain the historical version documents of the target regulatory title; it uses the various levels of blocks corresponding to the historical version documents and the latest version documents as a recall block set, extracts the content of the root node block, parent block, and child block in the recall block set, concatenates them to form prompt words, and inputs them into the large language model; the large language model outputs the comparison results of the revision differences between the old and new regulatory entries corresponding to the query text.
[0034] Preferably, the full lifecycle version traceability management module further includes: when new document metadata is extracted, based on the title of the metadata, counting the number of documents with multiple versions having the same title in the vector database; if there is only one existing document with the same title as the current document in the vector database, then establishing the inheritance and revision relationship between the existing document and the new document's old and new versions through the doubly linked list, forming the traceable full lifecycle version chain and storing it in the vector database; if there are multiple existing documents with the same title as the current document in the vector database, then maintaining the inheritance and revision relationship between the new document's old and new versions in the full lifecycle version chain corresponding to each document with the same title.
[0035] The beneficial effects of this invention are as follows:
[0036] This invention provides a hierarchical weighted RAG intelligent question-answering method for financial and regulatory scenarios. It can be understood as a solution and practical application of RAG technology for financial and regulatory scenarios. It focuses on the core pain points of enhanced retrieval generation in financial and regulatory scenarios (RAG technology application), and innovatively proposes solutions for multi-source data collaborative integration, parent-child hierarchical intelligent segmentation, and dynamic management of regulatory versions.This method first extracts core metadata from documents (such as title, effective date, and expiration date) to lay a data foundation for subsequent version management and retrieval, ensuring business scenarios and time matching are accurate. This avoids retrieval bias or version confusion caused by missing metadata. Simultaneously, it employs differentiated block-segmentation strategies for different document categories: industry standard documents have varied structures, and fixed-length blocks balance processing efficiency with basic semantic integrity, reducing unnecessary complexity; internal enterprise policy documents and regulations have strict hierarchical structures (including chapters and entries), and a parent-child hierarchical block-segmentation strategy uses a three-layer tree-like index structure (metadata as the root node, chapters as the parent node, and entries as child nodes) to fully preserve the logical relationships between legal provisions (such as chapters and articles). It not only establishes the hierarchical relationship between items, but also enables the flexibility of fine-grained item matching and coarse-grained chapter positioning in retrieval, avoiding the problem of traditional block-based legal semantics fragmentation, which leads to the difficulty in achieving both retrieval accuracy and completeness; it accurately identifies multiple versions of the same regulation using metadata titles as anchors, constructing a version chain for documents with the same title through a doubly linked list. This not only clearly presents the inheritance and revision relationships between old and new versions through effective and expiration dates, but also enables full lifecycle management by tracing update history forward and retracing back to the original version, solving the problem of difficulty in associating different versions with the same title, and achieving dynamic management of frequently iterated regulatory provisions; through deep analysis of user query text using a large language model, it highlights... It overcomes the limitations of traditional keyword matching in distinguishing ambiguous needs (such as the difference between the intent to "check individual income tax policy" and "compare old and new individual income tax policies"), achieving accurate determination of core intents such as "legal retrieval" and "legal comparison." During legal retrieval, differentiated processing strategies are developed for different data sets (different types of documents), recalling the first block set corresponding to various hierarchical knowledge bases. This enables hierarchical processing of multi-source heterogeneous data. By combining the query text's scenario and time dimension with a doubly linked list, it intelligently matches the most appropriate legal version, ensuring that the first block set contains the legal document content most suitable for the current business version among multiple versions. This achieves accurate version tracing and content recommendation, accurately matching the most suitable regulations. The system considers different versions of regulations. Furthermore, based on the citation priority of different data sources (different types of documents) within the business scenarios of financial enterprises, different weights can be assigned to various hierarchical knowledge bases. Weighted fusion is used to filter the second block set, enhancing the authority and applicability of the recall results. A reordering model further optimizes the relevance of the results, achieving accuracy and completeness. Ultimately, this significantly reduces the risk of illusion in large language models and comprehensively improves the accuracy and compliance of large language model retrieval results. By using regulatory title positioning and version chain tracing, different versions of the target regulation can be quickly obtained, greatly reducing the operational complexity and time consumption of cross-version comparisons, providing accurate data for the comparative analysis of different versions of regulatory content in large language models.This invention significantly improves the collaborative processing efficiency of multi-source data by segmenting and differentiating multi-source heterogeneous financial documents, managing version traceability throughout the entire lifecycle, identifying and diverting query intent, conducting regulatory retrieval and comparison, and combining a data layering processing mechanism, a parent-child hierarchical segmentation strategy, and a full lifecycle version traceability system. It also significantly reduces the risk of model generation errors or incomplete information, perfectly meeting the extremely high requirements of financial regulatory consultation for the accuracy and rigor of responses. Furthermore, it achieves full traceability from generation to update and is more adaptable to the complex scenarios of regulatory version applications in the financial field, avoiding compliance risks caused by version misuse.
[0037] This invention addresses the pain points of frequent iterations and confusing multiple versions of the same title in internal enterprise policy and regulatory documents. Through an automated process of title anchoring, version number determination, and dynamic maintenance using a doubly linked list, it effectively ensures the continuity and integrity of the version chain throughout its entire lifecycle. When only one version with the same title exists in the vector database, the inheritance and revision relationship between the new document and that version is directly established through the doubly linked list, avoiding version tracing gaps caused by isolated storage of new documents and ensuring that each new document is clearly associated with a historical benchmark. When multiple versions with the same title exist, the new document is integrated into the existing doubly linked list, achieving relationship maintenance without reconstructing the entire version chain. This reduces operational complexity and data redundancy while ensuring a clear and traceable version evolution path. This dynamically adaptable maintenance method ensures the real-time performance and accuracy of the version chain throughout its entire lifecycle, providing solid data support for accurate matching of versions corresponding to business time during subsequent retrievals and complete tracing of all revisions during comparisons, overcoming the version confusion problem of existing technologies under frequent regulatory iterations.
[0038] When the document category is industry standard documents, this invention adopts a fixed-length block segmentation strategy for block processing. Without the need for complex semantic analysis or structure recognition, multiple blocks can be generated in batches simply by looping through the starting position and the preset number of characters. This greatly reduces the computational cost and development complexity of the block segmentation process. It is especially suitable for industry regulations and other documents that do not have a fixed hierarchical structure and do not require fine semantic segmentation, thus improving the efficiency of batch document processing.
[0039] This invention employs differentiated retrieval rules for different categories of hierarchical knowledge bases, achieving precise matching between retrieval logic and document attributes. For industry-specific documents, the hierarchical knowledge base efficiently retrieves industry regulations related to the user's query text based on industry-specific retrieval rules. For internal enterprise policy documents and regulations, the hierarchical knowledge bases rely on a root-parent-child three-layer tree index structure (child nodes correspond to regulatory entries, parent nodes to chapters, and root nodes to metadata) and a bidirectional index, respectively. This allows for layer-by-layer retrieval from fine-grained clauses to coarse-grained chapters and then to core metadata, balancing retrieval accuracy and content completeness. Through precise matching of child nodes and complete backtracking of parent nodes, the risk of errors or incomplete information generated by large language models is significantly reduced. Furthermore, by combining the business scenario and time dimension of the query text, a doubly linked list is used to accurately locate the most suitable document version, perfectly adapting to the complex scenarios in the financial field where "multiple versions of the same regulation" and "different clauses for different scenarios" are required.
[0040] The industry standard retrieval rule of this invention transforms the query text and hierarchical knowledge base into vectors within the same semantic space using a vectorization model. It then calculates the correlation between the two using cosine similarity, accurately capturing deep semantic connections. A pre-set cosine similarity threshold filtering mechanism proactively filters out low-relevance blocks, reducing unnecessary computational costs. This rule does not rely on complex document structure analysis, perfectly suited to the simple structure and strong semantic unit independence of industry standard documents. It can quickly complete vector calculation and similarity ranking while ensuring that the retrieved industry regulations are highly relevant to the query requirements.
[0041] The enterprise internal regulations retrieval rules and financial and legal regulations retrieval rules of this invention conduct vector semantic matching with sub-nodes (specific legal entries) as the core. By filtering highly relevant sub-nodes through a cosine similarity threshold, it can directly locate the detailed content that best matches the user's query needs, significantly improving the recall accuracy of fine-grained information. Utilizing a three-layer tree-like index structure, it reversely links parent nodes (corresponding chapters) and root nodes (metadata) from sub-nodes, linking isolated clauses with complete chapters and avoiding semantic fragmentation caused by recalling only a single clause. By combining the full lifecycle version chain with the business scenario and time dimension of the query text to lock the root node of the most suitable version, and then reversely determining the corresponding parent and child nodes, it effectively avoids the compliance risks of matching old version clauses with new business. The final recalled root, parent, and child node information includes both specific implementation details and complete chapter logic, completely solving the balance problem between retrieval accuracy and contextual completeness in financial and legal consultation scenarios, providing comprehensive and reliable information support for financial compliance decisions.
[0042] This invention calculates the recall quantity based on the weights of various hierarchical knowledge bases and a preset recall quantity threshold. It can reasonably allocate quotas according to the authority priority of different sources of regulations in the financial field (e.g., the weight of hierarchical knowledge bases corresponding to internal corporate policy documents and regulatory documents is usually higher than the weight of hierarchical knowledge bases corresponding to industry standard documents), ensuring that key compliance content is selected first, reducing compliance risks caused by the lack of authoritative information from the source, and ensuring the authority and applicability of the first recall results.
[0043] This invention also relates to a hierarchical weighted RAG intelligent question-answering processing system for financial regulatory scenarios. This system corresponds to the aforementioned hierarchical weighted RAG intelligent question-answering processing method for financial regulatory scenarios. It can be understood as a system that implements the aforementioned hierarchical weighted RAG intelligent question-answering processing method for financial regulatory scenarios. It includes a multi-source heterogeneous financial document segmentation and differentiation processing module, a full lifecycle version traceability management module, a query intent identification and diversion module, a regulatory retrieval module, and a regulatory comparison module. These modules work collaboratively, providing a practical implementation framework for the large-scale deployment of RAG technology in various financial enterprises and organizations. Compared to existing technologies, this system addresses the unique challenges of RAG technology applications in the financial regulatory field through multi-dimensional innovative design, demonstrating significant beneficial effects: First, at the multi-source data collaboration level, it breaks through the limitations of the traditional single data set model of RAG technology, constructs a multi-level classification system and implements a differentiated processing strategy. Combined with hierarchical retrieval and weight allocation, it effectively solves the problems of differences in authority, timeliness, and applicability of multi-source heterogeneous data such as financial regulatory documents (regulatory documents), industry standards (industry normative documents), and internal regulations (corporate internal system documents). Compared to methods like TF-IDF and BM25 that lack semantic understanding, and the indiscriminate processing of multi-source data by traditional RAG technology, the system of this invention can accurately retrieve high-priority information based on business scenarios, making the response content both authoritative and scenario-adaptable, significantly improving the collaborative efficiency of multi-source data. Secondly, in terms of the coexistence of accuracy and completeness in the retrieval of financial regulations (including internal corporate regulations and financial legal regulations), the innovative parent-child hierarchical segmentation strategy constructs a tree structure and bidirectional index based on the characteristics of regulatory documents, balancing retrieval accuracy and content completeness. Compared to the "illusion" problem easily encountered by large models such as the GPT series and BERT, and the shortcomings of traditional RAG technology optimization methods in integrating regulatory provisions, this system significantly reduces the risk of model-generated errors or incomplete information through precise matching of child nodes and complete backtracking of parent nodes, perfectly meeting the extremely high requirements of financial regulatory consultation for the accuracy and rigor of responses. Third, at the version management level, the node-based full lifecycle version traceability system overcomes the version chaos problem under high-frequency regulatory iterations by creating file source nodes (i.e., file metadata), constructing version chains, and employing an intelligent matching mechanism (intelligently matching the most appropriate regulatory version). Compared to the simple version replacement or overlay methods in existing technologies, this system can accurately locate the most suitable regulatory version based on business time, scenario, and other dimensions, achieving full traceability from generation to update. It is more adaptable to the complexity of regulatory version applications in the financial field and avoids compliance risks caused by version misuse. Attached Figure Description
[0044] Figure 1 This is a flowchart of the hierarchical weighted RAG intelligent question answering method for financial and regulatory scenarios according to the present invention.
[0045] Figure 2 This is a schematic diagram illustrating the execution logic of the hierarchical weighted RAG intelligent question-answering processing method for financial and regulatory scenarios according to the present invention.
[0046] Figure 3 This is a schematic diagram of the root-parent-child three-level tree index structure corresponding to the parent-child hierarchical block division strategy of the present invention.
[0047] Figure 4 This is an example diagram of the regulatory documents used in this invention.
[0048] Figure 5 This is an example diagram of the root node corresponding to the legal document of this invention after it has been processed into blocks.
[0049] Figure 6 , Figure 7 This is an example diagram of the parent node corresponding to the legal document of this invention after it has been segmented.
[0050] Figure 8 , Figure 9 , Figure 10 , Figure 11 , Figure 12 This is an example diagram of the child nodes corresponding to the legal documents of this invention after being processed into blocks.
[0051] Figure 13 A diagram illustrating the construction of a full lifecycle version chain.
[0052] Figure 14 This is a flowchart illustrating the specific implementation process of the hierarchical parent-child recall method and version management scheme of the present invention.
[0053] Figure 15 This is an example diagram illustrating the application of the legal retrieval question and answer function of this invention.
[0054] Figure 16 This is an example diagram illustrating the application of the regulatory comparison Q&A for this invention. Detailed Implementation
[0055] The present invention will now be described with reference to the accompanying drawings.
[0056] This invention discloses a hierarchical weighted RAG intelligent question-answering method for financial and regulatory scenarios, such as... Figure 1 and Figure 2 As shown, it includes the following steps:
[0057] I. Differentiated Processing Steps for Multi-Source Heterogeneous Financial Document Segmentation: A multi-source heterogeneous financial document set is collected, including regulatory documents, industry standard documents, and internal corporate policy documents. Metadata, including title, effective date, and expiration date, is extracted from each document in the multi-source heterogeneous financial document set. Differentiated segmentation strategies are configured for different categories of documents in the multi-source heterogeneous financial document set: a parent-child hierarchical segmentation strategy is used for regulatory documents and internal corporate financial policy documents, while a fixed-length segmentation strategy is used for industry standard documents. The parent-child hierarchical segmentation strategy involves generating a root node from the extracted metadata, using chapters in the document as parent nodes, and items under each chapter as child nodes, thus forming a root-parent-child three-level tree index structure. Parent nodes in the root-parent-child three-level tree index structure are used to generate parent segments, and child nodes are used to generate child segments. A vectorization model is used to convert each segment obtained from the segmentation process into a semantic vector, which is then categorized and stored in its corresponding hierarchical knowledge base in the vector database according to different document categories.
[0058] This invention addresses the challenge of collaborative processing of multi-source heterogeneous data by employing a hierarchical processing mechanism: breaking away from the traditional single-dataset model of RAG tasks, it constructs a multi-level classification system based on the characteristics of the data sources. Differentiated block processing strategies are formulated for different data set characteristics. For example... Figure 2 As shown in the figure, the left side of the figure illustrates the differentiated segmentation and vectorization process (Chunking & Embedding). In this embodiment of the invention, for documents of different categories in a multi-source heterogeneous financial document collection, differentiated segmentation strategies corresponding to various segmentation rules are selected to carry out segmentation processing. After segmentation, semantic vectorization is performed to generate multiple semantic segments corresponding to each category, and they are classified and stored in the corresponding hierarchical knowledge base in the vector database according to different document categories.
[0059] The block storage process of this invention is shown in formulas (1) and (2):
[0060] (1)
[0061] (2)
[0062] Where D is a set of multi-source heterogeneous financial documents, and the set contains... This indicates documents from different sources (such as legal documents, industry standard documents, internal company policy documents, etc.). This is the set of blocks after the block processing; This is the block-based strategy function. Indicates the type of chunking strategy (adjusted depending on the document source). This refers to a single document in set D; It is a hierarchical knowledge base collection in a vector database. Hierarchical knowledge bases representing different categories This represents a specific type of hierarchical knowledge base.
[0063] As shown in formula (2), through Document category corresponding chunking strategy function After the document is segmented, it is stored in the hierarchical knowledge base corresponding to that category of document. middle.
[0064] Meanwhile, to ensure the accuracy of handling regulatory issues (including internal corporate regulations and financial legal regulations), this invention proposes a block-segmentation method adapted to legal and regulatory documents—a parent-child hierarchical block-segmentation strategy—as a variant of the traditional parent-child block-segmentation, such as... Figure 3 The diagram illustrates a root-parent-child three-level tree-like index structure corresponding to the parent-child hierarchical segmentation strategy. Under the head node (also called the root node), there are multiple chapter nodes (also called parent nodes), containing all chapter information in the document and serving as the core content supporting the model's contextual understanding. Each chapter node is further subdivided into multiple entry nodes (also called child nodes), each containing specific information about the corresponding entry, providing crucial information for relevance judgment during retrieval. For extremely long chapters, this embodiment of the invention sets a dynamic text threshold for splitting, such as a preset threshold of 500 characters. When the total number of characters in a chapter exceeds 500, the chapter is split into multiple parent nodes, each with fewer than 500 characters, ensuring balanced data granularity across all parent nodes.
[0065] Specifically, the parent-child hierarchical block division strategy is shown in formula (3):
[0066] (3)
[0067] in, For internal company policy or regulatory documents, their hierarchical structure can be represented as a triplet of root node, parent node, and child node. Represents the root node. Represents the specific attributes of a document (also known as metadata, such as title, effective date, etc.). Represents the set of parent nodes. Represent each parent node, and satisfy any All are root nodes child nodes, Represents the set of child nodes. Representing each child node, Indicates the first The first chapter node (parent node) Entry node (child node), and satisfies any All are child nodes of the parent node.
[0068] For example, the "Accounting Law of the People's Republic of China" document is divided into sections. An example of a portion of the original document is shown below. Figure 4 As shown, the root node after block processing is as follows: Figure 5 As shown, it includes the title "Accounting Law of the People's Republic of China" and the effective date "June 28, 2024"; the parent node after block processing includes two nodes. Figure 6 This is an example of a parent node corresponding to the content in Chapter 1. Figure 7 This is an example of a parent node corresponding to the content in Chapter 2; the child nodes after the block processing include 5, such as... Figure 8 , Figure 9 , Figure 10 , Figure 11 and Figure 12 The examples shown are child nodes corresponding to different clauses, with each clause corresponding to one child node.
[0069] Furthermore, the fixed-length segmentation strategy of this invention includes: starting from the beginning of the document, extracting text by a preset number of characters (e.g., 500 characters) as the first segment; then, starting from the end of the extracted text segment, generating the second segment by a preset number of characters, and so on, until the end of the document, ultimately obtaining multiple segments.
[0070] II. Full Lifecycle Version Traceability Management Steps: Based on the title of the metadata, identify multiple versions of documents with the same title; for the multiple versions of documents with the same title, construct a doubly linked list with the root node corresponding to each version of the document as the carrier, establish the inheritance and revision relationship between the old and new versions through the doubly linked list, combine the effective time and expiration time in the metadata of the document to form a traceable full lifecycle version chain, and store the full lifecycle version chain in the vector database.
[0071] The full lifecycle version chain constructed in this embodiment of the invention is as follows: Figure 13 As shown, each document corresponds to a full lifecycle version chain (e.g. Figure 13 Documents 1 and N in the document have the same title in each full lifecycle version chain. The root nodes of different versions of documents with the same title are connected by a doubly linked list. Each root node corresponds to a three-level tree index structure. Within each version document, the root node is associated with the corresponding parent node, and the parent node is associated with the corresponding child node. The root nodes of different versions of documents are associated with each other by a doubly linked list.
[0072] When new document metadata is extracted, based on the title of the metadata, the number of documents with multiple versions of the same title in the vector database is counted. If there is only one existing document with the same title as the current document in the vector database, the inheritance and revision relationship between the existing document and the new document's old and new versions is established through the doubly linked list, forming a traceable full lifecycle version chain and storing it in the vector database. If there are multiple existing documents with the same title as the current document in the vector database, the inheritance and revision relationship between the new document's old and new versions is maintained in the full lifecycle version chain corresponding to each document with the same title.
[0073] The full lifecycle version chain is shown in formula (4):
[0074] (4)
[0075] in, , This indicates different versions of the same document. , indicating the version number, This represents a doubly linked list, where different versions are linked through the doubly linked list of the root node; This represents the root node of version v. This indicates a two-way pointer association, i.e. storage pointer, Also stores The pointer.
[0076] III. Query Intent Recognition and Triage Steps: Receive the query text input by the user, and identify the query intent of the query text using a large language model; for example... Figure 1 As shown, if the query intent is identified as a regulatory retrieval, the process will proceed to the regulatory retrieval step; if the query intent is identified as a regulatory comparison, the process will proceed to the regulatory comparison step.
[0077] IV. Legal research steps: such as Figure 14As shown, based on the retrieval rules of various hierarchical knowledge bases, combined with the business scenario and time dimension carried by the query text, the full lifecycle version chain is invoked to match the target version document with the appropriate timeliness. The query text is vectorized to generate query embeddings. The first retrieval (child node retrieval) is performed, which retrieves child nodes based on the root-parent-child three-level tree index structure. The second retrieval (child node tracing parent node) is then performed backtracking according to the association relationship of the root-parent-child three-level tree index structure, obtaining the corresponding parent node and root node level by level, generating the first recall block set corresponding to the query text in each hierarchical knowledge base. Weights are configured for each hierarchical knowledge base, and all first recall block sets are weighted and fused according to the weights to obtain the second recall block set. The semantic relevance of the second recall block set to the query text is sorted using a reordering model to obtain the sorting result. The contents of the root node block, parent block, and child block in the sorting result are concatenated to form prompt words, which are input into the LLM (Large Language Model). The LLM outputs the enhanced question answering retrieval result corresponding to the query text.
[0078] Specifically, the process of generating the first recall chunk set corresponding to the query text in various hierarchical knowledge bases in this embodiment of the invention includes applying differentiated retrieval rules for the three types of hierarchical knowledge bases respectively:
[0079] For the hierarchical knowledge base corresponding to the industry standard documents, based on the industry standard retrieval rules, the retrieval is first performed on the sub-blocks of the root-parent-child three-level tree index structure, and the corresponding parent block and root node block are retrieved back according to the association relationship of the root-parent-child three-level tree index structure to recall industry standard information related to the query text, forming the first recall block set corresponding to the hierarchical knowledge base; wherein, the industry standard retrieval rules include: using a vectorization model to convert the query text into a vector representation, calculating the cosine similarity between the vector representation of the query text converted into a vector representation and all vector representations in the hierarchical knowledge base corresponding to the industry standard documents; and selecting the block corresponding to the vector representation with a cosine similarity greater than a preset cosine similarity threshold as the industry standard information related to the query text.
[0080] For the hierarchical knowledge base corresponding to the enterprise internal regulations documents, based on the enterprise internal regulations retrieval rules, a retrieval is first performed on the sub-blocks of the root-parent-child three-level tree index structure. Then, based on the association relationship of the root-parent-child three-level tree index structure, the corresponding parent block and root node block are retrieved back. Combining the business scenario and time dimension of the query text, the target version of the enterprise internal regulations document is matched to the business scenario and time dimension using the doubly linked list. Finally, enterprise internal regulations information related to the query text is recalled from the matched enterprise internal regulations documents, forming the first recall block set corresponding to the hierarchical knowledge base. The enterprise internal regulations retrieval rules include: converting the query text into a vector representation using a vectorization model, and calculating the... The cosine similarity between the vector representation of the query text and the vector representations of all child nodes in the hierarchical knowledge base is calculated, and child nodes corresponding to vector representations with cosine similarity greater than a preset cosine similarity threshold are selected. Using the root-parent-child three-layer tree index structure, the parent nodes corresponding to each selected child node are obtained, and the root nodes corresponding to each parent node are obtained. Based on the full lifecycle version chain corresponding to each root node, and the business scenario and time dimension of the query text, the root node corresponding to the most appropriate version of the company's internal policy document is determined, and the parent and child nodes are determined based on this root node. The company's internal policy document information corresponding to the finally determined root node, parent node, and child node is recalled as company internal regulations information related to the query text.
[0081] For the hierarchical knowledge base corresponding to the regulatory documents, based on the financial legal provisions retrieval rules, the retrieval is first performed on the sub-blocks of the root-parent-child three-level tree index structure. Then, based on the association relationship of the root-parent-child three-level tree index structure, the corresponding parent block and root node block are retrieved back. Combining the business scenario and time dimension of the query text, the target version of the regulatory documents is matched to the business scenario and time dimension using the doubly linked list. Financial legal provisions information related to the query text is then recalled from the matched regulatory documents, forming the first recall block set corresponding to the hierarchical knowledge base. The financial legal provisions retrieval rules include: converting the query text into a vector representation using a vectorization model; calculating the query text in the hierarchical knowledge base corresponding to the regulatory documents; and... The transformed vector representation is compared with the cosine similarity of the vector representations corresponding to all child nodes in the hierarchical knowledge base, and the child nodes corresponding to the vector representations with a cosine similarity greater than a preset cosine similarity threshold are selected. Using the root-parent-child three-layer tree index structure, the parent nodes corresponding to each child node are obtained based on the selected child nodes, and the root nodes corresponding to each parent node are obtained based on the obtained parent nodes. Based on the full lifecycle version chain corresponding to each root node, and the business scenario and time dimension of the query text, the root node corresponding to the most appropriate version of the regulatory document is determined, and the parent and child nodes are determined based on this root node. The regulatory document information corresponding to the finally determined root node, parent node, and child node is recalled as financial and legal regulations information related to the query text.
[0082] Furthermore, based on the full lifecycle version chain corresponding to each root node, and the business scenario and time dimension of the query text, the process of determining the root node corresponding to the most appropriate version of the enterprise's internal policy or regulatory document can be expressed by formula (5):
[0083] (5)
[0084] in, This indicates the target version obtained based on the full lifecycle version chain; Represents based on arbitrary nodes User questions regarding version requirements Locate the target version. Represents any node, ; Indicates passing through any node Trace back to the relevant root node.
[0085] The embodiments of the present invention can use formula (6) to represent the process of conducting legal retrieval using internal enterprise regulations retrieval rules and financial and legal regulations retrieval rules:
[0086] (6)
[0087] in, This represents the set of item nodes to be recalled. express and The relevance score, This represents the query text used by the user. This represents the relevance threshold (i.e., the preset cosine similarity threshold). This represents the set of chapter nodes that an entry node traces. Indicates access via entry node Tracing back to the relevant chapter nodes; This represents the root node from which chapter nodes are traced. Represents the set of chapter nodes Tracing back to the relevant root node; This represents the set of chapter nodes. With the root node Integrate and recall, and input the recall structure into the retrieval recall function. Ultimately by The final prompt word is output as input to the larger model.
[0088] Specifically, in this embodiment of the invention, the recall quantity corresponding to each type of hierarchical knowledge base is calculated based on the weight of each type of hierarchical knowledge base and a preset recall quantity threshold. For the first recall block set corresponding to each type of hierarchical knowledge base, the blocks in the first recall block set are sorted according to the relevance of each block in the first recall block set to the query text, and the blocks with the highest relevance to the query text in the first recall block set are selected and summarized to obtain the second recall block set.
[0089] The regulatory retrieval process can be represented using formulas (7) and (8) in this embodiment of the invention:
[0090] (7)
[0091] (8)
[0092] in, Indicates from a hierarchical knowledge base The collection of text (chunks) recalled in the middle; This represents the retrieval rule function. Indicates the type of retrieval rule, allowing for diverse strategies to adapt to different knowledge bases; This indicates the question entered by the user; The weights represent the hierarchical knowledge base. The weights are set according to the importance of the source; This indicates the recall result after weighted processing; This represents the rearrangement model function, used to rearrange and filter the weighted recall results; Represents the generation function of a large language model; This represents the final output of the large language model.
[0093] The complete processing mechanism, encompassing the integrated block processing, storage, and regulatory retrieval stages, is shown in formula (9):
[0094] (9)
[0095] The pseudocode for the regulatory retrieval process is as follows:
[0096]
[0097] For example, such as Figure 15 As shown, when a user asks the question "What should a finance company pay attention to when handling electronic commercial draft business?", the large language model quickly generates a targeted Q&A response based on the RAG recall results, outputting business handling constraints, prohibited behaviors, and acceptance and discounting requirements one by one; at the same time, it displays the original legal text supporting this answer, presenting the original text of the corresponding chapter and clause of the "Administrative Measures for Electronic Commercial Draft Business". This invention bidirectionally binds the generated answer with the supporting basis, making it easy for users to verify the source of the conclusion and achieving accurate traceability and correlation between the Q&A result and the original legal text.
[0098] V. Procedures for comparing regulations: (e.g.) Figure 14 As shown, the query text is parsed using the function calling function of the large language model to determine the target regulatory title required by the query text. A latest version retrieval is performed to find the latest version document corresponding to the target regulatory title in the vector database. The entire lifecycle version chain is traversed through the root node bound to the latest version document to perform a historical version retrieval, obtaining historical version documents of the target regulatory title. The historical version documents and the corresponding blocks at all levels of the latest version document are integrated into a recall block set. The content of the root node block, parent block, and child block in the recall block set is extracted and concatenated to form prompt words, which are then input into the large language model. The large language model outputs a comparison result of the revision differences between the old and new regulatory entries corresponding to the query text.
[0099] The pseudocode for the regulatory comparison process is as follows:
[0100]
[0101] For example, such as Figure 16As shown, when a user asks the question "What changes have been made to the Management Measures for Electronic Commercial Drafts compared to the previous version?", the system accurately retrieves the latest and historical versions of the "Management Measures for Electronic Commercial Drafts" from the vector database based on the identified regulatory titles. The large language model then automatically sorts out and outputs the comparison results of the revisions in the text structure, clause content, and management rules between the two types of documents based on the retrieved content of the old and new versions.
[0102] Based on the same inventive concept, this invention also provides a hierarchical weighted RAG intelligent question-answering system for financial and regulatory scenarios. Since the working principle of the hierarchical weighted RAG intelligent question-answering system for financial and regulatory scenarios is the same as that of the aforementioned hierarchical weighted RAG intelligent question-answering method for financial and regulatory scenarios, the implementation of the hierarchical weighted RAG intelligent question-answering system for financial and regulatory scenarios can refer to the aforementioned implementation of the hierarchical weighted RAG intelligent question-answering method for financial and regulatory scenarios, and the repeated parts will not be described again.
[0103] This invention provides a hierarchical weighted RAG intelligent question-answering system for financial and regulatory scenarios. It includes a multi-source heterogeneous financial document segmentation and differentiation processing module, a full lifecycle version traceability management module, and a query intent recognition and routing module, all connected sequentially. It also includes a regulatory retrieval module and a regulatory comparison module, both connected to the query intent recognition and routing module.
[0104] The multi-source heterogeneous financial document segmentation differentiation processing module is used to collect a multi-source heterogeneous financial document set including regulatory documents, industry standard documents, and internal enterprise policy documents. It extracts metadata from each document in the multi-source heterogeneous financial document set, including title, effective date, and expiration date, and configures differentiated segmentation strategies for different categories of documents in the multi-source heterogeneous financial document set: a parent-child hierarchical segmentation strategy is used for regulatory documents and internal enterprise financial policy documents, while a fixed-length segmentation strategy is used for industry standard documents. The parent-child hierarchical segmentation strategy involves generating a root node from the extracted metadata, using chapters in the document as parent nodes, and items under the chapters as child nodes, thus forming a root-parent-child three-level tree index structure. Parent nodes in the root-parent-child three-level tree index structure are used to generate parent blocks, and child nodes are used to generate child blocks. A vectorization model is used to convert each segment obtained from the segmentation process into a semantic vector, which is then classified and stored in its corresponding hierarchical knowledge base in the vector database according to different document categories.
[0105] The full lifecycle version traceability management module identifies multiple versions of documents with the same title based on the title of the metadata. For each version of the document with the same title, a doubly linked list is constructed using the root node corresponding to each version as the carrier. The doubly linked list establishes the inheritance and revision relationship between the old and new versions. Combined with the effective time and expiration time in the document's metadata, a traceable full lifecycle version chain is formed and stored in the vector database. Further, when the metadata of a new document is extracted, the number of documents with multiple versions of the same title in the vector database is counted based on the title of the metadata. If there is only one existing document with the same title as the current document in the vector database, the doubly linked list establishes the inheritance and revision relationship between the existing document and the new document's old and new versions, forming the traceable full lifecycle version chain and storing it in the vector database. If there are multiple existing documents with the same title as the current document in the vector database, the inheritance and revision relationship between the new document's old and new versions is maintained in the full lifecycle version chain corresponding to each document with the same title.
[0106] The query intent recognition and routing module is used to receive query text input by the user and identify the query intent of the query text through a large language model; if the query intent is identified as a legal retrieval, it will jump to the legal retrieval module; if the query intent is identified as a legal comparison, it will jump to the legal comparison module.
[0107] The regulatory retrieval module, based on the retrieval rules of various hierarchical knowledge bases and combined with the business scenario and time dimension carried by the query text, calls the full lifecycle version chain to match the target version document with the appropriate timeliness. It first performs retrieval based on sub-blocks of the root-parent-child three-layer tree index structure, and then backtracks to obtain the corresponding parent block and root node block according to the association relationship of this three-layer tree index structure, generating a first recall block set corresponding to the query text in each hierarchical knowledge base. Weights are configured for each hierarchical knowledge base, and all first recall block sets are weighted and fused according to the weights to obtain a second recall block set. A re-ranking model is used to sort the semantic relevance between the second recall block set and the query text to obtain a ranking result. The contents of the root node block, parent block, and child block in the ranking result are concatenated to form prompt words, which are input into the large language model. The large language model then outputs the enhanced question-answering retrieval result corresponding to the query text.
[0108] The regulatory comparison module parses the query text using the function call functionality of the large language model, determines the target regulatory title required by the query text, and searches for the latest version document corresponding to the target regulatory title in the vector database. It then traverses the entire lifecycle version chain through the root node bound to the latest version document to obtain historical version documents of the target regulatory title. The module uses the various levels of blocks corresponding to the historical version documents and the latest version documents as a recall block set. It extracts the content of the root node block, parent block, and child block from the recall block set, concatenates them to form prompt words, and inputs them into the large language model. The large language model then outputs the comparison results of the revision differences between the old and new regulatory entries corresponding to the query text.
[0109] Exemplary project implementation
[0110] It should be noted that the framework and model selection described below are only one preferred implementation scheme among the many optional embodiments of the present invention, and are not necessary technical features for realizing the core solution of the present invention. They should not be construed as limiting the scope of protection of the present invention. Other similar frameworks and models can also achieve the regulatory retrieval and regulatory comparison functions of the present invention.
[0111] In this embodiment of the invention, the backend uses LlamaIndex and LangChain as the Agent development framework, combined with FastAPI to build web services; the frontend uses the Chainlit framework and Vue framework to build the interactive interface. At the model level, Qwen3-32B and DeepSeek-32B are used as the base large language models, combined with the BGE-M3 vectorization model to achieve semantic retrieval, and the BGE-Reranker-Large re-ranking model is used to optimize the ranking of recall results, forming a complete technical closed loop.
[0112] LlamaIndex is a framework focused on the development of large language model applications. Its core function is to connect large language models with external data (such as documents, databases, etc.), providing tools for data loading, index building, query parsing, etc., to help developers quickly implement functions such as question answering and search enhancement generation (RAG) based on private data, and simplify the process of integrating large language models with actual business data.
[0113] LangChain is a large language model development framework centered on "Chain" and "Agent." It supports the chaining of modular components such as large language models, tools (e.g., search engines, database interfaces), and data processing steps to achieve complex tasks (e.g., multi-step reasoning, automatic tool invocation). Its Agent function allows the large language model to autonomously decide which tools to invoke based on needs, improving the flexibility and intelligence of applications.
[0114] FastAPI is a high-performance web framework based on Python, which supports asynchronous programming, features automatic API documentation generation (Swagger), type hint friendliness, lightweight and high efficiency, etc., and is often used to quickly build back-end API services, especially suitable for integration with scenarios such as large language models and data processing.
[0115] Chainlit is a lightweight front-end framework specially designed for large language model applications, which supports rapid construction of interactive chat interfaces, and can realize functions such as message flow display, loading status, tool call visualization, etc. without complex front-end knowledge. It is often used in conjunction with back-end frameworks such as LangChain and LlamaIndex to quickly build prototypes or production-level dialogue applications.
[0116] The base large language models (Qwen3-32B, DeepSeek-32B) are general-purpose large language models with strong natural language understanding, generation and reasoning capabilities, which can serve as the core "brain" of applications to process tasks such as dialogue, text generation, and logical analysis. Qwen3 (Tongyi Qianwen 3) comes from Alibaba DAMO Academy, and DeepSeek-32B comes from DeepSeek, both of which are open-source commercial models with relatively strong performance.
[0117] The vectorization model (BGE-M3) is a model focused on semantic vector generation, which can convert texts (such as sentences and paragraphs) into high-dimensional vectors (Embedding), and realize semantic retrieval through vector similarity calculation (such as finding document fragments with similar meanings to the query content). It is a key component connecting queries and data in the RAG process.
[0118] The reranking model (BGE-Reranker-Large) is a model used to optimize the ranking of retrieval results. After obtaining preliminary results through vector retrieval, it reorders the candidate results through in-depth semantic analysis to improve relevance (for example, filtering redundant information and giving priority to more matching content), further improving retrieval accuracy.
[0119] It should be pointed out that the above specific embodiments allow those skilled in the art to understand the present invention more comprehensively, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail with reference to the accompanying drawings and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention. In short, all technical solutions and improvements that do not depart from the spirit and scope of the present invention shall be covered within the protection scope of the patent of the present invention.
Claims
1. A hierarchical weighted RAG intelligent question-answering method for financial regulatory scenarios, characterized in that, Includes the following steps: The steps for differentiated processing of multi-source heterogeneous financial documents are as follows: A collection of multi-source heterogeneous financial documents, including regulatory documents, industry standard documents, and internal corporate regulations, is collected. Metadata, including title, effective date, and expiration date, is extracted from each document in the collection. Differentiated segmentation strategies are configured for different document categories: a parent-child hierarchical segmentation strategy is used for regulatory documents and internal corporate financial regulations, while a fixed-length segmentation strategy is used for industry standard documents. The parent-child hierarchical segmentation strategy involves generating a root node from the extracted metadata, using chapters in the document as parent nodes, and items under each chapter as child nodes, thus forming a root-parent-child three-level tree index structure. Parent nodes in this three-level tree index structure are used to generate parent blocks, and child nodes are used to generate child blocks. Each block obtained from the segmentation process is converted into a semantic vector using a vectorization model and stored according to different document categories in their respective hierarchical knowledge bases within the vector database. Full lifecycle version traceability management steps: Based on the title of the metadata, identify multiple versions of documents with the same title; for the multiple versions of documents with the same title, construct a doubly linked list with the root node corresponding to each version of the document as the carrier, establish the inheritance and revision relationship between the old and new versions through the doubly linked list, combine the effective time and expiration time in the metadata of the document to form a traceable full lifecycle version chain, and store the full lifecycle version chain in a vector database; Query intent identification and triage steps: Receive the query text input by the user, and identify the query intent of the query text through a large language model; If the query intent is identified as a regulatory retrieval, proceed to the regulatory retrieval step; if the query intent is identified as a regulatory comparison, proceed to the regulatory comparison step. Regulatory retrieval steps: Based on the retrieval rules of various hierarchical knowledge bases, and combined with the business scenario and time dimension carried by the query text, the full lifecycle version chain is invoked to match the target version document with the appropriate timeliness. First, the sub-blocks are retrieved based on the root-parent-child three-level tree index structure. Then, the corresponding parent block and root node block are retrieved by backtracking according to the association relationship of the root-parent-child three-level tree index structure, generating the first recall block set corresponding to the query text in each hierarchical knowledge base. Weights are configured for each hierarchical knowledge base, and all first recall block sets are weighted and merged according to the weights to obtain the second recall block set. Using a reordering model, the semantic relevance between the second recall chunk set and the query text is sorted to obtain a sorting result; the contents of the root node chunk, parent chunk, and child chunk in the sorting result are concatenated to form prompt words, which are input into the large language model, and the large language model outputs the enhanced question answering retrieval result corresponding to the query text; The regulatory comparison process is as follows: The query text is parsed using a function call function of the large language model to determine the target regulatory title required for the query text. The latest version document corresponding to the target regulatory title is then searched in the vector database. The entire lifecycle version chain is traversed through the root node bound to the latest version document to obtain historical version documents of the target regulatory title. The various levels of blocks corresponding to the historical version documents and the latest version documents are used as a recall block set. The contents of the root node block, parent block, and child block in the recall block set are extracted and concatenated to form a prompt word, which is then input into the large language model. The large language model outputs the comparison results of the revision differences between the old and new regulatory entries corresponding to the query text.
2. The method according to claim 1, characterized in that, The full lifecycle version traceability management steps further include: when new document metadata is extracted, based on the title of the metadata, counting the number of documents with multiple versions having the same title in the vector database; if there is only one existing document with the same title as the current document in the vector database, then establishing the inheritance and revision relationship between the existing document and the new document's old and new versions through the doubly linked list, forming the traceable full lifecycle version chain and storing it in the vector database; if there are multiple existing documents with the same title as the current document in the vector database, then maintaining the inheritance and revision relationship between the new document's old and new versions in the full lifecycle version chain corresponding to each document with the same title.
3. The method according to claim 1 or 2, characterized in that, In the multi-source heterogeneous financial document segmentation differentiation processing step, the fixed-length segmentation strategy includes: starting from the beginning of the document, extracting text according to a preset number of characters as the first segment, then starting from the end of the previous segment of text, generating the second segment according to a preset number of characters, and so on, until the end of the document, ultimately obtaining multiple segments.
4. The method according to claim 1 or 2, characterized in that, In the regulatory retrieval step, the process of generating the first recall chunk set corresponding to the query text in each of the three hierarchical knowledge bases specifically includes applying differentiated retrieval rules for the three types of hierarchical knowledge bases: For the hierarchical knowledge base corresponding to the industry standard documents, according to the industry standard retrieval rules, the sub-blocks of the root-parent-child three-level tree index structure are first retrieved, and the corresponding parent block and root node block are retrieved back according to the association relationship of the root-parent-child three-level tree index structure. The industry standard information related to the query text is recalled to form the first recall block set corresponding to the hierarchical knowledge base. For the hierarchical knowledge base corresponding to the enterprise internal policy documents, based on the enterprise internal regulations retrieval rules, the retrieval is first performed on the sub-blocks of the root-parent-child three-level tree index structure, and the corresponding parent block and root node block are obtained by backtracking according to the association relationship of the root-parent-child three-level tree index structure. Combining the business scenario and time dimension of the query text, the target version of the enterprise internal regulations document that is adapted to the business scenario and time dimension is matched through the doubly linked list, and the enterprise internal regulations information related to the query text is recalled from the matched enterprise internal regulations document to form the first recall block set corresponding to the hierarchical knowledge base; For the hierarchical knowledge base corresponding to the aforementioned regulatory documents, based on the financial legal provisions retrieval rules, the search is first performed on the sub-blocks of the root-parent-child three-level tree index structure. Then, the corresponding parent block and root node block are obtained by backtracking according to the association relationship of the root-parent-child three-level tree index structure. Combining the business scenario and time dimension of the query text, the target version of the financial legal provisions document that is adapted to the business scenario and time dimension is matched through the doubly linked list. The financial legal provisions information related to the query text is recalled from the matched financial legal provisions document, forming the first recall block set corresponding to the hierarchical knowledge base.
5. The method according to claim 4, characterized in that, The industry standard retrieval rules include: converting the query text into a vector representation using a vectorization model; calculating the cosine similarity between the vector representation of the query text and all vector representations in the hierarchical knowledge base corresponding to the industry standard document; and selecting the blocks corresponding to the vector representations with a cosine similarity greater than a preset cosine similarity threshold as industry standard information related to the query text.
6. The method according to claim 4, characterized in that, The internal regulations retrieval rules include: converting the query text into a vector representation using a vectorization model; calculating the cosine similarity between the vector representation of the query text and the vector representations of all child nodes in the hierarchical knowledge base corresponding to the internal regulations documents; selecting child nodes corresponding to vector representations with a cosine similarity greater than a preset cosine similarity threshold; obtaining the parent node corresponding to each child node based on the selected child node using the root-parent-child three-layer tree index structure; obtaining the root node corresponding to each parent node based on the obtained parent node; determining the root node corresponding to the most appropriate version of the internal regulations document based on the full lifecycle version chain corresponding to each root node, as well as the business scenario and time dimension of the query text; and determining the parent node and child node based on the root node; and recalling the internal regulations document information corresponding to the finally determined root node, parent node, and child node as internal regulations information related to the query text.
7. The method according to claim 4, characterized in that, The financial legal regulations retrieval rules include: converting the query text into a vector representation using a vectorization model; calculating the cosine similarity between the vector representation of the query text and the vector representations of all child nodes in the hierarchical knowledge base corresponding to the regulatory documents; selecting child nodes corresponding to vector representations with a cosine similarity greater than a preset cosine similarity threshold; obtaining the parent node corresponding to each child node based on the selected child node using the root-parent-child three-layer tree index structure; obtaining the root node corresponding to each parent node based on the obtained parent node; determining the root node corresponding to the most appropriate version of the regulatory document based on the full lifecycle version chain corresponding to each root node, as well as the business scenario and time dimension of the query text; and determining the parent node and child node based on the root node; and recalling the regulatory document information corresponding to the finally determined root node, parent node, and child node as financial legal regulations information related to the query text.
8. The method according to claim 1 or 2, characterized in that, In the regulatory retrieval step, all first recall blocks are weighted and fused according to the weights to obtain a second recall block set, specifically including: Based on the weights of various hierarchical knowledge bases and the preset recall threshold, the recall quantity corresponding to each hierarchical knowledge base is calculated. For the first recall block set corresponding to each hierarchical knowledge base, the blocks in the first recall block set are sorted according to their relevance to the query text, and the top 10 blocks in the first recall block set with the highest relevance to the query text are selected to obtain the second recall block set.
9. A hierarchical weighted RAG intelligent question-answering system for financial regulatory scenarios, characterized in that, The system includes a multi-source heterogeneous financial document segmentation and differentiation processing module, a full lifecycle version traceability management module, a query intent recognition and diversion module, a regulatory retrieval module, and a regulatory comparison module. These modules are sequentially connected, with the query intent recognition and diversion module also connected to the regulatory retrieval module and the regulatory comparison module. The multi-source heterogeneous financial document segmentation differentiation processing module is used to collect a multi-source heterogeneous financial document set including regulatory documents, industry standard documents, and internal enterprise policy documents. It extracts metadata from each document in the multi-source heterogeneous financial document set, including title, effective date, and expiration date, and configures differentiated segmentation strategies for different categories of documents in the multi-source heterogeneous financial document set: a parent-child hierarchical segmentation strategy is used for regulatory documents and internal enterprise financial policy documents, while a fixed-length segmentation strategy is used for industry standard documents. The parent-child hierarchical segmentation strategy involves generating a root node from the extracted metadata, using chapters in the document as parent nodes, and items under the chapters as child nodes, thus forming a root-parent-child three-level tree index structure. Parent nodes in the root-parent-child three-level tree index structure are used to generate parent blocks, and child nodes are used to generate child blocks. A vectorization model is used to convert each segmentation result into a semantic vector, which is then classified and stored in its corresponding hierarchical knowledge base in the vector database according to different document categories. The full lifecycle version traceability management module: Based on the title of the metadata, it identifies multiple versions of documents with the same title; for the multiple versions of documents with the same title, it constructs a doubly linked list with the root node corresponding to each version of the document as the carrier, establishes the inheritance and revision relationship between the old and new versions through the doubly linked list, and forms a traceable full lifecycle version chain by combining the effective time and expiration time in the metadata of the document, and stores the full lifecycle version chain in the vector database; The query intent recognition and routing module is used to receive query text input by the user, and to identify the query intent of the query text through a large language model; if the query intent is identified as a legal retrieval, it will jump to the legal retrieval module; if the query intent is identified as a legal comparison, it will jump to the legal comparison module. The regulatory retrieval module: Based on the retrieval rules of various hierarchical knowledge bases, and combined with the business scenario and time dimension carried by the query text, it calls the full lifecycle version chain to match the target version document with the appropriate timeliness. First, it performs retrieval based on the sub-blocks of the root-parent-child three-layer tree index structure, and then backtracks to obtain the corresponding parent block and root node block according to the association relationship of this three-layer tree index structure, generating the first recall block set corresponding to the query text in each hierarchical knowledge base. Weights are configured for each hierarchical knowledge base, and all first recall block sets are weighted and fused according to the weights to obtain the second recall block set. Using a re-ranking model, the semantic relevance of the second recall block set to the query text is sorted to obtain the ranking result. The contents of the root node block, parent block, and child block in the ranking result are concatenated to form prompt words, which are input into the large language model. The large language model then outputs the enhanced question-answering retrieval result corresponding to the query text. The regulatory comparison module parses the query text using a function call function of the large language model, determines the target regulatory title required by the query text, and searches for the latest version document corresponding to the target regulatory title in the vector database; it traverses the entire lifecycle version chain through the root node bound to the latest version document to obtain the historical version documents of the target regulatory title; it uses the various levels of blocks corresponding to the historical version documents and the latest version documents as a recall block set, extracts the content of the root node block, parent block, and child block in the recall block set, concatenates them to form prompt words, and inputs them into the large language model; the large language model outputs the comparison results of the revision differences between the old and new regulatory entries corresponding to the query text.
10. The system according to claim 9, characterized in that, The full lifecycle version traceability management module further includes: when new document metadata is extracted, based on the title of the metadata, counting the number of documents with multiple versions having the same title in the vector database; if there is only one existing document with the same title as the current document in the vector database, then the inheritance and revision relationship between the existing document and the new document's old and new versions is established through the doubly linked list, forming a traceable full lifecycle version chain and storing it in the vector database; if there are multiple existing documents with the same title as the current document in the vector database, then the inheritance and revision relationship between the new document's old and new versions is maintained in the full lifecycle version chain corresponding to each document with the same title.
