Regulation retrieval method based on knowledge graph multi-hop reasoning query, medium and equipment
By constructing a financial and tax knowledge graph and vector database, and combining hybrid retrieval and a large language model, the problems of incomplete law recall and interference from irrelevant information in financial and tax law retrieval are solved, achieving efficient and accurate multi-hop reasoning queries and generating structured search results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUJIAN BOSS SOFTWARE
- Filing Date
- 2026-02-25
- Publication Date
- 2026-05-08
AI Technical Summary
Existing knowledge graph-based regulatory retrieval methods suffer from incomplete regulatory recall and interference from irrelevant information in multi-hop reasoning queries in the financial and tax fields, affecting the accuracy and efficiency of retrieval.
We construct a knowledge base that includes a tax knowledge graph and a vector database. By parsing query requests, we extract tax tags and key tax concepts, perform hybrid retrieval and multi-dimensional feature ranking, and combine a large language model to generate structured retrieval results. We remove irrelevant information and cover multi-hop related regulations.
It improves the accuracy and efficiency of tax and financial regulations retrieval, ensures the completeness of regulations recall and the accuracy of results, reduces redundant information, and meets the complex multi-hop reasoning needs in the tax and financial field.
Smart Images

Figure CN121996780A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of knowledge graph information retrieval technology, specifically to a legal retrieval method, medium, and device based on knowledge graph multi-hop reasoning query. Background Technology
[0002] Tax and financial regulations retrieval is a branch of information retrieval, characterized by its strong domain specificity, high accuracy requirements, and frequent involvement of complex multi-hop reasoning processes. Existing knowledge graph-based hybrid retrieval methods (GraphRAG) have significant shortcomings in handling multi-hop reasoning queries in the tax and financial domain: one common approach is to first find seed nodes in the graph through vector retrieval, and then construct a subgraph using one-hop relationships. However, this method cannot retrieve complete target regulations when dealing with multi-hop reasoning scenarios due to hop count limitations. Another approach is to use Text2Cypher technology to directly transform user questions into graph query language, but this method relies on the quality of the user question's wording and is also difficult to effectively handle multi-hop reasoning problems. Furthermore, existing methods generally do not distinguish the types of relationships when constructing subgraphs, leading to the introduction of a large amount of irrelevant information in a single expansion, significantly increasing the cost and difficulty of subsequent filtering, and affecting the accuracy and efficiency of retrieval. Summary of the Invention
[0003] In view of the above problems, this application provides a legal retrieval method, medium and device based on knowledge graph multi-hop reasoning query to solve the problems of incomplete legal retrieval and interference from irrelevant information in multi-hop reasoning scenarios, thereby improving the accuracy and efficiency of financial and tax legal retrieval.
[0004] To achieve the above objectives, in a first aspect, this application provides a regulatory retrieval method based on knowledge graph multi-hop reasoning query, the method comprising:
[0005] Construct a financial and tax knowledge base, which includes a financial and tax knowledge graph and a vector database. The vector database is used to store document fragments that are segmented from legal texts and quantified.
[0006] Receive query requests from users;
[0007] The query request is parsed, and tax tags and key tax concepts are extracted from the query request. The tax tags are obtained by matching the large model and the pre-built financial and tax domain keyword library, and the key tax concepts are extracted by the named entity recognition model based on the large model.
[0008] The document fragments in the vector database are filtered based on tax tags. Then, the semantic similarity between the query request and the filtered document fragments is calculated using a hybrid retrieval method. The K document fragments with the highest semantic similarity are selected as the first candidate fragment set.
[0009] Based on the legal provisions corresponding to the first candidate fragment set and their corresponding legal provisions nodes in the tax knowledge graph, a one-hop query is performed to obtain tax concept nodes directly associated with these legal provisions nodes, forming an initial extended concept set. The initial extended concept set is then filtered using key tax concepts extracted from the query request to obtain a filtered extended tax concept set.
[0010] Starting with each tax concept node in the filtered extended tax concept set, a one-hop query is performed in the financial and tax knowledge graph to obtain the legal provisions nodes directly associated with these tax concept nodes. Based on these legal provisions nodes, the corresponding document fragments are obtained to form a second candidate fragment set. The first candidate fragment set and the second candidate fragment set are merged to form a relevant legal candidate set.
[0011] Based on preset multi-dimensional features, document fragments in the relevant regulatory candidate set are sorted and filtered to generate structured final search results. The multi-dimensional features include the level of regulatory effectiveness, publication time, and semantic similarity between the document fragments and the query request.
[0012] Furthermore, generating structured final search results includes:
[0013] The top-ranked candidate document fragments are input into the large language model along with the query request. The large language model then performs relevance assessment, redundancy removal, and information summary generation on the input candidate fragments based on the query request, outputting a structured final retrieval result.
[0014] Furthermore, the construction of the financial and tax knowledge base includes:
[0015] The full text of financial and tax regulations is preprocessed to obtain document fragments. The preprocessing includes text cleaning, paragraph division, and fragment segmentation.
[0016] Based on the document fragment, by combining rules and models, legal provisions entities and tax concept entities are extracted, and the first association between the legal provisions entities and tax concept entities and the second association between the legal provisions entities to which the tax concept entities belong are identified.
[0017] Using the legal provisions and tax concepts as nodes, and the first or second association as edges, the financial and tax knowledge graph is constructed.
[0018] The document fragments are vectorized and encoded using a pre-trained semantic vector model, and the vectorized document fragments and their metadata are stored in the vector database. The metadata includes the relevant law, the level of effectiveness, and the publication time.
[0019] Furthermore, the calculation of semantic similarity between the query request and the filtered document fragments using a hybrid retrieval method includes:
[0020] Calculate the cosine similarity between the semantic vector of the query request and the semantic vectors of each filtered document fragment to obtain the first similarity score;
[0021] Based on the frequency and location information of the tax tag in the document fragment, keyword matching degree is calculated to obtain a second similarity score;
[0022] Based on preset weighting coefficients, the first similarity score and the second similarity score are weighted and fused to obtain a comprehensive semantic similarity score.
[0023] Furthermore, after obtaining the filtered and expanded set of tax concepts, the following steps are also included:
[0024] The tax concept nodes in the filtered extended tax concept set are prioritized and sorted. The priority sorting is determined based on the type of association between the tax concept node and the corresponding legal provision node in the first candidate fragment set. Specifically, this includes: identifying the relationship edges connecting the legal provision node and the tax concept node in the tax knowledge graph; if the relationship edge is a specific relationship representing the change of legal validity, the corresponding tax concept node is assigned a high priority; if the relationship edge is another type, the corresponding tax concept node is assigned a normal priority lower than the high priority.
[0025] The step of performing a one-hop query in the tax knowledge graph, starting from each tax concept node in the filtered extended tax concept set, includes: prioritizing the execution of the one-hop query from the tax concept node with the highest priority, based on the priority sorting.
[0026] Furthermore, the legal provisions nodes in the tax knowledge graph are associated with a structured list of requirements, which describes the legal conditions that must be met to apply the legal provisions.
[0027] The method includes:
[0028] When extracting tax tags and key tax concepts from the query request, a list of structured fact elements is also extracted from the query request.
[0029] After forming the relevant legal candidate set, for each legal provision node in the relevant legal candidate set, a requirement-element matching calculation is performed, specifically including: comparing the structured requirement list associated with the legal provision node with the structured fact element list extracted from the query request, and calculating a matching score;
[0030] When sorting and filtering document fragments in a candidate set of relevant regulations based on preset multi-dimensional features, the multi-dimensional features also include the matching score.
[0031] Furthermore, the legal provisions nodes in the tax knowledge graph are associated with historical version nodes and revision summary information corresponding to the legal provisions nodes, forming a legal evolution chain;
[0032] After generating the structured final search results, the following steps are also included:
[0033] For the legal provisions involved in the final search results, if there are related historical version nodes in the financial and tax knowledge graph, then based on the legal evolution chain, the key revision summary between the current version of the legal provision and the historical version is extracted, and evolution prompt information is generated and attached to the legal provision.
[0034] Furthermore, the tax knowledge graph also includes a risk warning subgraph, which contains the following risk nodes connected by relationships: risk nodes representing violations, risk clause nodes representing prohibitive or obligatory clauses, and penalty basis nodes representing corresponding penalties.
[0035] When parsing a query request, a large language model is used to identify any violations or risk scenarios hidden in the query request and extract them as risk keywords.
[0036] The method further includes:
[0037] Based on the risk keywords, a matching query is performed in the risk warning subgraph. If a relevant risk clause node and / or penalty basis node is matched, the corresponding legal text fragment is obtained, an independent risk warning message is generated, and the risk warning message is output together with the final search result.
[0038] In a second aspect, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in the first aspect of this application.
[0039] In a third aspect, this application provides an electronic device having a computer program stored thereon, including a processor and a storage medium, wherein the computer program is stored on the storage medium, and when executed by the processor, the computer program implements the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in the first aspect of this application.
[0040] Unlike existing technologies, the above technical solution involves a legal retrieval method, medium, and device based on multi-hop reasoning query using a knowledge graph. The method first constructs a knowledge base comprising a tax knowledge graph and a vector database. Upon receiving a query request, it parses and extracts tax tags and key tax concepts. Based on the tax tags, it filters and performs a mixed search on the vector database to obtain a first candidate fragment set. Based on the corresponding legal provision nodes in this set, it performs a one-hop query in the knowledge graph to obtain associated tax concept nodes, and filters this set using the key tax concepts in the query request to obtain a precise extended tax concept set. Starting from each tax concept node in the extended tax concept set, it performs a one-hop query to obtain associated legal provision nodes and their document fragments, forming a second candidate fragment set. After merging the two sets, it sorts and filters based on multi-dimensional features such as legal validity level, publication time, and semantic similarity, ultimately generating structured retrieval results. This invention effectively solves the problems of incomplete legal retrieval and interference from irrelevant information in multi-hop reasoning scenarios through two queries and intermediate concept filtering, improving the accuracy and efficiency of tax legal retrieval.
[0041] The above description of the invention is merely an overview of the technical solution of this application. In order to enable those skilled in the art to better understand the technical solution of this application and to implement it based on the description and drawings, and to make the above-mentioned objectives and other objectives, features and advantages of this application easier to understand, the following description is provided in conjunction with the specific embodiments and drawings of this application. Attached Figure Description
[0042] The accompanying drawings are only used to illustrate the principles, implementation methods, applications, features, and effects of specific embodiments of this application and other related content, and should not be considered as limitations on this application.
[0043] In the accompanying drawings of the instruction manual:
[0044] Figure 1 This is a flowchart of the legal retrieval method based on knowledge graph multi-hop reasoning query as described in the first exemplary embodiment of this application;
[0045] Figure 2 This is a flowchart of the legal retrieval method based on knowledge graph multi-hop reasoning query as described in the second exemplary embodiment of this application;
[0046] Figure 3 This is a flowchart of the legal retrieval method based on knowledge graph multi-hop reasoning query as described in the third exemplary embodiment of this application;
[0047] Figure 4 This is a flowchart of the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in the fourth exemplary embodiment of this application;
[0048] Figure 5 This is a schematic diagram of a module of the legal retrieval method based on knowledge graph multi-hop reasoning query as described in an exemplary embodiment of this application;
[0049] Figure 6 This is an overall workflow diagram of the legal retrieval method based on knowledge graph multi-hop reasoning query as described in an exemplary embodiment of this application;
[0050] Figure 7 This is a schematic diagram of a tax knowledge graph as an exemplary embodiment of this application;
[0051] Figure 8 This is a schematic diagram of an electronic device according to an exemplary embodiment of this application;
[0052] The reference numerals used in the above figures are explained as follows:
[0053] 10. Electronic equipment; 101. Processor; 102. Storage medium. Detailed Implementation
[0054] To explain in detail the possible application scenarios, technical principles, specific feasible solutions, and the objectives and effects that this application can achieve, the following detailed description is provided in conjunction with the listed specific embodiments and accompanying drawings. The embodiments described herein are only used to more clearly illustrate the technical solutions of this application, and are therefore only examples, and should not be used to limit the scope of protection of this application.
[0055] In the first aspect, such as Figure 1 , Figure 5 and Figure 6 As shown, this application provides a regulatory retrieval method based on knowledge graph multi-hop reasoning query, the method comprising:
[0056] S1: Construct a financial and tax knowledge base, which includes a financial and tax knowledge graph and a vector database. The vector database is used to store document fragments that are segmented from legal texts and quantified.
[0057] S2: Receive the query request input by the user, parse the query request, and extract the tax tags and key tax concepts from the query request. The tax tags are obtained by matching through a pre-set keyword library in the financial and tax field, and the key tax concepts are extracted through a named entity recognition model based on a large model.
[0058] S3: Filter the document fragments in the vector database based on the tax tag, and calculate the semantic similarity between the query request and the filtered document fragments through a hybrid retrieval method in the filtered document fragments, and select the K document fragments with the highest semantic similarity as the first candidate fragment set;
[0059] S4: Based on the legal provisions corresponding to the first candidate fragment set and their corresponding legal provisions nodes in the financial and tax knowledge graph, perform a one-hop query to obtain tax concept nodes directly associated with these legal provisions nodes, forming an initial extended concept set. Use the key tax concepts extracted from the query request to filter the initial extended concept set to obtain the filtered extended tax concept set.
[0060] S5: Starting with each tax concept node in the filtered extended tax concept set, perform a one-hop query in the financial and tax knowledge graph to obtain the legal provisions nodes directly related to these tax concept nodes. Based on these legal provisions nodes, obtain their corresponding document fragments to form a second candidate fragment set. Merge the first candidate fragment set and the second candidate fragment set to form a relevant legal candidate set.
[0061] S6: Based on preset multi-dimensional features, sort and filter document fragments in the relevant regulatory candidate set to generate structured final search results. The multi-dimensional features include the level of regulatory effectiveness, publication time, and semantic similarity between the document fragments and the query request.
[0062] In this embodiment, a query request refers to a user's search needs regarding issues related to finance and taxation. It is typically presented in natural language and includes the user's core request to obtain legal basis.
[0063] Tax tags are core keywords closely related to the financial and tax field extracted from query requests. They are obtained through a large model and matching with a pre-built financial and tax keyword database, which can quickly locate the core business direction of the query request, such as "general taxpayer", "debt-for-equity swap", "simplified tax calculation method", "value-added tax", etc.
[0064] Key tax concepts are standardized academic or business concepts extracted from query requests by a named entity recognition model based on a large model. They have a unified semantic connotation and expression form, and can eliminate ambiguity in natural language expressions, such as "value-added tax rate" and "ordinary invoice".
[0065] Hybrid retrieval is a comprehensive retrieval strategy that combines semantic vector matching and keyword matching. It takes into account the semantic relevance of the query request and the document fragment and the accuracy of the matching of key information, thereby improving the comprehensiveness and accuracy of the retrieval results.
[0066] The first candidate fragment set refers to the set of K document fragments with the highest semantic similarity to the query request selected after calculating semantic similarity through hybrid retrieval (K is a preset threshold, and K=20 is preferred in combination with the retrieval accuracy requirements and efficiency in the financial and tax field). It is the basic candidate set for subsequent retrieval expansion.
[0067] The nodes in a tax and finance knowledge graph include legal provision nodes and tax concept nodes. Legal provision nodes correspond to specific clauses in tax and finance regulations, while tax concept nodes correspond to professional terminology in the tax and finance field. Nodes are the basic units for storing information in the knowledge graph. A schematic diagram of a tax and finance knowledge graph is shown below. Figure 7 As shown.
[0068] A one-hop query refers to a query operation that starts from a target node and retrieves adjacent nodes in the knowledge graph that are directly connected to that node (associated through a relation edge). It is used to quickly expand the core concepts related to the initial candidate fragments.
[0069] The initial extended concept set refers to the set of all tax concept nodes directly associated with the legal provisions corresponding to the first candidate fragment set, obtained through a one-hop query. This set includes basic related concepts connected to the initial candidate regulations. The filtered extended tax concept set is the set obtained after filtering the initial extended concept set using key tax concepts extracted from the query request. The filtering process combines statistical indicators based on word frequency and semantic relevance between concepts to eliminate irrelevant or weakly related tax concept nodes, improving the accuracy of subsequent searches.
[0070] A one-hop query refers to starting from each node in the filtered extended set of tax concepts and performing another one-hop query in the knowledge graph (i.e., forming a two-hop association retrieval starting from the initial legal provision node), used to discover legal provisions that are indirectly related to the query request but are important.
[0071] The second candidate fragment set refers to the set of document fragments corresponding to the legal provisions nodes directly associated with the extended tax concept node, obtained through a one-hop query. It is an effective supplement to the first candidate fragment set and can cover relevant regulations associated with multiple hops.
[0072] Multi-dimensional features are the core evaluation indicators used to sort and filter relevant candidate sets of regulations. These include the level of effectiveness (such as regulations, interpretations of regulations, etc.), the applicable administrative region (such as the scope of administrative regions covered by different levels of regulations, such as national, provincial, municipal, and county), the publication time (to ensure that the search results are consistent with the applicable scenarios of currently effective regulations), and the semantic similarity between document fragments and query requests (to ensure the relevance of results to user needs). Multi-dimensional comprehensive evaluation can improve the practicality and accuracy of search results.
[0073] Structured final search results refer to search results presented in a pre-defined format. The filtered and sorted legal document fragments are output in a clear and organized manner, making it easy for users to quickly locate the core legal basis and understand the relationship between the regulations and the query request.
[0074] In step S1, the massive amount of financial and tax regulations text is first segmented. The documents are split according to the directory structure (such as chapters, sections, and articles), and the attachments are split separately to form document fragments with appropriate granularity, ensuring that the retrieval can be accurate to specific clauses. Then, these document fragments are vectorized and encoded to convert the text information into semantic vectors that can be computed by computers and stored in a vector database to provide data support for subsequent semantic similarity retrieval.
[0075] Meanwhile, based on the segmented document fragments, a tax knowledge graph is constructed: 10 core entities such as legal provisions and tax concepts are extracted, and 15 types of relationships between entities such as inclusion, reference, modification, and supplementation are identified. With entities as nodes and relationships as edges, a complete semantic network is formed, which enables accurate modeling of the relationship logic between laws and regulations and provides support for multi-hop reasoning queries.
[0076] In step S2, after receiving the user's input natural language query request, key information needs to be extracted to provide a clear direction for subsequent searches. On the one hand, by matching with a large model and a pre-built keyword database in the financial and tax field, tax tags are extracted to quickly identify the core business elements involved in the query request. On the other hand, a named entity recognition model based on the large model is used to extract key tax concepts, eliminate ambiguity in natural language expressions, and ensure consistency in concept understanding during subsequent searches. For example, for the query request "If a manufacturing enterprise is a general taxpayer and acquires property as debt settlement in 2025, and obtains a 5% ordinary invoice, can it apply the simplified tax calculation method to calculate and pay value-added tax at a 5% collection rate when selling it externally?", the tax tags "general taxpayer," "debt settlement property," "2025," "ordinary invoice," "simplified tax calculation method," "5% collection rate," and "value-added tax" can be extracted, along with key tax concepts such as "general taxpayer qualification," "simplified value-added tax calculation method," "value-added tax collection rate," and "ordinary invoice management."
[0077] In step S3, the extracted tax tags are first used to initially filter document fragments in the vector database, eliminating fragments that do not contain core business elements, thus narrowing the search scope and reducing subsequent computational costs. For the filtered document fragments, a hybrid retrieval method is used to calculate the semantic similarity with the query request: combining the advantages of semantic vector matching and keyword matching, it captures the overall semantic relevance between the query and the document through semantic vectors, while ensuring accurate matching of core information through keyword frequency and location information, avoiding the limitations of a single retrieval method. Based on the calculated comprehensive semantic similarity, the top K document fragments are selected as the first candidate fragment set, ensuring a high relevance between the initial candidate set and the query request.
[0078] In step S4, starting with the legal provisions node corresponding to the first candidate fragment set, a one-hop query is performed in the tax knowledge graph to obtain directly related tax concept nodes, forming an initial extended concept set. Then, the initial extended concept set is filtered using key tax concepts extracted from the query request. Through word frequency statistics and semantic relevance analysis, concept nodes irrelevant or weakly related to the query request are eliminated, resulting in a filtered extended tax concept set. This reduces redundancy in subsequent searches and improves efficiency.
[0079] In step S5, starting with each node in the filtered extended tax concept set, a one-hop query is performed again (i.e., forming a two-hop inference overall) to obtain other legal provisions directly related to these concept nodes, extract the corresponding document fragments, and form a second candidate fragment set. This step effectively covers regulations with multi-hop associations with the query request, solving the problem that traditional retrieval struggles to discover indirectly related regulations. Then, the first and second candidate fragment sets are merged to form a relevant regulatory candidate set containing both directly and indirectly related regulations, ensuring the comprehensiveness of the search results.
[0080] In step S6, document fragments in the candidate set are sorted and filtered based on preset multi-dimensional features (legal validity level, publication time, semantic similarity): document fragments with high validity level (such as laws taking precedence over departmental regulations), recent publication time (to ensure the validity of regulations), and high semantic similarity (to ensure relevance to user needs) are retained first, and finally, structured search results are generated for user convenience.
[0081] The above solution, through multi-hop reasoning queries using a knowledge graph, overcomes the limitations of traditional retrieval methods that can only discover directly related regulations. It can uncover important regulations indirectly related to the query request, forming a complete set of candidate regulations, effectively solving the problem of incomplete coverage of candidate regulations in multi-hop reasoning scenarios. Through multiple precise filtering mechanisms, such as tax tag filtering and key tax concept screening, irrelevant document fragments are effectively eliminated, reducing redundant information and lowering screening costs and difficulty. Simultaneously, the hybrid retrieval method balances semantic relevance and key information matching, further improving the accuracy of search results. Addressing the characteristics of tax and financial regulations—strong domain relevance, complex relationships, and the need to consider legal force levels and timeliness—a rich entity relationship model is built in the knowledge base, and the legal force level and publication time features are incorporated into the ranking and filtering process, making the retrieval method more aligned with the practical application needs of the tax and financial field. Through multi-round filtering mechanisms (tag filtering, concept filtering), the search scope is gradually narrowed, reducing redundant calculations. Furthermore, multi-hop reasoning queries are based on a structured knowledge graph, resulting in a clear search path and significantly improved efficiency compared to traditional text-based blind searches.
[0082] In some embodiments, generating structured final search results includes: inputting the top-ranked candidate document fragments along with the query request into a large language model, so that the large language model performs relevance discrimination, redundancy removal, and information summary generation on the input candidate fragments according to the query request, and outputs structured final search results.
[0083] In this embodiment, redundant information removal refers to the large language model identifying repetitive or highly similar information content among candidate document fragments. For example, if multiple fragments express the core requirements of the same regulatory clause, only the most complete and clear fragment or the core information is retained to avoid a large amount of redundant content in the search results and reduce the reading burden on users.
[0084] Information summary generation refers to the process by which a large language model extracts key information such as core clauses, applicable conditions, and key conclusions from valid document fragments after relevance assessment and redundancy removal, generating a concise and clear information summary to avoid users having to read lengthy original legal texts to obtain the core information.
[0085] Structured output refers to the large language model organizing the processed valid fragments and their summaries according to a preset structured format (such as listing the law name, core clauses, applicable scenarios, etc. in bullet points) and outputting structured final search results, which makes it easier for users to quickly locate core information and understand the relationship logic between the law and the query request.
[0086] The above solution generates information summaries and structured outputs through a large language model, transforming complex and lengthy legal texts into concise, clear, and well-organized search results. Users can quickly obtain core information without spending a lot of time reading the original text, significantly reducing user costs. Leveraging the powerful semantic understanding capabilities of the large language model for secondary relevance discrimination, it can more accurately identify legal fragments truly relevant to the query request, eliminating irrelevant fragments that may have been missed in the initial screening, further improving the accuracy of search results. Through the redundancy removal function of the large language model, it effectively integrates duplicate or similar information, making the search results more concise, avoiding information overload, and improving the user's reading and usage experience.
[0087] In some embodiments, such as Figure 2 As shown, the construction of the financial and tax knowledge base includes:
[0088] S201: Preprocess the full text of financial and tax regulations to obtain document fragments. The preprocessing includes text cleaning, paragraph division, and fragment segmentation.
[0089] S202: Based on the document fragment, extract legal provisions entities and tax concept entities by combining rules and models, and identify the first association between the legal provisions entities and tax concept entities, and the second association between the legal provisions entities to which the tax concept entities belong;
[0090] S203: Construct the financial and tax knowledge graph using the legal provisions and tax concepts as nodes and the first or second association as edges;
[0091] S204: The document fragment is vectorized and encoded using a pre-trained semantic vector model, and the vectorized document fragment and its metadata are stored in the vector database. The metadata includes the relevant law, level of validity, and publication time.
[0092] In this embodiment, the full text of financial and tax regulations refers to the original text of various legal documents in the field of finance and taxation, including laws, administrative regulations, departmental rules, normative documents, etc., which are the original data sources for building the financial and tax knowledge base, such as the "Provisional Regulations on Value-Added Tax" and the "Notice of the State Administration of Taxation on the Comprehensive Implementation of the Pilot Program of Replacing Business Tax with Value-Added Tax".
[0093] Semantic vector models are pre-trained models that can convert text into semantic vectors (such as the BGE-M3 model). They can capture the semantic information of text and convert it into a computer-computable vector form for subsequent semantic similarity calculation.
[0094] Metadata refers to descriptive information related to document fragments, including the relevant regulations (clearly indicating the source of the fragment), the level of validity (such as laws, interpretations of regulations, etc.), the applicable administrative region (clearly indicating the regions where it can be used), and the publication time (clearly indicating the timeliness of the regulations). This information is an important basis for subsequent sorting and filtering.
[0095] In step S201, the collected full-text financial and tax regulations are first cleaned to remove formatting symbols (such as special punctuation and page numbers), redundant spaces, irrelevant comments, and other invalid information, ensuring the purity and consistency of the text content. Then, according to the natural structure (chapter, section, article, clause) and semantic logic of the financial and tax regulations, paragraphs and segments are divided, breaking down the lengthy full-text regulations into multiple independent text units. This provides a foundation for subsequent document segmentation and ensures the semantic integrity of each text unit. Finally, based on the required retrieval accuracy, the divided text units are further segmented into document segments of appropriate granularity (such as specific articles and clauses), and the attachment content is separated separately, forming the final set of document segments for subsequent processing.
[0096] In step S202, based on the segmented document fragments, legal provisions entities and tax concept entities are extracted using a combination of rules and models: preliminary extraction is performed using preset keyword rules (such as keywords like "Article 1" and "Regulations" corresponding to legal provisions entities, and professional terms like "Value Added Tax" and "Tax Calculation Method" corresponding to tax concept entities), and then a named entity recognition model based on a large model is used for accurate identification and supplementation to ensure the comprehensiveness and accuracy of entity extraction.
[0097] Simultaneously, identifying the first association between legal provision entities and tax concept entities specifically includes: based on preset first relationship rules (such as inclusion relationship corresponding to "a certain legal provision contains a certain tax concept", and association relationship corresponding to "a certain legal provision is associated with a certain tax concept") and a relationship extraction model, identifying 15 core relationships such as inclusion, reference, and association to accurately characterize the semantic relationships between entities. Preferably, identifying the second association between the legal provision entities to which the tax concept entity belongs specifically includes: based on preset second association relationship rules, identifying associations such as reference, modification, and supplementation between the legal provision entities to which the tax concept entity belongs.
[0098] In step S203, a tax knowledge graph is constructed using the extracted legal provisions and tax concepts as nodes and the identified relationships between entities as edges. During the construction process, it is ensured that each node contains complete entity information (such as the specific content of the legal provisions and the definition of the tax concepts), and each edge is clearly labeled with its relationship type (such as "contains," "references," "modifies," etc.), forming a structured semantic network to support multi-hop reasoning queries.
[0099] In step S204, a pre-trained semantic vector model (such as BGE-M3) is used to vectorize and encode each document fragment, transforming the text-based document fragments into low-dimensional, dense semantic vectors. This captures the semantic information of the document fragments, enabling the computer to quickly calculate semantic similarity. The vectorized document fragments and their metadata (related regulations, level of effectiveness, publication time) are stored together in a vector database, establishing a mapping relationship between document fragments, semantic vectors, and metadata. This provides data support for subsequent vector-based rapid retrieval and sorting filtering.
[0100] The aforementioned solution, through entity extraction and relationship recognition, constructs a tax knowledge graph that transforms unstructured legal texts into a structured semantic network. This clearly depicts the relationships between various entities, providing a solid foundation for multi-hop reasoning queries and solving the problem of traditional databases' inability to express complex semantic relationships. Multiple processing steps, including text cleaning, rule-based and model-driven entity extraction, and relationship recognition, ensure the purity, integrity, and accuracy of the data in the knowledge base, guaranteeing the precision of subsequent retrieval results. The construction of a vector database enables rapid and efficient semantic similarity calculation, significantly improving retrieval speed compared to traditional text-matching-based methods and meeting users' demands for retrieval efficiency. The rich entity relationship modeling within the knowledge graph enables multi-hop reasoning queries, supporting retrieval paths from initial regulations to indirectly related regulations, effectively covering multi-hop association scenarios.
[0101] In some embodiments, such as Figure 3 As shown, the calculation of semantic similarity between the query request and the filtered document fragments using a hybrid retrieval method includes:
[0102] S301: Calculate the cosine similarity between the semantic vector of the query request and the semantic vector of each filtered document fragment to obtain the first similarity score;
[0103] S302: Based on the frequency and location information of the tax label in the document fragment, calculate the keyword matching degree to obtain the second similarity score;
[0104] S303: Based on the preset weight coefficients, the first similarity score and the second similarity score are weighted and fused to obtain a comprehensive semantic similarity.
[0105] In this embodiment, the preset weight coefficient refers to the weight parameter set in advance to balance the first similarity score and the second similarity score according to the actual needs of retrieval in the financial and tax field. For example, the weight of the first similarity score can be set to 0.6 and the weight of the second similarity score can be set to 0.4 to ensure that the comprehensive semantic similarity can fully reflect the relevance of the text.
[0106] The core of the hybrid retrieval method is to combine the advantages of semantic vector matching and keyword matching to comprehensively and accurately calculate the relevance between the query request and the document fragment. The specific steps and principles are as follows:
[0107] First, using the same pre-trained semantic vector model (such as BGE-M3) as when building the vector database, the user's query request is vectorized and encoded to generate a semantic vector for the query request. This ensures that the semantic vectors of the query request and the document fragments are in the same vector space, guaranteeing the effectiveness of the similarity calculation. Then, the filtered semantic vectors corresponding to each document fragment are extracted from the vector database; these vectors were pre-generated and stored during the knowledge base construction phase. Next, the cosine similarity between the query request semantic vector and the semantic vector of each document fragment is calculated to obtain the first similarity score. Cosine similarity effectively measures the directional consistency between two vectors, i.e., the semantic relevance of the text. A higher first similarity score indicates that the overall semantics of the query request and the document fragment are more similar.
[0108] Next, keyword matching is calculated. First, a set of tax tags (such as "general taxpayer" and "simplified tax calculation method") is extracted from the query request. Then, the frequency (number of occurrences) of each tax tag in the document fragment is counted. The higher the frequency, the closer the document fragment is to the key information of the query request. At the same time, the position information of the tax tags in the document fragment is analyzed. If the tag appears at the beginning of a paragraph or in a core sentence, it is given higher weight, because the information in these positions usually better reflects the core content of the document fragment. Then, based on the frequency and position information, the keyword matching degree, i.e., the second similarity score, is calculated using a preset calculation rule (such as the sum of frequency score and position weight). The higher the second similarity score, the richer the key information of the query request contained in the document fragment and the more important its position.
[0109] Based on the actual needs of retrieval in the financial and tax field, weight coefficients for the first and second similarity scores are preset (e.g., first similarity weight 0.6, second similarity weight 0.4). These weight coefficients can be adjusted according to actual search results to ensure a balance between semantic relevance and key information matching. The first and second similarity scores are then weighted and fused according to the preset weight coefficients, calculated using the following formula:
[0110] The overall similarity score is calculated as follows: First similarity score × First weight + Second similarity score × Second weight. This yields the overall semantic similarity score.
[0111] Then, the filtered document fragments are sorted based on comprehensive semantic similarity, and the K document fragments with the highest scores are selected as the first candidate fragment set.
[0112] The above scheme combines the advantages of semantic vector matching (measuring overall semantic relevance) and keyword matching (measuring the matching degree of key information), avoiding the problems that single semantic vector retrieval may overlook key entities and single keyword retrieval may lack semantic understanding, making similarity calculation more comprehensive and accurate. Tax and financial regulation retrieval needs to focus on both overall semantic relevance (ensuring that the regulations match the business scenario of the query request) and the accurate matching of key entities (ensuring that the regulations involve core tax elements). The hybrid retrieval method precisely meets this need, improving the applicability of the retrieval results. By balancing the two similarity scores through weighted fusion, it can handle different types of query requests (such as queries with ambiguous semantic descriptions but clear key entities, and queries with unclear semantics but less prominent key entities), ensuring that the retrieval method maintains good retrieval performance in various scenarios and has stronger robustness.
[0113] In other embodiments, during the construction of the tax knowledge base, the entities in the tax knowledge graph not only include legal provisions and tax concepts, but also cover 10 entity types such as interpretation, appendices, full text, chapters, and sections. The relationships between entities not only include inclusion, reference, and association, but also define 15 relationship types in detail, such as interpretation, explanation, modification, supplementation, conflict priority, simple repeal, and alternative repeal, which can more comprehensively and accurately depict the complex relationship logic between tax regulations.
[0114] For example, the "modification" relationship is used to characterize the revision association between one legal provision and another; the "conflict priority" relationship is used to clarify the applicable priority when two legal provisions conflict; and the "repealed" relationship is used to mark expired legal provisions and their replacements. These detailed entity and relationship types enable the knowledge graph to accurately model complex scenarios such as the revision trajectory of financial and tax regulations and conflict resolution rules, providing important support for determining the validity of regulations and handling conflicts during the retrieval process, and further improving the accuracy and practicality of the retrieval results.
[0115] In multi-hop reasoning based on knowledge graphs, subgraph construction is a crucial intermediate step. After a one-hop query based on the legal provisions nodes corresponding to the first candidate fragment set, an initial extended concept set is generated. In addition to filtering using key tax concepts, the concept set can be further optimized by incorporating business logic from the tax and finance domain. For example, concept nodes strongly related to core tax and finance issues (such as tax calculation methods and applicable tax rates) are given higher priority and retrieved first in subsequent one-hop queries, further improving retrieval efficiency and accuracy.
[0116] Meanwhile, the subgraph construction process fully considers the differences in entity relationships within the fiscal and tax knowledge graph, avoiding the problem of traditional GraphRAG algorithms introducing a large amount of irrelevant information due to a lack of distinction between relationship types. By focusing on core relationship types relevant to the query request (such as containment, reference, modification, etc.), the relevance of the extended concept set and the second candidate fragment set is ensured, reducing redundant interference.
[0117] In the fragment retrieval step with tag filtering, a hybrid retrieval algorithm combining BGE-M3 and BM25 is employed. BGE-M3 is a high-performance pre-trained semantic vector model with powerful semantic capture capabilities, transforming query requests and document fragments into high-precision semantic vectors. By calculating the cosine similarity between vectors, it measures the overall semantic relevance, providing semantic-level matching support for hybrid retrieval. BM25 is a keyword retrieval algorithm that measures the degree of keyword matching by calculating factors such as the term frequency, inverse document frequency, and document length of the tax tag in the query request within the document fragment, providing precise keyword-level matching support for hybrid retrieval.
[0118] First, semantic similarity scores and keyword matching scores are calculated using the BGE-M3 model and the BM25 algorithm, respectively. Then, based on the retrieval characteristics of the finance and taxation field, weight coefficients are set for both (e.g., BGE-M3 weight is 0.6, and BM25 weight is 0.4). The weighted fusion is then used to obtain a comprehensive similarity score. Based on this score, the top 20 segments are selected as the first candidate segment set to ensure the high relevance and comprehensiveness of the initial candidate set.
[0119] In the process of sorting and screening the candidate set of relevant regulations, in addition to the basic sorting based on preset multi-dimensional features, further optimization can be achieved by combining the KNN clustering algorithm and the PageRank algorithm, as follows:
[0120] The KNN clustering algorithm is used to cluster document fragments in the relevant regulatory candidate set according to semantic similarity. Fragments with high semantic similarity are grouped together, and only the most representative fragments (such as those with the highest semantic similarity and most complete information) are retained in each cluster, effectively reducing redundant information and improving the simplicity of the results. The PageRank algorithm is used to analyze the importance of regulatory clause nodes in the financial and tax knowledge graph. Based on the in-degree (number of times a node is referenced by other nodes) and relationship strength, the document fragments in the candidate set are re-ranked, prioritizing regulatory clauses that are more important and more frequently referenced in the knowledge graph, further enhancing the value of the search results. The introduction of these algorithms makes the ranking and selection process more scientific and accurate, better balancing the comprehensiveness, simplicity, and value of the search results.
[0121] In some embodiments, after obtaining the filtered extended set of tax concepts, the following steps are also included:
[0122] The tax concept nodes in the filtered extended tax concept set are prioritized and sorted. The priority sorting is determined based on the type of association between the tax concept node and the corresponding legal provision node in the first candidate fragment set. Specifically, this includes: identifying the relationship edges connecting the legal provision node and the tax concept node in the tax knowledge graph; if the relationship edge is a specific relationship representing the change of legal validity, the corresponding tax concept node is assigned a high priority; if the relationship edge is another type, the corresponding tax concept node is assigned a normal priority lower than the high priority.
[0123] The step of performing a one-hop query in the tax knowledge graph, starting from each tax concept node in the filtered extended tax concept set, includes: prioritizing the execution of the one-hop query from the tax concept node with the highest priority, based on the priority sorting.
[0124] In this embodiment, the specific relationship characterizing the change of the validity of regulations refers to the correlation used to describe the change of the effectiveness of regulations in the time dimension, including the relationship of amendment, replacement of repeal, supplementation, etc. This type of relationship is directly related to the validity and applicable boundaries of regulations, such as "Regulations A amends Regulations B" and "Regulations C replaces and repeals Regulations D".
[0125] After obtaining the filtered and expanded set of tax concepts, the execution order of multi-hop queries is optimized through priority sorting to ensure that key related regulations are retrieved first, thereby improving retrieval efficiency and result value. The specific steps and principles are as follows:
[0126] Relationship edge type identification: Traverse each tax concept node in the filtered extended tax concept set, locate the relationship edge connecting the tax concept node with the corresponding legal provision node in the first candidate fragment set in the financial and tax knowledge graph, and clarify the specific type of each relationship edge (such as modification, supplementation, inclusion, reference, etc.).
[0127] Priority Determination and Assignment: Priority is determined based on the type of the relationship edge. If the relationship edge represents a specific relationship indicating a change in the validity of regulations (such as amendment, replacement, repeal, supplementation, etc.), then the association between this tax concept node and the initial candidate regulations is considered to have core value, and it is assigned a high priority. Regulations corresponding to this type of relationship often involve key information such as clause revisions and changes in validity, which are crucial for answering user queries (especially those involving the applicability and timeliness of regulations). If the relationship edge is of other types (such as inclusion, reference, related, etc.), then the importance of this tax concept node is considered relatively low, and it is assigned a normal priority. Regulations corresponding to this type of relationship are mostly basic associations or supplementary explanations, and should be further explored after the core related regulations have been retrieved.
[0128] Prioritized one-hop query execution: Based on the priority ranking results, the execution order of one-hop queries is adjusted. Specifically, this includes: prioritizing the execution of one-hop queries starting with high-priority tax concept nodes to quickly obtain related legal provisions nodes relevant to regulatory expiration dates, extracting corresponding document fragments, and supplementing them into the second candidate fragment set. This step ensures that core and critical regulations are retrieved first, enhancing the core value of the search results. After the high-priority nodes are retrieved, one-hop queries are then executed on ordinary-priority tax concept nodes to uncover other related legal provisions, further enriching the second candidate fragment set and ensuring the comprehensiveness of the search results.
[0129] The above solution prioritizes the retrieval of relevant regulations corresponding to high-value tax concept nodes, avoiding the waste of resources caused by indiscriminately traversing all nodes, shortening the recall time of key regulations, and improving the overall retrieval efficiency.
[0130] Focusing on specific relationships representing the changing timelines of regulations, this approach ensures that core regulations related to key information such as revisions, repeals, and supplements are retrieved first. This makes the search results more aligned with users' core needs regarding the effectiveness and applicability of regulations, thereby enhancing the practical value of the results. Building upon the initial concept filtering, priority ranking clarifies the focus of the query, avoiding invalid searches of low-value nodes. This further reduces the actual size of the subgraph construction and lowers redundant computational costs.
[0131] In some embodiments, such as Figure 4 As shown, the legal provisions nodes in the tax knowledge graph are associated with a structured list of requirements, which describes the legal conditions that must be met to apply the legal provisions.
[0132] The method includes:
[0133] S401: When extracting tax tags and key tax concepts from the query request, a list of structured fact elements is also extracted from the query request.
[0134] S402: After forming the relevant legal candidate set, for each legal provision node in the relevant legal candidate set, perform a requirement-element matching calculation, specifically including: comparing the structured requirement list associated with the legal provision node with the structured fact element list extracted from the query request, and calculating a matching score;
[0135] S403: When sorting and filtering document fragments in the relevant regulatory candidate set based on preset multi-dimensional features, the multi-dimensional features also include the matching score.
[0136] In this embodiment, the structured requirement list refers to the structured data associated with the legal provisions nodes in the tax knowledge graph. It is used to clearly and explicitly describe the legal conditions that need to be met to apply the legal provisions. It is usually presented in the form of items and includes core elements such as subject requirements, behavior requirements, time requirements, and scenario requirements. For example, the requirements for a general taxpayer to apply the simplified tax calculation method to the sale of real estate include: (1) the taxpayer type is a general taxpayer; (2) the subject of sale is real estate; and (3) it meets the specific policy application scenario.
[0137] The structured fact element list is the core fact information related to the applicable conditions of the regulations extracted from the user's query request. It is presented in a structured form and corresponds to various elements in the structured requirement list. For example, the fact element list extracted from the query request "The production enterprise is a general taxpayer, acquired real estate in 2025 to offset debts, and sold it to the outside world" is: "(1) Taxpayer type: general taxpayer; (2) Behavior: sale of real estate; (3) Method of acquiring real estate: debt offset; (4) Time: 2025".
[0138] Requirement-element matching calculation refers to the process of comparing the structured requirement list of legal provisions with the structured fact element list extracted from the query request one by one, and calculating the degree of fit between the two. It is the core calculation step to determine whether legal provisions are applicable to the user's query scenario.
[0139] The matching score is a quantitative value calculated through element-factor matching. It is used to intuitively reflect the degree of fit between the structured list of elements and the structured list of factual elements. The higher the score, the more applicable the legal provision is to the specific scenario in which the user queries.
[0140] In this embodiment, by introducing a matching mechanism between structured requirements and factual elements, the accuracy of legal retrieval is further improved, ensuring that the retrieval results are highly adapted to the specific scenario of the user's query. The specific steps and principles are as follows:
[0141] The first step is the construction of a structured list of requirements. During the construction phase of the tax and finance knowledge base, for each legal provision, based on the specific content of the provision, the legal conditions required for its application are extracted and compiled into a structured list of requirements. During the construction process, considering the characteristics of tax and finance regulations, the types of requirements (such as subject, action, time, and subject matter) are clearly defined to ensure the completeness and organization of the list. For example, the requirements list for the "Applicable Clauses of the Simplified Value-Added Tax Calculation Method" is defined as follows: Subject Requirements (general taxpayers / small-scale taxpayers), Subject Matter Requirements (real estate / goods / services), Action Requirements (sale / lease / transfer), Time Requirements (specific tax period), and Special Requirements (such as acquisition method, invoice type, etc.).
[0142] Secondly, there is the extraction of structured factual elements. When parsing user query requests, in addition to extracting tax tags and key tax concepts, structured factual elements related to the applicable legal conditions are extracted from the query request based on pre-defined factual element extraction rules and the semantic understanding capabilities of the large language model, forming a structured factual element list. During the extraction process, it is ensured that the factual elements correspond one-to-one with the element types in the structured element list. For example, for the aforementioned VAT-related query request, the extracted factual element list must cover elements such as subject, object, behavior, time, acquisition method, and invoice type.
[0143] The third step is the requirement-element matching calculation. After forming the relevant candidate set of regulations, the following operations are performed for each regulation clause node: The structured requirement list associated with the regulation clause node is retrieved from the knowledge graph; the structured requirement list is compared one by one with the structured fact element list extracted from the query request, and for each requirement type, it is determined whether there is a corresponding fact element match. Specifically, this includes:
[0144] Exact match: The factual elements and the requirements are completely consistent, and a higher score is assigned (e.g., 1 point).
[0145] Partial match: Factual elements and requirements overlap or are compatible, and are assigned a moderate score (e.g., 0.5 points).
[0146] Mismatch: The factual elements do not match the requirements at all, and a score of 0 is assigned.
[0147] Based on the matching results of all requirement types, the matching score of the regulatory clause node is calculated by weighted summation (with weights set according to the importance of the requirements). The weight setting can be combined with the applicable logic of regulations in the financial and tax field. For example, the weight of subject requirements and behavioral requirements is higher than that of time requirements.
[0148] When sorting and filtering based on preset multi-dimensional features (legal validity level, publication time, and semantic similarity), the matching score mentioned above is incorporated into the multi-dimensional feature system and participates in the ranking calculation together with other features. For example, the ranking score = validity level score × 0.3 + publication time score × 0.2 + semantic similarity score × 0.3 + matching score × 0.2, ensuring that the final ranking result considers both the authority and timeliness of the regulations, and also fully takes into account the adaptability of the regulations to the specific query scenarios of users.
[0149] The above solution, through precise matching of structured requirements and factual elements, effectively filters out legal provisions truly applicable to the user's specific query scenario. This avoids the problem of "semantically relevant but scenario-incompatible" results that may occur with filtering based solely on semantic similarity, significantly improving the accuracy of search results. Tax and financial issues often involve complex conditional filtering. The matching mechanism between the structured requirement list and the factual element list can accurately capture these complex conditions, perfectly adapting to the retrieval characteristics of the tax and financial field and solving the problem that traditional retrieval methods struggle to handle complex conditional filtering. Incorporating the matching score into multi-dimensional ranking features ensures that the ranking results not only reflect the authority, timeliness, and semantic relevance of the regulations but also fully demonstrate the degree of adaptability of the regulations to the user's actual scenario, allowing users to quickly locate the legal basis that best suits their needs.
[0150] In some embodiments, the legal provisions nodes in the tax knowledge graph are associated with historical version nodes and revision summary information corresponding to the legal provisions nodes, forming a legal evolution chain. After generating the structured final search results, the following steps are also included: for the legal provisions involved in the final search results, if the legal provisions have associated historical version nodes in the tax knowledge graph, then based on the legal evolution chain, the key revision summaries between the current version of the legal provisions and the historical versions are extracted, and evolution prompt information is generated and attached to the legal provisions.
[0151] In this embodiment, a historical version node refers to a node in the tax knowledge graph that is associated with the current legal provision node and represents the previous effective versions of the legal provision. Each historical version node stores core information such as the content of the legal provision of the corresponding version, the effective time, and the expiration time.
[0152] Revision summary information refers to the summary information formed by extracting and summarizing the changes in different versions of legal provisions. It includes key information such as the core clauses that were modified, the time of modification, the reasons for modification, and the changes in the effectiveness of the modified provisions, and is used to quickly present the evolution trajectory of legal provisions.
[0153] The regulatory evolution chain refers to a chain structure consisting of current regulatory clause nodes, historical version nodes, and revision relationship edges (such as "modification", "replacement", etc.) connecting these nodes, which clearly presents the complete evolution process of regulatory clauses from their promulgation to each revision and then to the current version.
[0154] Evolutionary hints are information extracted from the regulatory evolution chain and added to the final search results. They include summaries of historical version revisions, core differences between the current version and historical versions, changes in the scope of application, and other information to help users fully understand the evolutionary logic of regulatory provisions.
[0155] In this embodiment, by constructing a regulatory evolution chain and generating evolution prompts, a complete reference for the regulatory revision trajectory is provided to the user, helping the user accurately understand the applicable boundaries and historical evolution of the regulations. The specific steps and principles are as follows:
[0156] During the construction phase of the tax and finance knowledge base, the following operations are performed for each legal provision node: Collect all historical effective versions of the legal provision, including the published version and all previous revisions; create a corresponding historical version node for each historical version, storing core information such as the content of the legal provision, its effective date, its expiration date, and the issuing department; identify the revision relationships between the current legal provision node and historical version nodes, and between different historical version nodes (e.g., "the current version was modified from the 2023 version," "the 2023 version replaced the 2020 version"), and construct a legal evolution chain connecting the current version node and all historical version nodes using these revision relationships as edges; for each revision, extract revision summary information and associate it with the corresponding revision relationship edge or historical version node to ensure that the evolution chain contains complete revision details.
[0157] After generating the structured final search results, the following operations are performed: traverse each legal provision involved in the final search results, and query the tax knowledge graph to see if there are any related historical version nodes for that legal provision node; if historical version nodes exist, extract the following core information based on the legal evolution chain: the number of historical versions and the effective / expired time of each version, a summary of key revisions between each historical version and the current version (such as changes in core clauses, adjustments to the scope of application, changes in tax rates, etc.), and the core advantages or changes in applicable scenarios of the current version compared to historical versions.
[0158] The extracted information is then organized into concise and clear evolutionary prompts, which are appended to the corresponding legal provisions in the form of "Legal Evolution Explanation" and presented together with the structured search results.
[0159] The above solution, through the construction of a regulatory evolution chain and the generation of evolutionary prompts, helps users fully understand the historical evolution of regulations, avoiding errors in the application of regulations due to a lack of understanding of revisions. The evolutionary prompts provide users with added value beyond the current legal provisions themselves, ensuring that search results not only include currently valid legal basis but also encompass the historical background and evolutionary logic of the regulations. This helps users gain a deeper understanding of the regulatory content and enhances the practicality of the search results. Users do not need to separately consult historical versions of regulations; they can quickly obtain the complete revision trajectory of regulations through the evolutionary prompts attached to the search results, significantly reducing users' information gathering costs and time.
[0160] In some embodiments, the tax knowledge graph further includes a risk warning subgraph, which contains the following risk nodes connected by relationships: risk nodes representing violations, risk clause nodes representing prohibitive or obligatory clauses, and penalty basis nodes representing corresponding penalties.
[0161] When parsing a query request, a large language model is used to identify any violations or risk scenarios hidden in the query request and extract them as risk keywords.
[0162] The method further includes:
[0163] Based on the risk keywords, a matching query is performed in the risk warning subgraph. If a relevant risk clause node and / or penalty basis node is matched, the corresponding legal text fragment is obtained, an independent risk warning message is generated, and the risk warning message is output together with the final search result.
[0164] In this embodiment, risk nodes representing violations are used to describe various violations in the financial and tax field, such as "issuing false VAT invoices" and "failing to declare and pay taxes as required"; risk clause nodes representing prohibitive or mandatory clauses are used to describe behaviors explicitly prohibited or mandatory requirements stipulated in financial and tax regulations, such as "it is prohibited to issue false VAT invoices" and "taxpayers should declare and pay taxes within the prescribed period"; and penalty basis nodes representing corresponding penalties are used to describe the penalty clauses and basis corresponding to violations, such as "those who issue false VAT invoices shall be fined XX, and those with serious circumstances shall be held criminally liable".
[0165] Risk keywords refer to core terms related to tax and financial violations or risk scenarios that are identified and extracted from user query requests, such as "false invoicing," "failure to declare," "tax evasion," and "illegal deduction," which are used for matching queries in the risk warning sub-graph.
[0166] The risk warning information is an independent prompt generated based on the risk warning subgraph matching results. It includes information such as the associated risk clauses, consequences of violations, and basis for penalties, and is used to remind users of the financial and tax risks implied in their query requests.
[0167] When parsing user query requests, the above solution, in addition to extracting tax tags, key tax concepts, and structured fact elements, also utilizes the semantic understanding and risk identification capabilities of a large language model to analyze whether the query request contains implicit violations or risk scenarios: if the query request contains a clear description of a violation (such as "how to issue false VAT invoices to reduce taxes"), the corresponding violation keywords are directly extracted as risk keywords; if the query request does not explicitly mention a violation, but the described scenario may involve violation risks (such as "whether input tax can be deducted after obtaining a false invoice"), then keywords related to that risk scenario are extracted as risk keywords.
[0168] Then, based on the extracted risk keywords, a matching query is performed in the risk warning sub-graph to search for the existence of relevant risk clause nodes and / or penalty basis nodes. If a relevant node is matched, the corresponding risk clause content and penalty basis content are retrieved and compiled into independent risk warning information, including: risk scenario description, original text of relevant risk clauses, violation consequences warning, compliance suggestions, etc. The risk warning information is output together with the final regulatory search results to ensure that users can clearly distinguish between regulatory basis and risk warning.
[0169] The aforementioned solution proactively reminds users to avoid violations by identifying potential regulatory risks in user queries and generating risk alerts. It helps users understand relevant penalties, enhances their financial and tax compliance awareness and operational compliance, and prevents losses due to unintentional violations. Building upon traditional regulatory search functions, the addition of risk warning services enriches the search service by providing not only positive regulatory evidence but also negative risk warnings, offering users a more comprehensive and user-friendly solution.
[0170] In a second aspect, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in the first aspect of the present invention.
[0171] The computer-readable storage medium may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
[0172] The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD ROM); the magnetic surface memory may be a disk storage device or a magnetic tape storage device.
[0173] The volatile memory may be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synclink dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The computer-readable storage media described in the embodiments of the present invention are intended to include these and any other suitable types of memory.
[0174] like Figure 8 As shown, in a third aspect, the present invention provides an electronic device 10, including a processor 101 and a storage medium 102, wherein a computer program is stored on the storage medium, and the computer program, when executed by the processor, implements the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in the first aspect of the present invention.
[0175] In some embodiments, the processor may be implemented by software, hardware, firmware, or a combination thereof, and may use at least one of the following: circuit, single or multiple application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), central processing units (CPUs), controllers, microcontrollers, and microprocessors, thereby enabling the processor to execute some or all of the steps, or any combination thereof, of the regulatory retrieval methods based on knowledge graph multi-hop reasoning queries described in the various embodiments of this application.
[0176] Finally, it should be noted that although the above embodiments have been described in the text and drawings of this application, this should not limit the scope of patent protection of this application. Any technical solutions that are based on the essential concept of this application and utilize the content described in the text and drawings of this application, resulting in equivalent structural or procedural substitutions or modifications, as well as the direct or indirect application of the technical solutions of the above embodiments to other related technical fields, are all included within the scope of patent protection of this application.
Claims
1. A legal retrieval method based on knowledge graph multi-hop reasoning query, characterized in that, The method includes: Construct a financial and tax knowledge base, which includes a financial and tax knowledge graph and a vector database. The vector database is used to store document fragments that are segmented from legal texts and quantified. The system receives a query request input by the user, parses the query request, and extracts tax tags and key tax concepts from the query request. The tax tags are obtained by matching a large model and a pre-built database of keywords in the financial and tax field, and the key tax concepts are extracted by a named entity recognition model based on the large model. Based on the tax tag, the document fragments in the vector database are filtered, and the semantic similarity between the query request and the filtered document fragments is calculated through a hybrid retrieval method. The K document fragments with the highest semantic similarity are selected as the first candidate fragment set. Based on the legal provisions corresponding to the first candidate fragment set and their corresponding legal provisions nodes in the tax knowledge graph, a one-hop query is performed to obtain tax concept nodes directly associated with these legal provisions nodes, forming an initial extended concept set. The initial extended concept set is then filtered using key tax concepts extracted from the query request to obtain a filtered extended tax concept set. Starting with each tax concept node in the filtered extended tax concept set, a one-hop query is performed in the financial and tax knowledge graph to obtain the legal provisions nodes directly associated with these tax concept nodes. Based on these legal provisions nodes, the corresponding document fragments are obtained to form a second candidate fragment set. The first candidate fragment set and the second candidate fragment set are merged to form a relevant legal candidate set. Based on preset multi-dimensional features, document fragments in the relevant regulatory candidate set are sorted and filtered to generate structured final search results. The multi-dimensional features include the level of regulatory effectiveness, publication time, and semantic similarity between the document fragments and the query request.
2. The legal retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, The generated structured final search results include: The top-ranked candidate document fragments are input into the large language model along with the query request, so that the large language model can perform relevance discrimination, redundancy removal and information summary generation on the input candidate fragments according to the query request, and output structured search results.
3. The legal retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, The construction of the financial and tax knowledge base includes: The full text of financial and tax regulations is preprocessed to obtain document fragments. The preprocessing includes text cleaning, paragraph division, and fragment segmentation. Based on the document fragment, by combining rules and models, legal provisions entities and tax concept entities are extracted, and the first association between the legal provisions entities and tax concept entities and the second association between the legal provisions entities to which the tax concept entities belong are identified. Using the legal provisions and tax concepts as nodes, and the first or second association as edges, the financial and tax knowledge graph is constructed. The document fragments are vectorized and encoded using a pre-trained semantic vector model, and the vectorized document fragments and their metadata are stored in the vector database. The metadata includes the relevant law, the level of effectiveness, and the publication time.
4. The legal retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, The calculation of semantic similarity between the query request and the filtered document fragments using a hybrid retrieval method includes: Calculate the cosine similarity between the semantic vector of the query request and the semantic vectors of each filtered document fragment to obtain the first similarity score; Based on the frequency and location information of the tax tag in the document fragment, keyword matching degree is calculated to obtain a second similarity score; Based on preset weighting coefficients, the first similarity score and the second similarity score are weighted and fused to obtain a comprehensive semantic similarity score.
5. The regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, After obtaining the filtered and expanded set of tax concepts, the following steps are also included: The tax concept nodes in the filtered extended tax concept set are prioritized and sorted. The priority sorting is determined based on the type of association between the tax concept node and the corresponding legal provision node in the first candidate fragment set. Specifically, this includes: identifying the relationship edges connecting the legal provision node and the tax concept node in the tax knowledge graph; if the relationship edge is a specific relationship representing the change of legal validity, the corresponding tax concept node is assigned a high priority; if the relationship edge is another type, the corresponding tax concept node is assigned a normal priority lower than the high priority. The step of performing a one-hop query in the tax knowledge graph, starting from each tax concept node in the filtered extended tax concept set, includes: prioritizing the execution of the one-hop query from the tax concept node with the highest priority, based on the priority sorting.
6. The legal retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, The legal provisions nodes in the tax knowledge graph are associated with a structured list of requirements, which describes the legal conditions that must be met to apply the legal provisions. The method includes: When extracting tax tags and key tax concepts from the query request, a list of structured fact elements is also extracted from the query request. After forming the relevant legal candidate set, for each legal provision node in the relevant legal candidate set, a requirement-element matching calculation is performed, specifically including: comparing the structured requirement list associated with the legal provision node with the structured fact element list extracted from the query request, and calculating a matching score; When sorting and filtering document fragments in a candidate set of relevant regulations based on preset multi-dimensional features, the multi-dimensional features also include the matching score.
7. The legal retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, The legal provisions nodes in the tax knowledge graph are associated with historical version nodes and revision summary information corresponding to the legal provisions nodes, forming a legal evolution chain; After generating the structured final search results, the following steps are also included: For the legal provisions involved in the final search results, if there are related historical version nodes in the financial and tax knowledge graph, then based on the legal evolution chain, the key revision summary between the current version of the legal provision and the historical version is extracted, and evolution prompt information is generated and attached to the legal provision.
8. The regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in claim 1, characterized in that, The tax knowledge graph also includes a risk warning subgraph, which contains the following risk nodes connected by relationships: risk nodes representing violations, risk clause nodes representing prohibitive or obligatory clauses, and penalty basis nodes representing corresponding penalties. When parsing a query request, a large language model is used to identify any violations or risk scenarios hidden in the query request and extract them as risk keywords. The method further includes: Based on the risk keywords, a matching query is performed in the risk warning subgraph. If a relevant risk clause node and / or penalty basis node is matched, the corresponding legal text fragment is obtained, an independent risk warning message is generated, and the risk warning message is output together with the final search result.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in any one of claims 1 to 8.
10. An electronic device having a computer program stored thereon, characterized in that, The system includes a processor and a storage medium, wherein a computer program is stored on the storage medium, and the computer program, when executed by the processor, implements the regulatory retrieval method based on knowledge graph multi-hop reasoning query as described in any one of claims 1 to 8.