Text content replacement method and device, electronic equipment and storage medium
By employing numerical noise fusion and entity replacement methods on the text, the problems of sensitive information leakage and semantic damage in retrieval enhancement generation technology are solved, achieving a balance between privacy protection and text semantic integrity, and improving the accuracy of the generated results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-04-03
AI Technical Summary
Existing search enhancement generation technologies pose risks of sensitive information leakage and semantic damage in the processing of sensitive information, affecting the accuracy of search results.
By performing numerical extraction and noise fusion on the text to be processed, combined with named entity recognition technology for entity replacement, and converting the replaced text into text vectors, a vector index library is built for enhanced retrieval generation.
It achieves the goal of maintaining the semantic integrity of the text while protecting privacy, and improves the accuracy and security of the generated results.
Smart Images

Figure CN121787376A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a text content replacement method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the development of artificial intelligence models, Retrieval-Augmented Generation (RAG) technology is finding increasingly widespread applications. RAG employs a collaborative model of "retrieval of external knowledge + model generation" to retrieve document fragments relevant to the user's query from an external knowledge base, and then generates the final model response based on the retrieval results.
[0003] However, external knowledge bases used for retrieval may contain sensitive information, such as user conversations, medical data, and financial data. Direct retrieval may pose a risk of sensitive information leakage. Current technologies typically use AI models to extract sensitive information and then use the same model for keyword identification and rewriting, such as a dual-proxy privacy rewriting approach, where one proxy performs keyword detection and the other performs text rewriting. However, this approach introduces new risks of sensitive information leakage during the AI model's identification process, and dual-proxy privacy rewriting may suffer from convergence issues. Furthermore, the AI model's processes of sensitive information extraction, keyword detection, and text rewriting are black-box operations, which may distort the original semantics, affecting the accuracy of retrieval results and reducing the usability of retrieval enhancement generation techniques. Summary of the Invention
[0004] This invention provides a text content replacement method, apparatus, electronic device, and storage medium to achieve efficient replacement of sensitive content in text while maintaining the semantic integrity of the text.
[0005] In a first aspect, embodiments of the present invention provide a text content replacement method, the method comprising:
[0006] Numerical values are extracted from the text to be processed, noise is generated, the noise is fused with the extracted values, and the extracted values are replaced.
[0007] Based on named entity recognition technology, entity recognition is performed on the text to be processed, and replacement words are used to replace the recognized entities;
[0008] The replaced text to be processed is converted into a text vector, and retrieval enhancement generation is performed based on the text vector.
[0009] Secondly, embodiments of the present invention also provide a text content replacement device, the device comprising:
[0010] The numerical replacement module is used to extract numerical values from the text to be processed, generate noise, fuse the noise with the extracted numerical values, and replace the extracted numerical values.
[0011] The entity replacement module is used to identify entities in the text to be processed based on named entity recognition technology, and replace the identified entities with replacement words;
[0012] The text conversion module is used to convert the replaced text into a text vector, so as to perform retrieval enhancement generation based on the text vector.
[0013] Thirdly, embodiments of the present invention also 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 program to implement the text content replacement method as described in any of the embodiments of the present invention.
[0014] Fourthly, embodiments of the present invention also provide a storage medium for storing computer-executable instructions, which, when executed by a computer processor, are used to perform a text content replacement method as described in any of the embodiments of the present invention.
[0015] The technical solution of this invention involves extracting numerical values from the text to be processed, generating noise, and then superimposing the noise with the extracted numerical values to achieve numerical replacement. Named entity recognition is then performed on the text to be processed, and replacement words are selected to replace the identified entities. The replaced text is converted into text vectors, and each text vector is saved as the data basis for subsequent retrieval enhancement generation. By blurring the numerical information in the original text and replacing entities, sensitive information is efficiently shielded, protecting privacy while maintaining the semantic integrity of the text, thereby improving the accuracy of the generated results.
[0016] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1This is a flowchart of a text content replacement method provided in Embodiment 1 of the present invention;
[0019] Figure 2 This is a flowchart of a text content replacement method provided in Embodiment 2 of the present invention;
[0020] Figure 3 This is a schematic diagram of the structure of a text content replacement device provided in Embodiment 3 of the present invention;
[0021] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices. In the embodiments of this application, certain software, components, models, and other existing industry solutions may be mentioned. These should be considered exemplary, intended only to illustrate the feasibility of implementing the technical solutions of this application, and do not imply that the applicant has already used or necessarily used such solutions.
[0024] The acquisition, transmission, storage, use, and processing of data in this application all comply with the relevant provisions of national laws and regulations.
[0025] Example 1
[0026] Figure 1The flowchart of a text content replacement method is provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where the method can be executed by a text content replacement device, which can be implemented in hardware and / or software and can be configured in a server.
[0027] like Figure 1 As shown, the method includes:
[0028] S110. Extract numerical values from the text to be processed, generate noise, fuse the noise with the extracted numerical values, and replace the extracted numerical values.
[0029] The text to be processed is text data that has been stored or will be stored in an external knowledge base. In retrieval-enhanced generation technology, document fragments related to the user's query text are usually retrieved from the external knowledge base. The retrieved text data and the query text are then input into the generation model to generate the final model response result.
[0030] Numerical values can take many forms, such as Arabic numerals, numbers with decimal points, and Chinese descriptions of numbers. Numerical value extraction can be performed using regular expressions. Specifically, by pre-setting a regular expression that accommodates various numerical forms, the text to be processed can be matched against the regular expression to locate the numerical values within the text.
[0031] The noise can be Laplace noise, Gaussian noise, etc., and this embodiment does not limit the type of noise. The noise is fused with the extracted values, which can be done by weighting the noise and the original extracted values, and then replacing the original values with the fused values.
[0032] In this embodiment, by fusing noise with the extracted original value and replacing the original value, it is possible to prevent attackers from reconstructing sensitive content through numerical information, and also to ensure the overall logical and semantic coherence of the text.
[0033] Specifically, generating noise, fusing the noise with the extracted values, and replacing the extracted values can include:
[0034] S111. Generate Gaussian noise using a natural language model based on the principle of differential privacy.
[0035] S112. The Gaussian noise is weighted and fused with the extracted values, and the extracted values are then replaced.
[0036] Differential privacy, in this context, refers to adding random noise to data to make the difference between query results that "contain data about a specific individual" and those that "do not contain data about that individual" negligible. This mathematically prevents attackers from inferring the privacy information of individual individuals. In this embodiment, based on differential privacy, the text to be processed after adding noise to the extracted values maintains overall logical and semantic coherence. Its impact on the subsequent query text retrieval results generated by retrieval enhancement is negligible, thus ensuring the accuracy of the query text retrieval results.
[0037] Specifically, differential privacy can employ either a pure differential privacy mechanism (ε-differential privacy) or a relaxed differential privacy mechanism ((ε, δ)-differential privacy). This embodiment uses Gaussian noise generation as an example. The Gaussian noise uses the (ε, δ)-differential privacy mechanism, which can better balance the impact of noise on data usability. Using a natural language model and combining differential privacy principles, suitable Gaussian noise is generated for the numerical values in the text to be processed. The Gaussian noise is then weighted and fused with the original numerical value before replacing the original value.
[0038] S120. Based on named entity recognition technology, perform entity recognition on the text to be processed, and replace the recognized entities with replacement words.
[0039] Named Entity Recognition (NER) is a technology that can identify and classify named entities from unstructured text and categorize them into predefined types. Entity types can include sensitive content such as names, addresses, and contact information.
[0040] Furthermore, in addition to conventional entity types, we can also combine the applicable scenarios and the domain of the text to be processed to train an entity recognition model that matches the scenario and domain, and recognize specific types of entities under the applicable scenarios and domains.
[0041] In this embodiment, by combining named entity recognition technology with specific models for particular scenarios and domains, various types of entities can be accurately identified, thus laying a solid data foundation for subsequent processing.
[0042] Replacement words can be synonyms, semantically similar words, or domain-specific variants of the identified entities. It is essential to ensure that replacing the identified entities with replacement words maintains the semantic integrity of the text being processed while simultaneously preventing attackers from recovering sensitive content by combining information.
[0043] After an entity is identified, since named entity recognition technology can classify each identified entity, in an optional embodiment, replacing the identified entity with a replacement word may include: pre-setting at least two replacement words for each predefined entity type, and randomly selecting a replacement word from the replacement words corresponding to the entity type for the identified entity and replacing it.
[0044] In another alternative embodiment, replacing the identified entities with replacement words may further include:
[0045] S121. Using a natural language model, generate at least two candidate replacement words for the identified entities;
[0046] S122. Using a semantic matching algorithm, determine the semantic similarity between the identified entities and each candidate replacement word, and determine the target replacement word among each candidate replacement word based on the semantic similarity between the identified entities and each candidate replacement word.
[0047] S123. Replace the identified entities according to the target replacement word.
[0048] This embodiment also provides a method for generating replacement words based on a natural language model. Since the entities input to the natural language model do not contain contextual information when generating replacement words, calling the natural language model to generate replacement words can not only generate semantically similar and more accurate replacement words, but also avoid introducing new privacy leakage risks.
[0049] After the natural language model generates multiple candidate replacement words for the identified entity, it evaluates the semantic similarity between each candidate replacement word and the original entity using a semantic matching algorithm, and then selects the candidate replacement word with the highest semantic similarity as the target replacement word. The semantic matching algorithm can employ BERT (Bidirectional Encoder Representations from Transformers), and this embodiment does not limit the specific algorithm type used.
[0050] In this embodiment, a pre-trained natural language model is invoked to generate multiple candidate replacement words, and semantic matching algorithms such as BERT are used to evaluate the semantic similarity between each candidate scheme and the original entity. Sensitive entities are replaced, which can not only ensure the integrity of key semantic components, but also interrupt the possibility of attackers recovering sensitive data by combining information.
[0051] S130. Convert the replaced text to be processed into a text vector, and perform retrieval enhancement generation based on the text vector.
[0052] In this embodiment, for each text to be processed, numerical noise addition and entity replacement are performed using steps S110-S120, thereby achieving privacy protection processing for sensitive content. To construct an efficient and searchable knowledge base from the privacy-protected text data, enabling the retrieval enhancement generation system to quickly and accurately extract the most relevant text fragments from the knowledge base when faced with user queries, this embodiment uses vector representation for the privacy-protected text.
[0053] Specifically, sentence embedding models, such as BERT or Sentence-BERT, can be pre-trained to vectorize each text after privacy protection processing. Then, a vector retrieval engine is used to index each text vector, building a vector index library. In the subsequent Retrieval Augmentation (RAG) system, the vector index library serves as the data foundation for retrieving the query text. Text vectors matching the query text are retrieved from the vector index library, and the text corresponding to the retrieved text vectors, along with the query text, are used as input to the generative model to obtain the generated output.
[0054] Specifically, the retrieval enhancement generation based on the text vector may include:
[0055] S131. Determine the query text and convert the query text into a query text vector;
[0056] S132. Calculate the vector similarity between the query text vector and at least two text vectors, and determine the target text vector among the text vectors based on the vector similarity.
[0057] S133. Input the query text and the text to be processed corresponding to the target text vector into the generation model to obtain the query result output by the generation model.
[0058] Specifically, after the user enters the query text, the query text is vectorized in the same way that the text after privacy protection processing is vectorized, resulting in the query text vector.
[0059] The similarity between the query text vector and each text vector in the vector index is calculated. For example, cosine similarity can be used. After calculating the similarity between the query text vector and each text vector, a predetermined number of text vectors are selected as target text vectors to match the query text vector, based on their similarity scores from highest to lowest. The text data corresponding to the target text vectors, along with the query text, are used as input to the generative model, which then outputs the final query result.
[0060] In this embodiment, text data is processed using regular expressions, and named entity recognition is combined with a scene-specific model to extract numerical values and entities related to sensitive content. Differential privacy principles are used to add noise to the numerical values, and natural language models are used to replace entities, achieving privacy protection for the text data. This privacy protection process is traceable, facilitating problem verification. Finally, by constructing a vector index library, the consistency of text semantics is ensured when external data is accessed. This achieves efficient and accurate information retrieval, meets the requirements for high-quality text generation, and significantly reduces the risk of sensitive content being recovered.
[0061] The technical solution of this invention involves extracting numerical values from the text to be processed, generating noise, and then superimposing the noise with the extracted numerical values to achieve numerical replacement. Named entity recognition is then performed on the text to be processed, and replacement words are selected to replace the identified entities. The replaced text is converted into text vectors, and each text vector is saved as the data basis for subsequent retrieval enhancement generation. By blurring the numerical information in the original text and replacing entities, sensitive information is efficiently shielded, protecting privacy while maintaining the semantic integrity of the text, thereby improving the accuracy of the generated results.
[0062] Example 2
[0063] Figure 2 This is a flowchart of a text content replacement method provided in Embodiment 2 of the present invention. Based on the above embodiments, the present invention adds a process for dynamically adjusting the noise generation parameters and entity replacement parameters.
[0064] like Figure 2 As shown, the method includes:
[0065] S210. Numerical extraction is performed on the text to be processed. Gaussian noise is generated using a natural language model based on pre-set noise amplitude and differential privacy principles.
[0066] The use of differential privacy principle for numerical noise addition has been described in the above embodiments and will not be repeated here.
[0067] Building upon the above embodiments, this embodiment incorporates a noise amplitude parameter, which adjusts the noise level during Gaussian noise generation. Understandably, a larger noise amplitude results in better privacy protection, but simultaneously, it also creates a stronger blurring effect on numbers, potentially leading to a decrease in text quality after replacement. Conversely, a smaller noise amplitude results in better semantic consistency of the text after numerical noise addition, but may not achieve optimal privacy protection. Therefore, reasonably and dynamically adjusting the noise amplitude is a crucial step in balancing privacy protection and text quality.
[0068] S220. The Gaussian noise is weighted and fused with the extracted values, and the extracted values are replaced.
[0069] S230. Based on named entity recognition technology, perform entity recognition on the text to be processed.
[0070] S240. Using a natural language model, generate at least two candidate replacement words for the identified entities.
[0071] S250. Using a semantic matching algorithm, determine the semantic similarity between the identified entities and each candidate replacement word, and determine the target replacement word among each candidate replacement word based on the semantic similarity between the identified entities and each candidate replacement word.
[0072] S260. Replace each identified entity with the target replacement word according to the preset replacement probability.
[0073] The specific process of entity replacement using a natural language model has been described in the above embodiments, and will not be repeated here.
[0074] Building upon the above embodiments, this embodiment adds a replacement probability parameter. The replacement probability represents the number of entities to be replaced, representing the proportion of the total number of entities in the text to be processed. By using a preset replacement probability to replace only a portion of the entities in the text to be processed, the integrity of key semantic components can be guaranteed, while preventing attackers from recovering sensitive content by combining entity information.
[0075] Furthermore, when the replacement probability is less than 100%, a method of randomly selecting from all entities in the text to be processed can be used to select a portion of the entities for replacement. Alternatively, entities can be selected from each page or paragraph based on the replacement probability according to the page number, paragraph, etc., so that the entities to be replaced are evenly distributed across the pages or paragraphs.
[0076] Understandably, a higher replacement probability indicates a higher proportion of entities to be replaced, resulting in better privacy protection. However, this also means a higher proportion of key semantic components are replaced with replacement words, potentially leading to a decrease in text quality and semantic consistency after the replacement. Conversely, a lower replacement probability results in a smaller proportion of entities being replaced, leading to better semantic consistency, but it may not achieve optimal privacy protection. Therefore, reasonably and dynamically adjusting the replacement probability is a crucial step in balancing privacy protection and text quality.
[0077] S270. Determine the feedback value of the text to be processed after replacement.
[0078] The feedback values include at least one quality evaluation value and / or at least one effect evaluation value. The feedback values are used to quantitatively represent the text quality and replacement effect of the replaced text, where the quality evaluation value represents the text quality of the text to be processed, and the effect evaluation value represents the replacement effect of the text to be processed.
[0079] Quality evaluation metrics can include BLEU (Bilingual Evaluation Understudy), ROUGE-L (Recall-Oriented Understudy for Gisting Evaluation - Longest Common Subsequence), and text embedding cosine similarity. BLEU quantifies the accuracy and fluency of the replaced text by comparing the n-gram overlap between the original and replaced text. ROUGE-L measures the semantic and structural match between the two texts by calculating the longest common subsequence (LCS), particularly assessing text coherence and overall semantic consistency. Text embedding cosine similarity is represented by the cosine similarity between the text vectors of the replaced and original texts.
[0080] The performance evaluation can also include the sensitive information matching rate, which can be achieved by pre-training a natural language model to detect the proportion of sensitive content in the replaced text. A higher sensitive information matching rate indicates a worse replacement effect.
[0081] In this embodiment, by monitoring and providing feedback on the replaced text in real time, parameters are automatically adjusted to maximize the quality of text generation and the effect of privacy protection.
[0082] S280. Adjust the noise amplitude and / or replacement probability based on the feedback value.
[0083] In one optional embodiment, threshold ranges for quality evaluation values and / or effect evaluation values can be preset. Taking the example of quality evaluation values simultaneously including BLEU, ROUGE-L, and text embedding cosine similarity, when the quality evaluation values include at least two items, the three quality evaluation values can be weighted and summed to obtain a comprehensive quality evaluation value. A threshold range can then be set for this comprehensive quality evaluation value for unified monitoring. Alternatively, threshold ranges can be set for each quality evaluation value separately for individual monitoring.
[0084] Furthermore, if the quality evaluation value is less than the preset quality evaluation value threshold, and the effect evaluation value is within the preset effect evaluation value threshold range, it indicates that the text quality output by the system has decreased, but the privacy protection effect is still within the required range. In this case, the noise amplitude and / or replacement probability can be appropriately reduced to improve the text quality while ensuring the privacy protection effect. Conversely, if the quality evaluation value is within the preset quality evaluation value threshold range, and the effect evaluation value is greater than the preset effect evaluation value threshold, it indicates that the text quality output by the system is within the required range, but the privacy protection effect is poor. In this case, the noise amplitude and / or replacement probability can be appropriately increased to improve the privacy protection effect while ensuring the text quality.
[0085] Furthermore, when adjusting the noise amplitude and / or replacement probability, an adjustment can be made once according to the preset adjustment step size. Based on the adjusted noise amplitude and / or replacement probability, the text to be processed is numerically noise-added and / or entity-replaced again, and the feedback value is recalculated for the new replaced text until both the quality evaluation value and the effect evaluation value are within the preset threshold range.
[0086] In another alternative embodiment, the optimal noise amplitude and / or replacement probability can be determined by using a target optimization algorithm, such as a Bayesian optimization algorithm or a grid search algorithm, with the goal of maximizing the quality evaluation value and minimizing the effect evaluation value. This embodiment does not limit this.
[0087] In this embodiment, dynamic adjustment of noise amplitude and / or replacement probability based on feedback values can achieve optimal text generation quality while maintaining privacy protection, thus achieving a balance between privacy protection and text generation quality and ensuring stable and efficient operation of the system in different application scenarios.
[0088] Furthermore, the preset noise amplitude and replacement probability are updated based on the feedback values of at least two replaced texts.
[0089] Specifically, at preset time intervals, statistical analysis can be performed based on the feedback values corresponding to each text to be processed to determine the optimal noise amplitude and replacement probability. The optimal noise amplitude and replacement probability are then used as preset noise amplitude and replacement probability values for subsequent text processing.
[0090] This embodiment updates the optimal parameters periodically based on long-term statistical results of feedback values so that they can be automatically invoked in subsequent text processing. This achieves the best balance between privacy protection and text generation quality, ensuring the robustness of the system in long-term operation and allowing for flexible adjustment of parameters according to different application scenarios.
[0091] S290. Convert the replaced text to be processed into a text vector, and perform retrieval enhancement generation based on the text vector.
[0092] The specific process of retrieval enhancement generation has been described in the above embodiments, and will not be repeated in this embodiment.
[0093] In this embodiment, text data is processed using regular expressions, and named entity recognition is combined with a scene-specific model to extract numerical values and entities related to sensitive content. Based on noise amplitude, differential privacy principles are used to add noise to the numerical values, and entity replacement with a certain probability is performed using a natural language model to achieve privacy protection of the text data. The privacy protection process is traceable, facilitating problem verification. During the operation of the text content replacement system, noise amplitude and replacement probability are dynamically adjusted through feedback optimization of text quality and replacement effect, achieving an optimal balance between privacy protection and text generation quality. Finally, by constructing a vector index library, the consistency of text semantics when calling external data is ensured, achieving efficient and accurate information retrieval, meeting the needs of high-quality text generation, and significantly reducing the risk of sensitive content being recovered.
[0094] Example 3
[0095] Figure 3 This is a schematic diagram of a text content replacement device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes:
[0096] The numerical replacement module 310 is used to extract numerical values from the text to be processed, generate noise, fuse the noise with the extracted numerical values, and replace the extracted numerical values.
[0097] The entity replacement module 320 is used to perform entity recognition on the text to be processed based on named entity recognition technology, and replace the recognized entities with replacement words;
[0098] The text conversion module 330 is used to convert the replaced text to be processed into a text vector, so as to perform retrieval enhancement generation based on the text vector.
[0099] The technical solution of this invention involves extracting numerical values from the text to be processed, generating noise, and then superimposing the noise with the extracted numerical values to achieve numerical replacement. Named entity recognition is then performed on the text to be processed, and replacement words are selected to replace the identified entities. The replaced text is converted into text vectors, and each text vector is saved as the data basis for subsequent retrieval enhancement generation. By blurring the numerical information in the original text and replacing entities, sensitive information is efficiently shielded, protecting privacy while maintaining the semantic integrity of the text, thereby improving the accuracy of the generated results.
[0100] Based on the above embodiments, optionally, the numerical replacement module 310 includes:
[0101] The Gaussian noise generation unit is used to generate Gaussian noise based on the differential privacy principle using a natural language model.
[0102] The numerical replacement unit is used to perform weighted fusion of Gaussian noise and the extracted numerical values, and then replace the extracted numerical values.
[0103] Based on the above embodiments, optionally, the entity replacement module 320 includes:
[0104] The candidate replacement word generation unit is used to generate at least two candidate replacement words for the identified entities using a natural language model.
[0105] The target replacement word determination unit is used to determine the semantic similarity between the identified entity and each candidate replacement word through a semantic matching algorithm, and to determine the target replacement word among each candidate replacement word based on the semantic similarity between the identified entity and each candidate replacement word.
[0106] The entity replacement unit is used to replace the identified entities based on the target replacement word.
[0107] Based on the above embodiments, optionally, the text conversion module 330 includes:
[0108] A query text conversion unit is used to determine the query text and convert the query text into a query text vector;
[0109] The target text vector determination unit is used to calculate the vector similarity between the query text vector and at least two other text vectors, and to determine the target text vector among the text vectors based on the vector similarity.
[0110] The query result generation unit is used to input the query text and the text to be processed corresponding to the target text vector into the generation model to obtain the query result output by the generation model.
[0111] Based on the above embodiments, optionally, the Gaussian noise generation unit is specifically used for:
[0112] Gaussian noise is generated using a natural language model, based on pre-set noise amplitude and differential privacy principles.
[0113] Based on the above embodiments, optionally, the entity replacement unit is specifically used for:
[0114] Based on the pre-set replacement probability, the target replacement word replaces each identified entity.
[0115] Optionally, based on the above embodiments, the apparatus further includes:
[0116] The feedback value determination module is used to determine the feedback value of the text to be processed after replacement, wherein the feedback value includes at least one quality evaluation value and / or at least one effect evaluation value;
[0117] The parameter adjustment module is used to adjust the noise amplitude and / or replacement probability based on the feedback value;
[0118] The preset parameter update module is used to update the preset noise amplitude and replacement probability based on the feedback values of at least two replaced texts.
[0119] The text content replacement device provided in the embodiments of the present invention can execute the text content replacement method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.
[0120] Example 4
[0121] Figure 4 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0122] like Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0123] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0124] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as text content replacement methods.
[0125] In some embodiments, the text content replacement method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the text content replacement method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the text content replacement method by any other suitable means (e.g., by means of firmware).
[0126] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0127] Computer programs used to implement the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable text content replacement device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer programs can be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0128] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0129] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0130] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0131] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0132] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0133] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for replacing text content, characterized in that, include: Numerical values are extracted from the text to be processed, noise is generated, the noise is fused with the extracted values, and the extracted values are replaced. Based on named entity recognition technology, entity recognition is performed on the text to be processed, and replacement words are used to replace the recognized entities; The replaced text to be processed is converted into a text vector, and retrieval enhancement generation is performed based on the text vector.
2. The method according to claim 1, characterized in that, Noise is generated and fused with the extracted values. The extracted values are then replaced, including: Gaussian noise is generated using a natural language model based on the principle of differential privacy. The Gaussian noise is weighted and fused with the extracted values, and then the extracted values are replaced.
3. The method according to claim 1, characterized in that, Replace the identified entities with replacement words, including: Using a natural language model, at least two candidate replacement words are generated for the identified entities; The semantic matching algorithm determines the semantic similarity between the identified entities and each candidate replacement word, and the target replacement word is determined from each candidate replacement word based on the semantic similarity between the identified entities and each candidate replacement word. Replace the identified entities based on the target replacement word.
4. The method according to claim 1, characterized in that, The retrieval enhancement generation based on the text vector includes: Determine the query text and convert it into a query text vector; Calculate the vector similarity between the query text vector and at least two other text vectors, and determine the target text vector among the text vectors based on the vector similarity. The query text and the text to be processed corresponding to the target text vector are input into the generative model to obtain the query results output by the generative model.
5. The method according to claim 2, characterized in that, Gaussian noise is generated using a natural language model based on the principle of differential privacy, including: Gaussian noise is generated using a natural language model, based on pre-set noise amplitude and differential privacy principles.
6. The method according to claim 3, characterized in that, Replace the identified entities based on the target replacement word, including: Based on the pre-set replacement probability, the target replacement word replaces each identified entity.
7. The method according to claim 5 or 6, characterized in that, After replacing the identified entities with replacement words, the process also includes: Determine the feedback value of the text to be processed after replacement, the feedback value including at least one quality evaluation value and / or at least one effect evaluation value; Adjust the noise amplitude and / or replacement probability based on the feedback value; The preset noise amplitude and replacement probability are updated based on the feedback values of at least two replaced texts.
8. A text content replacement device, characterized in that, include: The numerical replacement module is used to extract numerical values from the text to be processed, generate noise, fuse the noise with the extracted numerical values, and replace the extracted numerical values. The entity replacement module is used to identify entities in the text to be processed based on named entity recognition technology, and replace the identified entities with replacement words; The text conversion module is used to convert the replaced text into a text vector, so as to perform retrieval enhancement generation based on the text vector.
9. 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 program, it implements the text content replacement method as described in any one of claims 1-7.
10. A storage medium for storing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the text content replacement method as described in any one of claims 1-7.