Watermark adding method, watermark detecting method, watermark processing apparatus, and storage medium

By obtaining the text probability distribution of a large model and correcting it using the probability transition matrix, combined with historical gain adjustment, we can accurately add watermarks to the text generated by the large model. This solves the problems of increased deep learning consumption and the impact of hash functions on accuracy in existing technologies, and improves the credibility and usability of the generated text.

CN119885118BActive Publication Date: 2025-11-28IFLYTEK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411753584.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-11-28
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

Existing large-scale watermarking technology adds extra deep learning model consumption and affects accuracy due to the hash function partitioning method when generating text, resulting in a decrease in the usability and credibility of the generated content.

Method used

By acquiring the original text probability distribution of user interaction content and historical output text, a preset probability transition matrix is ​​used to correct it. The maximum probability value in the corrected text probability distribution is selected as the watermark output text, and combined with the historical probability gain adjustment matrix, the watermark is accurately added.

Benefits of technology

It improves the accuracy of watermark addition, avoids the direct partitioning of the generated content by the hash function, thus enhancing the verifiability and credibility of the generated text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119885118B_ABST
    Figure CN119885118B_ABST
Patent Text Reader

Abstract

The application provides a watermark adding method, a watermark detection method, a watermark processing device and a computer storage medium. The watermark adding method comprises the following steps: inputting user interaction content and historical output text into a text generation model to obtain an original text probability distribution; obtaining a preset probability transition matrix; correcting the original text probability distribution by using the probability transition matrix to obtain a corrected text probability distribution; and taking a text corresponding to a maximum probability value in the corrected text probability distribution as current output text after watermark adding. By using the watermark adding method, the accuracy and usability of generated content are not damaged by directly setting a red-green set for a single character by using a hash function or other methods, and the output of the large model is corrected by using the probability transition matrix, so that the accuracy of watermark adding is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of text processing, in particular to a watermark adding method, a watermark detection method, a watermark processing device and a computer storage medium. BACKGROUND

[0002] Current large model watermark technology is at the intersection of text generation and information security fields. Large models such as GPT-4 have achieved great success in natural language processing tasks, but the generated text lacks verifiability and credibility. In order to ensure the authenticity, source reliability and prevent misuse of the text generated by the large model, the concept of large model watermark is proposed. Large model watermark 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 watermark technology introduces an additional deep learning model when forming a watermark style by directly rewriting the generated text, increasing the consumption of computing power and time. Moreover, the current large model watermark technology mainly uses hash functions or other methods to directly set a red-green set for single word to hard partition the watermark generation content, which greatly affects the effect and accuracy of watermark addition. SUMMARY

[0004] To solve the above technical problems, the present application provides a watermark adding method, a watermark detection method, a watermark processing device and a computer storage medium.

[0005] To solve the above technical problems, the present application provides a watermark adding method, which comprises:

[0006] inputting the user interaction content and the historical output text into a text generation type large model to obtain an original text probability distribution;

[0007] obtaining a preset probability transition matrix;

[0008] correcting the original text probability distribution using the probability transition matrix to obtain a corrected text probability distribution;

[0009] taking the text corresponding to the maximum probability value in the corrected text probability distribution as the current output text after adding the watermark.

[0010] The watermark adding method further comprises:

[0011] obtaining a historical probability gain based on the historical output text;

[0012] After obtaining the preset probability transition matrix, the watermark adding method further comprises:

[0013] Gain the probability transition matrix by using the historical probability gain, to obtain a gain probability transition matrix.

[0014] The historical probability gain is obtained based on the historical output character, and the historical probability gain includes:

[0015] An output round of each historical output character is obtained.

[0016] The output round is input into a probability gain function to obtain the historical probability gain of each historical output character.

[0017] The original text probability distribution is an M*1 matrix, and the probability transition matrix is an M*M matrix; wherein, M is the number of dictionary characters.

[0018] The modified text probability distribution is obtained by using the probability transition matrix to modify the original text probability distribution, and the modification includes:

[0019] The probability transition matrix and the original text probability distribution are multiplied to obtain the modified text probability distribution.

[0020] To solve the above technical problems, the present application also provides a watermark detection method, which includes:

[0021] Obtain a to-be-detected character segment and a plurality of character segment slices of the to-be-detected character segment.

[0022] Obtain an encoding sequence of each character segment slice by using a preset probability transition matrix.

[0023] Input the encoding sequence into a watermark classifier to obtain a watermark existence probability of the character segment slice.

[0024] Use the average value of the watermark existence probabilities of all character segment slices as the final watermark existence probability of the to-be-detected character segment.

[0025] Determine the watermark information of the to-be-detected character segment based on the final watermark existence probability.

[0026] The to-be-detected character segment is generated by the above watermark adding method.

[0027] The watermark detection method further includes:

[0028] Obtain a historical probability gain based on historical detection characters of the to-be-detected character segment.

[0029] The encoding sequence of each character segment slice is obtained by using a preset probability transition matrix, and the obtaining includes:

[0030] gain the probability transition matrix by using the historical probability gain to obtain a gain probability transition matrix;

[0031] obtain the encoding sequence of each piece of text segment slice by using the gain probability transition matrix.

[0032] obtain the encoding sequence of each piece of text segment slice by using the preset probability transition matrix, including:

[0033] determine the red region set and the green region set by using the preset probability transition matrix;

[0034] encode the text located in the red region set as a first encoding value and encode the text located in the green region set as a second encoding value by traversing the text of each piece of text segment slice;

[0035] combine all the first encoding values and / or second encoding values in the order of the text of each piece of text segment slice to obtain the encoding sequence of each piece of text segment slice.

[0036] To solve the above technical problems, the present application further provides a watermark processing device, which comprises a memory and a processor coupled with the memory; wherein the memory is used to store program data, and the processor is used to execute the program data to realize the watermark adding method and / or the watermark detection method as described above.

[0037] To solve the above technical problems, the present application further provides a computer storage medium, which is used to store program data, and the program data is used to realize the watermark adding method and / or the watermark detection method when executed by a computer.

[0038] Compared with the prior art, the beneficial effects of the present application are that 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 transition matrix; modifies the original text probability distribution by using the probability transition matrix to obtain the modified text probability distribution; and takes the text corresponding to the maximum probability value in the modified text probability distribution as the current output text after adding the watermark. Through the above watermark adding method, the accuracy and usability of the generated content are not damaged by directly setting the red and green sets with single words using the hash function or other methods, and the output of the large model is modified by using the probability transition matrix to improve the accuracy of adding the watermark. BRIEF DESCRIPTION OF DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of these drawings.

[0040] Wherein:

[0041] Figure 1 is the flowchart of the whole process of the text generation type large model hidden watermark adding provided by the present application;

[0042] Figure 2 is the flowchart of an embodiment of the watermark adding method provided by the present application;

[0043] Figure 3 is the flowchart of the output content specification module based on watermark provided by the present application;

[0044] Figure 4 is the flowchart of an embodiment of the watermark detection method provided by the present application;

[0045] Figure 5 is the flowchart of the watermark specification detection module of the output content provided by the present application;

[0046] Figure 6 is the schematic diagram of the adversarial training process of the watermark adder and the watermark detector provided by the present application;

[0047] Figure 7 is the structural schematic diagram of an embodiment of the watermark processing device provided by the present application;

[0048] Figure 8 is the structural schematic diagram of an embodiment of the computer storage medium provided by the present application. DETAILED DESCRIPTION

[0049] The technical solutions in the embodiments of the present application will be described clearly and completely in the following description of the embodiments of the present application in combination with the drawings. Obviously, the described embodiments are only some embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0050] The terms "first", "second", "third", "fourth" and the like in the description and in the claims of the present application, and above-mentioned drawings, if any, are used to distinguish between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of data so designated is not meant to limit potentially identical data in order to highlight the presence of certain mere characteristics while they coexist. Furthermore, the terms "comprise", "comprising", "have", "having", "include", "including" and any variations thereof in the present specification are intended to cover a non-exclusive inclusion, such that a process, method, system, product or apparatus that comprises a list of steps or units not necessarily limited to those listed explicitly and can include other steps or units not expressly listed or inherent to such process, method, product or apparatus.

[0051] Currently, there are several existing technical solutions that can be used to add watermarks to large model outputs:

[0052] Post-Inference Watermarking: After the language model generates the complete 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: Modify the logistic regression value at each generation step 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: Embed watermark information in the generated text by modifying the logistic regression value of the next token. This method watermarking in token units can embed watermark information at each token position.

[0055] Sentence-Level Watermarking: Add watermark information by associating the semantic embedding of the next sentence with its prefix. This method watermarking in sentence units can embed watermark information at each sentence position.

[0056] To solve the problems of the prior art, the present application provides a text generation large model hidden watermark adding method, please refer to Figure 1 , Figure 1 is the flowchart of the whole process of the text generation large model hidden watermark adding method provided by the present application.

[0057] As Figure 1As shown, the whole process of adding a hidden watermark by the text generation type large model mainly includes the following three parts: a stage of adding a hidden watermark when the large model generates text, a stage of detecting whether a piece of to-be-detected text contains a hidden watermark, and a training confrontation stage of the process of adding a watermark and detecting a watermark.

[0058] In the stage of adding a hidden watermark when the large model generates text, the following steps are included.

[0059] The large model takes the user interactive content and the historical output text as input, generates text content through self-recurrence decoding, and includes the probability distribution of the text in the current dictionary in each output.

[0060] In the present application, the probability distribution of the text in the current dictionary is selected by the output content specification module based on a watermark, and the text with the optimal probability after the watermark rule is selected as the current output text.

[0061] After obtaining the output text of the current time, the content of the historical output text is updated, and the next round of self-recurrence is performed.

[0062] In the stage of detecting whether a piece of to-be-detected text contains a hidden watermark, the following steps are included.

[0063] After the to-be-detected text is preprocessed to retain the pure text information, the to-be-detected content is sent to the watermark specification detection module of the output content to check the probability of the text sequence of the to-be-detected content arranged according to the watermark rule.

[0064] In the training confrontation stage of the process of adding a watermark and detecting a watermark, the following steps are included.

[0065] The output content specification module based on a watermark and the watermark specification detection module of the output content are trained in the training stage.

[0066] The present application further provides a watermark adding method. Figure 1 The stage of adding a hidden watermark when the large model generates text is explained.

[0067] For details, please refer to Figure 2 and Figure 3 , Figure 2 is a flowchart of an embodiment of the watermark adding method provided by the present application, Figure 3 is a flowchart of the output content specification module based on a watermark provided by the present application.

[0068] The watermark adding method of the present application is applied to a watermark processing device. The watermark processing device of the present application can be a server, a terminal device, or a system comprising a server and a terminal device. Accordingly, each part of the watermark processing device, such as each unit, subunit, module, and sub-module, can be provided in the server, the terminal device, or both.

[0069] Further, the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster comprising multiple servers or 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 for providing a distributed server, or as a single software or software module, without being specifically limited here.

[0070] As shown in FIG. 1, the specific steps are as follows: Figure 2

[0071] Step S11: inputting the user interaction content and the historical output text into the text generation model to obtain an original text probability distribution.

[0072] In the embodiments of the present application, as shown in FIG. 1, the watermark processing device inputs the user interaction content and the historical output text into the text generation model to obtain an original text probability distribution output by the text generation model. Figure 1

[0073] The historical output text can be one or more characters.

[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 probability of all characters in the dictionary. The higher the text probability, the more likely the corresponding character is the current output character.

[0075] It should be noted that the original text probability distribution is the original text probability distribution output by the current text generation model. The text generation model outputs an original text probability distribution for each predicted text.

[0076] Step S12: obtaining a preset probability transition matrix.

[0077] In the embodiments of the present application, the watermark processing device extracts a preset probability transition matrix. The preset probability transition matrix is a fixed value, which is an optimal probability transition matrix obtained by training in the training and confrontation stage of the process of adding and detecting watermarks.

[0078] ​​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 context information between the dictionary words, such as the text probability of “ri” when “ri” is in the M*M matrix, the text probability of “ri” when “ri” is in the M*M matrix, and the text probability of two “ri” is different.

[0079] To further improve the accuracy of adding watermarks, the watermark processing device of the present application can also introduce historical output words to compensate the preset probability transition matrix, so that the probability transition matrix can be adjusted to the current text generation direction.

[0080] Specifically, the watermark processing device obtains the probability gain of each word by taking the last H words of the historical output token 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, the corresponding historical output word is the previous output word; when h is 2, the corresponding historical output word is the previous two output words.

[0084] The value range of h depends on the number of the last H words obtained by the watermark processing device, and H is a positive integer greater than or equal to 1.

[0085] If H is not 1, the watermark processing device can obtain the historical probability gain of multiple words, and then use multiple historical probability gains to compensate the preset probability transition matrix.

[0086] Specifically, the watermark processing device calculates the probability transition matrix at the current time 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 gain of H words through the above process, and performs matrix operation on the preset probability transition matrix using the historical probability gain of the H words: probability transition matrix*historical probability gain.

[0088] Therefore, the watermark processing device obtains the gain probability transition matrix and continues to perform the following step S13.

[0089] Step S13: correcting the original text probability distribution using the probability transition matrix to obtain a corrected text probability distribution.

[0090] In the embodiment of the present application, the watermark processing apparatus corrects the original text probability distribution output by the large model by using a preset probability transition matrix or a probability transition matrix after gain compensation to obtain a corrected text probability distribution.

[0091] The correction method includes but is not limited to: performing matrix multiplication operation on the probability transition matrix and the original text probability distribution to obtain the corrected text probability distribution.

[0092] Step S14: taking the character corresponding to the maximum probability value in the corrected text probability distribution as the current output character after adding the watermark.

[0093] In the embodiment of the present application, the watermark processing apparatus selects the character corresponding to the maximum probability value in the corrected text probability distribution as the current output character in the current text watermark adding process. Further, the current output character in the current text watermark adding process also needs to be re-input into the large model to guide the next text watermark adding process as the historical output character.

[0094] It should be noted that in a complete text watermark adding task, the watermark processing apparatus needs to repeatedly perform the above steps S11 to S14 until the character output by the large model is an end symbol.

[0095] Therefore, the text generation type large model can well reflect the added watermark information in combination with the text content output by the output content specification module based on the watermark.

[0096] In the present application, the watermark processing apparatus inputs the user interaction content and the historical output character into the text generation type large model to obtain an original text probability distribution; obtains a preset probability transition matrix; corrects the original text probability distribution by using the probability transition matrix to obtain a corrected text probability distribution; and takes the character corresponding to the maximum probability value in the corrected text probability distribution as the current output character after adding the watermark. By using the above watermark adding method, the accuracy and usability of the generated content are not damaged by directly setting the red and green sets for single characters to perform hard division, and the output of the large model is corrected by using the probability transition matrix to improve the accuracy of adding the watermark.

[0097] The present application further provides a watermark detection method for detecting whether a piece of text contains a hidden watermark. Figure 1 The above-mentioned stage of detecting whether a piece of text contains a hidden watermark is explained as shown in FIG. 1.

[0098] For details, please refer to Figure 4 and Figure 5 , Figure 4 is a flowchart of an embodiment of the watermark detection method provided by the present application, Figure 5 is a flowchart of a watermark specification detection module of the output content provided by the present application.

[0099] The watermark specification detection module of the output content is mainly applied in a training stage and a detection stage. In the training stage, the watermark specification detection module has two functions. On one hand, the watermark specification detection module trains a classifier of a detector to classify the output text of the large model and the regular text. On the other hand, the watermark specification detection module assists the watermark output content specification module in adjusting an internal original transition probability matrix and a historical gain weight coefficient.

[0100] As shown in FIG. 6, the specific steps are as follows. Figure 4

[0101] Step S21: obtaining a to-be-detected text segment and a plurality of text segment slices of the to-be-detected text segment.

[0102] In the embodiment of the present application, the watermark processing device obtains a to-be-detected text segment. The to-be-detected text segment can be a text segment generated by the watermark adding method shown in FIG. 5. Figure 2

[0103] Specifically, the watermark processing device can first preprocess the to-be-detected text, that is, remove the output text not generated by the large model, so as to improve the efficiency and accuracy of watermark detection.

[0104] In addition, the watermark processing device also needs to slice the preprocessed detection content into a plurality of text segment slices with a length L, and each text segment slice has a maximum length of L. In this way, the watermark detection method of the present application can detect text segments of any length, while ensuring accuracy, adaptability and flexibility.

[0105] Step S22: obtaining an encoding sequence of each text segment slice by using a preset probability transition matrix.

[0106] In the embodiment of the present application, the watermark processing device calculates the encoding sequence of the text segment slice by using the preset probability transition matrix. The encoding process is as follows.

[0107] The watermark processing device divides the red and green regions according to the preset probability transition matrix, that is, divides all the texts in the dictionary into a red region set and a green region set. The red region set represents the texts to be avoided by the large model, and the green region represents the texts to be guided by the large model.

[0108] The watermark processing device traverses each text of the text segment slice. If the text is in the red region set, the text is marked as 1. If the text is in the green region set, the text is marked as 0, so as to obtain a 0-1 encoding sequence with a maximum length of L.

[0109] ​​In other embodiments, the watermark processing apparatus can also use the following encoding method: if the character is in the red set, mark it as 0, if it is in the green set, mark it as 1, so as to obtain a 0-1 encoding sequence with the longest length L.

[0110] Further, the watermark processing apparatus encodes the 0-1 encoding sequence with length L from binary to decimal with a window length W, for example, if the window length is 16, the 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0010 with length 32 is converted to 1, 2.

[0111] In order to further improve the accuracy of adding watermark, the watermark processing apparatus of the present application can also introduce historical probability gain to compensate the preset probability transition matrix, so as to adjust the probability transition matrix to the current text detection direction.

[0112] Wherein, the way of calculating the historical probability gain is the same as that in step S12, which will not be repeated here.

[0113] Step S23: input the encoding sequence into the watermark classifier to obtain the watermark existence probability of the character segment slice.

[0114] In the embodiment of the present application, the watermark processing apparatus inputs the encoding sequence obtained in step S22 into the SVM (Support Vector Machine) classifier to classify the encoded result, the input is the encoded sequence, and the output is the probability of watermark existence.

[0115] Step S24: use the mean value of the watermark existence probability of all character segment slices as the final watermark existence probability of the to-be-detected character segment.

[0116] Step S25: determine the watermark information of the to-be-detected character segment based on the final watermark existence probability.

[0117] In the embodiment of the present application, if the final watermark existence probability is higher than the preset probability threshold, the watermark processing apparatus can determine that there is a watermark in the to-be-detected character segment.

[0118] Further, in the output content specification module and the watermark specification detection module, the preset probability transition matrix will be used, and the pros and cons of the probability transition matrix setting will directly affect the overall effect, but due to the large number of characters and the lack of grammar rules that can well meet the demand of the transition probability of the present application, a swarm intelligence algorithm is used to find the probability transition matrix value that best meets the demand of the present application and meets certain restrictions.

[0119] For details, please refer to Figure 6 , Figure 6Fig. 1 is a schematic diagram of the adversarial training process of the watermark adder and watermark detector provided by the present application.

[0120] As shown in Fig. 1, the watermark processing device uses the following steps when training the probability transition matrix values: Figure 6

[0121] Initialize the population of probability transition matrices: At the beginning, create a population, each individual representing a probability transition matrix. These probability transition matrices are used to control the specifications of the generator's output text and the watermark content.

[0122] Divide the red-green area: According to a certain red-green threshold, divide the values in the probability transition matrix into red and green areas. This may be to limit and control the output of the generator.

[0123] Update the probability transition matrix values to the output content specification module: Apply the probability transition matrix values in the population to the output content specification module. This module may be used to normalize the output of the generator, ensuring that the generated text meets certain specifications or standards.

[0124] Add watermark module: Add a 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 transition matrix and watermark module to drive the generator of the large model to generate text.

[0126] Construct the training set and validation set of the watermark content classification trainer: Create a dataset for training the watermark content classifier, where part of the encoded sequences come from the preprocessed dataset, and the other part comes from the large model output without the output content specification module.

[0127] Train the watermark specification detection module: Train the watermark specification detection module using the training set data.

[0128] Verify the effect of the classifier: Use the validation set to evaluate the effect of the classifier and calculate the classification loss, where focal loss is used as the classification loss.

[0129] Calculate the loss value of the output text: Calculate the output loss according to the difference between the output text and the expected output, and the Manhattan distance loss is used in the present application.

[0130] ​Computing fitness values: In this algorithm, the fitness function is defined as the inverse of the loss value. The loss value is composed of a classification loss and an output loss, the classification loss reflects the accuracy of the generated text by the watermark content classifier, 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 is better.

[0131] Adjusting probability matrix values using particle swarm optimization algorithm: Using the update speed and update position functions of the particle swarm optimization algorithm, the probability matrix values of each particle in the population are attracted to the fitness-optimal particle. Through the iterative process of the particle swarm optimization algorithm, each particle in the population updates its speed and position according to 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 speed at the last 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 the particles in the population gradually converge to the fitness-optimal particle, so as to find a better probability transition matrix for driving the large model generator to output text that meets the specifications and contains watermark information.

[0132] Iterative training until training is complete: Repeat the above steps for multiple iterations until the training is complete.

[0133] Those skilled in the art can understand that in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0134] To implement the above watermark adding method and / or watermark detection method, the present application also provides a watermark processing device, please refer to Figure 7 , Figure 7 is a structural schematic diagram of an embodiment of the watermark processing device provided by the present application.

[0135] The watermark processing device 400 of the present embodiment comprises a processor 41, a memory 42, an input / output device 43 and a bus 44.

[0136] The processor 41, the memory 42 and the input / output device 43 are connected to the bus 44 respectively, the memory 42 stores program data, and the processor 41 is used to execute the program data to realize the watermark adding method and / or watermark detection method described in the above embodiments.

[0137] In the embodiments of the present application, the processor 41 can also be referred to as a CPU (Central Processing Unit). The processor 41 can be an integrated circuit chip having a processing capability of signals. The processor 41 can also be a general-purpose processor, a DSP (Digital Signal Process), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor 41 can also be any conventional processor.

[0138] The present application also provides a computer storage medium, please continue to refer to Figure 8 , Figure 8 is a structural schematic diagram of an embodiment of the computer storage medium provided by the present application. The computer storage medium 600 stores a computer program 61. When the computer program 61 is executed by a processor, the watermark adding method and / or the watermark detecting method of the above-mentioned embodiments are implemented.

[0139] When the embodiments of the present application are realized 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 solutions of the present application or the whole or part of the technical solutions that make essential contributions to the prior art can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0140] The above only describes the embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation based on the content of the specification and drawings, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A watermark adding method characterized by comprising: The watermark adding method comprises: inputting the user interaction content and historical output text into a text generation model to obtain an original text probability distribution; obtaining a preset probability transition matrix; correcting the original text probability distribution by using the probability transition matrix to obtain a corrected text probability distribution; taking the text corresponding to the maximum probability value in the corrected text probability distribution as the current output text after adding the watermark; The watermark adding method further comprises: obtaining a historical probability gain based on the historical output turns and historical gain weight coefficients of the historical output text; wherein the historical probability gain is the probability gain of the historical output text to the current text generation direction; After obtaining the preset probability transition matrix, the watermark adding method further comprises: gain the probability transition matrix by using the historical probability gain to obtain a gain probability transition matrix.

2. The watermark adding method of claim 1, wherein: obtaining a historical probability gain based on the historical output text comprises: obtaining the output turns of each historical output text; inputting the output turns into a probability gain function to obtain the historical probability gain of each historical output text; wherein the probability gain function is: wherein, h is the history gain weight factor, h is the output turn of the history output text.

3. The watermark adding method of claim 1, wherein: the original text probability distribution is an M*1 matrix, and the probability transition matrix is an M*M matrix; wherein M is the number of dictionary texts.

4. The watermark adding method of claim 3, wherein: correcting the original text probability distribution by using the probability transition matrix to obtain a corrected text probability distribution comprises: performing matrix multiplication operation on the probability transition matrix and the original text probability distribution to obtain the corrected text probability distribution.

5. A watermark detection method characterized by, The watermark detection method comprises: obtaining a to-be-detected text segment and a plurality of text segment slices of the to-be-detected text segment; obtaining an encoding sequence of each text segment slice by using a preset probability transition matrix; inputting the encoding sequence into a watermark classifier to obtain the watermark existence probability of the text segment slice; taking the mean value of the watermark existence probabilities of all text segment slices as the final watermark existence probability of the to-be-detected text segment; determining the watermark information of the to-be-detected text segment based on the final watermark existence probability; wherein the to-be-detected text segment is generated by the watermark adding method of any one of claims 1 to 4.

6. The watermark detection method of claim 5, wherein: The watermark detection method further comprises: obtaining a historical probability gain based on the historical detection text of the to-be-detected text segment; obtaining an encoding sequence of each text segment slice by using a preset probability transition matrix comprises: gain the probability transition matrix by using the historical probability gain to obtain a gain probability transition matrix; obtaining an encoding sequence of each text segment slice by using the gain probability transition matrix.

7. The watermark detection method of claim 5 or 6, wherein: The code sequence of each text segment slice is obtained by using the preset probability transition matrix, and the code sequence of each text segment slice comprises: determining the red region set and the green region set by using the preset probability transition matrix; traversing the text of each text segment slice, encoding the text in the red region set as a first code value, and encoding the text in the green region set as a second code value; combining all the first code values and / or the second code values according to the text sequence of each text segment slice to obtain the code sequence of each text segment slice.

8. A watermark processing apparatus characterized by comprising: The watermark processing device comprises a memory and a processor coupled with the memory; wherein the memory is configured to store program data, and the processor is configured to execute the program data to implement the watermark adding method according to any one of claims 1 to 4, and / or the watermark detecting method according to any one of claims 5 to 7.

9. A computer storage medium, characterized in that The computer storage medium is configured to store program data, and the program data, when executed by a computer, is configured to implement the watermark adding method according to any one of claims 1 to 4, and / or the watermark detecting method according to any one of claims 5 to 7.

Citation Information

Patent Citations

  • Text watermark detection and watermark adding method, program product, equipment and medium

    CN118656810A