A multi-level secure RAG retrieval method, system, device and storage medium

By constructing a dynamic searchable subspace during the vector retrieval phase and employing a hybrid retrieval method based on user security level and business scope, the problems of data leakage and inefficiency in the RAG system are solved, achieving data isolation and efficient retrieval in security management.

CN122087872APending Publication Date: 2026-05-26THINKING CHAIN (TIANJIN) INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202610543478.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-23
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing RAG systems suffer from high data leakage risks and low efficiency in security management scenarios. Current technologies have failed to effectively address the risks of data exposure during the retrieval phase and the dynamic matching of access control with business scope.

Method used

By moving access control and business scope control from post-retrieval filtering to before vector retrieval, a dynamic searchable subspace is constructed. Using user security level and business scope, mixed retrieval commands are executed in the vector database, and vector data that does not meet the permissions are pruned, enabling vector similarity calculation to be performed within the dynamic subspace.

Benefits of technology

It achieves data isolation during the retrieval process, eliminates the risk of high-security data leakage in memory, significantly improves retrieval efficiency and response speed, and meets the compliance requirements of a multi-level security system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122087872A_ABST
    Figure CN122087872A_ABST
Patent Text Reader

Abstract

This invention belongs to the interdisciplinary field of artificial intelligence and information security, and provides a multi-level secure RAG retrieval method, system, device, and storage medium to address the risk of leakage of security management data during the retrieval process. The method includes acquiring user-input query content, user security level, and user business scope; converting the user security level and user business scope into scalar filtering conditions recognizable by a vector database; executing a hybrid retrieval instruction in the vector database, wherein the hybrid retrieval instruction includes a query vector and the scalar filtering conditions, to prune vector data that does not meet permissions during the indexing scan phase; calculating the similarity between the query vector and the remaining document vectors based on the pruned logical subspace, and returning the retrieval results. This invention is applicable to RAG systems in a multi-level data hierarchical isolation environment and can reduce the risk of leakage of security management data during the retrieval process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of interdisciplinary technology of artificial intelligence and information security, and in particular to a multi-level secure RAG retrieval method, system, device and storage medium. Background Technology

[0002] The core challenge in applying large-scale models to security management scenarios is the high risk of data leakage. Existing RAG (Retrieval-augmented Generation) systems generally employ a "post-retrieval filtering" mechanism. In the retrieval phase, the system searches the entire vector library for all potentially relevant documents (including high-security-level data) and loads them into memory. In the filtering phase, the search results are further filtered based on user permissions (e.g., removing high-security-level content). The drawbacks are the risk of data leakage, as high-security-level data is exposed in memory during the retrieval phase, potentially leading to malicious exploitation (e.g., memory dump attacks) or accidental leakage, and inefficiency, as retrieving the entire dataset increases computational overhead and results in high response latency.

[0003] Existing patents only focus on "post-content generation review" (such as filtering generated results, which can lead to model hallucinations due to knowledge chain gaps), without addressing the underlying retrieval mechanism. Their technical solutions suffer from logical inconsistencies: relying on "post-process filtering" fails to prevent data exposure during the retrieval stage; and the problem of "dynamic matching of security level and business scope" remains unresolved, resulting in inaccurate filtering (e.g., a user with a "level three" security level can access "level two" data). Summary of the Invention

[0004] This invention provides a multi-level secure RAG retrieval method, system, device, and storage medium to address the risk of data leakage during the retrieval process for secure management data.

[0005] In a first aspect, the present invention provides a multi-level secure RAG retrieval method, comprising: Obtain the query content entered by the user, as well as the user's security level and the user's business scope; Convert user security level and user business scope into scalar filtering conditions that can be recognized by the vector database; A hybrid retrieval instruction is executed in the vector database, the hybrid retrieval instruction containing query vectors and scalar filtering conditions, in order to prune vector data that does not meet the permissions during the index scanning phase; Based on the pruned logical subspace, the similarity between the query vector and the remaining document vectors is calculated, and the retrieval results are returned.

[0006] Furthermore, the method also includes: Based on the knowledge document storage rules, the document security level and document business scope are defined and then vectorized for storage, resulting in a vector database.

[0007] Furthermore, the step of defining document security levels and document business scope for vectorized storage according to knowledge document storage rules includes: Verify that the document's security level is a valid integer value, and verify that the document's business scope belongs to a predefined set. Reject non-compliant documents from entering the database and record audit logs.

[0008] Furthermore, the process of converting user security levels and user business scope into scalar filtering conditions recognizable by the vector database includes: Dynamic filtering conditions are calculated based on user security level and user business scope, document security level and document business scope. Specifically, the dynamic filtering conditions are: document security level >= user security level and the intersection of document business scope and user business scope is not empty. The dynamic filtering conditions are embedded as metadata filtering expressions into the retrieval execution plan of the vector database.

[0009] Furthermore, the method also includes: When a document permission update is detected, a two-phase commit or version number-based optimistic locking mechanism is initiated to block query requests related to the document or invalidate the query cache before the metadata update transaction in the vector database is committed. For queries that are already in progress, the document permission version number is compared with the snapshot version number in the query context. If they do not match, the result is discarded and a retry is triggered.

[0010] Furthermore, the method also includes: By employing a vector database that supports hybrid retrieval, the search scope is limited through subspace indexes, and vectors that do not meet the permissions are ignored, thus achieving approximate nearest neighbor retrieval within the subspace.

[0011] Furthermore, the method also includes: Based on the search results, a large model is used to generate enhanced search results, which are then output.

[0012] Secondly, the present invention provides a multi-level secure RAG retrieval system for implementing the multi-level secure RAG retrieval method described above.

[0013] Thirdly, the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the multi-level secure RAG retrieval method as described above.

[0014] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the multi-level secure RAG retrieval method described above.

[0015] The above-described technical solution of the present invention has the following advantages: The multi-level secure RAG retrieval method provided in the first aspect of this invention moves access control and business scope control from "post-retrieval filtering" to "pre-vector retrieval," constructing a dynamic "searchable subspace" to achieve data isolation during the retrieval process. Based on user security levels (e.g., level 1, 2, 3) and business scopes (e.g., technical, financial, human resources), the vector database is filtered in real time, allowing users to access only subsets matching their permissions and business scope. By dynamically constructing the "searchable subspace," the access control mechanism is moved forward to the vector retrieval stage, fundamentally solving the problem of the risk of leakage of secure management data during the retrieval process.

[0016] It is understood that the beneficial effects of the second, third and fourth aspects mentioned above can be found in the relevant descriptions in the first aspect above, and will not be repeated here. Attached Figure Description

[0017] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 A flowchart of a multi-level secure RAG retrieval method provided in an embodiment of the present invention. Detailed Implementation

[0019] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.

[0020] It should be understood that, when used in this specification, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0021] Furthermore, in the description of this invention, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance.

[0022] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of the invention include a particular feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized. "A plurality" means "two or more."

[0023] This invention relates to a secure retrieval method for Large Language Models (LLM) in security management scenarios (such as industrial sectors, functional departments, and fintech), particularly applicable to RAG systems in multi-level data hierarchical isolation environments. This invention moves access control and business scope control from "post-retrieval filtering" to "pre-vector retrieval," constructing a dynamic "searchable subspace" to achieve data isolation during the retrieval process. Based on user security levels (e.g., Level 1, 2, 3) and business scopes (e.g., technical, financial, human resources), the vector database is filtered in real time, allowing users to access only subsets matching their permissions and business scope. By dynamically constructing the "searchable subspace," the access control mechanism is moved forward to the vector retrieval stage, fundamentally solving the problem of data leakage risks during security management retrieval.

[0024] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.

[0025] This invention provides a multi-level secure RAG retrieval method, comprising the following steps: obtaining the query content input by the user, as well as the user's security level and business scope; converting the user's security level and business scope into scalar filtering conditions recognizable by a vector database; executing a hybrid retrieval instruction in the vector database, wherein the hybrid retrieval instruction includes a query vector and the scalar filtering conditions, to prune vector data that does not meet permissions during the index scanning stage; calculating the similarity between the query vector and the remaining document vectors based on the pruned logical subspace, and returning the retrieval results.

[0026] like Figure 1The diagram shows a flowchart of a multi-level secure RAG retrieval method provided by an embodiment of the present invention. The core of this invention lies in sinking access control down to the retrieval operator layer of the vector database, generating a subspace index that matches user permissions. Specifically, in the vector database, a scalar-vector hybrid retrieval technique is used to transform user security levels and business scope into scalar filtering expressions. The scalar filtering expressions and the vector similarity calculation of the query vector are executed in parallel. During the database index scanning phase, data blocks that do not meet permissions are pruned, thereby logically forming a dynamic, searchable subspace containing only authorized data.

[0027] By employing a hybrid retrieval mechanism, the retrieval process cannot access unauthorized data at the physical level, achieving isolation during the retrieval process and avoiding the waste of computing power caused by full-scale retrieval. Access control and business scope control are moved from "post-retrieval filtering" to "pre-vector retrieval," constructing a dynamic "retrievalable subspace" to achieve data isolation during the retrieval process.

[0028] Technical essence: Based on the user's security level (such as level 1, 2, 3) and the user's business scope (such as technology, finance, human resources, etc.), the vector database is filtered in real time, allowing users to access only a subset that matches their permissions and business scope.

[0029] Fundamental Advantages: It fundamentally prevents high-security-level data from being exposed in memory, eliminating the root cause of leaks. Logical Closed Loop: User input → Acquisition of user security level and user business scope → Dynamic subspace construction → Secure retrieval → Return of unfiltered results, with no logical gaps; High Approval Rate: The solution focuses on underlying mechanism innovation, not content post-processing, meeting the "substantive characteristics" requirement of patent examination.

[0030] In some embodiments, the method further includes: defining document security levels and document business scope according to knowledge document entry rules, and then vectorizing the documents for entry into the database to obtain a vector database.

[0031] In some embodiments, the step of defining document security level and document business scope for vectorized entry into the knowledge document database according to the knowledge document entry rules includes: verifying whether the document security level is a valid integer value, verifying whether the document business scope belongs to a predefined set, rejecting non-compliant documents from entering the database, and recording audit logs.

[0032] In some embodiments, converting user security level and user business scope into scalar filtering conditions recognizable by the vector database includes: calculating dynamic filtering conditions based on user security level and user business scope, document security level and document business scope, wherein the dynamic filtering conditions are specifically: document security level >= user security level and the intersection of document business scope and user business scope is not empty; and embedding the dynamic filtering conditions as metadata filtering expressions into the retrieval execution plan of the vector database.

[0033] In some embodiments, the method further includes: when a document permission update is detected, initiating a two-phase commit or a version number-based optimistic locking mechanism to block query requests related to the document or invalidate the query cache before the metadata update transaction in the vector database is committed; for query tasks that are already being executed, the document permission version number is compared with the snapshot version number in the query context, and if they are inconsistent, the result is discarded and a retry is triggered.

[0034] In some embodiments, the method further includes: employing a vector database that supports hybrid retrieval, limiting the retrieval scope through a subspace index, ignoring vectors that do not meet the permissions, and achieving approximate nearest neighbor retrieval within the subspace.

[0035] In some embodiments, the method further includes: performing retrieval enhancement generation using a large model based on the retrieval results, and outputting retrieval enhancement generation results.

[0036] Compared with existing technologies, this invention achieves significant improvements in several key dimensions. Firstly, in terms of data leakage risk, existing technologies use a "post-retrieval filtering" mechanism, which results in high-security data being loaded into memory during the retrieval stage, posing a high risk of leakage. In contrast, this invention reduces the risk of data leakage to zero by constructing a dynamic searchable subspace before vector retrieval, thus isolating unauthorized data from the source.

[0037] In terms of retrieval efficiency, existing technologies require searching the entire vector library, resulting in long response times; this invention performs retrieval only within a subset of user-permitted data, significantly reducing computational load and improving response speed.

[0038] Regarding compliance support, existing solutions rely on post-event filtering, which is insufficient to meet mandatory regulations such as hierarchical management. This invention embeds hierarchical control into the retrieval process, naturally conforming to the requirements of a multi-level security system. In terms of feasibility for implementation in security management scenarios, existing technologies are often excluded due to security flaws, while this invention directly addresses the core pain point of customers—data hierarchical isolation—laying a solid foundation for large-scale platform deployment.

[0039] This invention also provides a multi-level secure RAG retrieval system for implementing the multi-level secure RAG retrieval method described above.

[0040] I. Key Explanations: 1. Encoding Rules: Security levels are represented by numerical values, with smaller values ​​indicating higher security levels. Specifically: Level 1 = 0, Level 2 = 1, Level 3 = 2. Users can only access documents that meet the condition user_level <= doc_level, ensuring that content with higher security levels (i.e., smaller numerical values) cannot be read.

[0041] 2. Permission Acquisition: The system obtains the user's security level (e.g., user_level=Level 3) and business scope (e.g., user_scope={Technical}) in real time.

[0042] 3. Scalar Filtering + Vector Retrieval: Dynamically filter the vector library based on user_level and user_scope (only retaining those where user_level <= doc_level and doc_scope ∩ user_scope ≠ doc_level). (Document).

[0043] • user_level <= doc_level explanation (1) The document's security level value is less than or equal to the user's security level value. (2) Users do not have permission to access documents with a higher security level than themselves. Example: User: Level 2 (user_level = 1) Document A: Level 3 (doc_level = 2) → Accessible from 1 <= 2 Document B: Level 1 (doc_level = 0) → 1 <= 0 Inaccessible ·doc_scope ∩ user_scope ≠ explain (1) doc_scope This represents the set of business scopes that a document is authorized to cover.

[0044] For example, a document about aviation radar technology has doc_scope = {"technology", "aviation", "electronics"}.

[0045] (2) user_scope This represents the set of business scopes that the current user is authorized to access.

[0046] For example, an engineer's permissions are user_scope = {"technology", "aviation"}.

[0047] (3) ∩ (intersection) Set operators represent elements that are common to two sets.

[0048] The result of doc_scope ∩ user_scope is the business scope that is included in both collections.

[0049] (4) ≠ (Not equal to the empty set) : indicates an empty set (without any elements).

[0050] ≠ This means that the intersection contains at least one common element, i.e., there is overlap.

[0051] Summary of meaning: The business scope of this document and the user's business scope have at least one common area.

[0052] 4. Retrieval security: Vector retrieval operations only operate on subspaces, and the full data is never put into memory.

[0053] 5. No logical gaps: From user input to result return, every step is based on real-time permissions, with no redundant or assumed steps.

[0054] II. Key Module Technical Logic: Module 1: Metadata Standardization Processing. Based on the system's functional definitions, knowledge document entry rules are defined, and document security levels and business scopes are defined for vectorized entry into the database. This ensures semantic consistency of knowledge base permissions across the entire system and avoids security policy retrieval failures caused by arbitrary definitions.

[0055] Technical Logic: Input: Original document and its security level / business scope tags; ·deal with: (1) Verify whether the security level is a valid integer value; (2) Verify whether the business scope belongs to a predefined set (such as {"Aerospace", "Finance"}); (3) Refuse to include non-compliant documents in the database and record them in the audit log; Output: Standardized metadata for use in vector indexing.

[0056] Technical effect: Ensures semantic consistency of permissions across the entire system, and prevents security policies from failing due to free text.

[0057] Module 2: User Security Level and Business Scope Management Module.

[0058] Technical Logic: • Input: User ID (e.g., U1001).

[0059] • Processing: Read user attributes from a permissions database (such as an RBAC model): • user_level: Security level (0=Level 1, 1=Level 2, 2=Level 3).

[0060] • user_scope: A list of business scopes (e.g., ["technology", "aerospace"]).

[0061] • Output: Structured permission data, used as input for subspace construction.

[0062] Technical effect: Dynamic permission binding avoids permission mismatch caused by static configuration.

[0063] Module 3: Dynamically searchable subspace construction module.

[0064] Technical Logic: Input: User permissions (user_level, user_scope) + vector database metadata (document security level, business scope).

[0065] ·deal with: 1. Expression Construction: Based on the user's security level (user_level) and business scope (user_scope), construct a scalar filtering condition expression (expr). The logic is as follows: expr = (doc_level ≥ user_level) ∧ (doc_scope ∩ user_scope ≠ ) 2. Hybrid retrieval execution: The query vector Q and the scalar expression expr are sent together to the vector database engine. Specifically, the search interface of the vector database is called, and expr is embedded into the filtering conditions of the query parameters. When performing an approximate nearest neighbor (ANN) search, the database engine (such as Milvus or Elasticsearch) first uses a scalar index (such as an inverted index) to filter out data segments that satisfy expr, and then only performs distance calculations and traversals on the vectors in these data segments.

[0066] 3. Index pruning: For vector data shards or storage nodes that do not meet the expr conditions, the engine skips their vector loading and calculation process, thereby logically limiting the search scope to a restricted subspace that meets the permissions.

[0067] Compared to the traditional "full database search + application layer filtering", this step directly blocks the memory loading of high-security data at the database level, fundamentally eliminating the risk of data leakage caused by memory dumps, while significantly reducing the number of vectors involved in similarity calculation and improving retrieval throughput.

[0068] When a document permission update request conflicts with an ongoing retrieval task, the system applies a distributed exclusive lock (e.g., based on Redis RedLock: the system generates a unique lock key for each document ID whose permissions need updating (e.g., lock:doc_12345), sets TTL=5s, and uses the RedLock algorithm to acquire the lock from a majority of nodes; if the lock is not released within the timeout period, a background task forcibly cleans it up) at the application layer to block all newly initiated query requests involving that document. For queries already in progress, the system compares the document permission version number with the snapshot version number in the query context; if they do not match, the result is discarded and a retry is triggered. After the permission metadata is successfully written to the vector database and the index is refreshed, the system releases the lock, allowing subsequent retrievals to be based on the latest permissions.

[0069] • Output: Subspace index (e.g., [V_A, V_C]), for use by the retrieval module.

[0070] Technical effects: • Dynamism: Subspaces are generated in real time for each query, avoiding the rigidity of permissions caused by predefined subspaces (e.g., no need to rebuild the database when the user's business scope changes).

[0071] • Accuracy: Dual-dimensional filtering based on security level and business scope solves the problem of "security level matching but business mismatch" (e.g., a user with a technical security level accessing personnel data).

[0072] • If the vector database used does not support scalar filtering, it can be implemented in the following way: (1) Maintain a mapping table between document IDs and permission tags at the application layer. (2) First, filter out the set of document IDs that are allowed to be accessed based on user permissions. (3) Use the set of IDs as a filter condition to construct a searchable subspace for vector retrieval.

[0073] Module 4: Vector Retrieval Module.

[0074] Technical Logic: Input: Query vector Q + subspace index.

[0075] • Processing: Employing a vector database that supports hybrid retrieval (such as Milvus, Elasticsearch, etc.), the search scope is pre-defined through metadata filtering conditions (tag index) during retrieval. The engine ignores vectors that do not meet the permissions during the index scanning phase, achieving approximate nearest neighbor (ANN) retrieval within the logical subspace. This method does not require physical copying of vector data, has extremely low memory overhead, and its retrieval efficiency is sublinearly related to the subspace size. The similarity between Q and the vector is calculated within the subspace, and the Top-k results are returned.

[0076] Output: Secure search results (e.g., document A), no secondary filtering required.

[0077] Technical effects: • Source security: The search scope is limited to subspaces, and the full amount of data is never loaded, completely eliminating the risk of memory leaks.

[0078] • Efficiency improvement: The size of the subspace is much smaller than the full database (e.g., 1 million documents in the database, but only 100,000 in the subspace), resulting in a 50%+ improvement in retrieval speed.

[0079] Module 5: Permission Change Monitoring and Update Module Input: RBAC permission center change event (user / document permission update); ·deal with: (1) Parse the event subject (user ID / document ID); (2) Clear all subspace identifiers related to the subject in the local cache and generate a new version number for the subject; (3) For a query that is being executed, the system checks whether the current permission version number is consistent with the one at the beginning of the query before returning the result. If they are inconsistent, the result is discarded and a re-query is triggered. (4) Concurrency control: When a document permission update request is detected, the system applies a distributed exclusive lock (such as the RedLock algorithm based on Redis) to the relevant document ID at the application layer or database proxy layer to block concurrent retrieval requests and ensure mutual exclusion between read and write; (5) Version consistency verification: For long search tasks that are already in execution, the system adopts the multi-version concurrency control (MVCC) mechanism; when the search task starts, it records the snapshot version number of the current permission metadata; when the search task returns the results, it compares the latest version number of the current database with the snapshot version number; if the version numbers are inconsistent, it means that the permissions have changed during the search process, and the system will discard the search results and trigger the retry mechanism to prevent the return of expired or unauthorized data.

[0080] Logical explanation: The above mechanism solves the data consistency problem between metadata updates and real-time retrieval in the vector database, and ensures the strong consistency of the security isolation mechanism.

[0081] • Output: Triggers subsequent queries to rebuild the subspace, ensuring strong consistency. A version number mechanism ensures that query results are consistent with the latest permissions, preventing dirty reads.

[0082] • Permission update complete: The vector database has acknowledged receiving and persisted the updated document permission metadata, and its internal index structure reflects this change. This can be achieved through any of the following methods: (1) Call the synchronous refresh interface of the vector database (such as Milvus's `flush(collection_name)`) and wait for the return success; (2) Use the version number or timestamp mechanism provided by the vector database to ensure that subsequent queries use a snapshot of a version no lower than that; (3) Introduce a double buffering mechanism at the application layer: Before the new permissions take effect, retain the old permission view until the new index is loaded.

[0083] The following is a detailed description through specific embodiments. It should be noted that the user data involved in this embodiment is authorized, and its acquisition, processing, and transmission comply with legal and regulatory requirements, and necessary confidentiality measures have been taken.

[0084] Example: A certain intelligent question-answering system In practice, the scope of business can be expanded to support tag trees or role hierarchies, dictionaries, etc., and the matching logic can be adjusted to containment or inheritance relationships to adapt to more complex organizational structures.

[0085] 1. User A (security level = 2, business scope = {"aviation", "aerospace"}) submitted a query for "parameters of a certain type of radar"; 2. The system calls module 1 to obtain its permission information; 3. Module 2 iterates through the vector library metadata, filtering out those with 2 ≤ doc_level and doc_scope ∩ {"aviation","aerospace"} ≠ The document; 4. Construct a subspace (containing only 8,720 documents, instead of the full database of 1 million documents); 5. Module 3 performs an ANN search within the subspace and returns the Top-3 results; 6. Dynamic permission update handling: (1) If user A is transferred to the "Energy" department the next day, the RBAC system will issue a change event; (2) When module 4 detects an event, it clears its historical subspace cache; (3) New queries will build subspaces based on new permissions (business scope = {"energy"}), and old documents will be automatically invisible.

[0086] 7. Vector library compatibility: In vector libraries that only support ID filtering (such as the early FAISS), the system first obtains the list of document IDs that the user can access through the permission service, and then passes the list as a whitelist to the retrieval module to achieve equivalent dynamic subspace filtering.

[0087] Technical verification Operating environment: Hardware configuration includes an Intel Xeon Gold 6248 CPU @ 2.5GHz (40 cores), 256GB RAM, and an NVIDIA V100 GPU; software environment includes Kylin V8, Python 3.8, and Milvus 2.2 (vector database); vector dimension is 1024, total document count is 1 million, business scope tags are 20 categories, and security level distribution is Level 1 10%, Level 2 30%, and Level 3 60%. The comparison solution is a traditional "post-retrieval filtering" RAG system, using similar hardware and vector library.

[0088] 1. Security Test: Simulating 1,000 unauthorized queries, the leakage rate of this solution was 0%, while the leakage rate of the comparison solution was 16.3%. 2. Efficiency test: With 1 million documents, the average latency is 50ms (compared to 118ms), and the peak memory usage is 0.8GB (compared to 2.1GB). 3. Scalability: The latency growth is sublinear at document scales of 100,000 / 500,000 / 1,000,000, proving that the solution is scalable.

[0089] This invention proposes a mechanism-level innovative multi-level secure RAG retrieval method. By moving access control forward to the vector retrieval stage, it dynamically constructs a searchable subspace based on user security level and business scope, fundamentally eliminating the risk of memory exposure of high-security data during the retrieval process. The technical solution is logically rigorous and modularly clear, achieving a secure closed loop of "retrieval as isolation," while possessing zero leakage risk, high retrieval efficiency, and strong compliance adaptability. Verification shows that this method maintains millisecond-level response even with millions of documents, significantly outperforming existing "post-retrieval filtering" solutions.

[0090] This invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the multi-level secure RAG retrieval method provided in the first aspect.

[0091] In applications, terminal devices may include, but are not limited to, processors and memory. These are merely examples of terminal devices and do not constitute a limitation on them. They may include more or fewer components, combinations of certain components, or different components, such as input / output devices and network access devices. Input / output devices may include cameras, audio capture / playback devices, displays, etc. Network access devices may include network modules for wireless network communication with external devices.

[0092] In applications, the processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0093] In applications, the memory may be an internal storage unit of the terminal device in some embodiments, such as the hard drive or RAM of the terminal device. In other embodiments, the memory may be an external storage device of the terminal device, such as a plug-in hard drive, a smart media card (SMC), or a flash card. The memory may also include both internal and external storage units of the terminal device. The memory is used to store the operating system, applications, boot loader, data, and other programs, such as the program code of a computer program. The memory can also be used to temporarily store data that has been output or will be output.

[0094] This invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described method embodiments.

[0095] The present invention implements all or part of the processes in the methods of the above embodiments by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, such as a USB flash drive, a portable hard drive, a magnetic disk, or an optical disk.

[0096] Those skilled in the art will recognize that the device and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0097] In the embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be through some interfaces, or indirect couplings or communication connections between devices, and may be electrical, mechanical, or other forms.

[0098] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A multi-level secure RAG retrieval method, characterized in that, include: Obtain the query content entered by the user, as well as the user's security level and the user's business scope; Convert user security level and user business scope into scalar filtering conditions that can be recognized by vector database; A hybrid retrieval instruction is executed in the vector database, the hybrid retrieval instruction including the query vector and the scalar filtering conditions, so as to prune vector data that does not meet the permissions during the index scanning phase; Based on the pruned logical subspace, the similarity between the query vector and the remaining document vectors is calculated, and the retrieval results are returned.

2. The multi-level secure RAG retrieval method as described in claim 1, characterized in that, The method further includes: Based on the knowledge document storage rules, the document security level and document business scope are defined and then vectorized for storage, resulting in a vector database.

3. The multi-level secure RAG retrieval method as described in claim 2, characterized in that, The step of vectorizing and storing documents according to the knowledge document storage rules, defining document security levels and document business scope, includes: Verify that the document's security level is a valid integer value, and verify that the document's business scope belongs to a predefined set. Reject non-compliant documents from entering the database and record audit logs.

4. The multi-level secure RAG retrieval method as described in claim 1, characterized in that, The process of converting user security levels and user business scope into scalar filtering conditions recognizable by the vector database includes: Dynamic filtering conditions are calculated based on the user's security level and user's business scope, and the document's security level and document's business scope. Specifically, the dynamic filtering conditions are: document security level >= user security level and the intersection of document's business scope and user's business scope is not empty. The dynamic filtering conditions are embedded as metadata filtering expressions into the retrieval execution plan of the vector database.

5. The multi-level secure RAG retrieval method as described in claim 1, characterized in that, The method further includes: When a document permission update is detected, a two-phase commit or version number-based optimistic locking mechanism is initiated to block query requests related to the document or invalidate the query cache before the metadata update transaction in the vector database is committed. For queries that are already in progress, the document permission version number is compared with the snapshot version number in the query context. If they do not match, the result is discarded and a retry is triggered.

6. The multi-level secure RAG retrieval method as described in claim 1, characterized in that, The method further includes: By employing a vector database that supports hybrid retrieval, the search scope is limited through subspace indexes, and vectors that do not meet the permissions are ignored, thus achieving approximate nearest neighbor retrieval within the subspace.

7. The multi-level secure RAG retrieval method as described in claim 1, characterized in that, The method further includes: Based on the search results, a large model is used to perform search enhancement generation, and the search enhancement generation results are output.

8. A multi-level secure RAG retrieval system, characterized in that, Used to implement the multi-level secure RAG retrieval method as described in any one of claims 1 to 7.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the multi-level secure RAG retrieval method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the multi-level secure RAG retrieval method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data security document generation method and system based on RAG technology

    CN119475436A

  • Dynamic hierarchical encryption system for multi-tenant e-commerce data

    CN120915508A

  • Retrieval enhancement generation method and device based on data grading and classification management and control

    CN121030775A

  • Data retrieval method, system and equipment

    CN121542401A