Privacy purification method and electronic device for prompting context
By constructing a global entity relationship graph and distinguishing between semantic and identifier entities, a differentiated processing strategy is adopted to solve the problems of semantic integrity and reasoning accuracy caused by privacy anonymization in existing technologies, thus achieving the goal of maintaining the reasoning performance of a large language model while protecting user privacy.
Patent Information
- Application Number
- CN202611629373.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-21
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies struggle to ensure the inference performance of large language models while protecting user privacy, especially in retrieval-enhanced generation systems. The higher the degree of privacy desensitization, the more severe the damage to the semantic integrity of the context, and the lower the inference accuracy.
By constructing a global entity relationship graph, semantic and identifier-type entities are identified. Target virtual entities are determined for semantic entities, and format-preserving masks are applied to identifier-type entities. Privacy purification is performed in conjunction with the global entity relationship graph to generate target prompt context.
It effectively avoids semantic role fragmentation and cross-document reference failure, ensuring that the reasoning performance of large language models is maintained while protecting user privacy.
Smart Images

Figure CN123179462A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of large language model technology, and in particular relates to a privacy-preserving method and electronic device that provides contextual suggestions. Background Technology
[0002] With the deep deployment of large language models in scenarios such as medical diagnosis, financial consulting, service platforms, and enterprise internal knowledge services, retrieval-enhanced generation technology is gradually becoming a core architecture for improving the accuracy and controllability of model responses. In a typical retrieval-enhanced generation workflow, the system first retrieves relevant document fragments from an external knowledge base based on the user's query, and then concatenates these search results with the original query text to form a prompt context for the generation model to process. While this mechanism can effectively enhance the reliability of the response, it inevitably introduces new privacy threats: the retrieved document fragments often contain personally identifiable information such as personal names, organizational affiliations, job titles, residential addresses, contact numbers, email addresses, ID card numbers, medical records, and internal enterprise communications. When such raw sensitive information is directly entered into the prompt context without processing, the generation model may lead to privacy leaks through direct output, indirect rewriting, or cross-clue association inferences.
[0003] Current mainstream privacy protection solutions mainly employ differential privacy techniques during the training phase, static data cleaning, access control, or simple masking and deletion of sensitive words. However, differential privacy training is only applicable to the model training stage and cannot cover the risks during inference based on a frozen model and dynamic external corpora. While data cleaning and simple masking methods can prevent direct exposure of privacy, they often crudely remove or obscure key entities, causing semantic role breaks in the context, invalidation of cross-document reference relationships, and disruption of consistency with general world knowledge. For example, in medical question-answering scenarios, simple masking of patient names may prevent the model from correctly associating medical history information, leading to a break in multi-hop inference chains; in financial consulting scenarios, deletion of company names may cause the model to lose its ability to recognize specific financial rules, significantly reducing the usability of the answer.
[0004] It can be seen that a fundamental contradiction exists in retrieval-enhanced generation systems: the higher the degree of privacy desensitization, the more severe the damage to the semantic integrity of the context, and the lower the inference accuracy; conversely, in order to maintain sufficient contextual information to ensure inference ability, the risk of privacy leakage increases sharply. In summary, existing contextual privacy desensitization technologies struggle to ensure the inference performance of large language models while protecting user privacy. Summary of the Invention
[0005] In view of this, embodiments of this application provide a privacy-preserving method and electronic device for prompting context, in order to solve the technical problem that existing prompting context privacy-preserving technologies are unable to protect user privacy while ensuring the inference performance of large language models.
[0006] In a first aspect, embodiments of this application provide a privacy sanitation method that prompts context, including: The query text entered by the user and the knowledge text corresponding to the query text are concatenated to obtain the initial prompt context to be privacy-cleaned, and a global entity relationship graph corresponding to the initial prompt context is constructed; the global entity relationship graph is used to describe the semantic relationships between the various entities in the initial prompt context. Identify semantic entities and identifier entities in the context of the initial prompt; both the semantic entities and the identifier entities include user privacy information, the number of semantic information required for reasoning included in the semantic entities is greater than a preset semantic information quantity threshold, and the number of semantic information required for reasoning included in the identifier entities is less than or equal to the semantic information quantity threshold. For each semantic entity, the target virtual entity corresponding to the semantic entity is determined based on the attribute information of the semantic entity; For each of the identifier-type entities, a format-preserving mask is performed on the identifier-type entity to obtain the mask entity corresponding to the identifier-type entity. Based on each of the target virtual entities, each of the mask entities, and the global entity relationship graph, the initial prompt context is subjected to privacy purification processing to obtain the target prompt context.
[0007] Optionally, determining the target virtual entity corresponding to the semantic entity based on the attribute information of the semantic entity includes: Based on the attribute information of the semantic entity, several candidate virtual entities corresponding to the semantic entity are determined, and the selection probability of each candidate virtual entity is determined. The selection probability of the candidate virtual entity is positively correlated with the semantic consistency of the candidate virtual entity. The semantic consistency of the candidate virtual entity is used to describe the semantic similarity between the candidate virtual entity and the corresponding semantic entity. The target virtual entity corresponding to the semantic entity is determined based on the selection probability of each candidate virtual entity.
[0008] Optionally, determining the target virtual entity corresponding to the semantic entity based on the selection probability of each candidate virtual entity includes: Determine the current selection mode; the current selection mode includes the maximum probability selection mode and the non-maximum probability selection mode. In the maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is greater than a first probability threshold. In the non-maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is less than a second probability threshold. The first probability threshold is greater than or equal to the second probability threshold. Determine the current privacy budget; the current privacy budget is an adjustable parameter used to control the randomization intensity of the candidate virtual entity selection. The smaller the current privacy budget, the higher the degree of randomization when randomly determining the target virtual entity from multiple candidate virtual entities. Determine the utility sensitivity; the utility sensitivity is the maximum difference between the utility scores of each candidate virtual entity corresponding to the same semantic entity. The target virtual entity corresponding to the semantic entity is determined based on the current selection mode, the current privacy budget, the utility sensitivity, and the selection probability of each candidate virtual entity.
[0009] Optionally, the current selection mode is determined in the following way: If any of the first conditions are met, the current selection mode is determined to be the maximum probability selection mode; the first conditions include: the target virtual entity corresponding to the semantic entity is determined for the first time and the privacy sensitivity of the semantic entity is less than a preset sensitivity threshold; the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is greater than a preset probability difference threshold; the business scenario in which the current large language model is located requires the highest inference accuracy; If any of the second conditions are met, the current selection mode is determined to be the non-maximum probability selection mode; the second conditions include: the privacy sensitivity corresponding to the semantic entity is greater than the sensitivity threshold; the number of times the target virtual entity corresponding to the semantic entity is determined is greater than a preset number threshold; the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is less than or equal to the probability difference threshold; and the business scenario in which the current large language model is located requires the highest level of privacy security.
[0010] Optionally, the current privacy budget is determined in the following way: Determine the privacy sensitivity level corresponding to this semantic entity; Based on the privacy sensitivity level and the target mapping relationship, a candidate range for the current privacy budget is determined; the target mapping relationship is used to describe the relationship between the privacy sensitivity level and the candidate range for the current privacy budget. By labeling the validation set, with the dual optimization objectives of privacy sanitization rate and inference accuracy, the initial value of the current privacy budget is selected within the candidate interval of the current privacy budget; Based on the number of each candidate virtual entity corresponding to the semantic entity, the initial value of the current privacy budget is optimized to obtain the target value of the current privacy budget.
[0011] Optionally, the utility sensitivity is determined in the following way: Calculate the utility score of each candidate virtual entity relative to the semantic entity; The absolute difference between the utility scores of each candidate virtual entity and that of the semantic entity is determined to obtain the maximum utility score difference. The initial value of the utility sensitivity is determined based on the maximum utility score difference. Based on the preset minimum value of utility sensitivity, the initial value of the utility sensitivity is corrected to obtain the target value of the utility sensitivity.
[0012] Optionally, determining the target virtual entity corresponding to the semantic entity based on the current selection mode, the current privacy budget, the utility sensitivity, and the selection probability of each candidate virtual entity includes: Based on the current selection mode, the current privacy budget, and the utility sensitivity, determine whether to select the candidate virtual entity with the highest probability of selection as the target virtual entity; If so, the candidate virtual entity with the highest probability of being selected will be determined as the target virtual entity; Otherwise, among the candidate virtual entities whose selection probability is not the highest, a preset number of candidate virtual entities with the highest selection probability are selected and added to the target set; or, among the candidate virtual entities whose selection probability is not the highest, the candidate virtual entities whose selection probability differs from the maximum selection probability by less than a probability difference threshold are determined and added to the target set, and the selection probability of each candidate virtual entity in the target set is normalized, and the target virtual entity is determined based on the normalized selection probability.
[0013] Optionally, after performing privacy-cleaning processing on the initial prompt context based on each of the target virtual entities, each of the mask entities, and the global entity relationship graph to obtain the target prompt context, the method further includes: For each target virtual entity in the target prompt context, determine whether the context semantics of the target virtual entity is aligned with the context semantics of the corresponding semantic entity, and / or determine the set of functional attributes of the target virtual entity, and in conjunction with preset general world knowledge rules, detect whether there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity; If the contextual semantics of the target virtual entity are not aligned with the contextual semantics of the corresponding semantic entity, or if there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity, then the target prompt context shall be corrected.
[0014] Optionally, the modification of the target prompt context includes: The steps of determining the target virtual entity corresponding to each semantic entity based on its attribute information and subsequent steps are re-executed to obtain the target prompt context again. or, The minimum knowledge axiom is injected into the target prompt context to align the context semantics of the target virtual entity with the context semantics of the corresponding semantic entity, and to ensure that there is no contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity.
[0015] Secondly, embodiments of this application provide a privacy purifying device that provides contextual information, comprising: The text segment splicing unit is used to splice the query text segment input by the user and the knowledge text segment corresponding to the query text segment to obtain the initial prompt context to be privacy-cleaned, and to construct the global entity relationship graph corresponding to the initial prompt context; the global entity relationship graph is used to describe the semantic relationships between the various entities in the initial prompt context. An entity recognition unit is used to identify semantic entities and identifier entities in the initial prompt context; both the semantic entities and the identifier entities include user privacy information, the number of semantic information required for reasoning included in the semantic entities is greater than a preset semantic information quantity threshold, and the number of semantic information required for reasoning included in the identifier entities is less than or equal to the semantic information quantity threshold. An entity determination unit is used to determine the target virtual entity corresponding to each semantic entity based on the attribute information of the semantic entity. The mask processing unit is used to perform format-preserving mask processing on each of the identifier entities to obtain the mask entity corresponding to the identifier entity. The privacy purification unit is used to perform privacy purification processing on the initial prompt context based on each of the target virtual entities, each of the mask entities, and the global entity relationship graph to obtain the target prompt context.
[0016] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the privacy cleanup method for prompting context as described in any of the first aspects above.
[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the privacy cleanup method for prompting context as described in any of the first aspects above.
[0018] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to perform the steps of the privacy cleanup method for prompting context as described in any of the first aspects above.
[0019] The beneficial effects of the privacy-cleaning method for providing contextual prompts provided in this application are as follows: The privacy purification method for the prompt context provided in this application includes: concatenating a user-input query text and a corresponding knowledge text to obtain an initial prompt context to be privacy-purified, and constructing a global entity relationship graph corresponding to the initial prompt context; the global entity relationship graph is used to describe the semantic relationships between various entities in the initial prompt context; identifying semantic entities and identifier entities in the initial prompt context; both semantic entities and identifier entities include user privacy information, the number of semantic information required for reasoning included in semantic entities is greater than a preset semantic information quantity threshold, and the number of semantic information required for reasoning included in identifier entities is less than or equal to the semantic information quantity threshold; for each semantic entity, determining the target virtual entity corresponding to the semantic entity based on the attribute information of the semantic entity; for each identifier entity, performing format-preserving masking processing on the identifier entity to obtain the mask entity corresponding to the identifier entity; and performing privacy purification processing on the initial prompt context based on each target virtual entity, each mask entity, and the global entity relationship graph to obtain the target prompt context.
[0020] As can be seen from the above, this solution effectively avoids the problems of semantic role breakage and cross-document reference failure by distinguishing between semantic entities and identifier entities and adopting differentiated privacy processing strategies, and by combining the global entity relationship graph to maintain the semantic coherence of the context. It can protect user privacy while ensuring the reasoning performance of large language models. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 A flowchart illustrating the implementation of a privacy-preserving method that provides contextual information, as provided in this application embodiment. Figure 2 A schematic diagram of a privacy purification device that provides contextual prompts is provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0023] It should be noted that the terminology used in the embodiments of this application is only for explaining specific embodiments of this application and is not intended to limit this application. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more, "at least one" or "one or more" means one, two or more. The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0024] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0025] Existing privacy protection methods, such as differential privacy training of training sets, data cleaning, access control, or simple masking / removal of sensitive words, are insufficient to cover the risks during inference based on frozen models and external corpora. While simple masking / removal can block direct exposure, it often disrupts entity semantic roles, cross-document referential relationships, and consistency with world knowledge, leading to multi-hop inference failures and a sharp drop in answer usability. Therefore, existing privacy-preserving methods based on prompt context struggle to balance the inference accuracy and privacy security of large language models.
[0026] To address the above issues, this application provides a privacy-preserving method for providing contextual information. The execution entity of this privacy-preserving method can be an electronic device storing a large language model. For example, the electronic device may include, but is not limited to, computers, mobile phones, and tablets.
[0027] For ease of understanding, the following explains some key terms in this embodiment: The query text is understood as the original question or instruction text submitted by the user to the large language model. This text carries the user's core intent and information needs.
[0028] Knowledge segments are understood as supplementary information or document fragments retrieved from external knowledge bases that are related to the content of the query segment. These segments aim to provide background knowledge and factual support for the large language model, thereby enhancing the accuracy of the generated responses.
[0029] The initial context prompt is understood as the complete text input formed by concatenating the query text and the knowledge text. This text will serve as the basis for reasoning and generation by the large language model, and may contain sensitive user privacy information.
[0030] A global entity graph is understood as a graph structure used to represent the various entities contained in the initial prompt context and their semantic relationships. This graph structure can capture the complex relationships between entities, providing structured information for subsequent privacy sanitization and reasoning.
[0031] Semantic entities are those entities whose initial context contains user privacy information. These entities contain a large amount of semantic information required for reasoning, exceeding a preset threshold. Examples include names, organizations, hospitals / schools, job titles, locations, departments, and project names—entities that convey both identity and role connotations.
[0032] Identifier-type entities are understood as entities that contain user privacy information within the initial prompt context. These entities contain a relatively small amount of semantic information required for reasoning, less than or equal to a preset threshold for the amount of semantic information. Examples include phone numbers, ID card numbers, and other personal identification identifiers with specific formats.
[0033] The semantic information quantity threshold is understood as a preset value used to distinguish between semantic entities and identifier entities. When the amount of semantic information contained in an entity that requires reasoning exceeds this threshold, it is determined to be a semantic entity; otherwise, it is determined to be an identifier entity.
[0034] The target virtual entity is understood as an abstract or generalized representation used to replace the original semantic entity. This virtual entity retains the key semantic information of the original entity while removing specific privacy details, thereby achieving privacy protection.
[0035] Format-preserving masking is understood as a technique for protecting the privacy of identifier-type entities. This method replaces or hides entity content while preserving the original entity's format characteristics; for example, replacing a phone number with the format "XXX-XXXX-XXXX".
[0036] A masked entity is understood as an identifier-type entity that has undergone format-preserving masking. While similar in form to the original identifier-type entity, its content has been anonymized or replaced, and no longer contains sensitive privacy information.
[0037] The target prompt context is understood as the final prompt text after privacy sanitization. This text removes or replaces sensitive user privacy information while preserving the semantic information and contextual consistency required for reasoning to the greatest extent possible, and can be safely input into a large language model for processing.
[0038] Please see Figure 1 , Figure 1 The following is a flowchart illustrating the implementation of a privacy-preserving method for providing contextual prompts, as provided in this application embodiment. This method may include steps S101-S105, detailed below: In S101, the query text entered by the user and the knowledge text corresponding to the query text are concatenated to obtain the initial prompt context to be privacy-cleaned, and a global entity relationship graph corresponding to the initial prompt context is constructed; the global entity relationship graph is used to describe the semantic relationships between various entities in the initial prompt context.
[0039] In this embodiment, the user-input query text is first concatenated with knowledge text retrieved from an external knowledge base to form an initial prompt context. This initial prompt context serves as the raw input for subsequent privacy sanitization processing. Then, a global entity relationship graph is constructed based on this initial prompt context. This global entity relationship graph can be constructed in various ways. For example, a rule-based approach can be used to identify entities in the text through predefined grammatical patterns and dictionaries, and establish connections based on co-occurrence relationships or syntactic dependencies between entities. Alternatively, a statistical learning-based approach can be used to automatically identify entities and infer their relationships through a trained entity recognition model and relation extraction model. The construction of this global entity relationship graph aims to capture the entities and their semantic associations in the initial prompt context, providing structured information for subsequent privacy sanitization.
[0040] Unlike the traditional approach of separating and anonymizing query and knowledge texts, this invention first unifies query and knowledge texts into a unified context. This is because the retrieval enhancement generation process involves numerous entity relationships spanning multiple evidence documents: for example, a query text might state "Director Zhang is responsible for which project," while a knowledge text might state "Zhang Wei is the head of financial risk control in East China." Without joint modeling, this would lead to referential breaks, inconsistent mappings, and semantic conflicts.
[0041] Furthermore, the constructed global entity relationship graph can be represented as: V represents entity nodes, and E represents semantic relationship edges. These serve as the structural skeleton for subsequent virtualization, ensuring that the same semantic object is mapped to the same virtual entity across documents.
[0042] In S102, semantic entities and identifier entities in the initial prompt context are identified; both semantic entities and identifier entities include user privacy information, the amount of semantic information required for reasoning included in semantic entities is greater than a preset semantic information quantity threshold, and the amount of semantic information required for reasoning included in identifier entities is less than or equal to the semantic information quantity threshold.
[0043] In this embodiment, after constructing the global entity relationship graph, it is necessary to identify and classify the entities in the initial prompt context. Specifically, semantic entities and identifier entities containing user privacy information are identified. Semantic entities are defined as entities containing more than a preset threshold of semantic information required for reasoning, such as a detailed occupational description of a person or a complex medical diagnosis. Identifier entities are defined as entities containing less than or equal to a preset threshold of semantic information required for reasoning, such as phone numbers, bank card numbers, or email addresses.
[0044] Specifically, semantic entities can be identified by small-scale models deployed locally, avoiding privacy leaks during the detection phase. Identifier-type entities can be detected with high accuracy using regular expressions and heuristic rule engines.
[0045] In S103, for each semantic entity, the target virtual entity corresponding to the semantic entity is determined based on the attribute information of the semantic entity.
[0046] In this embodiment, after identifying each semantic entity, a corresponding target virtual entity needs to be determined for each identified semantic entity based on its attribute information. This target virtual entity aims to replace the original semantic entity while retaining its necessary semantic functions in reasoning. For example, the semantic entities "Zhang Wei, Finance Manager of East China Region" can be virtualized into the target virtual entities "Li Chengyuan, Executive Director of Donggang Financial Center." The identities are completely changed, but the financial industry, management authority, and regional attributes are retained. This replacement is essentially a semantic role mapping rather than a string replacement.
[0047] In one possible implementation, the electronic device can achieve "determining the target virtual entity corresponding to the semantic entity based on the attribute information of the semantic entity" in the following manner, detailed below: Based on the attribute information of the semantic entity, several candidate virtual entities corresponding to the semantic entity are identified, and the selection probability of each candidate virtual entity is determined. The selection probability of a candidate virtual entity is positively correlated with its semantic consistency, which describes the semantic similarity between the candidate virtual entity and its corresponding semantic entity.
[0048] The target virtual entity corresponding to the semantic entity is determined based on the selection probability of each candidate virtual entity.
[0049] Specifically, upon receiving a semantic entity, the system can utilize its attribute information, such as entity type, context, and related entities, to generate a set of candidate virtual entities semantically associated with the original semantic entity. This can be achieved by querying a pre-built knowledge base, generating them using a pre-trained language model, or retrieving them from a large-scale text corpus using entity linking technology. Subsequently, for each candidate virtual entity, the semantic similarity, or semantic consistency, between it and the original semantic entity is calculated. Semantic consistency can be calculated using various methods, such as cosine similarity based on word or entity embeddings, similarity measures based on knowledge graph paths, or evaluation using a specially trained semantic matching model. Higher semantic consistency indicates a closer semantic similarity between the candidate virtual entity and the original semantic entity, and thus a higher likelihood of its substitution. Therefore, the probability of each candidate virtual entity being selected is set to be positively correlated with its semantic consistency; that is, the higher the semantic consistency of a candidate virtual entity, the greater its probability of being selected.
[0050] After obtaining all candidate virtual entities and their corresponding selection probabilities, the electronic device will select the final target virtual entity based on these probability distributions.
[0051] In practical applications, if electronic devices consistently select the candidate virtual entity with the highest probability of selection as the target virtual entity, repeated queries could allow adversaries to accumulate statistical evidence and, combined with auxiliary knowledge, gradually narrow down the space for real identities, ultimately leaking user privacy. Therefore, electronic devices can achieve the following: "Determine the target virtual entity corresponding to a semantic entity based on the selection probability of each candidate virtual entity." This allows the electronic device to, in a small number of cases (with a low probability of occurrence), select the candidate virtual entity with a lower selection probability as the target virtual entity, thereby further reducing the possibility of privacy leakage. Details are as follows: Determine the current selection mode; the current selection mode includes the maximum probability selection mode and the non-maximum probability selection mode. In the maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is greater than the first probability threshold. In the non-maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is less than the second probability threshold. The first probability threshold is greater than or equal to the second probability threshold. Determine the current privacy budget; the current privacy budget is an adjustable parameter used to control the randomization intensity of candidate virtual entity selection. The smaller the current privacy budget, the higher the degree of randomization when randomly determining the target virtual entity from multiple candidate virtual entities. Determine the utility sensitivity; the utility sensitivity is the maximum difference between the utility scores of each candidate virtual entity corresponding to the same semantic entity; based on the current selection mode, the current privacy budget, the utility sensitivity, and the selection probability of each candidate virtual entity, determine the target virtual entity corresponding to the semantic entity.
[0052] The current selection mode is a mechanism used to guide the selection strategy for target virtual entities. This mode aims to flexibly adjust the selection strategy based on different application requirements and privacy protection levels. Specifically, the current selection mode can include a maximum probability selection mode and a non-maximum probability selection mode. In the maximum probability selection mode, the system tends to select the candidate virtual entity with the highest probability of selection as the target virtual entity, whose selection probability is greater than a preset first probability threshold. This is typically suitable for scenarios requiring high inference accuracy. In the non-maximum probability selection mode, the system reduces its tendency to select the candidate virtual entity with the highest probability of selection, whose selection probability is less than a preset second probability threshold, and the first probability threshold is greater than or equal to the second probability threshold. This means that more randomness is introduced into the selection process to enhance privacy protection. The determination of this mode can be based on preset strategies, user configurations, or dynamic system evaluation results.
[0053] The current privacy budget is an adjustable parameter used to control the randomization intensity of candidate virtual entity selection. The smaller the current privacy budget, the higher the degree of randomization when randomly determining the target virtual entity from multiple candidate virtual entities.
[0054] The higher the level of privacy protection, the greater the randomness of the selection outcome. A trade-off can be struck between privacy protection and data availability by adjusting the current privacy budget. The specific value can be determined based on the level of privacy sensitivity, business scenario requirements, or through algorithmic optimization.
[0055] Utility sensitivity measures the difference in impact of different candidate virtual entities on the overall system utility (e.g., inference accuracy, semantic consistency) when replacing semantic entities. Specifically, utility sensitivity is defined as the maximum difference between the utility scores of each candidate virtual entity corresponding to the same semantic entity. Utility scores reflect the performance of a candidate virtual entity in a specific task or its semantic matching degree with the original semantic entity. By calculating utility sensitivity, the system can assess the maximum potential utility loss when introducing randomness for privacy protection, thus providing a basis for decisions between privacy and utility. Utility sensitivity can be calculated based on the attributes of candidate virtual entities, contextual information, and a predefined utility function.
[0056] By introducing the current selection mode, current privacy budget, and utility sensitivity, this application provides a more refined and controllable mechanism for determining the target virtual entity corresponding to a semantic entity. The current selection mode allows the system to flexibly switch between pursuing maximum inference accuracy (maximum probability selection mode) and enhancing privacy protection (non-maximum probability selection mode) based on different business needs and privacy sensitivities. The introduction of the current privacy budget enables the system to quantify and control the randomness in the selection process, thereby directly adjusting the strength of privacy protection and ensuring effective protection of user privacy information. Simultaneously, utility sensitivity provides an indicator to measure the impact of different candidate virtual entities on system utility, enabling the assessment and limitation of potential utility loss when introducing randomness for privacy protection. These mechanisms work synergistically, so that when determining the target virtual entity based on the probability of candidate virtual entities being selected, it is no longer a simple matter of choosing the entity with the highest probability, but rather a comprehensive consideration of privacy protection needs, system utility loss, and the flexibility of the selection strategy. This ensures that, while guaranteeing privacy security, the accuracy of inference and semantic consistency of the context are maintained as much as possible, effectively solving the challenge of balancing privacy protection and inference accuracy.
[0057] This application further proposes a method for determining the current selection mode. Specifically, if any first condition is met, the current selection mode is determined to be the maximum probability selection mode. The first condition includes: when the target virtual entity corresponding to the semantic entity is first determined and the privacy sensitivity of the semantic entity is less than a preset sensitivity threshold, the system tends to select the virtual entity that is most likely to match, so as to prioritize the accuracy of inference in the initial stage where the privacy risk is low. For example, for a newly identified entity with low sensitivity, the system will tend to directly select the virtual entity with the highest semantic consistency to quickly establish an accurate context. In addition, when the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is greater than a preset probability difference threshold, it indicates that there is a significantly better choice. At this time, selecting the virtual entity with the highest probability can maximize the accuracy of the replacement and reduce inference errors caused by ambiguity. Furthermore, if the business scenario in which the current large language model is located requires the highest inference accuracy, such as in scenarios with extremely high accuracy requirements such as medical diagnosis assistance or legal text analysis, the system will actively select the virtual entity with the highest probability to maximize the inference performance of the model.
[0058] On the other hand, if any of the second conditions are met, the current selection mode is determined to be the non-maximum probability selection mode. The second conditions include: when the privacy sensitivity corresponding to the semantic entity is greater than a sensitivity threshold, even if there is a candidate virtual entity with the highest probability, the system will tend to introduce a certain degree of randomness to avoid directly selecting the most obvious alternative, thereby enhancing privacy protection. For example, for highly sensitive entities involving personal finances or health status, even if there is a high-probability virtual entity, the non-maximum probability mode may be selected to increase anonymity. Simultaneously, if the number of times the target virtual entity corresponding to the semantic entity is determined to be greater than a preset number threshold, to avoid the accumulation of privacy leakage risks due to repeated use of the same replacement strategy, the system will introduce a non-maximum probability selection mode to increase the diversity of replacements. Furthermore, when the difference between the selection probability of the candidate virtual entity with the highest probability and the selection probability of the candidate virtual entity with the second highest probability is less than or equal to the probability difference threshold, it means that there are multiple "almost good" alternative options. In this case, introducing a non-maximum probability selection mode can increase the randomness of privacy protection without significantly sacrificing accuracy. Finally, if the current large language model is used in a business scenario that requires the highest level of privacy and security, such as in scenarios involving the processing of users' personal identity information or confidential business data, the system will prioritize the non-probability maximum selection mode, maximizing privacy protection by introducing randomness.
[0059] Through the above technical solution, this application can dynamically adjust the selection strategy of target virtual entities based on the specific characteristics of semantic entities, their processing history, and the business scenario requirements of the current large language model. When prioritizing inference accuracy, such as when processing low-sensitivity entities for the first time, when there is a clear optimal substitute, or when the business scenario requires high accuracy, the system tends to adopt the maximum probability selection mode. This ensures that the replaced virtual entity has the highest semantic consistency with the original semantic entity, effectively maintaining the accuracy of subsequent inference. Conversely, when privacy protection is more prominent, such as when processing high-sensitivity entities, when entities are processed frequently, or when the business scenario requires high privacy security, the system switches to a non-maximum probability selection mode. By introducing randomness, it increases the diversity and unpredictability of replacements, thereby significantly improving the security of privacy sanitization and effectively reducing the risk of inferring original privacy information through reverse engineering. This adaptive mode selection mechanism enables the privacy sanitization method to achieve a flexible and optimized balance between inference accuracy and privacy security, meeting the differentiated needs of privacy protection and model performance in different application scenarios.
[0060] This application further proposes that the current privacy budget be determined in the following way: First, determine the privacy sensitivity level corresponding to the semantic entity; second, determine the candidate interval of the current privacy budget based on the privacy sensitivity level and the target mapping relationship; the target mapping relationship is used to describe the relationship between the privacy sensitivity level and the candidate interval of the current privacy budget; third, select the initial value of the current privacy budget within the candidate interval of the current privacy budget by labeling the validation set, with the dual optimization objectives of privacy sanitization rate and inference accuracy; finally, optimize the initial value of the current privacy budget according to the number of each candidate virtual entity corresponding to the semantic entity to obtain the target value of the current privacy budget.
[0061] Specifically, privacy sensitivity levels categorize or quantify the degree of sensitivity of the privacy information contained in a semantic entity. For example, privacy sensitivity levels can be divided into high, medium, and low levels, or represented by a continuous numerical value. The determination of this level can be based on preset privacy policies, industry standards, user preference settings, or through machine learning models analyzing and predicting entity types and contextual information. For instance, entities involving personally identifiable information, financial data, or health status are typically assigned a higher privacy sensitivity level.
[0062] The target mapping relationship is a pre-established rule or function used to associate different privacy sensitivity levels with corresponding candidate intervals of the current privacy budget. This mapping relationship can be represented as a lookup table, a series of conditional statements, or a parameterized function model. For example, when the privacy sensitivity level is "high," the corresponding candidate interval of the current privacy budget may be a larger range to allow greater randomness to enhance privacy protection; when the privacy sensitivity level is "low," the corresponding candidate interval may be a smaller range to preserve semantic information as much as possible while ensuring basic privacy.
[0063] The labeled validation set is a sample set containing the original cue context, sanitized cue contexts processed with different privacy budgets, and corresponding evaluation metrics (such as privacy sanitization rate and inference accuracy). This validation set is used to train and evaluate the privacy sanitization model to ensure it achieves the expected results in real-world applications. The privacy sanitization rate measures the degree to which privacy information is effectively removed or obscured, for example, by calculating the substitution rate of sensitive words or the degree of anonymization. Inference accuracy evaluates the ability of the sanitized cue context to retain original semantic information in downstream tasks (such as question answering, summarizing, or inference in large language models), for example, by comparing the model's accuracy in answering the same question before and after sanitization. By iteratively adjusting the privacy budget parameters within the candidate range of the current privacy budget and evaluating the privacy sanitization rate and inference accuracy under different parameters using the labeled validation set, an initial value for the current privacy budget that achieves the best balance between these two objectives can be selected.
[0064] After determining the initial value of the current privacy budget, further optimization is needed based on the number of candidate virtual entities corresponding to the semantic entity. For example, if a large number of candidate virtual entities are generated for a certain semantic entity, it means there are more replacement options. In this case, the privacy budget may need to be adjusted appropriately to better utilize these abundant candidate resources while maintaining sufficient randomness. Conversely, if the number of candidate virtual entities is small, the privacy budget may need to be adjusted more cautiously to avoid excessive loss of semantic information due to over-randomization. This optimization can be performed using a preset adjustment function or based on a machine learning model to obtain the final target value of the current privacy budget.
[0065] Through the above technical solution, this application can dynamically determine the current privacy budget based on the privacy sensitivity level of the semantic entity itself. First, by mapping the privacy sensitivity level to the target, a reasonable candidate range for the privacy budget is set, avoiding blind setting. Second, using a labeled validation set, with both privacy sanitization rate and inference accuracy as dual optimization objectives, an initial value is selected within the candidate range, ensuring a balance between privacy protection and inference utility. Finally, the initial value is optimized based on the number of candidate virtual entities, making the determination of the privacy budget more refined and adaptive. This allows for optimal privacy sanitization in scenarios with different privacy sensitivities and candidate entity richness, while maximizing the preservation of the semantic integrity of the prompt context and the accuracy of inference, effectively solving the problem of balancing privacy and utility.
[0066] This application further proposes a method for determining utility sensitivity. The method first calculates the utility score of each candidate virtual entity relative to the semantic entity. This step aims to quantify the utility impact of each candidate virtual entity on the entire system (e.g., the performance of a large language model in subsequent inference tasks) after replacing the original semantic entity. The utility score can reflect the degree to which the replacement operation maintains information integrity, inference accuracy, or performance for a specific task. Specifically, the calculation of the utility score can be based on various methods. For example, a pre-trained language model can be used to evaluate the context before and after the replacement, quantifying the utility by comparing the confidence score, relevance score, or task completion of the model output. Alternatively, an expert scoring mechanism can be used, where domain experts subjectively evaluate the candidate virtual entity and the semantic entity based on the semantic relevance and information loss in a specific context. Another approach is to calculate the cosine similarity between the embedding vector of the candidate virtual entity in the context and the embedding vector of the original semantic entity, using this similarity as a quantification of the utility score; the higher the similarity, the higher the utility score.
[0067] Subsequently, the absolute difference between the utility scores of each candidate virtual entity and the semantic entity is determined to obtain the maximum utility score difference. The purpose of this step is to identify the maximum fluctuation range of the system's utility impact after replacing the original semantic entity among all candidate virtual entities. This maximum utility score difference can intuitively reflect the degree of utility difference that may result from selecting different candidate entities. In practice, the system iterates through all candidate virtual entities whose utility scores have been calculated, calculates the absolute difference between their utility scores pairwise, and selects the maximum value from these differences as the maximum utility score difference.
[0068] Based on this, an initial value for utility sensitivity is determined according to the difference in maximum utility scores. This step aims to initially map the previously calculated range of utility score fluctuations into a quantified value of utility sensitivity, serving as the basis for subsequent adjustments. In some embodiments, the difference in maximum utility scores can be directly used as the initial value for utility sensitivity. In other embodiments, the difference in maximum utility scores can also be converted into an initial value using a preset mapping function (e.g., a linear or nonlinear function) to adapt to different business needs or model characteristics.
[0069] Finally, the initial value of utility sensitivity is adjusted based on the preset minimum value to obtain the target value. This step aims to ensure that the final determined utility sensitivity has sufficient robustness and stability in practical applications, avoiding excessively low utility sensitivity due to extreme cases (e.g., all candidate virtual entities have very similar utility scores), which could affect the reasonable allocation of the privacy budget. Specifically, if the calculated initial value of utility sensitivity is less than the preset minimum value, the target value of utility sensitivity is set to this preset minimum value; otherwise, the target value of utility sensitivity is the initial value. The preset minimum value of utility sensitivity can be empirically set based on historical data, experimental results, or specific privacy protection requirements to ensure that the utility sensitivity reaches a baseline level under any circumstances, thereby providing a stable parameter basis for subsequent privacy cleansing processes.
[0070] Through the above technical solution, this application provides a more accurate and robust method for determining utility sensitivity. By calculating the utility score of each candidate virtual entity relative to a semantic entity and further determining the maximum absolute difference between these scores, the potential impact of different replacement schemes on system utility can be quantified in detail. Based on this, a preset minimum utility sensitivity value is introduced to correct the initial value, effectively avoiding the situation where the utility sensitivity is incorrectly assessed as too low when the utility scores of candidate entities are highly similar. This correction mechanism ensures that the utility sensitivity is always maintained above a reasonable baseline level, thereby enabling a more accurate balance between privacy protection strength and inference accuracy when subsequently determining the target virtual entity based on utility sensitivity, the current selection mode, and the current privacy budget. Ultimately, this helps improve the stability and reliability of privacy sanitization processing, ensuring that while protecting user privacy, the utility and performance of the large language model in processing cue contexts are maintained to the greatest extent.
[0071] This application further proposes a method to flexibly adjust the selection strategy according to actual needs when determining the target virtual entity corresponding to a semantic entity based on the current selection mode, current privacy budget, and utility sensitivity. In some embodiments of this application, a method is proposed to determine several candidate virtual entities corresponding to a semantic entity and their selection probabilities based on the attribute information of the semantic entity, and to determine the target virtual entity by combining the current selection mode, current privacy budget, and utility sensitivity. However, in practical applications, relying solely on the candidate virtual entity with the highest selection probability as the target virtual entity may lead to insufficient privacy protection in certain scenarios, or when diversity needs to be introduced to enhance robustness, it may be impossible to effectively balance the relationship between privacy security and inference accuracy, thus limiting the flexibility and adaptability of privacy sanitization processing.
[0072] To address the aforementioned issues, this application proposes a more refined target virtual entity determination mechanism. Specifically, this mechanism first comprehensively determines whether to select the candidate virtual entity with the highest probability of selection as the target virtual entity based on the current selection mode, current privacy budget, and utility sensitivity. This judgment process is the core decision-making step, allowing the system to dynamically adjust its selection strategy according to current privacy protection requirements, inference accuracy requirements, and utility differences among different candidate entities. For example, when the system is in a non-maximum probability selection mode with high privacy security requirements, or when the current privacy budget requires introducing more randomness, the system may tend not to directly select the entity with the highest probability. Conversely, when the business scenario has the highest requirement for inference accuracy and low privacy sensitivity, it may directly select the entity with the highest probability. This judgment can be implemented through a pre-set decision function, rule set, or machine learning model. This function or model takes the current selection mode, current privacy budget, and utility sensitivity as input and outputs a Boolean value indicating whether to directly select the candidate entity with the highest probability.
[0073] If so, meaning the judgment result is to directly select the candidate virtual entity with the highest probability, then the system will directly identify the candidate virtual entity with the highest probability as the target virtual entity. In this case, the system believes that directly selecting the best-matching entity can maximize the accuracy of inference, and the privacy risks in the current environment are controllable or acceptable. For example, when the privacy sensitivity corresponding to the semantic entity is low, or when the probability difference between the candidate virtual entity with the highest probability and other candidate entities is very significant, direct selection can ensure the highest semantic consistency.
[0074] Otherwise, if the system determines that it will not directly select the candidate virtual entity with the highest probability, it will adopt a more random or diversified selection strategy. In this case, the system will select a preset number of candidate virtual entities with high probabilities from among those with non-maximum probabilities and add them to the target set. For example, if the preset number is 3, the system will select the second, third, and fourth most probable entities after the entity with the highest probability. This approach aims to introduce a certain degree of randomness while ensuring that the selected entities still have high semantic relevance. Alternatively, the system can also select candidate virtual entities whose probability difference from the maximum probability is less than a preset probability difference threshold from among those with non-maximum probabilities and add them to the target set. This approach can capture entities that are semantically very close to the optimal entity but are not absolutely optimal, thereby increasing the diversity of selection while ensuring quality. Both approaches aim to construct a set containing multiple suboptimal candidate entities, providing a basis for subsequent random selection.
[0075] Based on this, the system will normalize the selection probability of each candidate virtual entity in the target set. The purpose of normalization is to ensure that the sum of the selection probabilities of all candidate virtual entities in the target set is 1, thereby providing an effective probability distribution for subsequent probability sampling. Specifically, the normalized probability of each candidate virtual entity is equal to its original selection probability divided by the sum of the original selection probabilities of all candidate virtual entities in the target set.
[0076] Finally, the system determines the target virtual entity based on the normalized selection probabilities. This step randomly selects an entity from the target set as the final target virtual entity through probability sampling. For example, roulette wheel selection, Monte Carlo sampling, or other weighted random selection algorithms can be used. This method introduces randomness while still tending to select entities with relatively high probabilities, thus achieving a dynamic balance between privacy protection and inference accuracy.
[0077] Through the above technical solution, this application can flexibly decide whether to directly select the candidate virtual entity with the highest probability based on the current selection mode, privacy budget, and utility sensitivity. When higher privacy protection or the introduction of diversity is required, the system can avoid simply selecting the entity with the highest probability, and instead make a probabilistic selection from candidate entities that are suboptimal but still have high semantic consistency. This mechanism effectively solves the problem that relying solely on the maximum probability selection may lead to insufficient privacy protection or a lack of flexibility in certain scenarios. By introducing controlled randomness, this application significantly improves the robustness and adaptability of privacy sanitization while ensuring a certain level of inference accuracy, enabling the privacy sanitization method to better balance privacy security and practicality requirements, and avoiding the limitations of a single selection strategy.
[0078] In S104, for each identifier type entity, a format-preserving mask is performed on the identifier type entity to obtain the mask entity corresponding to the identifier type entity.
[0079] In this embodiment, after identifying each identifier-type entity, a format-preserving mask is applied to each identified entity to generate a corresponding masked entity. This process aims to hide specific privacy information while maintaining its original format characteristics to avoid excessive disruption to the context structure. For example, a phone number "12345678910" can be masked as "123". The mask can be "8910" or "XXX-XXXX-XXXX". This masking process can be implemented using a regular expression-based matching and replacement mechanism to ensure that the number and type of replaced characters match the original format.
[0080] In S105, based on each target virtual entity, each mask entity, and the global entity relationship graph, the initial prompt context is subjected to privacy purification processing to obtain the target prompt context.
[0081] In this embodiment, after obtaining the target virtual entities and mask entities, the initial prompt context is subjected to overall privacy purification processing in conjunction with the previously constructed global entity relationship graph, thereby obtaining the target prompt context. This process includes replacing the original semantic entities in the initial prompt context with the corresponding target virtual entities, and replacing the original identifier entities with the corresponding mask entities. Simultaneously, it is necessary to ensure that the connections between these entities in the global entity relationship graph are updated or adjusted accordingly during the replacement process to maintain the semantic coherence of the context and the integrity of the entity relationships. For example, if there is a "working at" relationship between "Zhang San" and "hospital" in the original text, when "Zhang San" is replaced with "senior physician of a certain hospital," the "working at" relationship between "senior physician" and "hospital" should be preserved. This overall purification process aims to generate a prompt context that both protects privacy and retains as much information as possible for reasoning.
[0082] In some of the above implementations, while privacy purification of the initial prompt context is achieved by replacing semantic entities with target virtual entities and masking identifier entities, this replacement and masking may lead to deviations in semantic coherence or knowledge consistency in the purified target prompt context. Specifically, the target virtual entity may not be able to completely maintain the same contextual semantics as the original semantic entity, or the knowledge constraints contained in the purified context may contradict the inherent functional attributes of the target virtual entity, thereby affecting the accuracy and effectiveness of subsequent reasoning based on the prompt context.
[0083] To address this, this application further proposes that, after performing privacy-cleaning processing on the initial prompt context based on each target virtual entity, each mask entity, and the global entity relationship graph to obtain the target prompt context, the application also includes quality verification and correction of the target prompt context. Specifically, for each target virtual entity in the target prompt context, it is necessary to determine whether the contextual semantics of the target virtual entity are aligned with the contextual semantics of the corresponding semantic entity, and / or, determine the set of functional attributes of the target virtual entity, and, in conjunction with preset universal world knowledge rules, detect whether there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity. If the contextual semantics of the target virtual entity are not aligned with the contextual semantics of the corresponding semantic entity, or if there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity, then the target prompt context is corrected.
[0084] The process of determining whether the contextual semantics of the target virtual entity are aligned with the contextual semantics of the corresponding semantic entity aims to assess whether, during the privacy sanitization process, the target virtual entity successfully maintains contextual coherence and the original intent at the semantic level after replacing the original semantic entity. If the semantics are not aligned, it means that the sanitized context may not accurately convey the original information. This alignment check can be implemented in various ways. For example, it can calculate the similarity (e.g., cosine similarity) between the semantic embedding vector of the target virtual entity in the target cue context and the semantic embedding vector of the corresponding semantic entity in the initial cue context. If the similarity is lower than a preset threshold, it is considered misaligned. Alternatively, a pre-trained language model can be used to assess semantic consistency by evaluating the performance differences of the context before and after replacement on specific semantic tasks.
[0085] Simultaneously, determining the set of functional attributes of the target virtual entity and combining it with pre-defined universal world knowledge rules to detect contradictions between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity is to ensure that the purified context is consistent in logic and factual terms. Although the target virtual entity is abstract, it usually represents a certain type of entity and has specific functional attributes (e.g., a virtual person's name may have attributes such as "occupation" and "age"). The knowledge constraints in the context (e.g., "He is a doctor") must be compatible with these functional attributes. The determination of the set of functional attributes can rely on knowledge graph queries, entity type inference, or attribute extraction through pre-trained models. Universal world knowledge rules can be a predefined set of logical rules or common sense knowledge learned from a large-scale corpus. Contradiction detection compares the knowledge constraints in the target prompt context (obtained through information extraction techniques) with the set of functional attributes of the target virtual entity and the universal world knowledge rules. For example, if the context describes "a company produces milk," but its set of functional attributes shows that its industry is "software development," then a contradiction is determined. This can be achieved through rule-based inference engines or logic programming techniques.
[0086] In one possible implementation, the electronic device can modify the target cue context in the following way: Re-execute the steps for each semantic entity, determining the target virtual entity corresponding to that semantic entity based on its attribute information, and subsequent steps to obtain the target prompt context again; or, inject the minimum knowledge axiom into the target prompt context so that the context semantics of the target virtual entity are aligned with the context semantics of the corresponding semantic entity, and that there is no contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity.
[0087] By re-executing the steps for determining the target virtual entity for each semantic entity and subsequent steps, and re-obtaining the target cue context, the system does not simply abandon the current result when semantic or knowledge issues are detected in the cleaned-up context. Instead, it backtracks to the critical step of semantic entity replacement. This process may include adjusting the parameters used to determine the target virtual entity. For example, different strategies or thresholds may be adopted when determining the current selection mode, current privacy budget, or utility sensitivity. For instance, in a non-maximum probability selection mode, more candidate virtual entities with non-maximum probability of selection may be explored, or the privacy budget may be adjusted to introduce higher randomness, thereby generating a new target virtual entity that may better conform to semantic alignment or knowledge constraints. Through this iterative or backtracking mechanism, the system can explore different privacy cleansing paths in order to find an optimized solution that satisfies privacy protection requirements while ensuring semantic and knowledge consistency of the context.
[0088] Injecting minimal knowledge axioms into the target context aims to directly correct inconsistencies in the context by introducing external, validated knowledge fragments. Minimal knowledge axioms refer to fundamental facts, common-sense rules, or domain-specific constraints that can resolve specific semantic or knowledge conflicts in the most concise and efficient way. For example, if the target virtual entity "Doctor Zhang San" has the attribute set "has a medical license," but the target context implies that it is "engaging in illegal medical activities," then the axiom "all doctors must have legal medical licenses" can be injected to guide the model to correct its understanding of "Doctor Zhang San," aligning its contextual semantics with the original semantic entity and eliminating the contradiction in knowledge constraints. These axioms can be predefined or dynamically generated based on the context and entity type. They can be injected by directly modifying the context text or as additional constraints provided to subsequent processing modules.
[0089] Through the above technical solution, this application provides a flexible and robust privacy-sanitizing context correction mechanism. When semantic misalignment or knowledge constraint contradictions are detected in the target cue context, the system can correct them through two complementary methods. On the one hand, by re-executing semantic entity replacement and subsequent steps, the system can re-explore better privacy-sanitizing schemes under different parameter configurations, thereby having the opportunity to generate a cue context that achieves a better balance between privacy protection and context quality. On the other hand, by injecting minimal knowledge axioms, specific semantic or knowledge errors in the context can be directly and accurately corrected, avoiding the computational overhead of complete reprocessing and ensuring the targetedness and effectiveness of the correction. The combination of these two correction strategies significantly improves the usability and accuracy of the privacy-sanitized cue context, ensuring that while protecting user privacy, the large language model can still perform accurate reasoning based on high-quality context.
[0090] Through the above technical solution, this application can further perform contextual semantic alignment checks on the target virtual entity in the target prompt context after privacy purification processing, and combine general world knowledge rules to detect contradictions between knowledge constraints and functional attribute sets, thereby effectively identifying and correcting semantic deviations or logical inconsistencies that may be introduced by entity replacement or masking processing. This ensures that the purified target prompt context not only meets privacy protection requirements, but also maintains its original semantic integrity and knowledge accuracy to the greatest extent, significantly improving the accuracy and reliability of subsequent large language models or other downstream tasks based on this prompt context for reasoning. In addition, this correction mechanism provides an important quality assurance link for the privacy purification process, avoiding contextual information distortion caused by over-purification or improper replacement, thus achieving a better balance between privacy protection and practicality.
[0091] As can be seen from the above, this solution effectively avoids semantic role breakage and cross-document reference failure by distinguishing between semantic entities and identifier entities and adopting differentiated privacy processing strategies, and by maintaining contextual semantic coherence in combination with a global entity relationship graph. It can protect user privacy while ensuring the reasoning performance of large language models.
[0092] Based on the privacy purification method for prompt context provided in the above embodiments, this application further provides a privacy purification device for prompt context that implements the above method embodiments. Please refer to [link to relevant documentation]. Figure 2 , Figure 2 This is a schematic diagram of a privacy-protecting device that provides contextual suggestions, as provided in an embodiment of this application. Figure 2 As shown, the privacy-cleaning device 20 that provides contextual information may include: a text splicing unit 21, an entity recognition unit 22, an entity determination unit 23, a masking processing unit 24, and a privacy-cleaning unit 25. Wherein: The text splicing unit 21 is used to splice the query text input by the user and the knowledge text corresponding to the query text to obtain the initial prompt context to be privacy cleaned, and to construct the global entity relationship graph corresponding to the initial prompt context; the global entity relationship graph is used to describe the semantic relationship between the various entities in the initial prompt context.
[0093] The entity recognition unit 22 is used to identify semantic entities and identifier entities in the initial prompt context. Both semantic entities and identifier entities include user privacy information. The number of semantic information required for reasoning included in the semantic entity is greater than the preset semantic information quantity threshold, while the number of semantic information required for reasoning included in the identifier entity is less than or equal to the semantic information quantity threshold.
[0094] The entity determination unit 23 is used to determine the target virtual entity corresponding to each semantic entity based on the attribute information of the semantic entity.
[0095] The mask processing unit 24 is used to perform format-preserving mask processing on each identifier type entity to obtain the mask entity corresponding to the identifier type entity.
[0096] The privacy purification unit 25 is used to perform privacy purification processing on the initial prompt context based on each target virtual entity, each mask entity and the global entity relationship graph to obtain the target prompt context.
[0097] Optionally, the entity determination unit 23 is specifically used for: Based on the attribute information of the semantic entity, several candidate virtual entities corresponding to the semantic entity are determined, and the selection probability of each candidate virtual entity is determined. The selection probability of the candidate virtual entity is positively correlated with the semantic consistency of the candidate virtual entity. The semantic consistency of the candidate virtual entity is used to describe the semantic similarity between the candidate virtual entity and the corresponding semantic entity. The target virtual entity corresponding to the semantic entity is determined based on the selection probability of each candidate virtual entity.
[0098] Optionally, the entity determination unit 23 is specifically used for: Determine the current selection mode; the current selection mode includes the maximum probability selection mode and the non-maximum probability selection mode. In the maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is greater than the first probability threshold. In the non-maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is less than the second probability threshold. The first probability threshold is greater than or equal to the second probability threshold. Determine the current privacy budget; the current privacy budget is an adjustable parameter used to control the randomization intensity of candidate virtual entity selection. The smaller the current privacy budget, the higher the degree of randomization when randomly determining the target virtual entity from multiple candidate virtual entities. Determine the utility sensitivity; the utility sensitivity is the maximum difference between the utility scores of each candidate virtual entity corresponding to the same semantic entity. Based on the current selection mode, current privacy budget, utility sensitivity, and the probability of selection for each candidate virtual entity, determine the target virtual entity corresponding to the semantic entity.
[0099] Optionally, the entity determination unit 23 is specifically used for: If any of the first conditions are met, the current selection mode is determined to be the maximum probability selection mode. The first conditions include: the target virtual entity corresponding to the semantic entity is determined for the first time and the privacy sensitivity of the semantic entity is less than the preset sensitivity threshold; the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is greater than the preset probability difference threshold; and the business scenario in which the current large language model is located requires the highest inference accuracy. If any of the second conditions are met, the current selection mode is determined to be a non-maximum probability selection mode. The second conditions include: the privacy sensitivity corresponding to the semantic entity is greater than the sensitivity threshold; the number of times the target virtual entity corresponding to the semantic entity is determined is greater than a preset number threshold; the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is less than or equal to the probability difference threshold; and the business scenario in which the current large language model is located requires the highest level of privacy and security.
[0100] Optionally, the entity determination unit 23 is specifically used for: Determine the privacy sensitivity level corresponding to this semantic entity; Based on the privacy sensitivity level and the target mapping relationship, the candidate range of the current privacy budget is determined; the target mapping relationship is used to describe the relationship between the privacy sensitivity level and the candidate range of the current privacy budget. By labeling the validation set, with the dual optimization objectives of privacy sanitization rate and inference accuracy, the initial value of the current privacy budget is selected within the candidate range of the current privacy budget; Based on the number of each candidate virtual entity corresponding to the semantic entity, the initial value of the current privacy budget is optimized to obtain the target value of the current privacy budget.
[0101] Optionally, the entity determination unit 23 is specifically used for: Calculate the utility score of each candidate virtual entity relative to the semantic entity; Determine the absolute difference between the utility scores of each candidate virtual entity and that of the semantic entity to obtain the maximum utility score difference; The initial value of utility sensitivity is determined based on the difference in maximum utility scores; Based on the preset minimum value of utility sensitivity, the initial value of utility sensitivity is modified to obtain the target value of utility sensitivity.
[0102] Optionally, the entity determination unit 23 is specifically used for: Based on the current selection mode, current privacy budget, and utility sensitivity, determine whether to designate the candidate virtual entity with the highest probability of selection as the target virtual entity; If so, the candidate virtual entity with the highest probability of being selected will be identified as the target virtual entity; Otherwise, among the candidate virtual entities whose selection probability is not the highest, a preset number of candidate virtual entities with the highest selection probability are selected and added to the target set. Alternatively, among the candidate virtual entities whose selection probability is not the highest, candidate virtual entities whose selection probability differs from the maximum selection probability by less than a probability difference threshold are determined and added to the target set. The selection probabilities of each candidate virtual entity in the target set are normalized, and the target virtual entity is determined based on the normalized selection probabilities.
[0103] Optionally, the privacy purification unit 25 is also used for: For each target virtual entity in the target prompt context, determine whether the context semantics of the target virtual entity are aligned with the context semantics of the corresponding semantic entity, and / or determine the set of functional attributes of the target virtual entity, and in combination with the preset general world knowledge rules, detect whether there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity; If the contextual semantics of the target virtual entity are not aligned with the contextual semantics of the corresponding semantic entity, or if there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity, then the target prompt context shall be corrected.
[0104] Optionally, the privacy purification unit 25 is specifically used for: Re-execute the steps for each semantic entity, including determining the target virtual entity corresponding to that semantic entity based on its attribute information, and subsequent steps, to obtain the target prompt context again; or, Inject minimal knowledge axioms into the target prompt context to align the contextual semantics of the target virtual entity with the contextual semantics of the corresponding semantic entity, and to ensure that there is no contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity.
[0105] It should be noted that the information interaction and execution process between the above-mentioned units are based on the same concept as the method embodiments of this application. Their specific functions and technical effects can be referred to the method embodiments section, and will not be repeated here.
[0106] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3As shown, the electronic device 3 provided in this embodiment may include: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a program corresponding to a privacy cleanup method with contextual prompts. When the processor 30 executes the computer program 32, it implements the steps described above in the embodiment of the privacy cleanup method with contextual prompts, for example... Figure 1 S101~S105 are shown. Alternatively, when processor 30 executes computer program 32, it implements the functions of each module / unit in the above-described privacy purifying device embodiment with contextual prompts, for example... Figure 2 The functions of units 21-25 shown.
[0107] For example, computer program 32 can be divided into one or more modules / units, one or more of which are stored in memory 31 and executed by processor 30 to complete this application. One or more modules / units can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of computer program 32 in electronic device 3. For example, computer program 32 can be divided into a text splicing unit 21, an entity recognition unit 22, an entity determination unit 23, a mask processing unit 24, and a privacy purification unit 25. For the specific functions of each unit, please refer to [link to relevant documentation]. Figure 2 The relevant descriptions in the corresponding embodiments are not repeated here.
[0108] Those skilled in the art will understand that Figure 3 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or use different components.
[0109] The processor 30 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0110] The memory 31 can be an internal storage unit of the electronic device 3, such as a hard disk or RAM. The memory 31 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, or flash card. Furthermore, the memory 31 can include both internal and external storage units of the electronic device 3. The memory 31 is used to store computer programs and other programs and data required by the electronic device. The memory 31 can also be used to temporarily store data that has been output or will be output.
[0111] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units is merely an example. In practical applications, the above functions can be assigned to different functional units as needed, that is, the internal structure of the privacy purification device that provides contextual prompts can be divided into different functional units to complete all or part of the functions described above. The functional units in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0112] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps in the various method embodiments described above.
[0113] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps described in the various method embodiments above.
[0114] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, refer to the relevant descriptions of other embodiments.
[0115] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0116] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A privacy simplification method that provides contextual information, characterized in that, include: The query text entered by the user and the knowledge text corresponding to the query text are concatenated to obtain the initial prompt context to be privacy-cleaned, and a global entity relationship graph corresponding to the initial prompt context is constructed; the global entity relationship graph is used to describe the semantic relationships between the various entities in the initial prompt context. Identify semantic entities and identifier entities in the context of the initial prompt; both the semantic entities and the identifier entities include user privacy information, the number of semantic information required for reasoning included in the semantic entities is greater than a preset semantic information quantity threshold, and the number of semantic information required for reasoning included in the identifier entities is less than or equal to the semantic information quantity threshold. For each semantic entity, the target virtual entity corresponding to the semantic entity is determined based on the attribute information of the semantic entity; For each of the identifier-type entities, a format-preserving mask is performed on the identifier-type entity to obtain the mask entity corresponding to the identifier-type entity. Based on each of the target virtual entities, each of the mask entities, and the global entity relationship graph, the initial prompt context is subjected to privacy purification processing to obtain the target prompt context.
2. The method according to claim 1, characterized in that, The step of determining the target virtual entity corresponding to the semantic entity based on the attribute information of the semantic entity includes: Based on the attribute information of the semantic entity, several candidate virtual entities corresponding to the semantic entity are determined, and the selection probability of each candidate virtual entity is determined. The selection probability of the candidate virtual entity is positively correlated with the semantic consistency of the candidate virtual entity. The semantic consistency of the candidate virtual entity is used to describe the semantic similarity between the candidate virtual entity and the corresponding semantic entity. The target virtual entity corresponding to the semantic entity is determined based on the selection probability of each candidate virtual entity.
3. The method according to claim 2, characterized in that, The step of determining the target virtual entity corresponding to the semantic entity based on the selection probability of each candidate virtual entity includes: Determine the current selection mode; the current selection mode includes the maximum probability selection mode and the non-maximum probability selection mode. In the maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is greater than a first probability threshold. In the non-maximum probability selection mode, the probability of the candidate virtual entity with the highest selection probability being identified as the target virtual entity is less than a second probability threshold. The first probability threshold is greater than or equal to the second probability threshold. Determine the current privacy budget; the current privacy budget is an adjustable parameter used to control the randomization intensity of the candidate virtual entity selection. The smaller the current privacy budget, the higher the degree of randomization when randomly determining the target virtual entity from multiple candidate virtual entities. Determine the utility sensitivity; the utility sensitivity is the maximum difference between the utility scores of each candidate virtual entity corresponding to the same semantic entity. The target virtual entity corresponding to the semantic entity is determined based on the current selection mode, the current privacy budget, the utility sensitivity, and the selection probability of each candidate virtual entity.
4. The method according to claim 3, characterized in that, The current selection mode is determined in the following way: If any of the first conditions are met, the current selection mode is determined to be the maximum probability selection mode; the first conditions include: the target virtual entity corresponding to the semantic entity is determined for the first time and the privacy sensitivity of the semantic entity is less than a preset sensitivity threshold; the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is greater than a preset probability difference threshold; the business scenario in which the current large language model is located requires the highest inference accuracy; If any of the second conditions are met, the current selection mode is determined to be the non-maximum probability selection mode; the second conditions include: the privacy sensitivity corresponding to the semantic entity is greater than the sensitivity threshold; the number of times the target virtual entity corresponding to the semantic entity is determined is greater than a preset number threshold; the difference between the selection probability of the candidate virtual entity with the highest selection probability and the selection probability of the candidate virtual entity with the second highest selection probability is less than or equal to the probability difference threshold; and the business scenario in which the current large language model is located requires the highest level of privacy security.
5. The method according to claim 3, characterized in that, The current privacy budget is determined in the following ways: Determine the privacy sensitivity level corresponding to this semantic entity; Based on the privacy sensitivity level and the target mapping relationship, a candidate range for the current privacy budget is determined; the target mapping relationship is used to describe the relationship between the privacy sensitivity level and the candidate range for the current privacy budget. By labeling the validation set, with the dual optimization objectives of privacy sanitization rate and inference accuracy, the initial value of the current privacy budget is selected within the candidate interval of the current privacy budget; Based on the number of each candidate virtual entity corresponding to the semantic entity, the initial value of the current privacy budget is optimized to obtain the target value of the current privacy budget.
6. The method according to claim 3, characterized in that, The utility sensitivity is determined in the following way: Calculate the utility score of each candidate virtual entity relative to the semantic entity; The absolute difference between the utility scores of each candidate virtual entity and that of the semantic entity is determined to obtain the maximum utility score difference. The initial value of the utility sensitivity is determined based on the maximum utility score difference. Based on the preset minimum value of utility sensitivity, the initial value of the utility sensitivity is corrected to obtain the target value of the utility sensitivity.
7. The method according to claim 3, characterized in that, The step of determining the target virtual entity corresponding to the semantic entity based on the current selection mode, the current privacy budget, the utility sensitivity, and the selection probability of each candidate virtual entity includes: Based on the current selection mode, the current privacy budget, and the utility sensitivity, determine whether to select the candidate virtual entity with the highest probability of selection as the target virtual entity; If so, the candidate virtual entity with the highest probability of being selected will be determined as the target virtual entity; Otherwise, among the candidate virtual entities whose selection probability is not the highest, a preset number of candidate virtual entities with the highest selection probability are selected and added to the target set; or, among the candidate virtual entities whose selection probability is not the highest, the candidate virtual entities whose selection probability differs from the maximum selection probability by less than a probability difference threshold are determined and added to the target set, and the selection probability of each candidate virtual entity in the target set is normalized, and the target virtual entity is determined based on the normalized selection probability.
8. The method according to any one of claims 1 to 7, characterized in that, After performing privacy-cleaning processing on the initial prompt context based on each of the target virtual entities, each of the mask entities, and the global entity relationship graph to obtain the target prompt context, the method further includes: For each target virtual entity in the target prompt context, determine whether the context semantics of the target virtual entity is aligned with the context semantics of the corresponding semantic entity, and / or determine the set of functional attributes of the target virtual entity, and in conjunction with preset general world knowledge rules, detect whether there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity; If the contextual semantics of the target virtual entity are not aligned with the contextual semantics of the corresponding semantic entity, or if there is a contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity, then the target prompt context shall be corrected.
9. The method according to claim 8, characterized in that, The modification of the target prompt context includes: The steps of determining the target virtual entity corresponding to each semantic entity based on its attribute information and subsequent steps are re-executed to obtain the target prompt context again. or, The minimum knowledge axiom is injected into the target prompt context to align the context semantics of the target virtual entity with the context semantics of the corresponding semantic entity, and to ensure that there is no contradiction between the knowledge constraints included in the target prompt context and the set of functional attributes of the target virtual entity.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements each step of the privacy sanitization method for prompting context as described in any one of claims 1 to 9.
