Method and system for improving RAG recall rate and accuracy based on block global correlation

By constructing a global association network between blocks and quantifying the structural value of blocks in the knowledge system, combined with a dynamic fusion retrieval mechanism, the limitations of traditional RAG in core knowledge recall, redundancy suppression, and logical completeness are solved, thereby improving the recall and accuracy of RAG.

CN121833868AInactive Publication Date: 2026-04-10SHANDONG XIEHE UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-04-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing RAG technology suffers from problems such as insufficient recall of core knowledge, redundant information crowding out resources, lack of coverage of long-tail and pivotal knowledge, and noise block interference affecting the quality of generation in complex or highly specialized knowledge bases, resulting in answers lacking necessary logical support and accuracy.

Method used

By constructing a global association network between blocks, combining explicit and implicit relationships, calculating a global relevance score, and dynamically fusing query similarity, the final answer is generated.

Benefits of technology

It significantly improves the recall rate of key concepts, reduces redundant information, supplements necessary contextual information, enhances the logic and accuracy of answers, and balances the practicality and scalability of large-scale knowledge bases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833868A_ABST
    Figure CN121833868A_ABST
Patent Text Reader

Abstract

The invention provides a method and system for improving RAG recall rate and accuracy based on block global relevance, and the method comprises the steps: detecting a newly-added document through timing scheduling, carrying out block processing, and fusing an explicit structure relation and an implicit semantic relation to construct a weighted adjacency matrix; block global correlation scores are calculated through an iterative algorithm; the query similarity and the global correlation score are dynamically fused, and Top-K blocks are returned to generate answers; the system comprises a knowledge block graph construction server, a global correlation calculation server, a fusion retrieval server and a data storage server. According to the method, the limitation that traditional RAG only depends on local similarity is broken through, the core knowledge recall rate is remarkably increased, redundant noise is restrained, and the accuracy and logicality of generated answers are improved by quantifying the global importance of the blocks in the knowledge network.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of artificial intelligence and natural language processing, and particularly relates to a method and system for improving recall rate and accuracy rate of RAG based on block global correlation. BACKGROUND

[0002] Retrieval Augmented Generation (RAG) technology has been widely applied in intelligent question answering, professional information query and content generation by combining the retrieval results of external knowledge base with generative large models. Its typical process includes document blocking cutting, blocking vectorization, similarity retrieval and answer generation. This architecture alleviates the deficiencies of large models in factual accuracy, domain expertise and timeliness to some extent.

[0003] However, when facing complex or professional knowledge bases, the existing RAG technology still has obvious limitations: the retrieval link generally relies on local similarity calculation between query and single block, without fully considering the structural position and global correlation of blocks in the overall knowledge network. This leads to the following problems in actual operation:

[0004] Insufficient recall of core knowledge: Some blocks that carry basic concepts, principles or frameworks, although essential for understanding derived problems, are easily ignored in local similarity sorting due to low direct lexical overlap with the query, resulting in a lack of necessary logical support for generated answers.

[0005] Redundant information occupies effective resources: Multiple semantically highly overlapping blocks often appear in retrieval results. Although these "similar block clusters" have high similarity with the query, the information increment is limited, and they occupy limited resources, making it difficult for other key blocks to enter, affecting the depth and breadth of the answer.

[0006] Missing coverage of long-tail and hub knowledge: Some "hub blocks" that play a bridge or background role in the knowledge system have low direct similarity with the query, and traditional retrieval easily excludes them, resulting in a lack of necessary context and correlation analysis in the answer, reducing the user's overall understanding of the information.

[0007] Noise blocks interfere with generation quality: Some blocks contain keywords highly matched with the query, but the actual semantic correlation is weak, which can easily be mistaken for high relevance in sorting, thus introducing content inconsistent with the intent, increasing the risk of generation errors or deviation from the topic.

[0008] In summary, the retrieval decision of the existing RAG relies too much on a single local similarity index, and fails to consider the global knowledge value of the blocks, cross-theme association and structural weight, thus it is difficult to balance accurate matching and knowledge integrity in complex knowledge scenarios, resulting in low core knowledge recall rate, high redundancy information proportion, and insufficient answer logic and accuracy.

[0009] Therefore, there is an urgent need for a method and system for improving RAG recall rate and accuracy based on block global correlation. SUMMARY

[0010] To overcome the above technical defects, the purpose of the present application is to provide a method and system for improving RAG recall rate and accuracy based on block global correlation, aiming to solve the technical problems of low core knowledge recall rate, high redundancy and inaccurate answers caused by traditional RAG relying only on local similarity retrieval.

[0011] To achieve the above purpose, in a first aspect, the present application provides a method for improving RAG recall rate and accuracy based on block global correlation, comprising the following steps:

[0012] S1, knowledge block graph construction and update: detect new documents by timing scheduling, and perform block processing on the documents; construct explicit relationship weight between blocks based on document structure, and calculate implicit semantic similarity between blocks by embedding model; fuse the two types of relationships according to the preset explicit weight coefficient, generate a weighted adjacency matrix and store it in a graph database;

[0013] S2, global correlation score calculation: load the adjacency matrix from the graph database, generate the transition probability matrix through column normalization; initialize the block score vector, and iteratively calculate based on the damping factor until convergence, and then normalize the result, generate the normalized global correlation score and store it in the Key-Value database;

[0014] S3, fusion retrieval and answer generation: after vectorizing the user query, calculate the similarity score with all blocks; dynamically fuse the query similarity and the global correlation score, return the Top-K blocks in descending order of fusion score to the external RAG system, and generate the final answer by the external RAG system.

[0015] As a further improvement of the above scheme, in step S1, the method for constructing and updating the knowledge block graph is as follows:

[0016] S11, determine whether there are new documents; if yes, cut each document according to semantic boundaries (such as chapters, paragraphs or sentences) to output a block set C={C1, C2,..., C n}, and update the global correlation score at the same time; if not, wait for the next scheduling;

[0017] S12. For the set of blocks C, determine whether each block belongs to a structured document. If it is not a structured document, only implicit relation construction is performed; if it is a structured document, explicit relation construction is performed simultaneously with implicit relation construction. The explicit and implicit relations are then merged to form a weighted adjacency matrix M of n blocks. n×n ;

[0018] S13. Divide the adjacency matrix M of the blocks. n×n Store in the graph database.

[0019] As a further improvement to the above scheme, in step S12, the weighted adjacency matrix M n×n The individual elements are shown below:

[0020] M ij =a×W e (i,j)+(1-a)×W i (i,j);

[0021] Among them, M ij The weighted adjacency matrix M n×n The element in the i-th row and j-th column represents block C. i and C j The weight of the fusion relationship;

[0022] 'a' is the weighting coefficient for explicit relationships; 'a' > 0.5 is used to enhance the influence of explicit relationships.

[0023] W e (i,j) represents the block C. i and C j The explicit relationship weights between them are determined based on document heading level, references, or hyperlink structure;

[0024] (1-a) represents the weighting coefficient of the implicit relationship;

[0025] W i (i,j) represents the block C. i and C j Implicit semantic similarity weights between them.

[0026] As a further improvement to the above scheme, the steps for obtaining implicit semantic similarity weights are as follows:

[0027] For each block, an embedding model (such as BERT) is applied to vectorize it, resulting in a vector for each block:

[0028] Vec(C i =Embedding(C i The implicit semantic similarity weights are obtained by calculating the similarity between the block vectors as shown below:

[0029] W i (i,j)=sim(Vec(C i ),Vec(C j ));

[0030] Where sim(·) is a similarity calculation function, Vec(C i ) is the vector representation of the block C i , and Vec(C j ) is the vector representation of the block C j ; the similarity algorithm is selected as cosine similarity (text length insensitive) or dot product similarity (reflecting vector length information), and the cosine similarity is used by default.

[0031] As a further improvement of the above scheme, the specific steps of the global correlation score calculation in step S2 are as follows:

[0032] S21, first load the adjacency matrix M n×n from the graph database, normalize the columns of M n×n to construct the transition probability matrix T n×n :

[0033] ;

[0034] S22, then initialize the global correlation score of each block to S (0) =[1 / n,1 / n,...,1 / n] T ;

[0035] S23, then execute the score iteration algorithm, the specific execution formula is as follows:

[0036] ;

[0037] Where d is the damping factor, taking the value of 0.85, used to avoid infinite circulation of scores between isolated nodes and ensure model convergence; the iteration number k is greater than a certain value (such as 50) or the Euclidean norm (square root of the sum of the differences of the vector elements): ;

[0038] S24, finally output the normalized global correlation score S g (C i )=S(C i ) / max(S), and store it to the Key-Value database, such as Redis or Etcd, etc., Key is the block number C i , and Value corresponds to the normalized global correlation score S g of the block.

[0039] As a further improvement of the above scheme, in step S3, the steps of fusion retrieval and answer generation are as shown below:

[0040] S31, the user inputs a query sentence q, and the query sentence q is converted into a query vector Q by an embedding model;

[0041] S32, the query similarity score S between the query vector Q and each block vector is calculated q (C i ):

[0042] S q (C i )=sim(Q,C i );

[0043] S33, dynamically fuse the query similarity and the global relevance score, and obtain the final fusion score S i (C final ) of each block C i according to the following formula:

[0044] S final (C i )=α S q (C i )+β S g (C i );

[0045] Wherein, α and β are weights, α+β=1, β ≥ 0.3, to ensure that the global relevance score accounts for not less than 30% weight in retrieval, and to enhance recall;

[0046] S34, return Top-K blocks in descending order according to the final fusion score S final of each block;

[0047] S35, the large model generates a final answer based on the query sentence q and the Top-K blocks.

[0048] In a second aspect, the present application also provides a system for implementing the method provided in the first aspect, comprising:

[0049] A knowledge block graph construction server, on which a knowledge block graph construction unit is deployed, for performing document blocking, relationship construction and fusion storage;

[0050] A global relevance calculation server, on which a block global relevance calculation unit is deployed, for iteratively calculating block global relevance scores;

[0051] A fusion retrieval server, on which a fusion retrieval unit is deployed, for processing queries and returning Top-K blocks;

[0052] A data storage server, on which a data storage unit is deployed, is used to store the adjacency matrix and the global correlation score.

[0053] As a further improvement of the above scheme, the knowledge block graph construction unit comprises a timing scheduling module, a document block module, an explicit relationship construction module, an implicit relationship construction module and a relationship fusion module, and supports an incremental update mechanism.

[0054] As a further improvement of the above scheme, the data storage server adopts a hybrid architecture of a graph database and a Key-Value database, the graph database stores the weighted adjacency matrix, and the Key-Value database stores the normalized global correlation score.

[0055] As a further improvement of the above scheme, the system supports distributed cluster deployment, and realizes high-concurrency and elastic expansion through multiple servers.

[0056] In a third aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to realize the method for improving the recall rate and accuracy rate of RAG based on block global correlation provided in the first aspect.

[0057] In a fourth aspect, the present application further provides an electronic device, which comprises a processor and a memory, and the memory stores a computer program, and the processor executes the program to realize the method for improving the recall rate and accuracy rate of RAG based on block global correlation provided in the first aspect.

[0058] Due to the above technical scheme, the present application has the following beneficial effects:

[0059] The present application provides a method for improving the recall rate and accuracy rate of RAG based on block global correlation, which constructs a global association network between blocks and quantifies the structural value of blocks in the knowledge system, combines a dynamic fusion retrieval mechanism, maintains retrieval efficiency, effectively solves the limitations of traditional RAG in core knowledge recall, redundancy suppression and logical completeness, and provides more reliable technical support for professional field knowledge question and answer.

[0060] Specifically embodied in the following aspects:

[0061] Firstly, the explicit and implicit relationship fusion model constructed by step S1 and the global relevance score calculated by step S2 based on iterative calculation can identify the blocks with pivotal role in the knowledge network, such as term definition and principle description. In the fusion retrieval of step S3, even if the direct similarity of such blocks with the query is low, the global importance score can still improve its ranking position through the weighted fusion mechanism, thereby effectively solving the problem of missing core knowledge caused by the limitation of local similarity in traditional RAG, and significantly improving the recall rate of key concepts.

[0062] Secondly, the global relevance score calculated by step S2 has a weight reduction effect on semantically overlapping blocks, reducing the redundancy information from occupying the Top-K positions; at the same time, it has a filtering effect on noise blocks with high keyword matching degree but content isolation (such as irrelevant data tables). Through the dynamic fusion of step S3, the weight of redundant and noisy blocks is reduced in the retrieval stage, optimizing the block quality input to the large model, thereby reducing the information repetition and theme deviation in the generated answer.

[0063] Thirdly, the knowledge block graph constructed based on step S1 can capture the cross-theme association between blocks, making the global relevance score of step S2 more inclined to give higher weight to summary and background blocks. In the retrieval process of step S3, such blocks are preferentially recalled to supplement necessary context information and logical chain for the answer, improving the one-sidedness of the answer caused by the neglect of long-tail knowledge in traditional RAG, and improving the completeness and persuasiveness of the generated content.

[0064] In addition, step S1 supports incremental update through the timing scheduling mechanism, avoiding the full reconstruction overhead when the knowledge base is expanded; the score calculation of step S2 can be performed offline and is not coupled with real-time retrieval; step S3 uses Key-Value database to store global scores, ensuring the retrieval response efficiency in high concurrency scenarios. With such settings, the recall quality is improved while considering the practicality and scalability of large-scale knowledge base. BRIEF DESCRIPTION OF DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, brief introductions to the drawings needed in the embodiments or prior art descriptions will be given below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor based on the drawings shown.

[0066] Figure 1 A flowchart of a method for improving RAG recall rate and accuracy rate based on block global relevance according to the embodiment 1 of the present application is disclosed.

[0067] Figure 2Flowchart of the process of knowledge block graph construction and update disclosed in Embodiment 1 of the present application;

[0068] Figure 3 Flowchart of the process of global correlation score calculation disclosed in Embodiment 1 of the present application;

[0069] Figure 4 Flowchart of the process of fusion retrieval and answer generation disclosed in Embodiment 1 of the present application;

[0070] Figure 5 Deployment schematic diagram of a system for improving RAG recall rate and accuracy rate based on block global correlation disclosed in Embodiment 2 of the present application;

[0071] Figure 6 Specific structure schematic diagram of a system for improving RAG recall rate and accuracy rate based on block global correlation disclosed in Embodiment 2 of the present application.

[0072] The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION

[0073] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0074] It should be noted that the technical solutions of the various embodiments of the present application can be combined with each other, but it must be based on the fact that they can be realized by those of ordinary skill in the art. When the combination of technical solutions appears to be contradictory or unachievable, it should be considered that the combination of technical solutions does not exist and is not within the protection scope of the present application.

[0075] Embodiment 1

[0076] Referring to Figures 1-4 The present application provides a method for improving RAG recall rate and accuracy rate based on block global correlation, and the steps thereof include:

[0077] S1, knowledge block graph construction and update:

[0078] This step solves the problem of ignoring the global correlation of blocks in traditional RAG by constructing a semantic association network between blocks. In specific implementation:

[0079] First, a scheduled module (e.g., every morning) automatically detects new documents. These new documents are then segmented based on semantic boundaries (e.g., paragraphs, chapters) to form a set of segments. The segmentation granularity needs to balance retrieval efficiency and semantic integrity, typically based on logical themes.

[0080] Next, explicit relation weights are constructed based on document structure features: for documents with a clear hierarchical structure (such as technical manuals and academic papers), weights are assigned according to the title hierarchy; for example, the weight between a chapter title and a sub-paragraph is set as the inverse of the hierarchy depth. Simultaneously, block vectors are calculated using a pre-trained embedding model (such as Sentence-BERT), and implicit semantic relation weights are calculated using cosine similarity.

[0081] Then, the two types of relationships are merged to ensure the dominant role of structured knowledge. Finally, the weighted adjacency matrix is ​​stored in a graph database such as Neo4j.

[0082] This step constructs a global relational network among blocks by integrating explicit and implicit relationships, laying the foundation for subsequent quantification of block importance.

[0083] S2, Calculation of global correlation score:

[0084] This step uses an iterative algorithm to quantify the pivotal role of segments in the knowledge network, addressing the problem of core knowledge being missed due to low local similarity. In specific implementation:

[0085] S21. First, load the adjacency matrix M from the graph database. n×n , for M n×n Construct the transition probability matrix T by performing column normalization. n×n :

[0086] ;

[0087] S22. Then initialize the global relevance score of each block to S. (0) =[1 / n,1 / n,...,1 / n] T ;

[0088] S23. Then execute the fractional iteration algorithm, the specific execution formula is as follows:

[0089] ;

[0090] Where d is the damping factor, with a value of 0.85, used to prevent scores from looping infinitely between isolated nodes and ensure model convergence; the number of iterations k is greater than a certain set value (e.g., 50) or the Euclidean norm (the square root of the sum of squares of the differences between vector elements). ;

[0091] S24, finally output the normalized global correlation score S g (C i )=S(C i ) / max(S), and stored to a Key-Value database, for example: Redis or Etcd, etc., the Key is the block number C i , and the Value corresponds to the normalized global correlation score S g of the block.

[0092] This step quantifies the global importance of the block to ensure that the block with pivotal role (such as definition, principle description) can be effectively identified, providing basis for subsequent fusion retrieval.

[0093] S3, fusion retrieval and answer generation

[0094] This step balances local similarity and global importance through dynamic fusion mechanism, solving the problems of redundancy interference and long-tail knowledge coverage deficiency. In specific implementation:

[0095] First, the user query is vectorized through the same embedding model, and the cosine similarity S q (C i ) between the user query and each block is calculated. Then, the fusion is performed according to the formula S final (C i )=α S q (C i )+β S g (C i ), where α+β=1, β ≥ 0.3, to ensure that the global correlation score occupies appropriate weight.

[0096] Top-K blocks (usually K=5-10) are selected in descending order of fusion score and passed to the external RAG system, and the external RAG system generates the final answer based on these blocks.

[0097] This embodiment combines the above three steps organically, and in the test of the financial knowledge base, for the query "LPR interest rate adjustment on housing loans", successfully recalls the core block "LPR mechanism definition" that is easily overlooked by traditional RAG, while suppressing redundant blocks of repeated case descriptions, and the accuracy of the generated answer is improved.

[0098] The present application constructs a global correlation network between blocks and quantifies the structural value of the blocks in the knowledge system, combines a dynamic fusion retrieval mechanism, and on the basis of maintaining retrieval efficiency, systematically solves the limitations of traditional RAG in core knowledge recall, redundancy suppression and logical completeness, providing more reliable technical support for professional field knowledge question answering.

[0099] Specifically embodied in the following several aspects:

[0100] Firstly, the explicit and implicit relationship fusion model constructed by step S1, and the global relevance score based on iterative calculation in step S2, can identify the blocks with pivotal role in the knowledge network, such as term definition and principle description. In the fusion retrieval of step S3, even if the direct similarity of such blocks with the query is low, their global importance score can still be improved in the ranking position through the weighted fusion mechanism, thereby effectively solving the problem of missing core knowledge caused by the limitation of local similarity in traditional RAG, and significantly improving the recall rate of key concepts.

[0101] Secondly, the global relevance score calculated in step S2 has a weight reduction effect on semantically overlapping blocks, reducing the redundant information from occupying the Top-K positions; at the same time, it has a filtering effect on noise blocks with high keyword matching degree but content isolation (such as irrelevant data tables). Through the dynamic fusion of step S3, the weight of redundant and noise blocks is reduced in the retrieval stage, optimizing the block quality input to the large model, thereby reducing the phenomenon of information repetition and theme deviation in the generated answer.

[0102] Thirdly, the knowledge block graph constructed based on step S1 can capture the cross-theme association between blocks, making the global relevance score of step S2 more inclined to give higher weight to summary and background blocks. In the retrieval process of step S3, such blocks are preferentially recalled to supplement necessary context information and logical chain for the answer, improving the one-sidedness of the answer caused by the neglect of long-tail knowledge in traditional RAG, and improving the completeness and persuasiveness of the generated content.

[0103] In addition, step S1 supports incremental update through the timing scheduling mechanism, avoiding the full reconstruction overhead when the knowledge base is expanded; the score calculation of step S2 can be performed offline and is not coupled with real-time retrieval; step S3 uses Key-Value database to store global scores, ensuring the retrieval response efficiency in high concurrency scenarios. Such settings, while improving the recall quality, also take into account the practicality and scalability of large-scale knowledge bases.

[0104] As a preferred embodiment, in step S1, the steps of knowledge block graph construction and update are as follows:

[0105] S11, document block and update judgment:

[0106] This step ensures the timeliness of knowledge base expansion through incremental update mechanism. In implementation: the timing scheduling module (such as crontab task) triggers at a fixed time every day to detect whether there are new documents in the document storage directory. When detecting new PDF, Word and other format documents, the document blocking process is started. The blocking process is based on the semantic boundaries of the document: for technical documents, the content between paragraphs is merged into one block according to the chapter division; for structured documents such as contract terms, the clauses are cut. The size of the block is usually controlled within 200-500 words to balance the semantic integrity and retrieval efficiency. After the blocking is completed, a block set C = {C1, C2,..., C n} is generated, and the subsequent global correlation score update process is triggered. If there are no new documents, the system remains in standby state until the next scheduling.

[0107] This embodiment avoids the full reconstruction overhead of knowledge base expansion through periodic incremental update, ensuring the practicality and scalability of the system.

[0108] S12, relationship construction and matrix generation:

[0109] This step improves the recognition ability of core knowledge blocks by constructing a block association network by fusing multiple source relationships. The specific implementation includes:

[0110] For the block set C, it is judged whether each block belongs to a structured document. If it is not a structured document, only implicit relationship construction is performed; if it is a structured document, implicit relationship construction is performed at the same time, and explicit relationship construction is also performed.

[0111] During explicit relationship construction, for documents with clear hierarchical structure, such as technical manuals and academic papers, relationship weights are generated based on the title hierarchy. For example, the weight between the first-level title and the corresponding second-level title is set to 1, and the weight between the second-level title and the paragraph content is set to 0.5. At the same time, the reference link and hyperlink structure information in the document are used to supplement the association relationship.

[0112] During implicit relationship construction, a domain-adapted embedding model (such as FinBERT for the financial domain) is used to vectorize each block, and the cosine similarity between blocks is calculated as the implicit relationship weight. For blocks with large length difference, the sentence vector mean strategy is used to eliminate the text length bias.

[0113] The relationship fusion stage is according to the formula M ij = 0.7 · W e (i, j) + 0.3 · W i(i, j) to generate a weighted adjacency matrix, where the explicit relationship weight coefficient 0.7 ensures the dominance of structured knowledge. This weighting strategy has been experimentally verified to significantly improve the global relevance score of core clause blocks in financial regulation document tests.

[0114] S13, matrix storage and data management:

[0115] The generated adjacency matrix M n×n is stored in the Neo4j graph database, and the adjacency list structure is used to store the block nodes and relationship edges. Each edge record contains weight values, relationship types (explicit / implicit), and other metadata. To improve query efficiency, a hash index of block IDs is established in the graph database to support O(1) time complexity node queries.

[0116] As a preferred embodiment, to solve the retrieval bias problem caused by the traditional RAG system ignoring the global association of blocks, the explicit relationship and implicit relationship are fused by weighting to construct an adjacency matrix that can accurately reflect the global association between blocks. The implementation of the weighted adjacency matrix is as follows:

[0117] In terms of explicit relationship weight W e (i,j), for documents with a clear hierarchical structure, the weight value is determined according to the title level depth. For example, when block C i is a chapter title and block C j is a subordinate paragraph, the weight is set to W e (i,j)=1 / d, where d is the level depth, such as d=2 representing the relationship between a second-level title and a content paragraph. For blocks associated through references, if block C i cites the content of block C j , then set W e (ij)=0.8; for blocks associated by hyperlinks, the weight is set to

[0118] W e (i,j)=0.6. This explicit relationship weight calculation based on document structure can effectively capture the logical association in the knowledge system.

[0119] In terms of implicit semantic similarity weight W i (i,j), a domain data fine-tuned BERT model (such as FinBERT for the financial domain and BioBERT for the medical domain) is used for block vectorization. In specific implementation, each block text is input into the model to obtain a 768-dimensional vector corresponding to the [CLS] marker as the block representation Vec(C i ), the similarity between block vectors is calculated to obtain the implicit semantic similarity weight as follows:

[0120] W i (i,j)=sim(Vec(C i ),Vec(C j ));

[0121] Where sim(·) is a similarity calculation function, Vec(C i ) is the vector representation of the block C i , and Vec(C j ) is the vector representation of the block C j ; the similarity algorithm selects cosine similarity (text length insensitive) or dot product similarity (reflecting vector length information), and the cosine similarity is used by default.

[0122] The algorithm is insensitive to text length and can accurately capture semantic similarity. For scenarios that need to consider vector length information, dot product similarity can be used as an alternative.

[0123] After obtaining the two types of relationship weights, weighted fusion is performed according to the formula M ij =a×W e (i,j)+(1-a)×W i (i,j). The value of the weight coefficient a is determined through experiments, and in the preferred embodiment of the present application, a=0.7 is set. This value ensures that explicit relationships dominate in the fusion process while retaining a certain proportion of implicit semantic information as a supplement. Through a large number of experiments, it is verified that when a 0.5, the global relevance score of the core concept block can be effectively improved. In the test of financial regulation documents, the setting of a=0.7 significantly improves the retrieval ranking of core blocks such as "LPR mechanism definition", while avoiding semantic bias that may be caused by relying solely on structural relationships. Where M ij is the element in the ith row and jth column of the weighted adjacency matrix M n×n , representing the fusion relationship weight of the blocks C i and C j ; (1-a) is the weight coefficient of implicit relationships.

[0124] The present application effectively combines explicit and implicit relationships and has superior performance in knowledge base tests in multiple fields. In the medical knowledge base question and answer test, for the query of "diabetes drug treatment plan", the system successfully recalls the basic concept blocks such as "drug mechanism of action" that are easily overlooked by traditional RAG, effectively improving the accuracy of the answers. At the same time, due to the introduction of implicit semantic weights, the system can identify cross-chapter semantic associations and effectively improve the coverage of long-tail knowledge.

[0125] As a preferred embodiment, in step S3, the steps of fusion retrieval and answer generation are as follows:

[0126] S31, query vectorization processing:

[0127] After the user inputs the query sentence q, the same embedding model (such as Sentence-BERT) is used to generate the query vector Q as the block vectorization. In specific implementation, the query text is preprocessed, including removing special characters, unifying case, etc. to ensure that the vectorization process is consistent with the block processing. The dimension of the query vector Q is the same as the block vector, both of which are 768 dimensions, providing a basis for subsequent similarity calculation.

[0128] Through the unified embedding model, the comparability of the query and the block vector in the same semantic space is ensured, laying a technical foundation for accurate similarity calculation.

[0129] S32, query similarity calculation:

[0130] The similarity score S q (C i )=sim(Q,C i ) between the query vector Q and each block vector Vec(C i ) is calculated. The preferred embodiment adopts the cosine similarity algorithm:

[0131] ;

[0132] It is not sensitive to text length and can effectively capture semantic relevance. In actual deployment, through the batch calculation function of the vector database (such as FAISS), the similarity calculation of the whole library block can be completed in milliseconds.

[0133] S33, dynamic score fusion:

[0134] The dynamic fusion is performed according to the formula S final (C i )=α×S q (C i )+β×S g (C i ), where α+β=1, β ≥ 0.3. In the preferred scheme, α=0.6 and β=0.4. This weight distribution ensures that the global relevance score accounts for no less than 30% of the weight, effectively balancing the query matching degree and the importance of knowledge. In specific implementation, the pre-calculated global relevance score S g (C i ) is first read from the KV database such as Redis, and then linearly weighted with the real-time calculated query similarity S q (C i ). For professional queries such as definition queries containing terms, β can be adaptively adjusted to 0.5 to further strengthen the role of global relevance.

[0135] S34, Top-K chunk screening:

[0136] According to the fusion score S final Sort in descending order, and select Top-K chunks (usually K=5-10) as the retrieval result. In implementation, the maximum heap algorithm is used for optimized sorting, and the time complexity is O(nlogk), which ensures the retrieval efficiency in a large-scale chunk library. At the same time, a score threshold is set, such as 0.6, to filter chunks with low fusion scores and avoid noise interference.

[0137] S35, answer generation and output:

[0138] Input Top-K chunks and the original query q into a large language model such as GPT-4 or ChatGLM. The prompt word template is designed as: "Please answer the query: [query q] based on the following background knowledge: [chunk content 1] [chunk content 2]...[chunk content K]". The model generates the final answer based on the provided chunk content, effectively avoiding the illusion phenomenon.

[0139] In the test of the financial regulatory question and answer scene, for the query of "cross-border payment regulatory requirements", the traditional RAG easily missed "regulatory framework overview" and other basic chunks, while effectively suppressing redundant chunks of repeated case descriptions, improving the accuracy of the generated answer, and fully embodying the technical effects of the present application in improving the core knowledge recall rate and answer quality.

[0140] Embodiment 2

[0141] Referring to Figure 5 and Figure 6 , the present application also provides a system for implementing the method of Embodiment 1, which adopts a four-layer server architecture, and each server communicates through RESTful API. Specifically, it includes:

[0142] Knowledge chunk graph construction server, developed with Java Spring Boot framework, equipped with 16-core CPU and 32GB memory, and deployed with knowledge chunk graph construction unit for document chunking, relationship construction and fusion storage;

[0143] Global relevance calculation server, built based on Python Flask framework, deployed with chunk global relevance calculation unit for iterative calculation of chunk global relevance score, and optimized matrix operation efficiency through mathematical libraries such as NumPy;

[0144] The fusion retrieval server is developed by using Go language, supports real-time retrieval request by using high concurrency characteristics, and has a fusion retrieval unit deployed thereon, which is used for processing query and returning Top-K blocks.

[0145] The data storage server has a distributed database cluster deployed thereon, guarantees data reliability by master-slave replication, and has a data storage unit deployed thereon, which is used for storing an adjacency matrix and a global correlation score.

[0146] As a preferred embodiment, the knowledge block graph construction unit comprises:

[0147] The timing scheduling module is implemented based on a Quartz scheduling framework and is configured to automatically trigger a detection task at 2 a.m. every day. In specific implementation, the module monitors file system events of a specified document storage directory, compares file changes by MD5 verification, and generates a processing task and adds the processing task to a message queue when detecting a newly added or modified document. The module sets an exponential backoff retry mechanism, automatically retries a failed processing task after 1 hour, 3 hours and 6 hours, and ensures the reliability of data processing. This timing scheduling mechanism avoids manual intervention and realizes automatic incremental update of the knowledge base.

[0148] The document block module adopts a multi-level block strategy: first, based on document format analysis, recognizing style title levels of a Word document and analyzing layout of a PDF document; and then, performing block according to semantic integrity, merging processing of logically close contents between paragraphs, and controlling size of a single block to be within a range of 200-500 words. In implementation, an Apache Tika document analysis engine is integrated, and automatic recognition and analysis of more than ten kinds of document formats are supported. By setting a sliding window mechanism, cutting off of text in the middle of a sentence is avoided, and semantic integrity of block is ensured.

[0149] The explicit relationship construction module constructs explicit association between blocks based on document structure features. For technical documents, title level relationship is analyzed: weight between a first title and a second title is set to 1.0, and weight between the second title and a content paragraph is set to 0.7. For academic papers, association is established through reference citation relationship, and a block with high citation frequency obtains a higher weight. The module simultaneously recognizes hyperlink relationship in a document, and sets weight of an internal link to 0.6 and weight of an external reference link to 0.4. This explicit relationship construction based on document structure effectively retains inherent logical association of a knowledge system.

[0150] The implicit relationship construction module uses the Sentence-BERT model for block vectorization to generate a 768-dimensional semantic vector. The cosine similarity algorithm is selected for similarity calculation, and vector normalization processing is used for blocks with large length differences to eliminate bias. GPU acceleration is used for calculation during implementation, and the time consumption of a single block vectorization is controlled within 50 milliseconds. The module supports model hot updating, and when the domain knowledge changes, it can seamlessly switch to a new model to ensure the accuracy of semantic understanding.

[0151] The relationship fusion module fuses the weights of the two types of relationships according to the formula M ij = 0.7 · W e (i, j) + 0.3 · W i (i, j). Matrix operations are used for optimization during implementation, and block-by-block calculation is used for large-scale block sets to reduce memory usage. The module has a weight verification mechanism that automatically raises the implicit relationship weight to 0.5 when the explicit relationship weight is missing, ensuring the reliability of the fusion results. The fused adjacency matrix is stored in sparse matrix format, improving storage and calculation efficiency.

[0152] The incremental update mechanism uses version number management to achieve incremental updates. Each block records the last modification timestamp, and when the document is updated, only the changed blocks are recalculated for relationship weights, avoiding full reconstruction. The module maintains a change log to support version rollback and data consistency verification. In actual deployment, this mechanism improves the knowledge base update efficiency by about 70%, effectively supporting the application requirements of dynamic knowledge bases.

[0153] As a preferred embodiment, the data storage server uses the Neo4j graph database enterprise version, and adopts a master-slave replication architecture to ensure high reliability. In specific implementation, the weighted adjacency matrix M n×n is converted to a graph structure for storage: each block is a node, and the node attributes include block ID, content summary, creation time, etc. The relationship between blocks is an edge, and the edge attributes store the fusion weight value M ij , the relationship type (explicit / implicit), and the update timestamp.

[0154] To improve query efficiency, a B+ tree index of block IDs is established to support O(1) time complexity node queries; bidirectional edges are established for high-frequency access neighbor relationships to avoid full graph scanning during traversal queries; and an edge weight threshold is set to filter low-weight relationships and reduce storage overhead. In actual deployment, it supports millisecond-level queries of hundreds of billions of relationships, providing efficient data support for global correlation calculation.

[0155] The Key-Value database uses Redis cluster storage to store normalized global correlation scores S gThe distributed architecture with three masters and three slaves is adopted. In the implementation, the block ID is taken as the Key, the normalized score is taken as the Value, and the hash table structure is adopted for storage. The LRU cache eviction policy is set to retain the 100,000 most recently accessed records in the memory. Meanwhile, the AOF persistence mechanism is enabled to synchronize data to the disk every second, thereby ensuring data safety.

[0156] To ensure data consistency, the double-write verification mechanism is implemented: when the global correlation score is updated, the data is written into the Redis cluster and the backup database simultaneously, and the data integrity is verified through the checksum. The score version number is set to support historical score query and rollback operation. This design enables the score reading delay to be controlled within 1 millisecond, thereby effectively supporting the high-concurrency retrieval scenario.

[0157] The transaction mechanism is adopted to ensure data consistency between the two databases. When the knowledge block graph is updated, the adjacency matrix is first stored in the graph database, then the global correlation score is recalculated, and finally the new score is updated to the Key-Value database in batches. The two-phase commit protocol is implemented to ensure the atomic update of the two databases.

[0158] The data synchronization monitoring is set to detect the data state difference between the two databases in real time. When the inconsistency is detected, the data repair process is automatically triggered: the adjacency matrix is first reconstructed based on the graph database, then the global correlation score is recalculated, and finally the Key-Value database is synchronized. This mechanism ensures the data reliability of the system under abnormal conditions.

[0159] For large-scale data scenarios, the sharding storage strategy is implemented: the graph database is divided into multiple subgraphs according to the document field, and each subgraph is independently stored and queried; the Key-Value database adopts the consistent hashing sharding to uniformly distribute data to the cluster nodes. Meanwhile, the database connection is managed by setting the connection pool to avoid the overhead of frequent connection establishment.

[0160] Embodiment 3

[0161] The application further provides a computer readable storage medium having a computer program stored thereon, wherein the program controls the device where the storage medium is located to perform part or all of the steps in embodiment 1 when the program is running.

[0162] The computer readable storage medium can include a high-speed RAM memory and can also include a non-volatile memory (NVM), such as at least one disk memory. It can be understood that the storage medium can be a random access memory (RAM), a disk, a hard disk, a solid state disk (SSD), or a non-volatile memory, and the like various machine readable media that can store program codes.

[0163] Those skilled in the art will appreciate that embodiments of the application can be provided as a method or stored on a storage medium. Thus, embodiments of the application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment containing both software and hardware aspects. Furthermore, embodiments of the application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer-readable program code.

[0164] Embodiment 4

[0165] The application also provides an electronic device, comprising:

[0166] a memory having a computer program stored thereon;

[0167] a processor configured to load and execute the computer program to implement the method for improving recall and accuracy of RAG based on block global correlation as provided in Embodiment 1.

[0168] The processor can include one or more processing units, for example: the processor can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units can be independent devices or integrated into one or more processors.

[0169] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to instruction operation codes and timing signals to complete the control of fetching and executing instructions.

[0170] The memory can also be provided in the processor for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. The memory can save instructions or data that have just been used or are frequently used by the processor. If the processor needs to use the instructions or data again, the instructions or data can be directly called from the memory. This avoids repeated access and reduces the waiting time of the processor, thereby improving the efficiency of the system.

[0171] The above merely describes the preferred embodiments of the present application, and is not intended to limit the patent scope of the present application. Any equivalent structural changes made according to the content of the present application specification and drawings, or direct or indirect application in other related technical fields are within the patent protection scope of the present application.

Claims

1. A method for improving the recall and precision of RAG based on block-based global relevance, characterized in that, The steps include: S1. Knowledge Block Graph Construction and Update: New documents are detected through timed scheduling, and documents are divided into blocks; explicit relation weights between blocks are constructed based on the document structure, and implicit semantic similarity between blocks is calculated through an embedding model; the two types of relations are fused according to preset explicit weight coefficients to generate a weighted adjacency matrix and store it in the graph database. S2. Global Relevance Score Calculation: Load the adjacency matrix from the graph database, generate the transition probability matrix after column normalization; initialize the block score vector, iterate the calculation based on the damping factor until convergence, normalize the result, generate the normalized global relevance score and store it in the Key-Value database. S3. Fusion Retrieval and Answer Generation: After vectorizing the user query, calculate the similarity score with all blocks; dynamically fuse the query similarity and global relevance scores, and return the Top-K blocks to the external RAG system in descending order of the fusion score. The external RAG system generates the final answer.

2. The method for improving RAG recall and precision based on block-based global relevance as described in claim 1, characterized in that, In step S1, the steps for constructing and updating the knowledge block graph are as follows: S11. Determine if there are any new documents; if so, segment each document according to semantic boundaries and output a set of chunks C={C1,C2,...,C...} n At the same time, update the global relevance score; if not, wait for the next scheduling. S12. For the set of blocks C, determine whether each block belongs to a structured document. If it is not a structured document, only implicit relation construction is performed; if it is a structured document, explicit relation construction is performed simultaneously with implicit relation construction. The explicit and implicit relations are then merged to form a weighted adjacency matrix M of n blocks. n×n ; S13. Divide the adjacency matrix M of the blocks. n×n Store in the graph database.

3. The method for improving RAG recall and precision based on block-based global relevance according to claim 2, characterized in that, In step S12, the weighted adjacency matrix M n×n The individual elements are shown below: M ij =a×W e (i,j)+(1-a)×W i (i,j); Among them, M ij The weighted adjacency matrix M n×n The element in the i-th row and j-th column represents block C. i and C j The fusion relationship weight; 'a' is the weight coefficient of the explicit relationship; W e (i,j) represents the block C. i and C j The explicit relation weights between them; (1-a) is the implicit relation weight coefficient; W i (i,j) represents the block C. i and C j Implicit semantic similarity weights between them.

4. The method for improving RAG recall and precision based on block-based global relevance according to claim 3, characterized in that, The steps to obtain implicit semantic similarity weights are as follows: Vectorize each block using an embedding model to obtain a vector for each block, Vec(C) i =Embedding(C i The implicit semantic similarity weights are obtained by calculating the similarity between the block vectors as shown below: W i (i,j)=sim(Vec(C i ),Vec(C j )); Where sim(·) is the similarity calculation function, and Vec(C i ) is a block C i Vector representation, Vec(C) j ) is a block C j The vector representation of .

5. The method for improving RAG recall and precision based on block-based global relevance according to claim 3, characterized in that, In step S2, the specific steps for calculating the global relevance score are as follows: S21. First, load the adjacency matrix M from the graph database. n×n , for M n×n Construct the transition probability matrix T by performing column normalization. n×n : ; S22. Then initialize the global relevance score of each block to S. (0) =[1 / n, 1 / n, ... , 1 / n] T ; S23. Then, perform fractional iterative calculations. The specific algorithm formula is shown below: ; Where d is the damping factor; k is the number of iterations; S24. Finally, output the normalized global correlation score S. g (C i )=S(C i ) / max(S), and store it in the Key-Value database.

6. A method for improving RAG recall and precision based on block-based global relevance according to any one of claims 1-3, characterized in that, In step S3, the steps for integrating retrieval and answer generation are as follows: S31. The user inputs a query q, and the query q is used to generate a query vector Q through an embedding model; S32. Calculate the query similarity score S for the query vector Q and each block vector. q (C i ): S q (C i )=sim(Q, C i ); S33. Dynamically fuse query similarity and global relevance scores, and obtain the C for each block according to the following formula. i The final fusion score S final (C i ): S final (C i )=a S q (C i )+b S g (C i ); Where α and β are weights, α+β=1, β≥0.3; S34, based on the final fusion score S of each block final Return the Top-K blocks in descending order; S35. The large model generates the final answer based on the query q and Top-K blocks.

7. A system employing the method for improving RAG recall and precision based on block-based global relevance as described in any one of claims 1-6, characterized in that, include: A knowledge block graph construction server, on which knowledge block graph construction units are deployed, is used to perform document segmentation, relationship construction and fusion storage; A global correlation calculation server, on which block-based global correlation calculation units are deployed for iterative calculation of block-based global correlation scores; A fusion retrieval server, on which fusion retrieval units are deployed, is used to process queries and return Top-K blocks; A data storage server, on which data storage units are deployed, is used to store the adjacency matrix and global correlation scores.

8. The system according to claim 7, characterized in that, The knowledge block graph construction unit includes a timed scheduling module, a document segmentation module, an explicit relationship construction module, an implicit relationship construction module, and a relationship fusion module, and supports an incremental update mechanism.

9. The system according to claim 7, characterized in that, The data storage server adopts a hybrid architecture of graph database and key-value database. The graph database is used to store the weighted adjacency matrix, and the key-value database is used to store the normalized global relevance score.

10. 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 method for improving RAG recall and accuracy based on block global relevance as described in any one of claims 1-6.