Watermark adding method, watermark detection method, watermark processing device and storage medium
By using the probability transfer matrix in the text-generated large model to correct the probability distribution of the original text, the problem of existing large model watermarking technology increasing computing power consumption and affecting the accuracy of the generated content is solved, and more efficient and accurate watermark addition is achieved.
Patent Information
- Application Number
- CN202411753584.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-02
AI Technical Summary
The existing large-model watermarking technology increases the consumption of computing power and time by directly rewriting the generated text, and directly sets the red and green set through hash functions or other methods, affecting the accuracy of the watermark and the availability of generated content.
By inputting the user interaction content and historical output text into the text generation model, the original text probability distribution is obtained, and the preset probability transfer matrix is used to correct it, the corrected text probability distribution is obtained, and the text corresponding to the maximum probability value in the corrected text probability distribution is selected as the current output text after adding the watermark.
Improve the accuracy of watermark addition, avoid the damage caused by using hash functions or other methods to directly set the red and green collection to generate content, and ensure the accuracy and usability of the generated content.
Smart Images

Figure CN119885118A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text processing, and in particular to a watermark adding method, a watermark detecting method, a watermark processing device and a computer storage medium. Background Art
[0002] At present, large model watermarking technology is at the intersection of text generation and information security. Large models such as GPT-4 have achieved great success in natural language processing tasks, but the texts they generate lack verifiability and credibility. In order to ensure the authenticity, source reliability and prevent abuse of texts generated by large models, the concept of large model watermarking is proposed. Large model watermarking aims to embed a hidden information in the generated text to verify the source and integrity of the text.
[0003] Then, the current large-model watermarking technology introduces an additional deep learning model when directly rewriting the generated text to form the watermark style, which increases the consumption of computing power and time. In addition, the current large-model watermarking technology mainly uses hash functions or other methods to directly set the red and green sets of single words to forcibly divide the watermark generation content, which has a great impact on the effect and accuracy of watermarking. Summary of the invention
[0004] In order to solve the above technical problems, the present application proposes a watermark adding method, a watermark detecting method, a watermark processing device and a computer storage medium.
[0005] In order to solve the above technical problems, the present application proposes a watermark adding method, which includes:
[0006] Input the user interaction content and historical output text into the text generation model to obtain the probability distribution of the original text;
[0007] Obtain a preset probability transfer matrix;
[0008] Using the probability transfer matrix to modify the original text probability distribution, to obtain a modified text probability distribution;
[0009] The text corresponding to the maximum probability value in the probability distribution of the modified text is used as the current output text after adding the watermark.
[0010] Wherein, the watermark adding method further comprises:
[0011] Based on the historical output text, obtaining a historical probability gain;
[0012] After obtaining the preset probability transfer matrix, the watermark adding method further includes:
[0013] The probability transfer matrix is gained by using the historical probability gain to obtain a gain probability transfer matrix.
[0014] Wherein, obtaining the historical probability gain based on the historical output text includes:
[0015] Get the output round of each historical output text;
[0016] The output round is input into a probability gain function to obtain the historical probability gain of each historical output text.
[0017] The probability distribution of the original text is an M*1 matrix, and the probability transfer matrix is an M*M matrix; wherein M is the number of dictionary characters.
[0018] The method of modifying the original text probability distribution by using the probability transfer matrix to obtain the modified text probability distribution includes:
[0019] The probability transfer matrix is multiplied by the original text probability distribution to obtain the modified text probability distribution.
[0020] In order to solve the above technical problems, the present application also proposes a watermark detection method, which includes:
[0021] Obtaining a text segment to be detected and a plurality of text segment slices of the text segment to be detected;
[0022] Using a preset probability transfer matrix, the encoding sequence of each text segment slice is obtained;
[0023] Inputting the coding sequence into a watermark classifier to obtain the watermark existence probability of the text segment slice;
[0024] Using the average of the watermark existence probabilities of all text segment slices as the final watermark existence probability of the text segment to be detected;
[0025] Determining the watermark information of the text segment to be detected based on the final watermark existence probability;
[0026] Wherein, the text segment to be detected is generated by the above-mentioned watermark adding method.
[0027] Wherein, the watermark detection method further includes:
[0028] Based on the historical detection text of the text segment to be detected, obtaining a historical probability gain;
[0029] The method of obtaining the encoding sequence of each text segment slice by using a preset probability transfer matrix includes:
[0030] Gaining the probability transfer matrix using the historical probability gain to obtain a gain probability transfer matrix;
[0031] The gain probability transfer matrix is used to obtain the coding sequence of each text segment slice.
[0032] The method of obtaining the encoding sequence of each text segment slice by using a preset probability transfer matrix includes:
[0033] Determine the red zone set and the green zone set using a preset probability transfer matrix;
[0034] Traversing the text in each text segment slice, encoding the text in the red zone set as a first encoding value, and encoding the text in the green zone set as a second encoding value;
[0035] According to the text order of each text fragment slice, all first coding values and / or second coding values are combined to obtain the coding sequence of each text fragment slice.
[0036] In order to solve the above technical problems, the present application also proposes a watermark processing device, which includes a memory and a processor coupled to the memory; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the watermark adding method and / or watermark detection method as mentioned above.
[0037] In order to solve the above technical problems, the present application also proposes a computer storage medium, which is used to store program data. When the program data is executed by a computer, it is used to implement the above watermark adding method and / or watermark detection method.
[0038] Compared with the prior art, the beneficial effects of the present application are as follows: the watermark processing device inputs the user interaction content and the historical output text into the text generation model to obtain the original text probability distribution; obtains the preset probability transfer matrix; uses the probability transfer matrix to correct the original text probability distribution to obtain the corrected text probability distribution; uses the text corresponding to the maximum probability value in the corrected text probability distribution as the current output text after adding the watermark. Through the above-mentioned watermark adding method, it is avoided to use hash functions or other methods to directly set the red and green sets with single words to destroy the accuracy and availability of the generated content, and the output of the large model is corrected by using the probability transfer matrix to improve the accuracy of adding watermarks. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0040] in:
[0041] Figure 1 It is a flowchart of the whole process of adding hidden watermarks in a large text generation model provided by this application;
[0042] Figure 2 It is a flow chart of an embodiment of a watermark adding method provided by the present application;
[0043] Figure 3 It is a flowchart of the watermark-based output content specification module provided by this application;
[0044] Figure 4 It is a flow chart of an embodiment of a watermark detection method provided by the present application;
[0045] Figure 5 It is a flow chart of the watermark specification detection module of the output content provided by this application;
[0046] Figure 6 It is a schematic diagram of the adversarial training process of the watermark adder and the watermark detector provided by the present application;
[0047] Figure 7 It is a structural schematic diagram of an embodiment of a watermark processing device provided by the present application;
[0048] Figure 8 It is a structural diagram of an embodiment of a computer storage medium provided by the present application. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0050] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0051] Currently, there are several existing technical solutions for adding watermarks to large model outputs:
[0052] Post-Inference Watermarking: After the language model generates the full output, the generated text is modified to add a watermark. This method can embed hidden watermark information in the generated text to verify the source and integrity of the text.
[0053] Inference-Time Watermarking: At each generation step, the logistic regression value is modified to add a watermark. This method can watermark the generated text in real time, ensuring that each generation step contains watermark information.
[0054] Token-Level Watermarking: Watermark information is embedded into the generated text by modifying the logistic regression value of the next token. This method performs watermarking in tokens and can embed watermark information at each token position.
[0055] Sentence-Level Watermarking: Watermark information is added by associating the semantic embedding of the next sentence with its prefix. This method performs watermarking on a sentence-by-sentence basis and can embed watermark information at each sentence position.
[0056] In order to solve the problems of the prior art, this application provides a text generation large model hidden watermark adding method, please refer to Figure 1 , Figure 1 It is a flowchart of the entire process of adding hidden watermarks in a text-generated large model provided by this application.
[0057] like Figure 1As shown in the figure, the whole process of adding hidden watermarks to the text generation large model mainly includes the following three parts: the stage of adding hidden watermarks when the large model generates text, the stage of detecting whether a section of text to be detected contains hidden watermarks, and the training adversarial stage of the process of adding watermarks and detecting watermarks.
[0058] Among them, in the stage of adding hidden watermarks when the large model generates text:
[0059] The large model takes user interaction content and historical output text as input, generates text content through autoregressive decoding, and contains the probability distribution of the text in the current dictionary in each output. Conventional technology directly uses the text with the optimal probability of the probability distribution as the current output text, but this technology cannot contain watermark information.
[0060] In the present application, the probability distribution of the characters in the current dictionary will be passed through the watermark-based output content standardization module to select the characters with the best probability after the watermark rule as the characters for the current output.
[0061] After obtaining the current output text, the content of the historical output text will be updated and the next round of autoregression will be carried out. The watermark-based output content specification module will also be used to obtain the text content output according to the watermark rules until the autoregression ends.
[0062] In the stage of detecting whether a piece of text to be detected contains a hidden watermark:
[0063] After the text to be detected is preprocessed and the pure text information is retained, the content to be detected is sent to the watermark standard detection module of the output content to check the probability of the text sequence of the content to be detected being arranged according to the watermark rule.
[0064] During the training adversarial phase of the watermarking and watermark detection process:
[0065] The watermark-based output content specification module and the output content watermark specification detection module compete with each other in the training stage until convergence, so as to output a probability transfer matrix required by both the watermark-based output content specification module and the output content watermark specification detection module.
[0066] The present application further provides a watermark adding method. Figure 1 The large model shown is explained in the stage of adding hidden watermarks when generating text.
[0067] Please refer to Figure 2 and Figure 3 , Figure 2 is a flow chart of an embodiment of a watermark adding method provided by the present application, Figure 3 It is a flowchart of the watermark-based output content standardization module provided by this application.
[0068] The watermark adding method of the present application is applied to a watermark processing device, wherein the watermark processing device of the present application can be a server, a terminal device, or a system composed of a server and a terminal device cooperating with each other. Accordingly, the various parts of the watermark processing device, such as various units, sub-units, modules, and sub-modules, can all be set in the server, can all be set in the terminal device, or can be set in the server and the terminal device respectively.
[0069] Furthermore, the above-mentioned server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules, such as software or software modules used to provide distributed servers, or it can be implemented as a single software or software module, which is not specifically limited here.
[0070] like Figure 2 As shown, the specific steps are as follows:
[0071] Step S11: Input the user interaction content and historical output text into the text generation model to obtain the original text probability distribution.
[0072] In the embodiments of the present application, Figure 1 As shown, the watermark processing device inputs the user interaction content and the historical output text into the text generation model to obtain the original text probability distribution output by the text generation model.
[0073] The historical output text may be one or more texts.
[0074] The original text probability distribution is an M*1 matrix, where M is the number of dictionary characters. The M*1 matrix includes the text probabilities of all characters in the dictionary. The higher the text probability, the greater the possibility that the corresponding character is the current output text.
[0075] It should be noted that the original text probability distribution is the original text probability distribution output by the current text generation model. Each time the text generation model outputs the original text probability distribution of a predicted text.
[0076] Step S12: Obtain a preset probability transfer matrix.
[0077] In an embodiment of the present application, the watermark processing device extracts a preset probability transfer matrix, wherein the preset probability transfer matrix is a fixed value and is the optimal probability transfer matrix obtained by training in the training adversarial stage of the process of adding watermarks and detecting watermarks.
[0078] Among them, the probability transition matrix is an M×M matrix. Compared with the M×1 matrix of the original text probability distribution, the probability transition matrix also contains the context information between dictionary words. For example, when the M×M matrix contains "今" to "日", it includes the text probability of "日"; when it is from "日" to "今", it also includes the text probability of "日", and the text probabilities of the two "日" are different.
[0079] To further improve the accuracy of watermark addition, the watermark processing device of the present application can also introduce historical output words to perform gain compensation on the preset probability transition matrix, so that the probability transition matrix can be adjusted in the direction of current text generation.
[0080] Specifically, the watermark processing device takes the nearest H words according to the historical output tokens, and obtains the probability gain of each word through the following function:
[0081]
[0082] where ω a is the historical gain weight coefficient, and h is the output round of the historical output.
[0083] It should be noted that when h is 1, it means that the corresponding historical output word is the output word of the previous time; when h is 2, it means that the corresponding historical output word is the output words of the previous two times.
[0084] The value range of h depends on the number H of the nearest words obtained by the watermark processing device, and H is a positive integer greater than or equal to 1.
[0085] When H is not 1, the watermark processing device can obtain the historical probability gains of multiple words, and then can use the historical probability gains of multiple words to perform gain compensation on the preset probability transition matrix.
[0086] Specifically, the process for the watermark processing device to calculate the probability transition matrix at the current moment is as follows:
[0087] The preset probability transition matrix W is an M×M matrix, where M is the number of words in the dictionary. The watermark processing device calculates the historical probability gains of H words through the above process, and uses the historical probability gains of these H words to perform matrix operations on the preset probability transition matrix: probability transition matrix * historical probability gain.
[0088] Thus, the watermark processing device obtains the gain probability transition matrix and continues to execute the following step S13.
[0089] Step S13: Use the probability transition matrix to correct the original text probability distribution and obtain the corrected text probability distribution.
[0090] In an embodiment of the present application, the watermark processing device corrects the original text probability distribution output by the large model through a preset probability transfer matrix or a probability transfer matrix after gain compensation to obtain a corrected text probability distribution.
[0091] The correction method includes but is not limited to: performing a matrix multiplication operation on the probability transfer matrix and the original text probability distribution to obtain the corrected text probability distribution.
[0092] Step S14: The text corresponding to the maximum probability value in the probability distribution of the modified text is used as the current output text after adding the watermark.
[0093] In the embodiment of the present application, the watermark processing device selects the text corresponding to the maximum probability value in the probability distribution of the modified text as the current output text of the current text watermarking process. Furthermore, the current output text of the current text watermarking process needs to be re-input into the large model to guide the next text watermarking process as the historical output text.
[0094] It should be noted that, in a complete text watermark adding task, the watermark processing device needs to repeatedly execute the above steps S11 to S14 until the text output by the large model is the end symbol.
[0095] Therefore, the text content output by the text generation model combined with the watermark-based output content specification module can well reflect the added watermark information.
[0096] In the present application, the watermark processing device inputs the user interaction content and the historical output text into the text generation model to obtain the original text probability distribution; obtains the preset probability transfer matrix; uses the probability transfer matrix to correct the original text probability distribution to obtain the corrected text probability distribution; and uses the text corresponding to the maximum probability value in the corrected text probability distribution as the current output text after adding the watermark. Through the above-mentioned watermark adding method, it is avoided to use hash functions or other methods to directly set the red and green sets with single words to destroy the accuracy and availability of the generated content, and the output of the large model is corrected by using the probability transfer matrix to improve the accuracy of adding watermarks.
[0097] The present application further provides a watermark detection method. Figure 1 The shown stage explains the process of detecting whether a piece of text to be detected contains a hidden watermark.
[0098] Please refer to Figure 4 and Figure 5 , Figure 4 is a flow chart of an embodiment of a watermark detection method provided by the present application. Figure 5 It is a flowchart of the watermark specification detection module of the output content provided by this application.
[0099] Among them, the watermark standard detection module of the output content is mainly used in the training stage and the detection stage. It has two functions in the training stage. On the one hand, it trains the classifier of the detector to complete the classification of large model output text and regular text. On the other hand, it assists the watermark output content standardization module to adjust the internal original transfer probability matrix and historical gain weight coefficient.
[0100] like Figure 4 As shown, the specific steps are as follows:
[0101] Step S21: obtaining a text segment to be detected and a plurality of text segment slices of the text segment to be detected.
[0102] In the embodiment of the present application, the watermark processing device obtains a text segment to be detected, wherein the text segment to be detected can be Figure 2 The text fragment generated by the watermark adding method shown.
[0103] Specifically, the watermark processing device may pre-process the text to be detected, that is, remove the output text that is not generated by the large model, thereby improving the efficiency and accuracy of watermark detection.
[0104] In addition, the watermark processing device also needs to slice the preprocessed detection content into multiple text segment slices with a length of L, and the longest length of each text segment slice is L. In this way, the watermark detection method of the present application can detect text segments of any length, while taking into account accuracy and improving adaptability and flexibility.
[0105] Step S22: Obtain the encoding sequence of each text segment slice using a preset probability transfer matrix.
[0106] In the embodiment of the present application, the watermark processing device calculates the encoding sequence of the text segment slice using a preset probability transfer matrix, and the encoding process is as follows:
[0107] The watermark processing device divides the red and green areas according to the preset probability transfer matrix, that is, divides all the words in the dictionary into a red area set and a green area set. The red area set represents the words to be avoided from being output by the large model, and the green area represents the words to be guided to be output by the large model.
[0108] The watermark processing device traverses each character of the text segment slice, and if the character is in the red zone set, it is marked as 1, and if it is in the green zone set, it is marked as 0, thereby obtaining a 0-1 coding sequence with a maximum length of L.
[0109] In other embodiments, the watermark processing device may also adopt the following encoding method: if the text is in the red zone set, it is marked as 0, and if it is in the green zone set, it is marked as 1, thereby obtaining a 0-1 encoding sequence with a maximum length of L.
[0110] Furthermore, the watermark processing device encodes the 0-1 code sequence of length L from binary to decimal with a window length W. For example, if the window length is 16, the length 32 of 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0010 is converted into 1, 2.
[0111] In order to further improve the accuracy of adding watermarks, the watermark processing device of the present application can also introduce a historical probability gain to perform gain compensation on a preset probability transfer matrix so that the probability transfer matrix can be adjusted in the direction of current text detection.
[0112] The method of calculating the historical probability gain is the same as the method of calculating the historical probability gain in step S12, which will not be repeated here.
[0113] Step S23: Input the coding sequence into the watermark classifier to obtain the watermark existence probability of the text segment slice.
[0114] In the embodiment of the present application, the watermark processing device inputs the encoded sequence obtained by step S22 into an SVM (Support Vector Machine) classifier to classify the encoded result, with the input being the encoded sequence and the output being the probability of the watermark existing.
[0115] Step S24: using the average watermark existence probability of all text segment slices as the final watermark existence probability of the text segment to be detected.
[0116] Step S25: Based on the final watermark existence probability, determine the watermark information of the text segment to be detected.
[0117] In the embodiment of the present application, if the final probability of the existence of the watermark is higher than a preset probability threshold, the watermark processing device can determine that a watermark exists in the text segment to be detected.
[0118] Furthermore, the preset probability transfer matrix is used in the output content specification module and the watermark specification detection module. The quality of the probability transfer matrix setting will directly affect the overall effect. However, due to the large number of characters and the lack of grammatical rules that can well meet the requirements of this solution for transfer probability, a swarm intelligence algorithm is adopted, and a particle swarm algorithm is used to iteratively search for the best value of the probability transfer matrix that best meets the requirements of this application and satisfies certain restrictions.
[0119] Please refer to Figure 6 , Figure 6It is a schematic diagram of the adversarial training process of the watermark adder and the watermark detector provided by the present application.
[0120] like Figure 6 As shown, the watermark processing device adopts the following steps when training the probability transfer matrix value:
[0121] Initialize the population of probability transfer matrices: At the beginning, create a population, each individual represents a probability transfer matrix. These probability transfer matrices are used to control the specification and watermark content of the generator output text.
[0122] Divide the red and green areas: According to a red and green threshold, the values in the probability transfer matrix are divided into red and green areas. This may be to limit and control the output of the generator.
[0123] Update the probability transfer matrix value to the output content specification module: Apply the probability transfer matrix value in the population to the output content specification module. This module may be used to normalize the output of the generator to ensure that the generated text meets certain specifications or standards.
[0124] Add watermark module: Add the watermark module to the generator of the large model. This watermark module may be used to embed specific watermark information in the generated text.
[0125] Drive the large model generator to output text: Use the updated probability transfer matrix and watermark module to drive the generator of the large model to generate text.
[0126] Construct training and validation sets for the watermark content classifier trainer: Create a dataset for training the watermark content classifier, where some of the encoded sequences come from the preprocessed dataset and the other part comes from the output of the large model without the output content specification module.
[0127] Training watermark specification detection module: Use training set data to train the watermark specification detection module.
[0128] Verify the effect of the classifier: Use the validation set to evaluate the effect of the classifier and calculate the classification loss. Here, focal loss is used as the classification loss.
[0129] Calculate the loss value of the output text: Calculate the output loss based on the difference between the output text and the expected output. This application uses Manhattan distance loss.
[0130] Calculate the fitness value: In this algorithm, the fitness function is defined as the inverse of the loss value. The loss value consists of classification loss and output loss. The classification loss reflects the accuracy of the watermark content classifier for the generated text, and the output loss reflects the difference between the generated text and the expected output. By defining the fitness as the inverse of the loss value, the particle with a larger fitness value can be made more excellent.
[0131] Use the particle swarm optimization algorithm to adjust the probability matrix value: Use the particle swarm optimization algorithm's update speed and update position function to bring the probability matrix values of each particle in the population closer to the particle with the best fitness. Through the iterative process of the particle swarm optimization algorithm, each particle in the population updates its speed and position based on the current fitness value and the information of neighboring particles. Among them, the inertia weight parameter w is used to balance the contribution of the velocity at the previous moment, the acceleration coefficients c1 and c2 control the influence of individual experience and group experience respectively, and the random numbers r1 and r2 introduce randomness. Through iterative training and updating of fitness values, the particle swarm optimization algorithm can help particles in the population gradually approach the particles with the best fitness, thereby finding a better probability transfer matrix to drive the large model generator to output text that meets the specifications and contains watermark information.
[0132] Iterate training until training ends: Repeat the above steps and perform multiple iterative training until the conditions for training end are met.
[0133] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0134] In order to implement the above-mentioned watermark adding method and / or watermark detecting method, the present application also proposes a watermark processing device, for details, please refer to Figure 7 , Figure 7 It is a structural diagram of an embodiment of a watermark processing device provided by the present application.
[0135] The watermark processing apparatus 400 of this embodiment includes a processor 41 , a memory 42 , an input / output device 43 , and a bus 44 .
[0136] The processor 41, memory 42, and input / output device 43 are respectively connected to a bus 44. The memory 42 stores program data. The processor 41 is used to execute the program data to implement the watermark adding method and / or watermark detecting method described in the above embodiments.
[0137] In the embodiment of the present application, the processor 41 may also be referred to as a CPU (Central Processing Unit). The processor 41 may be an integrated circuit chip having the ability to process signals. The processor 41 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or the processor 41 may also be any conventional processor, etc.
[0138] This application also provides a computer storage medium, please continue to refer to Figure 8 , Figure 8 It is a structural diagram of an embodiment of a computer storage medium provided in the present application. The computer storage medium 600 stores a computer program 61. When the computer program 61 is executed by a processor, it is used to implement the watermark adding method and / or watermark detection method of the above-mentioned embodiment.
[0139] When the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0140] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A watermark adding method, characterized in that: The watermark adding method comprises: Input the user interaction content and historical output text into the text generation model to obtain the probability distribution of the original text; Obtain a preset probability transfer matrix; Using the probability transfer matrix to modify the original text probability distribution, to obtain a modified text probability distribution; The text corresponding to the maximum probability value in the probability distribution of the modified text is used as the current output text after adding the watermark.
2. The watermark adding method according to claim 1, characterized in that: The watermark adding method further comprises: Based on the historical output text, obtaining a historical probability gain; After obtaining the preset probability transfer matrix, the watermark adding method further includes: The probability transfer matrix is gained by using the historical probability gain to obtain a gain probability transfer matrix.
3. The watermark adding method according to claim 2, characterized in that: The obtaining of a historical probability gain based on the historical output text includes: Get the output round of each historical output text; The output round is input into a probability gain function to obtain the historical probability gain of each historical output text.
4. The watermark adding method according to claim 1, characterized in that: The original text probability distribution is an M*1 matrix, and the probability transfer matrix is an M*M matrix; wherein M is the number of dictionary characters.
5. The watermark adding method according to claim 4, characterized in that: The method of modifying the original text probability distribution by using the probability transfer matrix to obtain a modified text probability distribution includes: The probability transfer matrix is multiplied by the original text probability distribution to obtain the modified text probability distribution.
6. A watermark detection method, characterized in that: The watermark detection method comprises: Obtaining a text segment to be detected and a plurality of text segment slices of the text segment to be detected; Using a preset probability transfer matrix, the encoding sequence of each text segment slice is obtained; Inputting the coding sequence into a watermark classifier to obtain the watermark existence probability of the text segment slice; Using the average of the watermark existence probabilities of all text segment slices as the final watermark existence probability of the text segment to be detected; Determining the watermark information of the text segment to be detected based on the final watermark existence probability; Wherein, the text segment to be detected is generated by the watermark adding method described in any one of claims 1 to 5.
7. The watermark detection method according to claim 6, characterized in that: The watermark detection method further comprises: Based on the historical detection text of the text segment to be detected, obtaining a historical probability gain; The method of obtaining the encoding sequence of each text segment slice by using a preset probability transfer matrix includes: Gaining the probability transfer matrix using the historical probability gain to obtain a gain probability transfer matrix; The gain probability transfer matrix is used to obtain the coding sequence of each text segment slice.
8. The watermark detection method according to claim 6 or 7, characterized in that: The method of obtaining the encoding sequence of each text segment slice by using a preset probability transfer matrix includes: Determine the red zone set and the green zone set using a preset probability transfer matrix; Traversing the text in each text segment slice, encoding the text in the red zone set as a first encoding value, and encoding the text in the green zone set as a second encoding value; According to the text order of each text fragment slice, all first coding values and / or second coding values are combined to obtain the coding sequence of each text fragment slice.
9. A watermark processing device, characterized in that: The watermark processing device includes a memory and a processor coupled to the memory; The memory is used to store program data, and the processor is used to execute the program data to implement the watermark adding method as described in any one of claims 1 to 5, and / or the watermark detection method as described in any one of claims 6 to 8.
10. A computer storage medium, characterized in that: The computer storage medium is used to store program data, and when the program data is executed by a computer, it is used to implement the watermark adding method according to any one of claims 1 to 5 and / or the watermark detection method according to any one of claims 6 to 8.
Citation Information
Patent Citations
Intelligent logistics monitoring method based on data traffic monitoring
CN108197451A
Key point detection method based on deep neural network
CN115546469A
Method for embedding and detecting digital watermark in large language model generated text
CN117272253A
Audio leakage protection method and device based on digital watermarking and electronic equipment
CN117935819A
Text watermark detection and watermark adding method, program product, equipment and medium
CN118656810A