Dynamic retrieval budget control methods, electronic devices, storage media and program products
By employing a dynamic retrieval budget control method, combined with terminal resources and privacy mode, low-latency, reliable question answering was achieved on mobile terminals. This solved the problems of high latency, privacy leakage, and evidence scope reuse on resource-constrained mobile terminals, and enabled resource-adaptive reliable question answering.
Patent Information
- Application Number
- CN202611344244.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-17
AI Technical Summary
Existing search enhancement generation methods suffer from high latency, high power consumption, privacy risks, superficial citations, reuse of evidence scope, and lack of joint resource mapping on resource-constrained mobile terminals, and lack a coupled closed loop for cross-layer linkage.
By using a dynamic retrieval budget control method, combined with terminal physical resource status, index physical health, risk level, and privacy mode for joint mapping, joint decision is output to achieve vector encoding, keyword document coarse screening, semantic retrieval, evidence scope management, and claim-by-claim verification, generating citation-based answers and recording retrieval diagnostic information.
On resource-constrained mobile terminals, low latency and reliable question answering are achieved, with auditable outbound and verifiable citations, resolving the technical contradiction between resource-adaptive retrieval performance and privacy credibility.
Smart Images

Figure CN123115385A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of retrieval technology, specifically to a dynamic retrieval budget control method, electronic device, storage medium, and program product. Background Technology
[0002] Retrieval augmentation generation refers to a technique that retrieves relevant fragments from an external dataset before the Large Language Model (MLM) generates an answer, and then injects these fragments as context into the model to constrain its answer. The general processing flow of retrieval augmentation generation is as follows: Documents are segmented into fragments (referred to as "chunks" in this paper); each chunk is converted into a high-dimensional vector using an embedding model (referred to as "vector embedding" in this paper), and stored in a vector library; during a query, the question is converted into a query vector, and candidate chunks are recalled using vector similarity (such as cosine similarity) or keyword retrieval (such as the BM25 word frequency ranking algorithm, a text retrieval ranking algorithm based on word frequency and inverse document frequency). Optionally, these chunks are re-ranked and then injected into the model to generate a cited answer.
[0003] On the desktop, known open-source desktop knowledge base software (such as Cherry Studio Desktop) has implemented: knowledge base import and indexing, embedded database index files stored in knowledge base partitions, retrieval based on keywords, vectors and hybrid retrieval (hybrid retrieval), and reciprocal rank fusion, reordering, persistent index task management and failure retries, and citations presented in numbered form. These desktop solutions run on personal computer environments with ample memory, continuous power supply, and computing power, typically performing a brute-force full cosine similarity comparison on the original single-precision floating-point vectors.
[0004] Existing search-enhanced generation methods for implementing trusted local knowledge base question answering on resource-constrained mobile devices still have the following problems: First, mobile terminals are limited by their memory, battery life, processor computing power, and local embedded database read / write capabilities. Performing full similarity comparisons on raw floating-point vectors requires reading and parsing massive amounts of vector text line by line from the database. This incurs significant reading and computational overhead with large corpora, leading to high retrieval latency, high power consumption, and UI lag. While existing binary quantization or integer quantization can compress vectors, for anisotropic embedding models where each dimension's value is far from zero, direct sign-based binary quantization causes many dimensions to fall under the same sign, resulting in a loss of discriminative power and a significant decrease in retrieval accuracy.
[0005] Second, user private data may be sent to cloud services during vectorization, reordering, and response generation, posing a risk of privacy leakage. Existing solutions are mostly coarse-grained "overall localization" or "overall outbound" solutions, lacking fine-grained layered control over outbound behavior and lacking a mechanism to generate auditable records without original plaintext.
[0006] Third, even with citations, the enhanced generation of ordinary search results still suffers from the problem of "superficial citations": the answer provides citation numbers, but the corresponding conclusions are not semantically supported by the cited evidence; existing mobile solutions lack the means to verify the "existence of citations" and even the "support of citations" for each high-risk conclusion after the answer is generated.
[0007] Fourth, in multi-round dialogues, the model tends to reuse references injected in the previous round, causing the current round's response to exceed the scope of evidence actually retrieved in the current round; existing solutions lack a mechanism to strictly isolate the scope of evidence in each round and not retain the original query plaintext within the scope of evidence.
[0008] Fifth, existing desktop and cloud solutions do not address the resource-constrained environment of mobile terminals by jointly mapping terminal physical resources, index physical health, query risks, and privacy constraints to retrieval budgets, evidence gates, and the strictness of per-claim verification, lacking a coupled closed loop of cross-layer linkage. Summary of the Invention
[0009] This invention provides a dynamic retrieval budget control method, electronic device, storage medium, and program product.
[0010] According to one aspect of the present invention, a dynamic retrieval budget control method is provided, comprising: S210: obtaining the current terminal physical resource status, index physical health, current query risk level, and currently set privacy mode of the terminal; S220: jointly mapping the terminal physical resource status, index physical health, risk level, and privacy mode, and outputting a joint decision, the joint decision including retrieval budget, evidence gate mode, assertion-by-claim verification strictness, and cloud outbound strategy; S230: determining whether the query information can be vector-encoded according to the cloud outbound strategy; if the query information can be vector-encoded, performing keyword document coarse screening based on the query information to obtain a keyword coarse screening document set; performing semantic retrieval based on document centroid based on the query vector obtained by vector encoding to obtain a centroid semantic channel candidate set; calculating the union of the keyword coarse screening document set and the centroid semantic channel candidate set as a candidate document set; within the candidate document set, searching for keyword candidate blocks based on the local full-text search index; and simultaneously, within the independent vector candidate space according to... The retrieval budget execution calibration low-bit two-stage vector recall is performed to obtain vector candidate blocks; the keyword candidate blocks are merged with the vector candidate blocks to obtain a candidate block set; when vector encoding of the query information is not possible, keyword document coarse screening is performed based on the query information to obtain a keyword coarse screening document set; within the keyword coarse screening document set, keyword candidate blocks are found based on the local full-text search index, and a candidate block set is constructed based on the keyword candidate blocks; S240: Based on the candidate block set and the evidence gate mode, an evidence range without the original query plaintext is established for the current round, and a citation-based answer is generated when the evidence range is not empty, and an insufficient evidence response or regression to normal dialogue is returned according to the evidence gate mode when the evidence range is empty; S250: For the citation-based answer generated when the evidence range is not empty, the conclusion support is verified according to the strictness of the statement verification; S260: The retrieval diagnosis information of the current round is recorded, the budget feedback information corresponding to the scan execution status is extracted from the retrieval diagnosis information, and the budget feedback information is fed back into the budget control of the next round of retrieval.
[0011] According to at least one embodiment of the dynamic retrieval budget control method of the present invention, before step S210, an index building stage is further included, in which the following index building method is executed: S110: receiving authorization from the user for a local folder via a storage access framework, registering the content identifier and permission status of the local folder, and creating a corresponding knowledge base; S120: scanning the list of the local folder to obtain a list of supported documents, and processing the list of supported documents in batches; S130: extracting local text from each supported document, and dividing the extracted text into multiple blocks according to preset rules, and attaching domain topic tags to each block; S140: based on the currently set privacy mode, the payload category of the block data, the risk level, and the local embedded backend... In the ready state, determine the network egress decision, which includes edge execution, permitted cloud execution, or blocking embedding route; S150: when the network egress decision is edge execution, call the edge embedding model to generate vector embeddings for each block; when the network egress decision is permitted cloud execution, call the cloud embedding model to generate vector embeddings for each block; when the network egress decision is blocking embedding route, stop generating vector embeddings; S160: write the generated vector embeddings to the local database and update the mean values of each dimension of the knowledge base incrementally; S170: generate a calibrated binary signature based on the mean values of each dimension of the corpus, and generate an integer re-scoring vector and document centroid, and write the calibrated binary signature, integer re-scoring vector, and document centroid to the local database.
[0012] According to at least one embodiment of the present invention, the dynamic retrieval budget control method, when jointly mapping the terminal physical resource status, index physical health, risk level, and privacy mode, is subject to at least one of the following invariant constraints: the retrieval budget of the low-end device's internal archive slot is not greater than the retrieval budget of the high-end device's internal archive slot; based on the retrieval budget, a throttling factor corresponding to the device temperature status and low battery flag is applied, and the reduced retrieval budget is not lower than the safety lower limit; when the risk level belongs to the high-risk area, the evidence gate mode adopts the hard gate mode; when the privacy mode is the strict local mode, the cloud outbound strategy adopts the blocking strategy; when the document centroid readiness ratio is greater than the ratio threshold, the coarse recall budget share allocated to the centroid routing channel is increased; otherwise, the coarse recall budget share allocated to the centroid routing channel is reduced; only when the device's internal archive slot is high-end and the risk level belongs to the high-risk area, the per-declaration verification strictness adopts the second level of verification; otherwise, the per-declaration verification strictness adopts the first level of verification; regardless of how the retrieval budget is reduced, the keyword channel recall result is always retained as the structured recall floor.
[0013] According to at least one embodiment of the present invention, a dynamic retrieval budget control method performs document centroid-based semantic retrieval based on a query vector obtained by vector encoding to obtain a centroid semantic channel candidate set, comprising: calculating the cosine similarity between the query vector and the centroids of each document with the same embedding spatial identifier in the current knowledge base of the local database; sorting the documents in descending order based on the cosine similarity; and selecting the top N documents to generate the centroid semantic channel candidate set; wherein... Indicates the number of documents.
[0014] According to at least one embodiment of the present invention, in the dynamic retrieval budget control method, in the two-stage vector recall of calibration low bits in an independent vector candidate space, the first stage includes: obtaining the calibration binary signature of each block under the current knowledge base, the same embedding space and the same calibration profile; The query vector is converted into a query calibration binary signature using the same calibration profile. The Hamming distance between the query calibration binary signature and the calibration binary signature of each block is calculated. Based on the row budget and timeout limit constraints in the retrieval budget, a preset number of blocks are selected in ascending order of Hamming distance to form a short list.
[0015] According to at least one embodiment of the present invention, in the dynamic retrieval budget control method, in the two-stage vector recall of low-bit calibration based on the retrieval budget within an independent vector candidate space, the second stage includes: obtaining the integer rescore vector of each block in the short list; calculating the cosine similarity between the query vector corresponding to the query information and the integer rescore vector, and sorting them in descending order of cosine similarity to obtain vector candidate blocks that satisfy the maximum number of blocks in the retrieval budget; and merging the vector candidate blocks with the keyword candidate blocks to obtain a set of candidate blocks.
[0016] According to at least one embodiment of the present invention, the dynamic retrieval budget control method performs conclusion support verification on the cited answers generated when the evidence range is not empty, based on the strictness of the statement verification. This includes: breaking down the answer into multiple conclusions according to the punctuation at the end of each sentence, and identifying the citation number in each conclusion; classifying each conclusion into high-risk or ordinary types based on risk level; and performing graded verification on the high-risk type conclusions according to the strictness of the statement verification: the first level verification is: determining whether the citation number exists in the citation set corresponding to the evidence range in the current round; if it does not exist, it is determined to be out of range; if there is no citation, it is determined to be unsupported; when the strictness of the statement verification output in step S220 is the second level, the second level verification is activated, and the second level verification is determined by the joint mapping result of the high-end device's internal archive location and the high-risk level; in the second level verification, for conclusions that have passed the first level verification, it is determined whether the cited evidence semantically implies the conclusion; if it is determined to be contradictory, the corresponding conclusion is determined to be conflicting; if the preset implication threshold is not reached, it is determined to be unsupported.
[0017] According to another aspect of the present invention, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, such that the processor performs a dynamic retrieval budget control method according to any embodiment of the present invention.
[0018] According to another aspect of the present invention, a readable storage medium is provided, wherein executable instructions are stored therein, which, when executed by a processor, are used to implement the dynamic retrieval budget control method of any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the dynamic retrieval budget control method of any embodiment of the present invention.
[0020] This invention can effectively resolve the technical contradiction between search performance and privacy credibility on resource-constrained mobile terminals, and realize low-latency, reliable question answering that is auditable when leaving the network, verifiable when cited, and adaptable to resources. Attached Figure Description
[0021] The accompanying drawings illustrate exemplary embodiments of the invention and, together with the description thereof, serve to explain the principles of the invention. These drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification.
[0022] Figure 1 This is a flowchart illustrating an index construction method according to an embodiment of the present invention.
[0023] Figure 2 This is a flowchart illustrating a retrieval question-answering method according to an embodiment of the present invention.
[0024] Figure 3 This is a schematic structural block diagram of an electronic device employing a processor-based hardware implementation according to an embodiment of the present invention. Detailed Implementation
[0025] The present invention will now be described in further detail with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present invention are shown in the accompanying drawings.
[0026] It should be noted that, unless otherwise specified, the embodiments and features described in this invention can be combined with each other. The technical solution of this invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0027] This invention proposes a dynamic retrieval budget control method. The execution of this method can be divided into two closely related stages in its lifecycle: an offline / background index building stage and an online retrieval question answering stage.
[0028] Before detailing the steps at each stage, the system architecture and underlying data structure of this invention will first be described. The system of this invention runs on a resource-constrained mobile terminal (such as a mobile phone) and does not rely on a necessary server. This invention stores data in a local database (an embedded relational database, such as SQLite) isolated according to knowledge base identifiers. The main data tables include: a knowledge base table (stores vector calibration data), a document table (stores document centroid vectors), a chunk table, an embedding table (stores binary signatures and integer recalculation vectors), a cluster centroid table and a chunk cluster affiliation table, and an index task table. The above data structure provides the underlying data support for the execution of subsequent steps. Vector comparison, corpus mean, and centroid aggregation are confined within the embedding space constituted by the same embedding model and vector dimensions.
[0029] Before the question-and-answer retrieval phase, the index building phase needs to be performed first. Figure 1 A flowchart illustrating the index construction method in the index construction stage of one embodiment of the present invention is shown. Figure 1 The method shown includes steps S110 to S170.
[0030] S110: Receive user authorization for local folders via the storage access framework, register the content identifier and permission status of local folders, and create the corresponding knowledge base.
[0031] This step does not copy the file in plaintext to outside the application's private directory, nor does it hardcode the file path to an absolute path on the local machine.
[0032] S120: Scan the list of local folders (without reading the full text) to obtain a list of supported documents, and process the list of supported documents in batches.
[0033] This step can avoid memory spikes caused by reading a large amount of text at once.
[0034] S130: Extract local text from each supported document and divide the extracted text into multiple blocks according to preset rules, and attach domain topic tags (such as medical) to each block.
[0035] As one possible implementation, in the local text extraction of each supported document, the marked text can be read directly, and the portable document format is extracted by the local text extraction module without being uploaded to the cloud.
[0036] As one possible implementation method, to avoid memory spikes and interface lag caused by reading and processing the entire large document at once on a mobile device, local text extraction adopts a segmented streaming approach: for portable document formats, extraction is performed in a loop using page windows (e.g., fifty pages); for marked text, it is divided into several segments based on character count, prioritizing segmentation at blank lines or line breaks.
[0037] Furthermore, the extracted text is segmented into multiple blocks according to preset rules, including structure-aware paragraph segments: a title path stack is maintained, and the title path is updated when a title is encountered, so that each block carries the hierarchical title path it belongs to; paragraphs are segmented by blank lines or title lines; and very long paragraphs are further segmented according to natural boundaries. Based on the document identifier, page number, paragraph number, and text content concatenated and a stable hash is obtained, deterministic and referable block identifiers are generated to support breakpoint resume and precise referencing.
[0038] Furthermore, after the extracted text is segmented into multiple blocks according to preset rules, the process includes constructing contextual retrieval text for each block: concatenating the document name, relative path, page number, current section title path, previous section title path, and next section title path with the original block text line by line, and limiting the total length. Vectorization and keyword retrieval both use this contextual retrieval text, allowing the blocks to carry their document and chapter structure information to improve recall. Citations and the final reference display still use the original block text to ensure the accuracy of the cited evidence.
[0039] S140: Based on the currently set privacy mode, the payload category of the chunked data, the risk level, and the readiness status of the local embedded backend, determine the network egress decision, which includes execution on the end side, execution on the cloud with permission, or embedded routing that is blocked.
[0040] This step aims to intercept and audit data for compliance before it leaves the terminal, thus protecting the privacy and security of users' private data from the source.
[0041] As one possible implementation, step S140 can be achieved through a privacy-layered state machine and a cloud-based outbound network guard. Specifically, the current data payload category is "chunk". The privacy-layered state machine outputs a network outbound decision based on the currently set privacy mode, the payload category of the chunked data, and the risk level (which can be the risk level of the domain) of the current chunk or its associated document. In one example, the privacy modes include strict local mode, cloud pre-verification mode (product default mode), and cloud-assisted mode. Data payload categories are divided into six types, including: query, chunk, summary, citation, conclusion, and diagnosis. The specific decision rules are as follows: (1) When the privacy mode is strict local mode, refuse to send any knowledge base data to the cloud and determine the network exit decision as a denial, thereby blocking data leakage from the cloud.
[0042] (2) When the privacy mode is cloud pre-confirmation mode, the user must explicitly confirm before sending any knowledge base data to the cloud, and the network exit decision is confirmed to require confirmation.
[0043] (3) When the privacy mode is cloud-assisted mode, if the risk level is high risk (i.e., it belongs to the preset high-risk area, such as medical, legal, financial, corporate confidentiality, personal privacy, etc.) and the payload category contains "block", then the network exit decision is determined to require confirmation. For other low-risk operations, the network exit decision is determined to be allowed.
[0044] The cloud-based outbound network guard intercepts and executes actions based on network egress decisions: When the network exit decision is to deny, the call to the cloud-embedded model is directly blocked.
[0045] When the network exit decision requires confirmation, if a confirmation pop-up has been registered, the pop-up will request the user to make explicit confirmation, and the call to the cloud-embedded model will only be allowed after the user explicitly agrees; if no confirmation pop-up has been registered or the user has not made confirmation, the call will be blocked and a record will be left.
[0046] If the network exit decision is allowed, the call to the cloud-embedded model is directly permitted.
[0047] Furthermore, the aforementioned decision-making process simultaneously generates a privacy-secure audit log. This audit log contains only the privacy mode, operation type, payload category, provider identifier, model identifier, risk level, irreversible query hash, and decision timestamp, deliberately excluding the original query plaintext, original chunked plaintext, complete prompts, and the Application Programming Interface Key. This ensures fine-grained control and auditability of outbound network activities while absolutely guaranteeing data privacy.
[0048] S150: When the network egress decision is to execute on the end side, the end-side embedding model is called to generate vector embeddings for each block; when the network egress decision is to execute on the cloud with permission, the cloud embedding model is called to generate vector embeddings for each block; when the network egress decision is to block the embedding route, vector embedding generation is stopped, and at this time the vector channel can be recorded as unavailable while the keyword channel is retained.
[0049] S160: Write the generated vector embeddings to the local database and update the average values of each dimension of the knowledge base incrementally.
[0050] Vector embeddings are written to the local database as an index. Simultaneously, for each vector embedding, the mean values of each dimension of the current knowledge base are updated incrementally. For example, the update formula for the mean values of each dimension of the corpus is:
[0051] Among them, Greek letters and These represent the numbers before and after the update, respectively. The mean of the corpus of dimensionality, Represents the new vector of the first generation. Dimension value, This represents the number of vectors before the update. Let the vector dimension be 1. Then the computational complexity of each block is... ,in It represents asymptotic complexity. It eliminates the need to backtrack through all historical data, perfectly adapting to the limited computing power and memory resources of mobile devices.
[0052] S170: Generate a calibrated binary signature based on the mean of the corpus in each dimension, and generate an integer rescore vector and document centroid. Write the calibrated binary signature, integer rescore vector and document centroid into the local database.
[0053] (1) Calibrate the generation of binary signatures.
[0054] Calibrated binary signatures can solve the problem of loss of discriminative power in traditional binary quantization under anisotropic embedding models.
[0055] Specifically, traditional ordinary symbolic quantization directly quantizes each dimension of a vector into one bit according to its sign, and the formula is as follows:
[0056] in, The signature of version one 3D quantization bits, Represents vector embedding. The value of the dimension.
[0057] However, for anisotropic embedding models where the values of each dimension are generally far from zero, the above method of directly taking the sign will cause a large number of dimensions to fall into the same bit (e.g., all 1s or all 0s), thus causing the vector to lose its discriminative power.
[0058] To overcome the above-mentioned shortcomings, this embodiment proposes a calibration binary signature: first, the average value of the corpus in each dimension of the knowledge base is used... Center the dimension and then determine its sign. The calculation formula is as follows:
[0059] in, This indicates the signature of version two. Dimensional quantization bits, Greek letters Indicates the knowledge base number The mean of the corpus of dimensionality.
[0060] Through the above centering process, each dimension regains its discriminative power near zero, thus effectively restoring the discriminative capability of the Hamming distance. Regarding data storage, the calibrated binary signature is processed using a version header byte plus... Each byte is stored in an embedded table in the local database and associated with the calibration profile identifier. Indicates rounding up. This represents the vector dimension. The version header byte is used to distinguish between ordinary signatures (version one) and calibration signatures (version two). The calibration profile identifier is used to distinguish the mean values of different frozen corpora, so as to support the comparison of the same signature version and the same calibration profile and the lazy calibration loading mechanism in the subsequent retrieval and question answering stage. After the calibration mean is formed, it is frozen as a calibration profile with an independent identifier; when the mean is updated, the next calibration profile is formed. Existing signatures in the same embedding space are uniformly regenerated, and the active calibration profile is atomically switched after completion.
[0061] (2) Generation of integer recalculation vectors.
[0062] The generation of integer reordering vectors aims to carry fine-grained ranking calculations with a very small storage volume, thereby avoiding the need to parse the massive floating-point vector text of the entire database in the second stage of retrieval, significantly reducing the amount of database reading and parsing overhead.
[0063] Specifically, the system maps raw floating-point vectors to integer quantized values using a one-vector-per-vector scaling approach. The formula for integer quantization is:
[0064] in, Indicates the first 2D integer quantization value, Represents the original floating-point value. Indicates a quantification scale. Represents the larger of the maximum absolute value of each dimension and the lower limit of positive numbers, represented by Greek letters. This indicates a preset lower limit for positive numbers. Represents the vector dimension. and These represent the functions for taking the maximum value and rounding to the nearest integer, respectively.
[0065] In terms of data storage, the integer reclassification vector is packaged and stored in the format of "version header byte + scale (four-byte floating point) + integer for each dimension". Since each dimension feature is represented by an eight-bit integer, its storage volume is about one-twentieth of the original single-precision floating point vector text, which greatly saves the storage space and input / output (I / O) read bandwidth of the local embedded database.
[0066] (3) Generation of document centroid.
[0067] As one possible implementation, the document centroid generation process includes: aggregating all blocks belonging to the same document and the same embedding space, and extracting the integer recalculation vector and its quantization scale already calculated during index construction for each block. First, an approximate vector is recovered according to its respective quantization scale, then the mean is calculated by dimension to generate the document centroid vector at that document level; the document centroid vector is then requantized into an eight-bit integer according to its own quantization scale, and the integer document centroid, quantization scale, and embedding space identifier are stored together. This calculation process aims to extract the macroscopic semantic features of the document, so that documents that do not literally overlap with the query but are semantically related can also be effectively included in the candidate range.
[0068] The document centroid, along with the calibration binary signature and integer recalculation vector, works together to form a low-bit index copy, providing underlying data support for document centroid routing and keyword union recall flooring in the subsequent retrieval and question-answering stage.
[0069] As a further implementation, the method also includes performing clustering processing on the vector embedding to generate several cluster centroids and registering the cluster affiliation of each block, and writing the cluster centroids and the cluster affiliation of each block into a local database. One possible implementation is to break down the overall indexing task into several smaller batches, execute them sequentially, and persist the current progress information to a local database after each batch is completed. When the indexing task is interrupted due to external factors such as application termination, user logout, or device resource constraints, the constructed index data and breakpoint records are retained. Upon the next application startup, the breakpoint progress is read, and completed processing steps are automatically skipped, resuming the unfinished indexing task directly from the breakpoint. This mechanism effectively prevents the index building process from being wasted due to abnormal interruptions, ensuring that the background indexing task can continue smoothly and reliably.
[0070] As one possible implementation, the index building phase also includes a yielding scheduling step between front-end retrieval and back-end indexing: At the start of each front-end retrieval, a front-end retrieval lease is registered, and it is released at the end; the back-end indexing task calls a yielding judgment between processing stages. When an active front-end retrieval lease exists, or the current batch has exceeded the frame budget (e.g., eight milliseconds), the back-end indexing yields the main thread, waiting for an idle opportunity to continue. This yielding scheduling, together with the thermal / electrical throttling of the dynamic evidence budget controller, constitutes a mobile device lag management mechanism, ensuring smooth user front-end interaction and scrolling.
[0071] As one possible implementation, after the index building phase is completed, the process also includes offline export and archiving of the local knowledge base and protected import steps to address the challenges of large-scale local knowledge base migration and backup across devices. During export, an archiving plan is generated based on the estimated total number of bytes of the selected knowledge base. An embedded database snapshot is used as the data carrier to generate an archive package containing a manifest file, checksum file, database snapshot file, and the root directory of the original text files. During import, a phased, verifiable, and resumable protected process is adopted: first, the compatibility of the manifest, checksum, archive version, and vector model is verified; second, the tables in the database snapshot are imported into the local database; finally, only the keyword full-text search index is rebuilt, and the number of imported vector rows is verified without re-vectorizing the documents. This preserves the imported vector embeddings, resulting in fast import speeds and no consumption of cloud-based vectorization computing power.
[0072] As one possible implementation, the index building phase also includes index portability and migration repair steps: For existing, ready but missing binary signature embeddings (e.g., low-version indexes), the background process involves batch backfilling and calibrating the binary signatures in a resumable manner. Before the backfilling is complete, the corresponding knowledge base uses a traditional full-scan search as a fallback, and the backfilling progress can be queried. This allows for a smooth upgrade to low-bit two-stage recall without rebuilding the entire index. When users import externally built knowledge base indexes, the imported index undergoes consistency verification and necessary repairs (such as supplementing missing low-bit copies, centroids, or full-text search rows) to ensure the imported index reaches a searchable and healthy state.
[0073] After the index building phase is completed, the search question and answer phase can be executed. Figure 2 This diagram illustrates a flowchart of a retrieval question-answering method during the retrieval question-answering stage according to one embodiment of the present invention. Figure 2 The method shown includes steps S210 to S260.
[0074] S210: Obtain the current terminal's physical resource status, index physical health, current query risk level, and currently set privacy mode.
[0075] This step aims to collect multidimensional adaptive input signals across layers as the basis for subsequent joint decision-making.
[0076] The terminal's physical resource status includes: device resource level (classified into high-end, mid-range, and low-end levels based on physical resources such as total terminal memory), device temperature status and low battery indicator, and the size of the knowledge base corpus (such as the total number of blocks in this knowledge base). The terminal's physical resource status can comprehensively reflect the terminal's load pressure and resource reserves.
[0077] Index physical health includes: the readiness rate of calibrated binary signatures in the local database, the readiness rate of integer refactoring vectors, and the readiness rate of document centroids.
[0078] The risk level is derived from a scalable, industry-configurable set of risk levels (e.g., including high-risk areas such as healthcare, legal, financial, corporate confidentiality, and personal privacy).
[0079] S220: By jointly mapping the terminal's physical resource status, index physical health, risk level, and privacy mode, a joint decision is output. The joint decision includes retrieval budget, evidence gate mode, per-claim verification strictness, and cloud outbound strategy.
[0080] This step is the core of this invention and can be implemented through a dynamic evidence budget controller. This step achieves the "cross-layer condition separation principle," aiming to resolve the trade-off between "privacy / trust strength" and "retrieval accuracy / latency / availability" on resource-constrained mobile terminals. The dynamic evidence budget controller does not uniformly adjust the overall levels of these two factors; instead, it separates and schedules them according to conditions such as "device physical state × index physical health × query risk × privacy mode," thereby simultaneously approximating the constraints of privacy, trust, accuracy, and latency within a single retrieval.
[0081] Specifically, the dynamic evidence budget controller jointly maps the terminal's physical resource status, index physical health, risk level, and privacy mode, outputting a set of joint decisions at once. For example, the joint decisions include: binary scan timeout limit, scan page size, scan row budget, re-scoring short list size, maximum number of blocks for injected answers, centroid routing share, evidence gate mode (hard gate / soft gate), per-claim verification strictness (level 1 / level 2), and cloud outbound strategy (block / confirm / allow), while constantly retaining the keyword union as a structured recall floor.
[0082] The core logic of this joint mapping includes the following seven falsifiable invariant constraints: (1) Monotonicity constraint: For the same input, the retrieval budget of the archive bits in the low-end device is no greater than the retrieval budget of the archive bits in the high-end device. This can be expressed as: Among them, uppercase letters The subscripts "high", "medium", and "low" indicate the budget, representing the high-end, mid-range, and low-end categories, respectively.
[0083] (2) Thermal / Electricity Throttling Constraint: Based on the retrieval budget, the throttling factor corresponding to the fuselage temperature status and low battery indicator is reduced, and the reduction of the retrieval budget is not lower than the safety lower limit. The calculation formula can be expressed as:
[0084] in, This indicates the reduced budget. Indicates the lower limit of safety. Indicates the equipment gear. Basic budget; Greek letters and These represent the fuselage temperature and the power throttling factor, respectively. , and These represent the functions for finding the minimum value, finding the maximum value, and rounding to the nearest integer, respectively.
[0085] (3) High-risk hard gate constraint: When the risk level is in a high-risk area (such as medical, legal, financial, corporate confidentiality, personal privacy, etc.), the evidence gate mode must be hard gate (empty evidence must be explicitly disclosed to the model that there is no evidence locally).
[0086] (4) Strict local outbound network restriction: When the privacy mode is strict local mode, the cloud outbound network policy must be a blocking policy.
[0087] (5) Centroid share constraint: When the document centroid ready ratio is greater than the ratio threshold (high enough), a larger share of the coarse recall budget is allocated to the centroid routing channel; otherwise, the centroid share is reduced.
[0088] (6) Verification strictness constraint: Only when the archive location in the device is a high-end file and the risk level is high risk, the verification strictness of each declaration shall adopt the second level of verification (local semantic implication verification); otherwise, the verification strictness of each declaration shall adopt the first level of verification (reference existence verification), and the level shall be marked accordingly.
[0089] (7) Recall floor constraint: Regardless of budget reduction, the structural recall floor of the keyword union is always retained to prevent centroids or vectors from misjudging blocks containing keyword evidence.
[0090] The aforementioned invariants are the concrete manifestations of the conditional separation principle, and their technical rationale is as follows: (1) Budget level is monotonous (corresponding to monotonicity constraint): Low-end devices have less memory, computing power and heat dissipation margin. If their retrieval budget exceeds that of high-end devices, it will directly violate the original intention of "preserving latency and power consumption". Therefore, it must always be no greater than the high-end level.
[0091] (2) Heat / electricity throttling (corresponding to heat / electricity throttling constraints): Maintaining high search intensity under high temperature or low power will aggravate heat generation, power consumption and interface lag. Therefore, the budget is reduced as a whole according to the heat state and power. At the same time, a safety lower limit is set to avoid excessive shrinkage that will result in no results being returned.
[0092] (3) High-risk areas must have hard gates (corresponding to high-risk hard gate constraints): If a high-risk area is answered with no evidence, the consequences of the error are significantly higher than in ordinary scenarios. Therefore, the model must explicitly declare that there is no evidence locally, rather than soft backoff.
[0093] (4) Strict local network outbound restriction (corresponding to strict local network outbound restriction): Once any payload category is allowed to leave the network, the privacy limit of "data not leaving the terminal" can no longer be guaranteed. Therefore, it is necessary to block it at the source rather than after auditing.
[0094] (5) Centroid share is adjusted according to readiness (corresponding to centroid share constraint): the centroid channel share is increased only when the document centroid readiness ratio is high enough and its semantic routing is reliable; otherwise, it is reduced to avoid misleading recall with unreliable semantic routing when the centroid is not ready.
[0095] (6) Verification strictness is enabled according to device and risk conditions (corresponding to verification strictness constraints): The latency and package cost of the second level local semantic implication verification are relatively high, so it is only enabled on high-end devices and under high-risk conditions. Low-end devices are downgraded to the first level reference existence verification, which is a targeted response to the device computing power conditions, rather than a consistent improvement across the entire domain.
[0096] (7) Recall floor is always retained (corresponding to recall floor constraint): any channel of clustering, centroid, or vector may miss the evidence block due to approximation or quantization distortion. Retaining the heterogeneous channel of keyword union can structurally prevent the recall rate from collapsing with index approximation.
[0097] The above conditions are separated and exported in one go by the dynamic evidence budget controller, and are connected with the refeeding of the retrieval diagnosis: the scan completion, scan timeout, scan row budget exhaustion and row budget utilization rate are extracted from the current scan execution status as budget feedback and refeeded; other indicators such as empty evidence reasons are only used for diagnosis, so that the budget of the next round will adaptively converge under the same terminal and corpus conditions, forming a closed loop.
[0098] It is important to note that the key difference of the Dynamic Evidence Budget Controller (DGB) lies in the following: Existing adaptive retrieval technologies typically involve adaptive decision-making within the model or retrieval layer. In contrast, the DGB uses terminal physical resources and index physical health as cross-layer inputs, directly binding them to evidence gates, per-claim verification strictness, and even cloud-based outbound strategies, forming a cross-layer joint mapping. The DGB does not bind to any specific approximate nearest neighbor index structure. Furthermore, the DGB advocates for the coupling relationship and invariant constraints between the aforementioned input dimensions and output decisions. Specific thresholds, scaling factors, and weights are adjustable implementation details that can be calibrated according to device and corpus, and are not limited here. Even if the specific values or the underlying index structure are replaced, the aforementioned coupling relationship and invariant constraints still hold.
[0099] Step S230: Determine whether the query information can be vector-encoded based on the cloud outbound network policy.
[0100] When the query information can be vector-encoded, a keyword-based document coarse screening is performed based on the query information to obtain a keyword-based document coarse screening document set. Based on the query vector obtained by vector encoding, a semantic retrieval based on the document centroid is performed to obtain a centroid semantic channel candidate set. The union of the keyword-based document coarse screening document set and the centroid semantic channel candidate set is calculated as the candidate document set. Within the candidate document set, keyword candidate blocks are obtained by searching based on the local full-text search index. At the same time, a two-stage vector recall with calibration low bits is performed in the independent vector candidate space according to the retrieval budget to obtain vector candidate blocks. The keyword candidate blocks and vector candidate blocks are merged to obtain a candidate block set.
[0101] In cases where vector encoding of the query information is not possible, a coarse screening of keyword documents is performed based on the query information to obtain a set of coarsely screened keyword documents. Within the set of coarsely screened keyword documents, candidate keyword blocks are obtained based on the local full-text search index, and a set of candidate blocks is constructed based on the candidate keyword blocks.
[0102] As one possible implementation, semantic retrieval based on document centroids is performed on the query vector obtained by vector encoding to obtain a centroid semantic channel candidate set. This includes: calculating the cosine similarity between the query vector and the centroids of each document with the same embedding spatial identifier in the current knowledge base of the local database; sorting the documents in descending order based on the cosine similarity; and selecting the top N documents to generate the centroid semantic channel candidate set. This indicates the number of documents. This mechanism ensures that documents that do not literally overlap with the query but are highly semantically related can also be effectively included in the candidate pool.
[0103] As one possible implementation, in the process of finding keyword candidate blocks based on the local full-text search index within the candidate document set, it is first determined which documents to search in, and then the specific paragraphs containing the keywords are found from these documents, and the specific paragraphs containing the keywords are used as keyword candidate blocks.
[0104] The independent vector candidate space is the range of paragraphs that vector retrieval can search. Performing a search within the independent vector candidate space ensures that the search is not limited by the previously generated set of candidate documents. Even if a useful document is missed in the previously generated set of candidate documents, it is still possible to find the truly relevant paragraphs.
[0105] In one example, when performing vector retrieval based on an independent vector candidate space, the following conditions must be followed: (1) Only chunks in the current knowledge base can be retrievald. (2) The query vector and chunk vector must be generated by mutually compatible embedding models. An embedding model is a tool for converting text into numbers. This is like comparing lengths; both sides must use the same ruler. (3) The same calibration standard must be used when generating binary signatures. A binary signature can be understood as a black and white barcode composed of "zero" and "one"; the calibration standard is to determine where to start judging "zero" and "one", which is equivalent to two rulers starting from the same zero point. (4) If only a few related groups are allowed to be checked in this round, vector retrieval must also be performed within these groups. Related groups are paragraphs with similar meanings that are placed in the same group in advance.
[0106] As one possible implementation, in the two-stage vector recall of calibration low bits in the independent vector candidate space according to the retrieval budget, the first stage (coarse recall stage) includes: obtaining block calibration binary signatures under the current knowledge base, the same embedding space and the same calibration profile, generating query calibration binary signatures according to the same calibration profile, calculating the Hamming distance between the two types of signatures, and selecting a preset number of blocks to form a short list in ascending order of Hamming distance according to the row budget and timeout upper limit constraint in the retrieval budget.
[0107] In one example, a scan is performed on the calibration binary signatures of the current knowledge base in the local database, within the same embedding space and on the same calibration profile. The Hamming distance between the calibration binary signature of the query vector and the calibration binary signatures of each block in the local database is calculated. To improve computational efficiency, a pre-built 256-item lookup table can be used to accelerate the bit counting process in the Hamming distance calculation. Since a smaller Hamming distance represents a higher approximate cosine similarity, the system is strictly constrained by the row budget and the binary scan timeout limit in the retrieval budget during the scanning process. The scanning stops when a stopping condition is triggered (such as the row budget being exhausted or the timeout limit being reached), and a preset number of blocks are selected in ascending order of Hamming distance.
[0108] Compared to reading and parsing the massive raw floating-point vector text line by line from the database and then performing floating-point cosine calculations, this stage uses bitwise Hamming scanning, which caps the worst-case scanning cost and significantly reduces the reading and calculation costs. This effectively addresses the issues of interface lag and high power consumption on resource-constrained mobile terminals when searching large corpora.
[0109] As one possible implementation, the second stage (re-scoring stage) of the calibration low-bit two-stage vector recall in the independent vector candidate space according to the retrieval budget includes: calculating the quantized cosine similarity between the current query vector and the integer re-scoring vectors in the shortlist, and outputting the vector candidate blocks in descending order of similarity.
[0110] In one example, the system directly calculates cosine similarity using integer recalculation vectors. Since the quantization scale can be canceled in the numerator and denominator of the cosine similarity, the calculation process does not require first converting the integer vector back to a floating-point array; integer values can be used directly for calculation. The above calculation can be completed in a single traversal, further eliminating the computational latency and memory spikes caused by floating-point text parsing while maintaining the precision of the ranking.
[0111] Specifically, in the first stage: the Hamming distance between the calibration binary signature of each block in the independent vector candidate space C and the calibration binary signature of the current query vector is calculated. Under the premise of satisfying the scan row budget and binary scan timeout upper limit constraints in the current retrieval budget, a preset number of blocks are selected in ascending order of Hamming distance to form a short list S. In the second stage: for each block in the short list S, its pre-stored integer quantized vector is read, and its quantized cosine similarity with the current query vector is calculated. Finally, the short list S is sorted in descending order according to the quantized cosine similarity, and the top... Each block (of which, (This represents the maximum number of blocks for the injected responses set in this round of budget), which are used as candidate vector blocks and fused with keyword candidate blocks to obtain the final candidate block set.
[0112] By employing the heterogeneous fusion mechanism of keyword candidate blocks and independent vector candidate blocks, a lower limit for recall can be structurally guaranteed. This effectively prevents missed recall of evidence-containing blocks due to clustering detection, centroid misjudgment, or vector quantization distortion, thus stabilizing the recall floor of the retrieval. When no query vector is obtained, document centroid semantic routing and vector channels are skipped, and only keyword retrieval is performed.
[0113] As one possible implementation, before step S230 is executed, a query understanding and rewriting step is also included: calling the query rewriting model to generate at most two rewritten variants for the original query; after the original query and each rewritten variant are recalled separately, the multi-way recall results are merged using Reverse Rank Fusion (RRF). At the same time, the query is segmented and expanded with domain synonyms, and question noise words are removed to extract the core concepts, so that different expressions of the indexed topic can also hit the evidence.
[0114] As one possible implementation, when the knowledge base is configured in hybrid retrieval mode, candidates are scored and ranked separately by the keyword channel and the vector channel, and then merged using Reverse Rank Fusion (RRF). The vector channel weight is given by a mixing coefficient (ranging from 0 to 1, with a default of 0.5), and the keyword channel weight is 1 minus this mixing coefficient. Whether a candidate constitutes final evidence needs to pass an evidence threshold determination: only when the candidate's overall score (the weighted sum of the vector score and the keyword score) is greater than or equal to the minimum overall score threshold, and at least one of its vector score or keyword score reaches its respective minimum threshold, is the candidate considered valid evidence, thereby suppressing noisy candidates that are weak in both directions.
[0115] Furthermore, when obtaining keyword channel recall results, a material-based weighting of keywords is introduced: when the query contains specific domain terms but the candidates do not cover these terms at all, the candidate keyword score is set to zero to avoid mismatch; for structured pages such as directories and indexes, if the title of its section does not match the query term, its keyword score is multiplied by a weighting coefficient of less than 1 to avoid index-like pages crowding out the main text evidence.
[0116] As one possible implementation, before step S230 is executed, a retrieval state machine and index health blocking step are also included: before retrieval, the health status of the index is evaluated, including ready, empty, indexed, paused, and needing to be rebuilt; the health evaluation comprehensively considers indicators such as the number of documents, the number of chunks, the number of ready embeddings, the availability of the full-text search index, and the number of unsigned embeddings; when the knowledge base being retrieved is in an unretrieval state, the retrieval directly returns a blocking state with health information and repair actions, so that the user can handle the matter according to the repair actions, rather than returning an empty result that is easily misunderstood.
[0117] Step S240: Based on the candidate block set and the evidence gate pattern, establish an evidence range for the current round that does not contain the original query plaintext, and generate a citation-based answer when the evidence range is not empty, and return an insufficient evidence response or fall back to normal dialogue according to the evidence gate pattern when the evidence range is empty.
[0118] This step, the core of trust and privacy, aims to achieve cross-round isolation and layered outbound control of evidence scope, ensuring that knowledge base answers are strictly limited to the evidence actually retrieved in this round, and protecting user privacy throughout the process. The specific execution process includes the following core steps: (1) Establish the scope of evidence.
[0119] Based on the candidate chunk set output in step S230, the evidence scope corresponding to the current round is constructed. For example, the fields corresponding to the evidence scope may include: round identifier, query hash, knowledge base identifier, document identifier, chunk identifier, citation set, retrieval mode, privacy mode, vector scan status, reason for empty results, and creation time. The evidence scope is strictly constrained to exclude the original query plaintext. Simultaneously, strict citation constraints are established: the answer in this round can only cite citations registered within the evidence scope of this round, and reuse of citations from the previous round is prohibited.
[0120] (2) Evidence gate mode control.
[0121] Based on the evidence gate mode output in step S220, the corresponding control logic is executed: when the evidence gate mode is hard gate mode and the evidence range is empty, a rejection mechanism is triggered, and the injected prompt explicitly requires the model to declare that the local knowledge base evidence is insufficient and that it must not make unsupported high-risk conclusions (such as conclusions in the medical field); when the evidence gate mode is soft gate mode and the retrieval is empty, knowledge injection is skipped, and the system reverts to the normal dialogue mode to avoid forcibly turning ordinary questions into rejections. Normal dialogue reverts to a mode that does not recommend support from knowledge base evidence and skips knowledge base reference verification.
[0122] (3) Prompt injection and response generation.
[0123] When generating a cited answer, each citation in the current round's candidate chunk set is injected into the generated prompt word in a numbered format. For example, the numbered format includes: number, source file name, relative path, page number, paragraph number, title path, and cited content. Simultaneously, a summary of the current round's evidence scope (including round identifier, query hash, source, privacy mode, retrieval mode, and number of citations) is appended to the prompt word, along with an explicit instruction that "only evidence within the scope of this round's evidence can be cited; citations from previous rounds cannot be reused," thereby constraining the large language model to generate a cited answer.
[0124] As one possible implementation, before injecting the candidate chunk set into the generated prompt, an adjacent context window supplementation step is included: only when adjacent chunks belong to the same document as the selected chunk, have the same title path, and are one paragraph number apart, the citations of at most two adjacent chunks are taken as context windows and appended to the content of the selected chunk to complete the fragmented context. Adjacent citations are not assigned citation numbers and are not used as the basis for per-declaration verification.
[0125] In addition, before generating the final citations, the results are diversified and deduplicated: using knowledge base identifiers, document identifiers and title paths as section keys, candidates from different sections are selected first; and a score cliff is applied, so that if the scores of adjacent candidates drop significantly after the minimum number of results has been generated, the score is truncated at that point to avoid irrelevant candidates being included in the final evidence set.
[0126] As one possible implementation, before injecting the candidate chunk set into the generated prompt words, hierarchical reordering and external reordering steps are included: First, a deterministic document structure boosting is applied: when the query contains a candidate document name, relative path, or hit token derived from a reference title after normalization, a preset boost is added to that candidate, and the ranking is reordered accordingly, prioritizing candidates highly relevant to the query at the document level. Second, when a configured external reordering model exists and there are more than one candidate, the first few loaded contents of the candidates are taken and submitted to the reordering model for scoring, and the reordering result is merged with the original ranking according to rank; the reordering call must be intercepted by a privacy-layered state machine and a cloud outbound network guard before it can be called; in any failure case, the ranking is rolled back to the unranked ranking to maintain the robustness of the link.
[0127] (4) Cloud-based outbound network guard interception.
[0128] When any knowledge base-related payload in the query, chunk, summary, citation, conclusion, or diagnosis needs to leave the network, the cloud outbound guard comprehensive step S220 outputs the cloud outbound strategy, privacy mode, payload category, and risk level to make a decision; the guard is skipped only if no knowledge base-related payload needs to leave the network in this round.
[0129] Step S250: For the cited response generated when the evidence range is not empty, perform conclusion support verification based on the strictness of the statement-by-statement verification.
[0130] This step aims to intercept the "superficial citation" problem (i.e., the phenomenon where the answer contains citations but the conclusion is not supported by the cited evidence). It uses a declaration-by-declaration evidence validator to perform deterministic decomposition and two-level support verification on the generated answer. The specific execution process is as follows: First, the answer is definitively broken down into multiple conclusions based on the punctuation at the end of each sentence, and the citation numbers appearing in each conclusion are identified. Then, deterministic regularization rules are used to classify each conclusion into high-risk types (such as factual or domain-specific conclusions, requiring supporting citations) and ordinary types (such as small talk, not requiring citations). Statements not identified as ordinary types are safely defaulted to the high-risk type.
[0131] Secondly, based on the declaration-by-declaration verification strictness output in step S220, tiered verification is performed on the high-risk conclusions after classification: Level 1 verification (citation existence verification): For each high-risk conclusion, check if its citation number exists in the citation set within the current round of evidence. If a conclusion claims to cite a citation but the citation number is not within the scope of evidence in this round, it is judged as "out of scope"; if a high-risk conclusion has no citations at all, it is judged as "unsupported". Level 1 verification is used to intercept citations that are not present in the citation list.
[0132] Level 2 verification (citation support verification): This is only enabled when the strictness of the per-declaration verification is Level 2 (i.e., the on-device archive is high-end and the risk level is high-risk). For conclusions that have passed Level 1 verification (not "out of scope" or "unsupported"), a locally injected semantic implication scorer is used to determine whether each cited piece of evidence semantically implies the conclusion. The specific judgment logic is as follows: each piece of cited evidence is scored separately. If a piece of cited evidence is judged as "contradictory," then the conclusion is judged as "conflicting." If no cited evidence has an implication score that reaches the preset implication threshold, then the conclusion is judged as "unsupported (citation surfaced)." Level 2 verification is used to intercept citation surfaced cases of "citation exists but does not support the conclusion." During this process, the cited evidence text is only temporarily used for verification in local memory and is never written into the evidence scope, not persistently stored, or sent to the cloud. If there is no cited evidence text, it is downgraded to Level 1 verification.
[0133] Finally, the verification results are processed and diagnostic indicators are recorded. In a preferred embodiment, when there are high-risk conclusions judged to be unsupported, out of scope, or conflicting, a privacy and security prompt is added to the end of the final answer, listing up to a set number (e.g., five, each truncated to a set length) of conclusions that do not match local citations and prompting the user to refer to them with caution; the rest are summarized by count. As another optional implementation, the aforementioned high-risk conclusions can also be removed from the answer, rewritten with supporting citations, or the answer can be directly rejected, and the entire answer can be rejected if no supporting conclusions are found. All of the above processing methods simultaneously record the number of unsupported conclusions in this round as a diagnostic indicator, but this indicator does not directly participate in the next round of search budget feedback.
[0134] The implication threshold for the second-level verification is set as follows: provided there is no cited evidence that is judged as "contradictory", the conclusion is accepted if and only if the implication score of at least one cited evidence is greater than or equal to the implication threshold. The implication threshold is an adjustable constant that can be calibrated according to the device and corpus.
[0135] Step S260: Record the retrieval diagnostic information of the current round, extract budget feedback information from the retrieval diagnostic information, and feed the budget feedback information back into the budget control of the next round of retrieval in a privacy-secure manner, forming a data flow coupling closed loop.
[0136] This step completes the final link in the data flow coupling closed loop, enabling the system to achieve adaptive convergence and interpretability. It should be noted that this step is not limited to any single step mentioned above, but rather summarizes the entire execution status of the current round and extracts budget feedback from the scan execution status.
[0137] Specifically, a self-diagnostic circular buffer for retrieval is set up in the terminal's local memory through a privacy protection diagnostic module to record the retrieval diagnostic information for the current round. This retrieval diagnostic information includes not only the number of conclusions without supporting evidence generated in step S250, but also end-to-end privacy and security indicators such as the scan status, number of rows and time consumed at each stage generated in step S230, and cloud outbound network decisions generated in step S240. The aforementioned diagnostic information deliberately excludes the original query plaintext and the original block plaintext.
[0138] Subsequently, scan completion, scan timeout, scan row budget exhaustion, and row budget utilization are extracted from the above diagnostic information as budget feedback information. This budget feedback information is then fed back into the dynamic evidence budget controller in step S220, enabling the budget for the next round of retrieval to adaptively converge under the same terminal and corpus conditions. The number of conclusions without supporting evidence and cloud-based outbound decisions are only used as diagnostic indicators and do not directly participate in budget feedback.
[0139] Furthermore, when the search results are empty but the index health status is abnormal, the system outputs "Unable to confirm no evidence" instead of "No answer in the knowledge base" based on the diagnosis, so that users can clearly distinguish between "no evidence" and "search / index abnormality" and avoid being misled.
[0140] As one possible implementation, before step S230 is executed, a clustered inverted index probing step is also included: based on the similarity between the current query vector and the centroids of each cluster, the most relevant cluster set with a preset probe width is selected as the probed cluster set; calibration low-bit two-stage vector recall is performed only within the probed cluster set; wherein, the preset probe width is jointly determined by the dynamic evidence budget controller and the total number of clusters in the knowledge base, and a minimum probe lower limit is set to ensure that the recall width is not lower than the minimum probe lower limit when thermal / electrical constraints are present.
[0141] The following specific example illustrates the above method.
[0142] Taking a high-end mobile terminal (approximately 12GB of memory, in normal operating condition, not low battery) as an example, which carries a professional knowledge base containing approximately 20,000 blocks (using legal data as an example) and handles a problem belonging to a high-risk area, the specific implementation method is as follows: The first step is to use the privacy layer state machine to take the product’s default cloud pre-confirmation mode; because the problem is in a high-risk area, the dynamic evidence budget controller sets the evidence gate mode to hard gate, the cloud outbound policy to confirmation, and the statement verification strictness to level two (because the device is high-end and high-risk).
[0143] The second step involves the dynamic evidence budget controller using a high-end basic retrieval budget combined with a normal hot state (throttling factor of 1) to provide a larger scan row budget and a larger short list of re-scoring, while retaining keywords and settling the recall floor.
[0144] The third step involves selecting several most relevant clusters based on the query vector using the clustered inverted index (the probe width is jointly given by the multidimensional state and the number of clusters, and is not lower than the minimum probe limit). Within the probed clusters, a calibrated binary signature Hamming coarse recall is performed. After obtaining the short list, the integer vector is read to perform quantization cosine rescoping, and the union of the result with the keyword channel candidate is taken to output the candidate block set for the injected answer.
[0145] The fourth step is to establish the scope of evidence for this round (excluding the original query plaintext) and generate a citation-based response.
[0146] The fifth step involves the statement evidence verifier breaking down the answer into conclusions. First, it performs a first-level citation existence check, and then a second-level local semantic implication check on high-risk conclusions, eliminating conclusions that are not supported by evidence or conflict with evidence. If there are no supported conclusions, the answer is rejected.
[0147] The sixth step involves recording the decision to exit the network, the scanning status, the number of rows in each stage, the time taken, the reasons for empty results, and the number of conclusions without supporting evidence in the privacy protection diagnosis circular buffer. Only the budget feedback information formed by scanning completion, scanning timeout, scanning row budget exhaustion, and row budget utilization rate is fed back to the next round of budget control.
[0148] For low-end devices carrying the same corpus, the dynamic evidence budget controller reduces the short list of re-scoring while maintaining the 95th percentile latency, and uses keyword union as a fallback for recall. Each declaration is downgraded to the first level and the level is accurately labeled, thus ensuring an adjustable working point that is both fast and accurate in structure.
[0149] The present invention has the following beneficial effects: 1. Achieve cross-layer condition separation to resolve the inherent contradiction between resource constraints and privacy trustworthiness.
[0150] Unlike existing adaptive retrieval schemes that rely solely on query difficulty or evidence quality for decision-making, this invention creatively utilizes terminal physical resources (internal storage space, device temperature, battery level) and index physical health (readiness ratio of binary signatures, integer vectors, and document centroids) as cross-layer inputs. Through a dynamic evidence budget controller, these multi-dimensional inputs are jointly mapped to a retrieval budget, evidence gate, verification strictness, and cloud outbound strategy in a single query. When physical resources are scarce, the retrieval budget is reduced to ensure latency and power consumption; under high-risk or strict privacy conditions, the evidence gate and outbound strategy are tightened independently. This allows for simultaneous approximation of the four constraints of privacy, trustworthiness, accuracy, and latency within a single retrieval, avoiding the one-way performance or experience sacrifices caused by the "one-size-fits-all" approach of traditional solutions.
[0151] 2. Significantly reduce retrieval latency and power consumption while ensuring that the recall rate does not collapse.
[0152] To address the limitations of computing power and memory on mobile devices, this invention employs a two-stage recall chain: "calibrated binary signature coarse recall + integer re-scoring fine ranking". The first stage restores the discriminative power of Hamming distance in anisotropic embedding models by centering the corpus mean, significantly reducing database reading and computation costs through bitwise operations. The second stage uses integer re-scoring vectors, carrying fine ranking in approximately one-twentieth the volume of the original floating-point text, eliminating memory spikes and latency caused by floating-point text parsing. Simultaneously, this invention constructs a heterogeneous fusion mechanism between keyword candidate blocks and independent vector candidate blocks, effectively preventing missed recall of evidence-containing blocks due to clustered approximate indexing or quantization distortion, ensuring the lower limits of retrieval accuracy and recall rate.
[0153] 3. By intercepting citation surface and cross-wheel drift, the credibility of answers and privacy security are significantly improved.
[0154] This invention establishes an evidence scope for each round of retrieval that excludes the original query plaintext, forcibly prohibiting the reuse of citations across rounds, and completely solving the evidence drift problem caused by the model's tendency to reuse citations from the previous round in multi-round dialogues. After the answer is generated, a two-level verification is performed through a declaration-by-declaration evidence validator: the first level blocks the surface-level citation of the "citation does not exist" type; the second level (enabled on high-end devices and in high-risk situations) uses a local semantic implication scorer to block the surface-level citation of the "citation exists but does not support the conclusion" type. During this process, the cited evidence text is only temporarily used in local memory and is never written into the evidence scope, not persisted, or left the network, thus significantly improving the credibility of the answer while upholding the bottom line of privacy.
[0155] 4. Implement fine-grained privacy layer control and auditability to prevent private data from being leaked online without authorization.
[0156] This invention categorizes data payloads into six types: query, chunk, summary, citation, conclusion, and diagnosis. It combines three privacy modes—strict local, cloud-based pre-verification, and cloud-assisted—to progressively determine the network exit point at any outgoing stage, including vectorization, reordering, and response generation. The system generates privacy and security audit records that deliberately exclude original plaintext and interface keys, enabling precise control and traceability of private data outgoing from the network. This provides robust and verifiable privacy protection for highly sensitive scenarios such as healthcare, law, finance, and corporate confidentiality.
[0157] 5. Provide interpretability for empty results to avoid misleading users.
[0158] This invention introduces a retrieval state machine and an index health blocking mechanism to comprehensively assess the health status of the index (e.g., ready, empty, indexing, paused, requiring reconstruction, etc.) when the retrieval result is empty. When an empty result is caused by an index anomaly or insecurity, the system will output "Unable to confirm no evidence" and corresponding repair actions, enabling users to clearly distinguish between "there is indeed no relevant evidence in the knowledge base" and "an anomaly has occurred in the retrieval or indexing system," effectively avoiding the problem of traditional solutions misleading users with easily misunderstood empty results.
[0159] 6. A robust mechanism for managing client-side lag and memory usage ensures smooth front-end interaction.
[0160] To address the issue of lag caused by large document processing on mobile devices, this invention employs segmented streaming extraction and structure-aware block partitioning to avoid memory spikes caused by one-time reading. Simultaneously, it introduces a yielding scheduling mechanism between foreground retrieval and background indexing. When there are active foreground retrieval leases or the current batch exceeds the frame budget, the background indexing proactively yields the main thread. This yielding scheduling, together with the thermal / electrical throttling of the dynamic evidence budget controller, constitutes a comprehensive approach to managing lag on mobile devices, thoroughly resolving interface lag and high power consumption issues in large corpus scenarios, and ensuring smooth foreground interaction and scrolling for users.
[0161] According to a further embodiment of the present invention, an electronic device is also provided. Figure 3 This diagram illustrates a schematic block diagram of an electronic device employing a processor-based hardware implementation according to an embodiment of the present invention. The hardware structure of the electronic device of the present invention can be implemented using a bus architecture. The bus architecture can include any number of interconnect buses and bridges, depending on the specific application and overall design constraints of the hardware. Bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules. Bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc. Bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one connecting line is used in this diagram, but this does not indicate that there is only one bus or one type of bus. The memory 1300 stores a computer program. When the processor 1200 executes the computer program, the processor 1200 is able to execute the dynamic retrieval budget control method of the above embodiments of the present invention.
[0162] The present invention also provides a readable storage medium storing a computer program, which, when executed by a processor, is used to implement the methods described above. A "readable storage medium" can be any means capable of containing, storing, communicating, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples of a readable storage medium include: an electrical connection (electronic device) having one or more wires, a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable read-only memory (CDROM), etc.
[0163] This invention also provides a computer program product. The method of this invention can be implemented wholly or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented wholly or partially in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of this invention are performed wholly or partially.
[0164] Computer programs or instructions can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any available medium capable of access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or it can include both volatile and non-volatile types of storage media.
[0165] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0166] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0167] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0168] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0169] In the description of this specification, the references to terms such as "one embodiment / mode," "some embodiments / modes," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, or characteristic described in connection with that embodiment / mode or example is included in at least one embodiment / mode or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment / mode or example. Moreover, the specific features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments / modes or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments / modes or examples described in this specification, as well as the features of different embodiments / modes or examples.
[0170] Those skilled in the art should understand that the above embodiments are merely for illustrating the present invention and are not intended to limit the scope of the invention. Those skilled in the art can make other changes or modifications based on the above disclosure, and these changes or modifications still fall within the scope of the present invention.
Claims
1. A dynamic retrieval budget control method, characterized in that, include: S210: Obtain the current terminal's physical resource status, index physical health, current query risk level, and currently set privacy mode; S220: Jointly map terminal physical resource status, index physical health, risk level and privacy mode, and output joint decision. The joint decision includes retrieval budget, evidence gate mode, per-claim verification strictness and cloud outbound strategy. S230: Determine whether the queried information can be vector-encoded based on the cloud outbound network policy; When vector encoding of the query information is possible, a keyword-based document coarse screening is performed based on the query information to obtain a keyword-based document set. Semantic retrieval based on document centroids is then performed on the query vectors obtained from the vector encoding to obtain a centroid semantic channel candidate set. The union of the keyword-based document set and the centroid semantic channel candidate set is calculated as the candidate document set. Within the candidate document set, keyword candidate blocks are obtained by searching based on the local full-text search index. Simultaneously, a two-stage vector recall with low-bit calibration is performed in the independent vector candidate space according to the retrieval budget to obtain vector candidate blocks. The keyword candidate blocks and vector candidate blocks are then merged to obtain a candidate block set. When vector encoding of the query information is not possible, a coarse screening of keyword documents is performed based on the query information to obtain a set of coarsely screened keyword documents. Within the set of coarsely screened keyword documents, candidate keyword blocks are obtained based on the local full-text search index, and a set of candidate blocks is constructed based on the candidate keyword blocks. S240: Based on the candidate block set and the evidence gate pattern, establish an evidence range for the current round that does not contain the original query plaintext, and generate a citation-based answer when the evidence range is not empty, and return an insufficient evidence response or fall back to normal dialogue according to the evidence gate pattern when the evidence range is empty. S250: For responses with citations generated when the scope of evidence is not empty, the supportability of the conclusions is verified based on the strictness of the statement-by-statement verification. S260: Record the retrieval diagnostic information of the current round, extract the budget feedback information corresponding to the scan execution status from the retrieval diagnostic information, and feed the budget feedback information back into the budget control of the next round of retrieval.
2. The dynamic retrieval budget control method as described in claim 1, characterized in that, Before step S210, there is also an index building phase, which executes the following index building methods: S110: Receive user authorization for local folders via storage access framework, register the content identifier and permission status of local folders, and create the corresponding knowledge base; S120: Scan the list of local folders to obtain a list of supported documents, and process the list of supported documents in batches. S130: Extract local text from each supported document and divide the extracted text into multiple blocks according to preset rules, and attach domain topic tags to each block; S140: Based on the currently set privacy mode, the payload category of the chunked data, the risk level, and the readiness status of the local embedded backend, determine the network egress decision, which includes execution on the end side, execution on the cloud with permission, or embedded routing that is blocked. S150: When the network egress decision is to execute on the end side, call the end-side embedding model to generate vector embeddings for each block; when the network egress decision is to execute on the cloud with permission, call the cloud embedding model to generate vector embeddings for each block; when the network egress decision is to block the embedding route, stop generating vector embeddings. S160: Write the generated vector embeddings into the local database and update the average values of each dimension of the knowledge base in an incremental manner; S170: Generate a calibrated binary signature based on the mean of the corpus in each dimension, and generate an integer rescore vector and document centroid. Write the calibrated binary signature, integer rescore vector and document centroid into the local database.
3. The dynamic retrieval budget control method as described in claim 1, characterized in that, The joint mapping logic when jointly mapping terminal physical resource status, index physical health, risk level, and privacy mode is subject to at least one of the following invariants: The retrieval budget for archive slots on low-end devices should not be greater than the retrieval budget for archive slots on high-end devices. Based on the retrieval budget, the budget is reduced according to the throttling factor corresponding to the device temperature status and low battery indicator, and the reduction of the retrieval budget shall not be lower than the safety lower limit. When the risk level falls into a high-risk area, the evidence gate model adopts the hard gate model; When the privacy mode is set to strict local mode, the cloud outbound network policy adopts a blocking strategy. When the document centroid readiness ratio is greater than the ratio threshold, increase the coarse recall budget share allocated to the centroid routing channel; otherwise, decrease the coarse recall budget share allocated to the centroid routing channel. Only when the archive location in the device is a high-end file and the risk level is in the high-risk area, the verification strictness of each declaration adopts the second level of verification. Otherwise, the strictness of the declaration-by-declaration verification shall be the first level of verification; Regardless of how much the search budget is reduced, the keyword channel recall results are always retained as the structured recall floor.
4. The dynamic retrieval budget control method as described in claim 1, characterized in that, Based on the query vector obtained by vector encoding, semantic retrieval based on document centroid is performed to obtain a candidate set of centroid semantic channels, including: Calculate the cosine similarity between the query vector and the centroids of documents with the same embedding spatial identifier in the current knowledge base of the local database. Sort the documents in descending order based on the cosine similarity, and select the top N documents to generate a candidate set of centroid semantic channels. Indicates the number of documents.
5. The dynamic retrieval budget control method as described in claim 1, characterized in that, In the two-stage vector recall process of calibrating low bits within the independent vector candidate space based on the retrieval budget, the first stage includes: Obtain the calibration binary signature of each block under the current knowledge base, the same embedding space, and the same calibration profile; The query vector is converted into a query calibration binary signature using the same calibration profile. The Hamming distance between the query calibration binary signature and the calibration binary signature of each block is calculated. Based on the row budget and timeout limit constraints in the retrieval budget, a preset number of blocks are selected in ascending order of Hamming distance to form a short list.
6. The dynamic retrieval budget control method as described in claim 5, characterized in that, In the two-stage vector recall process of calibrating low bits within the independent vector candidate space based on the retrieval budget, the second stage includes: Obtain the integer rescore vector for each block in the shortlist; Calculate the cosine similarity between the query vector corresponding to the query information and the integer rescore vector, and sort them in descending order of cosine similarity to obtain the candidate vector blocks that meet the maximum number of blocks limit in the retrieval budget; The candidate vector blocks are merged with the candidate keyword blocks to obtain a set of candidate blocks.
7. The method according to claim 1, characterized in that, For cited responses generated when the scope of evidence is not empty, the supportability of the conclusions is verified according to the strictness of the statement-by-statement check, including: The answer is broken down into multiple conclusions based on the punctuation at the end of the sentence, and the citation number in each conclusion is identified; Based on the risk level, the conclusions are classified into high-risk or ordinary types; The conclusions of high-risk types are graded and verified according to the strictness of the statement verification: The first level of verification is to determine whether the citation number exists in the citation set of the corresponding evidence range in the current round. If it does not exist, it is determined to be out of range; if there is no citation, it is determined to be unsupported. When the strictness of the statement verification output in step S220 is the second level, the second level of verification is activated. The second level of verification is determined by the joint mapping result of the high-end device's internal archive location and the high-risk level. In the second level of verification, for the conclusions that have passed the first level of verification, it is determined whether the cited evidence semantically implies the conclusion. If it is determined to be contradictory, the corresponding conclusion is determined to be conflicting; if the preset implication threshold is not reached, it is determined to be unsupported.
8. An electronic device, characterized in that, include: The memory stores the instructions to be executed. as well as A processor that executes execution instructions stored in memory, causing the processor to perform the dynamic retrieval budget control method of any one of claims 1 to 7.
9. A readable storage medium, characterized in that, The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the dynamic retrieval budget control method of any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When a computer program is executed by a processor, it implements the dynamic retrieval budget control method of any one of claims 1 to 7.
