Digital watermark embedding and detecting method, equipment and medium
By predicting and selecting target clauses, combining watermark feature encoding values and readability thresholds, the problems of susceptibility, opacity and low robustness of existing text digital watermark technologies are solved, and efficient and transparent digital watermark embedding and detection are achieved.
Patent Information
- Application Number
- CN202311133466.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2025-03-04
AI Technical Summary
The existing text digital watermarking technology has problems such as susceptibility, opacity and low robustness.
By predicting the target clause, generating candidate clauses, and determining the target clause based on the watermark feature encoding value and readability threshold, the low perception, transparency and robustness of digital watermarks are achieved.
It realizes embedding watermarks during text generation, improving the perceptuality and transparency of watermarks, and enhancing robustness to ensure that the watermarks can still be effectively detected after text modification.
Smart Images

Figure CN119562013A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital watermarking, and in particular to a digital watermark embedding and detection method, device and medium. Background Art
[0002] As artificial intelligence generated content (AIGC) technology matures, more and more AIGC models are beginning to be put into commercial use. Among them, text generation AI models can use the knowledge and grammar representation capabilities embedded in large-scale language models based on user-given demand descriptions to quickly generate natural and fluent high-quality articles that meet instruction requirements, helping users to efficiently complete a large number of text processing tasks. It has huge commercial value in multiple scenarios such as medical cases, official document writing, financial reports, and legal documents. As a powerful productivity tool, AIGC has brought huge commercial value while also introducing potential usage risks and security compliance issues. Therefore, copyright protection, source authentication, and content traceability for AIGC-generated content are issues that need to be urgently addressed.
[0003] The copyright protection of digital products is usually achieved by using electronic watermarking technology, which uses a non-encrypted strategy based on the text content to embed copyright-related watermarks into digital products, which can protect the copyright of digital products without affecting the use of the digital products themselves. However, the existing text digital watermarking technology has the main problems of being easily perceived, opaque, and low robustness. Summary of the invention
[0004] The embodiment of the present invention provides a digital watermark embedding and detection method, device and medium to solve the problems of the existing text digital watermark technology, which mainly exist in easy perception, opacity and low robustness.
[0005] To solve the above technical problems, the present invention is achieved as follows:
[0006] In a first aspect, an embodiment of the present invention provides a digital watermark embedding method, comprising:
[0007] Predict the Nth target clause and generate at least two N+1th candidate clauses;
[0008] Determine the first watermark feature encoding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature encoding sequence, wherein the N+1th target clause is the next clause of the Nth target clause;
[0009] Determining the N+1th target clause according to the predicted probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold;
[0010] In the case that the N+1 target clauses include a text terminator, the embedded watermark full text is determined, and the embedded watermark full text includes the N+1 target clauses, where N is an integer greater than 0.
[0011] In a second aspect, an embodiment of the present invention provides a digital watermark detection method, including:
[0012] Determine the first P clauses in the text to be detected as the second leading clauses;
[0013] Predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause;
[0014] Calculating respectively the edit distance between the first candidate clause and the P+1th clause, and the edit distance between the second candidate clause and the P+1th clause;
[0015] Determining a second watermark feature encoding value of the P+1th clause according to the edit distance;
[0016] According to the second watermark feature code value, updating the second watermark feature code sequence of the to-be-detected text, wherein the second watermark feature code sequence includes the second watermark feature code value; in the case where P+1 is less than the total number of clauses of the to-be-detected text, determining P=P+1, and repeating the above steps until P+1 is equal to the total number of clauses;
[0017] The second watermark feature coding sequence is matched with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
[0018] In a third aspect, an embodiment of the present invention provides a digital watermark embedding device, including:
[0019] A generation module, used to predict the Nth target clause and generate at least two N+1th candidate clauses;
[0020] A first determination module is used to determine a first watermark feature coding value of an N+1th target clause according to the Nth target clause and a preset first watermark feature coding sequence, wherein the N+1th target clause is a next clause of the Nth target clause;
[0021] a second determination module, configured to determine the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold;
[0022] The third determination module is used to determine the embedded watermark full text when the N+1 target clauses include a text terminator, and the embedded watermark full text includes N+1 target clauses, wherein N is an integer greater than 0.
[0023] In a fourth aspect, an embodiment of the present invention provides a digital watermark detection device, including:
[0024] A first determination module is used to determine the first P clauses in the text to be detected as the second leading clauses;
[0025] A prediction module, used for predicting the P+1th clause of the text to be detected according to the second guide clause to obtain a first candidate clause and a second candidate clause;
[0026] a calculation module, configured to calculate the edit distance between the first candidate clause and the P+1th clause, and between the second candidate clause and the P+1th clause;
[0027] A second determining module, configured to determine a second watermark feature encoding value of the P+1th clause according to the edit distance;
[0028] an updating module, configured to update the second watermark feature coding sequence of the to-be-detected text according to the second watermark feature coding value, wherein the second watermark feature coding sequence includes the second watermark feature coding value; in the case where P+1 is less than the total number of clauses of the to-be-detected text, determine P=P+1, and repeat the above steps until P+1 is equal to the total number of clauses;
[0029] A matching module is used to match the second watermark feature coding sequence with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, wherein P is an integer greater than 0.
[0030] In a fifth aspect, an embodiment of the present invention provides an electronic device, including a processor, wherein the processor is configured to:
[0031] Predict the Nth target clause and generate at least two N+1th candidate clauses;
[0032] Determine the first watermark feature encoding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature encoding sequence, wherein the N+1th target clause is the next clause of the Nth target clause;
[0033] Determining the N+1th target clause according to the predicted probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold;
[0034] In the case that the N+1 target clauses include a text terminator, the embedded watermark full text is determined, and the embedded watermark full text includes the N+1 target clauses, where N is an integer greater than 0.
[0035] In a sixth aspect, an embodiment of the present invention provides an electronic device, including a processor, wherein the processor is configured to:
[0036] Determine the first P clauses in the text to be detected as the second leading clauses;
[0037] Predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause;
[0038] Calculating respectively the edit distance between the first candidate clause and the P+1th clause, and the edit distance between the second candidate clause and the P+1th clause;
[0039] Determining a second watermark feature encoding value of the P+1th clause according to the edit distance;
[0040] According to the second watermark feature code value, updating the second watermark feature code sequence of the to-be-detected text, wherein the second watermark feature code sequence includes the second watermark feature code value; in the case where P+1 is less than the total number of clauses of the to-be-detected text, determining P=P+1, and repeating the above steps until P+1 is equal to the total number of clauses;
[0041] The second watermark feature coding sequence is matched with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
[0042] In the seventh aspect, an embodiment of the present invention provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the digital watermark embedding method as described in the first aspect are implemented; or, when the program is executed by the processor, the steps of the digital watermark detection method as described in the second aspect are implemented.
[0043] In an eighth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the digital watermark embedding method as described in the first aspect are implemented; or, when the computer program is executed by a processor, the steps of the digital watermark detection method as described in the second aspect are implemented.
[0044] In an embodiment of the present invention, the above-mentioned digital watermark embedding method can determine the first watermark feature coding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature coding sequence, and determine the N+1th target clause according to the first watermark feature coding value, the predicted probabilities of the at least two N+1th candidate clauses and the preset readability threshold, so that in the process of generating text, the text content can be determined according to the watermark feature coding value, and the readability of the text can be controlled by the readability threshold, thereby achieving low perception, transparency and robustness of digital watermark embedding. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0046] Figure 1 This is one of the flow charts of a digital watermark embedding method provided by an embodiment of the present invention;
[0047] Figure 2 It is one of the schematic diagrams of a syntactic structure provided by an embodiment of the present invention;
[0048] Figure 3 This is a second schematic diagram of a syntactic structure provided by an embodiment of the present invention;
[0049] Figure 4 is a schematic diagram of a syntactic structure replacement provided by an embodiment of the present invention;
[0050] Figure 5 This is the second flow chart of a digital watermark embedding method provided by an embodiment of the present invention;
[0051] Figure 6 This is a third flow chart of a digital watermark embedding method provided by an embodiment of the present invention;
[0052] Figure 7 This is a fourth flow chart of a digital watermark embedding method provided by an embodiment of the present invention;
[0053] Figure 8 This is one of the flow charts of a digital watermark detection method provided by an embodiment of the present invention;
[0054] Fig. 9 This is the second flow chart of a digital watermark detection method provided by an embodiment of the present invention;
[0055] Fig.10This is a third flow chart of a digital watermark detection method provided by an embodiment of the present invention;
[0056] Fig.11 It is a structural schematic diagram of a digital watermark embedding device provided by an embodiment of the present invention;
[0057] Fig.12 It is a structural schematic diagram of a digital watermark detection device provided by an embodiment of the present invention;
[0058] Fig.13 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0059] Fig.14 It is a schematic diagram of the structure of another electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] For ease of understanding, some contents involved in the embodiments of the present invention are described below:
[0062] As artificial intelligence generation (hereinafter referred to as AIGC) technology matures, more and more AIGC models are beginning to be put into commercial use. Among them, text generation AI models can use the knowledge and grammar representation capabilities embedded in large-scale language models based on the user's given demand descriptions to quickly generate natural and fluent high-quality articles that meet the requirements of instructions, helping users to efficiently complete a large number of text processing tasks. It has huge commercial value in many scenarios such as medical cases, official document writing, financial reports, and legal documents. As a powerful productivity tool, AIGC has brought huge commercial value while also introducing potential usage risks and security compliance issues. Therefore, copyright protection, source authentication, and content traceability for AIGC-generated content are issues that need to be urgently addressed.
[0063] The copyright protection of digital products is usually achieved by using electronic watermarking technology. Based on the text content, a non-encrypted strategy is used to embed copyright-related watermarks into digital products. This can protect the copyright of digital products without affecting the use of the digital products themselves. Existing text watermarking technologies can be mainly divided into the following strategies:
[0064] Solution 1: Treat the text as a picture that is typeset with text lines, so that the mature watermarking technology in the image field can be directly applied to the text field. Specifically, the original text can be digitally watermarked by embedding a background image, changing the font, color, size, spacing of the text, and modifying the pixel characteristics of the text itself.
[0065] Solution 2: Based on the string features of the text itself and the watermark position calculation strategy, the original text is directly modified at a specific position in the text. Specifically, the semantic features of the text itself can be used for equivalent substitution, such as synonym replacement, sentence replacement, and punctuation replacement. It can also be based on a model with masked character prediction function (such as the BERT model) to find a semantic vector word that is similar to the embedding representation of the word at the current position as a replacement word. It can even introduce some typos or grammatical errors through similar glyphs to achieve text watermarking.
[0066] Solution three: Utilize text layout features such as text strings, paragraph numbers, and page numbers, use the zero-width international code (Unicode) character set to encode the above features to form a marker string, and then write it in relatively imperceptible hidden locations in the text, such as titles, page numbers, directories, etc., so as to embed digital watermarks without changing the text content and affecting the user's reading experience.
[0067] However, these digital watermarking technologies have problems such as easy perception, opacity, and low robustness. The specific reasons are as follows:
[0068] The electronic watermark based on image features in Solution 1 is easily perceived by users and affects the user's reading experience to a certain extent. Users can blur the original watermark features by taking a second screenshot of the original text image, converting the format, compressing the image, etc., or even recognize the original text string through optical character recognition (OCR) technology and directly copy the original text content, thereby completely eliminating the original watermark.
[0069] The text replacement scheme adopted in Scheme 2 will change the original text content and even cause the semantics of the text to change, which is contrary to the transparency of the watermark. Language itself is polysemous and ambiguous. Synonyms in different contexts may not necessarily form synonym pairs in another context. Limited by the limitations of natural language processing technology, existing replacement schemes often lead to a decrease in the reading fluency of the original text, and even cause semantic deviation and grammatical errors in the text: for example, "encourage" and "encourage" can be replaced in the sentence "his deeds encourage (encourage) me", but direct replacement in "to encourage (encourage)" will lead to grammatical errors.
[0070] Solution three can maintain the consistency of the original text content before and after the watermark is embedded. Although zero-width characters can be hidden in regular reading software, they can be visualized using professional software tools. In addition, the types of zero-width characters are limited and enumerable. Users can use simple programs to display and batch delete the hidden characters, thereby making the watermark invalid.
[0071] The current text watermark embedding technology is mainly applied to manually written texts. Since the text writers are often not information security experts, it is difficult to consider the watermarking strategy while writing the text. The existing technical solution is a post-processing watermarking technology that requires secondary processing on the given text to achieve the watermarking. This method greatly limits the means of adding watermarks.
[0072] In the embodiment of the present invention, a digital watermark embedding and detection method, device and medium are proposed to solve the problems of the existing text digital watermark technology, such as easy perception, opacity and low robustness.
[0073] See also Figure 1 , Figure 1 is one of the flow charts of a digital watermark embedding method provided by an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0074] Step 101: predict the Nth target clause and generate at least two N+1th candidate clauses.
[0075] Specifically, the prediction of the Nth target clause can be performed using an autoregressive text generation model. The autoregressive text generation model is a natural language processing model based on a deep neural network. It predicts the probability distribution of the next text tag by modeling historical texts, and makes continuous decisions on text tags according to a specific algorithm until the entire text generation is completed.
[0076] It should be noted that the Nth target clause may be a text imported by the user, or a guide clause generated according to the user's instructions, and the N+1th candidate clause may be a clause that may be generated next to the Nth target clause.
[0077] Step 102: Determine the first watermark feature coding value of the N+1th target clause according to the Nth target clause and a preset first watermark feature coding sequence, wherein the N+1th target clause is the next clause of the Nth target clause.
[0078] Specifically, the preset first watermark feature coding sequence can be a sequence of limited length, which can be defined by the user or the system. The first watermark feature coding sequence remains unchanged during the watermark embedding process, for example, it can be a sequence of 0 and 1 of limited length. The first watermark feature coding value can be the coding value corresponding to the N+1th target clause, which can be determined by matching the N+1th target clause with the first watermark feature coding sequence in the order of generating the text.
[0079] Step 103: Determine the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold.
[0080] Specifically, the predicted probability may be the generation probability corresponding to the two N+1th candidate clauses respectively, and the preset readability threshold may be a specific numerical value corresponding to a certain text readability, which can be used to adjust the watermark embedding strategy and control the readability of the generated text.
[0081] Step 104: When the N+1 target clauses include a text terminator, determine the embedded watermark full text, the embedded watermark full text includes the N+1 target clauses, where N is an integer greater than 0.
[0082] Specifically, the text terminator can be used to control the generation of the entire watermark embedded text. It is a special text marker. During the watermark embedding process, if the algorithm determines that the next generated clause includes the text terminator, the generation of the entire text is terminated and the full text of the embedded watermark is determined. The embedded watermark full text includes all target clauses obtained during the watermark embedding process.
[0083] In an embodiment of the present invention, the above-mentioned digital watermark embedding method can determine the first watermark feature coding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature coding sequence, and determine the N+1th target clause according to the first watermark feature coding value, the predicted probabilities of the at least two N+1th candidate clauses and the preset readability threshold, so that in the process of generating text, the text content can be determined according to the watermark feature coding value, and the readability of the text can be controlled by the readability threshold, thereby achieving low perception, transparency and robustness of digital watermark embedding.
[0084] Optionally, the method further includes:
[0085] When the N+1 target clauses do not include the text terminator, determine N=N+1, and repeat the steps of predicting the Nth target clause and generating at least two N+1th candidate clauses until the N+1 target clause includes the text terminator.
[0086] Specifically, when the N+1 target clauses do not include the text terminator, it indicates that the generation of the article has not yet been completed, and it can be determined that N=N+1, and the prediction of the Nth target clause is repeated until the generation of the article is completed.
[0087] In an embodiment of the present invention, the above-mentioned digital watermark embedding method can determine whether the generation of the text is completed through the text terminator, and then before the article generation is completed, the prediction of the Nth target clause can be repeatedly performed until the text terminator is obtained, and the text generation is completed, thereby improving the efficiency of article generation and watermark embedding.
[0088] Optionally, determining the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value, and a preset readability threshold includes:
[0089] When the first watermark feature encoding value is equal to a preset value and the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is greater than the readability threshold, determining the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses as the N+1th target clause;
[0090] When the first watermark feature coding value is not equal to the preset value, or the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is less than or equal to the readability threshold, the N+1th candidate clause corresponding to the maximum prediction probability among the at least two N+1th candidate clauses is determined as the N+1th target clause.
[0091] It should be understood that the preset value may be a certain value in the first watermark feature coding sequence. The first watermark feature coding value being equal to the preset value indicates that the target clause being generated is at the coding position corresponding to the preset value. The readable value may be a specific value corresponding to the readability of the text, and the readable value corresponding to the generated text may be determined simultaneously in the process of predicting the text.
[0092] Specifically, when the first watermark feature encoding value is equal to the preset value, if the readable value of the candidate clause corresponding to the minimum predicted probability among the at least two N+1th candidate clauses is greater than the readability threshold, the candidate clause corresponding to the minimum predicted probability is determined to be the target clause; if the readable value of the candidate clause corresponding to the minimum predicted probability among the at least two N+1th candidate clauses is less than or equal to the readability threshold, the N+1th candidate clause corresponding to the maximum predicted probability among the at least two N+1th candidate clauses is determined to be the N+1th target clause. Furthermore, if the first watermark feature encoding value is not equal to the preset value, it means that the target clause being generated is not in the encoding position corresponding to the preset value, and at this time, the N+1th candidate clause corresponding to the maximum predicted probability among the at least two N+1th candidate clauses can also be determined to be the N+1th target clause.
[0093] In an embodiment of the present invention, the digital watermark embedding method can generate predicted probabilities of at least two N+1th candidate clauses and their corresponding readable values according to the first watermark feature coding value of the target clause, determine the target clause among the at least two N+1th candidate clauses, and directly embed the watermark in the generated text by controlling the sampling probability during the text generation process. This is a smooth watermark adding strategy. During the watermark embedding process, no explicit or implicit additional mark is used to add the text. It is difficult for users to perceive the existence of the watermark, thereby achieving low perception of digital watermark embedding. In addition, during the text generation process, a solution of in-process watermark generation is adopted instead of modifying the text after the full text is completed, thereby ensuring the consistency of the context before and after the text generation. The readability threshold is used to ensure the readability of the text itself. The digital watermark embedding does not affect the quality of the text itself and has good transparency.
[0094] Optionally, after determining the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold, the method further includes:
[0095] Comparing the syntactic structure of the N+1th target clause with a preset first syntactic structure;
[0096] When the syntactic structure of the N+1th target clause is the same as the preset first syntactic structure, the syntactic structure of the N+1th target clause is replaced with the preset second syntactic structure.
[0097] Specifically, the syntactic structure comparison may be performed by calling a dependency syntactic analyzer on a sentence-by-sentence basis to compare the N+1th target clause with a preset first syntactic structure. The dependency syntactic analyzer may perform analysis using an equivalent syntactic template library, and the equivalent syntactic template library may include a preset first syntactic structure and a preset second syntactic structure.
[0098] Exemplarily, the equivalent syntax template library includes two sets, synt_tree_a and synt_tree_b. Both sets are sets composed of pre-set syntax structures, and the two sets have no intersection. Each element of synt_tree_a and synt_tree_b can be manually constructed to form a one-to-one mapping pair. Figure 2 and Figure 3 is a schematic diagram of a syntax structure provided by an embodiment of the present invention. The synt_tree_a set in the equivalent syntax template library is as follows: Figure 2 As shown, the synt_tree_b collection is as follows Figure 3 shown. Figure 4 is a schematic diagram of a syntactic structure replacement provided by an embodiment of the present invention, such as Figure 4 As shown, when the syntactic structure in the synt_tree_a set is used, when the original text is: "I solved the problem.", it can be replaced with "The problem was solved by me" based on the syntactic structure in the synt_tree_b set.
[0099] In an embodiment of the present invention, the digital watermark embedding method can compare the syntactic structure of the N+1th target clause with the preset first syntactic structure, and when the syntactic structure of the N+1th target clause is the same as the preset first syntactic structure, replace the syntactic structure of the N+1th target clause with the preset second syntactic structure, so that all target clauses in the article do not adopt the first syntactic structure, and some target clauses adopt the second syntactic structure. Therefore, in the process of detecting the digital watermark, it is also possible to judge whether the digital watermark overlaps based on the overlap of the syntactic structure of the article, which can further improve the identifiability of the watermark.
[0100] Optionally, predicting the Nth target clause to generate at least two N+1th candidate clauses includes:
[0101] Predict the Nth target clause and generate at least two Mth candidate texts for the N+1th candidate clause;
[0102] Predicting the at least two M-th candidate texts respectively to generate at least two M+1-th candidate texts;
[0103] Combining the at least two Mth candidate texts and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses;
[0104] updating the at least two (N+1)th candidate clauses according to the probabilities corresponding to the combined multiple candidate clauses;
[0105] In the case where the at least two M+1th candidate texts are not sentence terminators, determining M=M+1, respectively predicting the at least two M+1th candidate texts, and generating at least two M+1th candidate texts;
[0106] Combining the at least two N+1th candidate clauses and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses;
[0107] According to the probabilities corresponding to the combined multiple candidate clauses, the at least two N+1th candidate clauses are updated until the at least two M+1th candidate texts are sentence terminators, where M is an integer greater than or equal to 2.
[0108] Specifically, the at least two Mth candidate texts may be multiple candidate texts determined according to the generation probability, and the at least two Mth candidate texts are predicted respectively to generate at least two M+1th candidate texts, and the Mth candidate text and the M+1th candidate text are combined to obtain multiple combined candidate clauses, and the at least two N+1th candidate clauses may be at least two candidate clauses with higher probabilities among the multiple combined candidate clauses. The sentence terminator may be a symbol marking the end of a clause, for example, if c∈[,。 ? ! ;], then c is a sentence terminator.
[0109] In an embodiment of the present invention, the digital watermark embedding method predicts the Nth target clause, generates at least two Mth candidate texts of the N+1th candidate clause, and predicts the at least two Mth candidate texts respectively to generate at least two M+1th candidate texts. Then, in the process of generating text, each time a candidate text is generated, at least two candidate texts are retained, and the two preceding and succeeding candidate texts are combined, and the candidate clause is updated using at least two combinations with a larger probability, so that each time a candidate clause is generated, at least two candidate clauses are obtained accordingly, and the target clause is determined according to a preset watermark coding sequence, that is, the watermark coding value corresponding to the target clause and the readable value of the candidate clause, so that the digital watermark embedding does not affect the text quality, and the generated text has a strong readability.
[0110] Exemplarily, the Nth target clause is predicted to generate at least two Mth candidate texts of the N+1th candidate clause, including text S1 and text S2, where S1 and S2 are the candidate texts with the first and second highest probabilities. Figure 5 This is a second flow chart of a digital watermark embedding method provided by an embodiment of the present invention. Figure 5 As shown, first, input historical texts S1 and S2, predict the next text of S1 and S2 respectively, predict S1 to get S11 and S12, predict S2 to get S21 and S22, and combine the historical text with the next text to get four groups of candidate clauses, determine the candidate clause with the highest probability and the candidate clause with the second highest probability according to the probability, and then update S1 and S2 respectively. If the candidate text is not a sentence terminator, continue to predict the next text of the updated S1 and S2, and repeat the above method to update S1 and S2 until a sentence terminator is generated, and the generation of S1 and S2 is completed. Calculate the watermark encoding value of the target clause corresponding to S1 and S2, and determine the output S1 or S2 according to the watermark encoding value of the target clause and the preset readability threshold. After outputting S1 or S2, the sentence structure of the output clause can also be replaced according to the equivalent template, and finally output the watermark embedded text.
[0111] The corresponding specific algorithm strategy can be as follows:
[0112] (1) The tag IDs and corresponding probability values of the text S1 with the highest probability and the text S2 with the second highest probability are selected using the following formula:
[0113] top1_idx=argmax(token_prob)
[0114] top1_prob=token_prob[top1_idx]
[0115] top2_idx = argmax(token_prob)
[0116] top2_prob=token_prob[top2_idx]
[0117] (2) Initialize the candidate clause sequence:
[0118] sent_output_ids1=[top1_idx,]
[0119] sent_output_probs1=[log(top1_prob),]
[0120] sent_output_ids2=[top2_idx,]
[0121] sent_output_probs2=[log(top2_prob),]
[0122] (3) The predicted probability of the next text token of S1 and S2 is calculated using the following formula:
[0123] token_prob1=norm_func(deep_net(input_ids+sent_output_ids1))
[0124] token_prob2=norm_func(deep_net(input_ids+sent_output_ids2))
[0125] (4) Obtain the first and second highest probability IDs and corresponding probability values of token_prob1 and token_prob2 respectively, and append them to the candidate clauses to obtain a temporary candidate sentence text token list and probability list, a total of four groups:
[0126] sent_output_ids11=sent_output_ids1+top11_idx
[0127] sent_output_probs11=sent_output_probs1+log(top11_prob)
[0128] sent_output_ids12=sent_output_ids1+top12_idx
[0129] sent_output_probs12=sent_output_probs1+log(top12_prob)
[0130] sent_output_ids21=sent_output_ids1+top21_idx
[0131] sent_output_probs21=sent_output_probs1+log(top21_prob)
[0132] sent_output_ids22=sent_output_ids1+top22_idx
[0133] sent_output_probs22=sent_output_probs1+log(top22_prob)
[0134] (5) Calculate the scores of the four groups of clauses according to the following formula and sort the results in descending order:
[0135]
[0136]
[0137]
[0138]
[0139] (6) According to the scores of the four groups of clauses, the corresponding clause text token list and probability list are used to replace the candidate clause sequence. If the last token is not a text end symbol or a sentence end symbol, the prediction of the next text is continued. If the last text token of sent_output_ids1 is a sentence end symbol sent_end or a text end symbol doc_end, sent_output_ids2 is continued to be generated until sent_end or doc_end is generated. Similarly, when the last text token of sent_output_ids2 is sent_end or doc_end, sent_output_ids1 is continued to be generated. After the generation is completed, the candidate clause sequences sent_output_ids1 and sent_output_ids2 are output.
[0140] After S1 and S2 are generated, the watermark code value of the target clause corresponding to S1 and S2 is calculated. If the watermark code value sent_watermark_code == 1, and average(sent_output_probs2)>λ read ,λ read If it is the preset readability threshold, S2 is determined as the target clause: input_ids=input_ids+sent_output_id2, and S2 is output. In other cases, S1 is determined as the target clause: input_ids=input_ids+sent_output_id1, S1 is output, and the sentence number is updated: sent_idx=sent_idx+1, and the next watermark embedded text is generated.
[0141] Exemplarily, the following paragraph describes the process of the digital watermark embedding method:
[0142] The watermark feature encoding sequence currently used is watermark_code: 1010, and the readability threshold is λ read Set to 0.5, the generated text completed by the current algorithm is:
[0143] Table 1
[0144]
[0145]
[0146] As can be seen from Table 1, the sequence number of the target clause currently being generated is sent_idx=4, where the leading clause is the Nth target clause. First, the feature coding value of the current target clause is calculated. The watermark feature coding value of the current clause can be specifically calculated using the following formula:
[0147] watermark_code_idx=sent_idx%len(1010)=4%4=0
[0148] sent_watermark_code=watermark_code[0]=1
[0149] Then, candidate clauses S1 and S2 are generated. Assume that the target clause sent_idx=4 has partially generated candidate clauses S1 and S2, as follows:
[0150] S1: [in,the present invention], corresponding probability 0.75;
[0151] S2: [In,this case], corresponding probability is 0.70;
[0152] Then continue to predict the first probability large text top1, the second probability large text top2 and their probabilities for the next candidate text of S1 and S2:
[0153] S1: top1 (proposed, 0.6), top2 (created, 0.1);
[0154] S2: top1 (invention, 0.9), top2 (proposition, 0.05);
[0155] Therefore, it can be calculated that:
[0156] S11 = (S1, 0.75) + (proposed, 0.6) = (0.75*3+0.6) / 4 = 0.71;
[0157] S12 = (S1, 0.75) + (creation, 0.1) = (0.75*3+0.6) / 4 = 0.59;
[0158] S21 = (S2, 0.6) + (invention, 0.9) = (0.7*3 + 0.9) / 4 = 0.75;
[0159] S22 = (S2, 0.6) + (proposed, 0.005) = (0.6*3 + 0.05) / 4 = 0.538;
[0160] Therefore, S1 and S2 are updated as follows:
[0161] S1=S21=[In, this case, invention], corresponding to probability 0.75;
[0162] S2=S11=[In the present invention, proposed], corresponding probability 0.71;
[0163] Repeat the above process until the sentence terminator is generated.
[0164] Assume that the final candidate clause is:
[0165] S1: [In ,the ,present ,paper, ,a ,watermark ,embedding ,method ,is ,proposed], ,corresponding ,probability ,0.8;
[0166] S2: [In ,this case, a digital ,watermark algorithm was invented], corresponding to probability 0.6;
[0167] For the traditional watermark-free generation scheme, S1 with a higher probability will be selected. However, in the embodiment of the present invention, since sent_watermark_code=1 and S2>λ read , finally output clause S2 as the content of clause sent_idx=4, and update the content in Table 1, as shown in Table 2 below:
[0168] Table 2
[0169]
[0170] If the last text token of the output clause is not the sentence terminator doc_end, the next candidate text is predicted until the sentence terminator is obtained. Then the watermark embedding process ends and the embedded watermark text is output.
[0171] In the embodiment of the present invention, during the text generation process, multiple candidate clauses are generated simultaneously with clauses as the generation unit, and the clauses are sampled and decided according to the watermark feature encoding value at the current position. Each clause only encodes one bit of watermark value, and the readability threshold λ is used to determine the candidate clauses. read The readability of the generated text is guaranteed, and robust digital watermark embedding is achieved by recycling the watermark feature encoding.
[0172] Optionally, the Nth target clause is a first guiding clause, and before predicting the Nth target clause to generate at least two N+1th candidate clauses, the method further includes:
[0173] Transcribing the input instruction to obtain a model prompt string, wherein the input instruction is used to control the text generation content;
[0174] Using a word segmenter to convert the model prompt string to obtain an integer list;
[0175] Perform text feature encoding according to the integer list to obtain a real number vector;
[0176] Normalizing the real number vector to convert it into a probability distribution to obtain a probability corresponding to the real number vector;
[0177] The first guiding clause is determined according to the probability.
[0178] Specifically, the input instruction may be an instruction input by a user or device for controlling the generation of text content. Exemplarily, the user inputs a generation instruction and an instruction description for controlling the generation of text content, wherein the generation instruction instruction_str and the instruction description input_str are both a string, respectively used to describe the requirements for the generated content and other detailed generation information to the model.
[0179] For example, generate an instruction: Translate the given English text into Chinese; instruction description: This is analleviation from your Lord and a mercy.
[0180] First, the command is transcribed, and the slot filling template promp_template is used to splice the user's command and description into the model prompt string prompt_str:
[0181] promp_template = "Requirement: {instruction_str} Description: {input_str} Answer:"
[0182] In the embodiment of the present invention, the generated prompt_str is:
[0183] prompt_str="Requirement: Translate the given English text into Chinese Description: This is analleviation from your Lord and a mercy. Answer:"
[0184] Secondly, text encoding is performed. Based on the model dictionary V, the word segmenter text_encoder (such as word piece, maximum forward matching, BPE, etc.) is used to convert prompt_str into an integer list input_ids:
[0185] input_ids=text_encoder(prompt_str)=[x0,x1,…,x n ],x i ∈[0,|V|]
[0186] The model dictionary V is a mapping dictionary of length |V|, which maps words or subwords to positive integers from 0 to |V|: V = {word:idx}, idx∈[0,|V|];
[0187] Then, text feature encoding is performed, and input_ids is converted into a real vector token_feature with dimension |V| based on a deep neural network deep_net (such as lstm, cnn, transformer, etc.):
[0188] token_feature |V| =deep_net(input_ids)=[f0,f1,f2,…f |V| ]
[0189] Finally, the probability of the next text tag is predicted, and the vector normalization function norm_func (such as the softmax function) is used to normalize the text feature encoding and transform the probability distribution token_prob:
[0190] token_prob=norm_func([f0,f1,f2,…f |V| ])=[p0,p1,……p |V| ]
[0191] sum(p0,p1,...p |V| )=1
[0192] For example, Figure 6 This is a flowchart of a digital watermark embedding method provided by an embodiment of the present invention. Figure 6 As shown:
[0193] First, the generation instruction, instruction description and watermark feature code are input, and then the guidance context is generated according to the generation instruction and instruction description. The watermark embedded text is generated according to the guidance context and the watermark feature code, and then the equivalent syntactic template is replaced according to the watermark embedded text, and finally the replaced watermark embedded text is output.
[0194] In an embodiment of the present invention, the above-mentioned digital watermark embedding method can obtain a model prompt string by transcribing the input instruction, and encode the text features according to the model prompt string, and then perform text prediction to obtain the first introduction clause, and then generate the entire text according to the first introduction clause, thereby further improving the automation of text generation.
[0195] Optionally, determining the first guiding clause according to the probability includes:
[0196] Determining the first text of the first introduction clause according to the text corresponding to the maximum probability among the probabilities;
[0197] Predicting the first text to obtain a predicted text;
[0198] The first guide clause is updated according to the predicted text until the number of generated sentence ending symbols is greater than a preset threshold;
[0199] When the number of generated sentence terminators is greater than the preset threshold, the generation of the first introduction clause is completed.
[0200] Specifically, the first introductory clause may be a generated text consisting of a plurality of clauses. For example, Figure 7 This is a fourth flow chart of a digital watermark embedding method provided by an embodiment of the present invention. Figure 7 As shown, first, the user's input instruction is transcribed, text encoded and text feature encoded to obtain a real number vector, and the next text tag is probability predicted. When the next text generated is not equal to the sentence end symbol, the next text tag probability prediction is continued until a sentence end symbol is generated, indicating that a guiding clause is generated. When the number of guiding clauses is less than or equal to the length of a preset guiding context, text feature encoding and next text tag probability prediction are continued until the number of guiding sentences is greater than the length of a preset guiding context, wherein the guiding context is the first guiding clause.
[0201] The corresponding specific algorithm strategy can be as follows:
[0202] Set the length of the guiding context to prior_length, that is, the guiding context is a generated text consisting of prior_length clauses;
[0203] Initialize the generated text sequence number sent_idx, set sent_idx = 0, and initialize the guide clause sequence:
[0204] sent_output_ids = [];
[0205] Calculate the next text token and select the text token with the maximum probability in token_prob: n_idx = argmax(token_prob). If n_idx is not the sentence terminator sent_end, append n_idx to sent_output_ids, and continue text feature encoding and next text token probability prediction to calculate token_prob of the current text:
[0206] token_feature |V|=deep_net(input_ids+sent_output_ids)
[0207] token_prob=norm_func([f0,f1,f2,…f |V| ])
[0208] If n_idx is the sentence terminator sent_end, the generation of the introductory clause is completed:
[0209] sent_idx=sent_idx+1
[0210] input_ids=input_ids+sent_output_ids
[0211] When sent_idx == prior_length, the guided context generation is terminated.
[0212] See also Figure 8 , Figure 8 is one of the flow charts of a digital watermark detection method provided by an embodiment of the present invention, such as Figure 8 As shown, the method comprises the following steps:
[0213] Step 801: Determine the first P clauses in the text to be detected as the second introduction clauses.
[0214] Specifically, the text to be detected may be a paragraph of text or an entire article, and the text to be detected may be disassembled by sentence terminators to obtain multiple clauses, and the first P clauses are selected as the second guide clauses.
[0215] Step 802: predict the P+1th clause of the text to be detected according to the second guide clause to obtain a first candidate clause and a second candidate clause.
[0216] Specifically, the first candidate clause and the second candidate clause may be two candidate clauses with the highest probability in the next candidate clause of the P+1th clause.
[0217] Step 803: Calculate the edit distance between the first candidate clause and the P+1th clause, and between the second candidate clause and the P+1th clause respectively.
[0218] Specifically, the Levenshtein Distance can be used to represent the similarity between two character strings, and can be calculated using an Levenshtein Distance algorithm.
[0219] Step 804: Determine the second watermark feature encoding value of the P+1th clause according to the edit distance.
[0220] Specifically, according to the edit distance, it can be determined which clause of the first candidate clause and the second candidate clause is more similar to the P+1 clause, and then the method of determining the clause in the process of generating the P+1 clause can be determined, so that the second watermark feature coding value of the P+1 clause can be determined according to the preset first watermark feature coding sequence.
[0221] Exemplarily, the corresponding specific algorithm strategy may be as follows:
[0222] Calculate the edit distance between the P+1th clause sent_ids and the first candidate clause top1 clause and the second candidate clause top2 clause respectively:
[0223] ld1=lev_distance(sent_output_ids1,sent_ids) / len(sent_output_ids1);
[0224] ld2=lev_distance(sent_output_ids2,sent_ids) / len(sent_output_ids2);
[0225] If ld1>ld2, the watermark feature code of the current P+1th sub-sentence is determined to be textmark=0, otherwise textmark=1.
[0226] Step 805: update the second watermark feature coding sequence of the text to be detected according to the second watermark feature coding value, wherein the second watermark feature coding sequence includes the second watermark feature coding value; when P+1 is less than the total number of clauses in the text to be detected, determine P=P+1, and repeat the above steps until P+1 is equal to the total number of clauses.
[0227] Specifically, the updating of the watermark feature coding sequence of the text to be detected may be to add the second watermark feature coding value to the second watermark feature coding sequence, and when P+1 is less than the total number of clauses of the text to be detected, that is, the text to be detected has not yet been encoded, repeating the execution until P+1 is equal to the total number of clauses, completing the encoding of the text to be detected, and obtaining the second watermark feature coding sequence.
[0228] Exemplarily, the corresponding specific algorithm strategy may be as follows:
[0229] Update the second watermark feature encoding sequence:
[0230] textmark_code=textmark_code+textmark
[0231] sent_idx = sent_idx + 1
[0232] sent_ids = A[sent_idx]
[0233] If sent_idx < len(A), continue to generate candidate clauses and calculate the edit distance until the feature encoding extraction of each clause in A is completed, and output the second watermark feature encoding sequence textmark_code, where A is the text to be detected.
[0234] Step 806: Match the second watermark feature encoding sequence with a preset first watermark feature encoding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
[0235] Specifically, the matching of the second watermark feature encoding sequence with the preset first watermark feature encoding sequence may be to determine the matching score between the second watermark feature encoding sequence and the first watermark feature encoding sequence, so as to determine whether the text to be detected passes the watermark detection.
[0236] In the embodiments of the present invention, the above digital watermark detection method can disassemble the text to be detected, select some clauses as guiding clauses for prediction, determine the watermark feature encoding sequence of the text to be detected by judging the generation method of the text to be detected, and match it with the preset first watermark feature encoding sequence to determine whether the watermark detection is passed. By adopting the fuzzy matching strategy of the edit distance, others can still effectively detect the watermark feature encoding after making a certain degree of modification to the watermark-embedded text, thereby improving the accuracy of detecting digital watermarks.
[0237] Exemplarily, the specific algorithm of the feature matching value can be as follows:
[0238] Algorithm1: Feature matching value calculation
[0239] Input: List l to be matched, matching template t
[0240] Output: Matching score s
[0241]
[0242]
[0243] Exemplarily, the specific algorithm of the watermark feature code matching score can be as follows:
[0244] Algprithm2: Watermark feature code matching score calculation
[0245] Input:
[0246] Extracted text feature code textmark_code
[0247] Generate model watermark feature code watermark_code
[0248] Output: Matching score
[0249] n=len(textmark_code) / len(watermark_code):
[0250] wm_code=watermark_code*n / / Repeat the watermark code n times
[0251] n_score=Algorithm1(textmark_code,wm_code)
[0252] score = n_score / len (textmark_code) / / algorithm matching score
[0253] return score
[0254] Calculate the watermark feature encoding matching score as:
[0255] score_watermark=Algorithm2(textmark_list,watermark_code)
[0256] If score_watermark>α, it is determined that the watermark detection has passed.
[0257] Optionally, predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause includes:
[0258] Using a word segmenter to transform the second introduction clause to obtain a second integer list;
[0259] Perform text feature encoding according to the second integer list to obtain a second real number vector;
[0260] Normalizing the second real number vector to convert it into a probability distribution, to obtain a probability corresponding to the second real number vector;
[0261] A first candidate clause and a second candidate clause are determined according to the texts corresponding to the first largest probability and the second largest probability in the probabilities.
[0262] Exemplarily, the corresponding specific algorithm strategy may be as follows:
[0263] First, the user inputs the text A to be detected, and A can be decomposed into n clauses by the sentence terminator sent_end: A = [sent_0, sent_1, ... sent_n]; intercept A [0: prior_length] as the second guide clause prior_context_str, and initialize:
[0264] sent_idx=prior_length
[0265] sent_ids=sent0
[0266] textmark_code=[]
[0267] Next, encode the text:
[0268] input_ids=text_ecoder(prior_context_str)=[x0,…,x n ], where x i ∈[0,|V|]
[0269] sent i _ids = text_encoder(sent i )=[x i 0,…x i m]
[0270] Then perform text feature encoding:
[0271] token_prob=norm_func(deep_net(input_ids))
[0272] Finally, candidate clauses are generated: based on the feature encoding token_prob of input_ids, candidate clauses sent_output_ids1 and sent_output_ids2 are obtained.
[0273] It should be noted that the specific implementation of this embodiment can also refer to the relevant description of the embodiment of the digital watermark embedding method. In order to avoid repeated description, this embodiment will not be described in detail.
[0274] Optionally, the method further includes:
[0275] Comparing the syntactic structure of each clause in the text to be detected with the preset syntactic structure to obtain a syntactic matching degree;
[0276] When the syntax matching degree is greater than a preset threshold, it is determined that the watermark detection is passed.
[0277] Specifically, when the syntactic matching degree is greater than a preset threshold, it is determined that the watermark detection is passed. The judgment can be made based on the watermark matching score of the second watermark feature coding sequence and the preset first watermark feature coding sequence. For example, when the watermark matching score is less than the preset first threshold, it can be further judged whether the syntactic matching degree is greater than the preset second threshold. If the syntactic matching degree is greater than the preset second threshold, it is determined that the watermark detection is passed.
[0278] Exemplarily, the corresponding specific algorithm strategy may be as follows:
[0279] The dependency parser is called with the sentences of the text to be detected as units, and the syntactic structure is compared with synt_tree_a and synt_tree_b respectively, and the number of syntactic structure matches count_a and count_b in the text to be detected is recorded respectively, and then the syntactic matching degree of the text to be detected is calculated:
[0280]
[0281] If score_watermark≥α, it is determined that the watermark detection has passed;
[0282] If β <score_watermark<α,score_synt> γ, it is determined that the watermark detection has passed;
[0283] In other cases, it is determined that the watermark detection fails, wherein α, β (α>β), and γ may be three preset thresholds.
[0284] For example, Fig. 9 and Fig.10 is a flow chart of a digital watermark detection method provided by an embodiment of the present invention. Fig. 9 and Fig.10 As shown:
[0285] First, input the watermark text to be detected and the watermark feature code, and extract the guiding context of the watermark text to be detected; perform text encoding and text feature encoding on the extracted guiding context, and then perform probability prediction of the next text tag based on the guiding context. When the next text is not a sentence terminator, continue to perform probability prediction of the next text tag until the generation of the clause is completed to obtain the candidate clause; extract the watermark code based on the candidate clause, and when the number of clauses is equal to the difference between the number of the text to be detected and the number of guiding sentences, complete the watermark code extraction and perform equivalent syntax recognition; calculate the watermark matching degree based on the obtained watermark code and the results of equivalent syntax recognition, and output the judgment result, whether the watermark detection is passed.
[0286] In an embodiment of the present invention, the above-mentioned digital watermark detection method can determine the syntactic matching degree of the text to be detected by performing equivalent syntax recognition on the text to be detected, and then detect the digital watermark according to the syntactic matching degree, so that others can still accurately judge whether the watermark detection is passed after adjusting the syntactic structure of the watermark embedded text, which can further improve the accuracy of detecting digital watermarks.
[0287] See also Fig.11 , Fig.11 is a structural diagram of a digital watermark embedding device provided by an embodiment of the present invention, such as Fig.11 As shown, the digital watermark embedding device 1100 includes:
[0288] A generating module 1101 is used to predict the Nth target clause and generate at least two N+1th candidate clauses;
[0289] A first determining module 1102 is configured to determine a first watermark feature coding value of an N+1th target clause according to the Nth target clause and a preset first watermark feature coding sequence, wherein the N+1th target clause is a next clause of the Nth target clause;
[0290] The second determination module 1103 is used to determine the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold;
[0291] The third determination module 1104 is configured to determine the embedded watermark full text when the N+1 target clauses include a text terminator, the embedded watermark full text including the N+1 target clauses, wherein N is an integer greater than 0.
[0292] Optionally, the device further includes:
[0293] The fourth determination module is used to determine that N=N+1 when the N+1 target clauses do not include the text terminator, and repeatedly perform the steps of predicting the Nth target clause and generating at least two N+1th candidate clauses until the N+1 target clause includes the text terminator.
[0294] Optionally, the second determining module includes:
[0295] a first determining unit, configured to determine, when the first watermark feature encoding value is equal to a preset value and the readability value of the N+1th candidate clause corresponding to the minimum predicted probability among the at least two N+1th candidate clauses is greater than the readability threshold, that the N+1th candidate clause corresponding to the minimum predicted probability among the at least two N+1th candidate clauses is the N+1th target clause;
[0296] A second determination unit is used to determine that the N+1th candidate clause corresponding to the maximum prediction probability among the at least two N+1th candidate clauses is the N+1th target clause when the first watermark feature coding value is not equal to the preset value, or the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is less than or equal to the readability threshold.
[0297] Optionally, the device further includes:
[0298] A comparison module, used for comparing the syntactic structure of the N+1th target clause with a preset first syntactic structure;
[0299] A replacement module is used to replace the syntactic structure of the N+1th target clause with a preset second syntactic structure when the syntactic structure of the N+1th target clause is the same as the preset first syntactic structure.
[0300] Optionally, the generating module includes:
[0301] A first generating unit is used to predict the Nth target clause and generate at least two Mth candidate texts of the N+1th candidate clause;
[0302] A second generating unit, configured to predict the at least two M-th candidate texts respectively, and generate at least two M+1-th candidate texts;
[0303] A combining unit, used for combining the at least two Mth candidate texts and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses;
[0304] A first updating unit, configured to update the at least two (N+1)th candidate clauses according to the probabilities corresponding to the combined plurality of candidate clauses;
[0305] A third generating unit is used for determining M=M+1 when the at least two M+1th candidate texts are not sentence terminators, respectively predicting the at least two M+1th candidate texts, and generating at least two M+1th candidate texts;
[0306] a third determining unit, configured to combine the at least two N+1th candidate clauses and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses;
[0307] The second updating unit is used to update the at least two N+1th candidate clauses according to the probabilities corresponding to the combined multiple candidate clauses until the at least two M+1th candidate texts are sentence terminators, where M is an integer greater than or equal to 2.
[0308] Optionally, the Nth target clause is a first guiding clause, and the device further includes:
[0309] A transcription module is used to transcribe the input instruction to obtain a model prompt string, wherein the input instruction is used to control the text generation content;
[0310] A conversion module, used for converting the model prompt string using a word segmenter to obtain an integer list;
[0311] An encoding module, used for encoding text features according to the integer list to obtain a real number vector;
[0312] A probability module, used for normalizing the real number vector into a probability distribution to obtain a probability corresponding to the real number vector;
[0313] A fifth determining module is configured to determine the first guiding clause according to the probability.
[0314] Optionally, the fifth determining module includes:
[0315] A fourth unit is used to determine the first text of the first introduction clause according to the text corresponding to the maximum probability among the probabilities;
[0316] A prediction unit, configured to predict the first text to obtain a predicted text;
[0317] a third updating unit, configured to update the first introduction clause according to the predicted text until the number of generated sentence ending symbols is greater than a preset threshold;
[0318] When the number of generated sentence terminators is greater than the preset threshold, the generation of the first introduction clause is completed.
[0319] See also Fig.12 , Fig.12 is a structural diagram of a digital watermark detection device provided by an embodiment of the present invention, such as Fig.12 As shown, the digital watermark detection device 1200 includes:
[0320] A first determination module 1201 is used to determine the first P clauses in the text to be detected as the second introduction clauses;
[0321] A prediction module 1202 is used to predict the P+1th clause of the text to be detected according to the second guide clause to obtain a first candidate clause and a second candidate clause;
[0322] A calculation module 1203, configured to respectively calculate the edit distance between the first candidate clause and the P+1th clause, and between the second candidate clause and the P+1th clause;
[0323] A second determining module 1204 is used to determine the second watermark feature encoding value of the P+1th clause according to the edit distance;
[0324] The updating module 1205 is used to update the second watermark feature coding sequence of the text to be detected according to the second watermark feature coding value, wherein the second watermark feature coding sequence includes the second watermark feature coding value; when P+1 is less than the total number of clauses of the text to be detected, determine P=P+1, and repeat the above steps until P+1 is equal to the total number of clauses;
[0325] The matching module 1206 is used to match the second watermark feature coding sequence with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
[0326] Optionally, the prediction module includes:
[0327] A conversion unit, configured to convert the second introduction clause using a word segmenter to obtain a second integer list;
[0328] An encoding unit, used for encoding text features according to the second integer list to obtain a second real number vector;
[0329] A probability unit, used to normalize and transform the second real number vector into a probability distribution to obtain a probability corresponding to the second real number vector;
[0330] A determination unit is used to determine a first candidate clause and a second candidate clause according to the texts corresponding to the first largest probability and the second largest probability in the probabilities.
[0331] Optionally, the device further includes:
[0332] A comparison module is used to compare the syntactic structure of each clause in the text to be detected with a preset syntactic structure to obtain a syntactic matching degree;
[0333] The third determination module is used to determine that the watermark detection is passed when the syntactic matching degree is greater than a preset threshold.
[0334] For details, see Fig.13 As shown, an embodiment of the present invention further provides an electronic device, including a bus 1301 , a transceiver 1302 , an antenna 1303 , a bus interface 1304 , a processor 1305 and a memory 1306 .
[0335] The processor 1305 is used to:
[0336] Predict the Nth target clause and generate at least two N+1th candidate clauses;
[0337] Determine the first watermark feature encoding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature encoding sequence, wherein the N+1th target clause is the next clause of the Nth target clause;
[0338] Determining the N+1th target clause according to the predicted probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold;
[0339] In the case that the N+1 target clauses include a text terminator, the embedded watermark full text is determined, and the embedded watermark full text includes the N+1 target clauses, where N is an integer greater than 0.
[0340] exist Fig.13 In the embodiment, the bus architecture (represented by bus 1301) may include any number of interconnected buses and bridges, and bus 1301 links various circuits including one or more processors represented by processor 1305 and memory represented by memory 1306. Bus 1301 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 1304 provides an interface between bus 1301 and transceiver 1302. Transceiver 1302 may be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. Data processed by processor 1305 is transmitted on a wireless medium via antenna 1303, and further, antenna 1303 also receives data and transmits the data to processor 1305.
[0341] The processor 1305 is responsible for managing the bus 1301 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 1306 can be used to store data used by the processor 1305 when performing operations.
[0342] Optionally, the processor 1305 may be a CPU, an ASIC, an FPGA or a CPLD.
[0343] Optionally, the processor 1305 is further configured to:
[0344] When the N+1 target clauses do not include the text terminator, determine N=N+1, and repeat the steps of predicting the Nth target clause and generating at least two N+1th candidate clauses until the N+1 target clause includes the text terminator.
[0345] Optionally, the processor 1305 is specifically configured to:
[0346] When the first watermark feature encoding value is equal to a preset value and the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is greater than the readability threshold, determining the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses as the N+1th target clause;
[0347] When the first watermark feature coding value is not equal to the preset value, or the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is less than or equal to the readability threshold, the N+1th candidate clause corresponding to the maximum prediction probability among the at least two N+1th candidate clauses is determined as the N+1th target clause.
[0348] Optionally, the processor 1305 is further configured to:
[0349] Comparing the syntactic structure of the N+1th target clause with a preset first syntactic structure;
[0350] When the syntactic structure of the N+1th target clause is the same as the preset first syntactic structure, the syntactic structure of the N+1th target clause is replaced with the preset second syntactic structure.
[0351] Optionally, the processor 1305 is specifically configured to:
[0352] Predict the Nth target clause and generate at least two Mth candidate texts for the N+1th candidate clause;
[0353] Predicting the at least two M-th candidate texts respectively to generate at least two M+1-th candidate texts;
[0354] Combining the at least two Mth candidate texts and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses;
[0355] updating the at least two (N+1)th candidate clauses according to the probabilities corresponding to the combined multiple candidate clauses;
[0356] In the case where the at least two M+1th candidate texts are not sentence terminators, determining M=M+1, respectively predicting the at least two M+1th candidate texts, and generating at least two M+1th candidate texts;
[0357] Combining the at least two N+1th candidate clauses and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses;
[0358] According to the probabilities corresponding to the combined multiple candidate clauses, the at least two N+1th candidate clauses are updated until the at least two M+1th candidate texts are sentence terminators, where M is an integer greater than or equal to 2.
[0359] Optionally, the Nth target clause is the first guiding clause, and the processor 1305 is further configured to:
[0360] Transcribing the input instruction to obtain a model prompt string, wherein the input instruction is used to control the text generation content;
[0361] Using a word segmenter to convert the model prompt string to obtain an integer list;
[0362] Perform text feature encoding according to the integer list to obtain a real number vector;
[0363] Normalizing the real number vector to convert it into a probability distribution to obtain a probability corresponding to the real number vector;
[0364] The first guiding clause is determined according to the probability.
[0365] Optionally, the processor 1305 is specifically configured to:
[0366] Determining the first text of the first introduction clause according to the text corresponding to the maximum probability among the probabilities;
[0367] Predicting the first text to obtain a predicted text;
[0368] The first guide clause is updated according to the predicted text until the number of generated sentence ending symbols is greater than a preset threshold;
[0369] When the number of generated sentence terminators is greater than the preset threshold, the generation of the first introduction clause is completed.
[0370] For details, see Fig.14 As shown, an embodiment of the present invention further provides another electronic device, including a bus 1401 , a transceiver 1402 , an antenna 1403 , a bus interface 1404 , a processor 1405 and a memory 1406 .
[0371] The processor 1405 is used to:
[0372] Determine the first P clauses in the text to be detected as the second leading clauses;
[0373] Predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause;
[0374] Calculating respectively the edit distance between the first candidate clause and the P+1th clause, and the edit distance between the second candidate clause and the P+1th clause;
[0375] Determining a second watermark feature encoding value of the P+1th clause according to the edit distance;
[0376] According to the second watermark feature code value, updating the second watermark feature code sequence of the to-be-detected text, wherein the second watermark feature code sequence includes the second watermark feature code value; in the case where P+1 is less than the total number of clauses of the to-be-detected text, determining P=P+1, and repeating the above steps until P+1 is equal to the total number of clauses;
[0377] The second watermark feature coding sequence is matched with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
[0378] exist Fig.14 In the embodiment, the bus architecture (represented by bus 1401) may include any number of interconnected buses and bridges, and bus 1401 links various circuits including one or more processors represented by processor 1405 and memory represented by memory 1406. Bus 1401 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 1404 provides an interface between bus 1401 and transceiver 1402. Transceiver 1402 may be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. Data processed by processor 1405 is transmitted on a wireless medium via antenna 1403, and further, antenna 1403 also receives data and transmits the data to processor 1405.
[0379] The processor 1405 is responsible for managing the bus 1401 and general processing, and may also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. The memory 1406 may be used to store data used by the processor 1405 when performing operations.
[0380] Optionally, the processor 1405 may be a CPU, an ASIC, an FPGA or a CPLD.
[0381] Optionally, the processor 1405 is specifically configured to:
[0382] Using a word segmenter to transform the second introduction clause to obtain a second integer list;
[0383] Perform text feature encoding according to the second integer list to obtain a second real number vector;
[0384] Normalizing the second real number vector to convert it into a probability distribution, to obtain a probability corresponding to the second real number vector;
[0385] A first candidate clause and a second candidate clause are determined according to the texts corresponding to the first largest probability and the second largest probability in the probabilities.
[0386] Optionally, the processor 1405 is further configured to:
[0387] Comparing the syntactic structure of each clause in the text to be detected with the preset syntactic structure to obtain a syntactic matching degree;
[0388] When the syntax matching degree is greater than a preset threshold, it is determined that the watermark detection is passed.
[0389] An embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor. When the program is executed by the processor, each process of the above-mentioned digital watermark embedding method and digital watermark detection method embodiments is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0390] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned digital watermark embedding method and digital watermark detection method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0391] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0392] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0393] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A digital watermark embedding method, characterized in that: include: Predict the Nth target clause and generate at least two N+1th candidate clauses; Determine the first watermark feature encoding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature encoding sequence, wherein the N+1th target clause is the next clause of the Nth target clause; Determining the N+1th target clause according to the predicted probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold; In the case that the N+1 target clauses include a text terminator, the embedded watermark full text is determined, and the embedded watermark full text includes the N+1 target clauses, where N is an integer greater than 0.
2. The method according to claim 1, characterized in that The method further comprises: When the N+1 target clauses do not include the text terminator, determine N=N+1, and repeat the steps of predicting the Nth target clause and generating at least two N+1th candidate clauses until the N+1 target clause includes the text terminator.
3. The method according to claim 1, characterized in that The determining the N+1th target clause according to the predicted probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold comprises: When the first watermark feature encoding value is equal to a preset value and the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is greater than the readability threshold, determining the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses as the N+1th target clause; When the first watermark feature coding value is not equal to the preset value, or the readability value of the N+1th candidate clause corresponding to the minimum prediction probability among the at least two N+1th candidate clauses is less than or equal to the readability threshold, the N+1th candidate clause corresponding to the maximum prediction probability among the at least two N+1th candidate clauses is determined as the N+1th target clause.
4. The method according to claim 1, characterized in that: After determining the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold, the method further includes: Comparing the syntactic structure of the N+1th target clause with a preset first syntactic structure; When the syntactic structure of the N+1th target clause is the same as the preset first syntactic structure, the syntactic structure of the N+1th target clause is replaced with the preset second syntactic structure.
5. The method according to claim 1 or 2, characterized in that: The predicting of the Nth target clause to generate at least two N+1th candidate clauses includes: Predict the Nth target clause and generate at least two Mth candidate texts for the N+1th candidate clause; Predicting the at least two M-th candidate texts respectively to generate at least two M+1-th candidate texts; Combining the at least two Mth candidate texts and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses; updating the at least two (N+1)th candidate clauses according to the probabilities corresponding to the combined multiple candidate clauses; In the case where the at least two M+1th candidate texts are not sentence terminators, determining M=M+1, respectively predicting the at least two M+1th candidate texts, and generating at least two M+1th candidate texts; Combining the at least two N+1th candidate clauses and the at least two M+1th candidate texts to determine a plurality of combined candidate clauses; According to the probabilities corresponding to the combined multiple candidate clauses, the at least two N+1th candidate clauses are updated until the at least two M+1th candidate texts are sentence terminators, where M is an integer greater than or equal to 2.
6. The method according to claim 1, characterized in that The Nth target clause is a first guiding clause. Before predicting the Nth target clause and generating at least two N+1th candidate clauses, the method further includes: Transcribing the input instruction to obtain a model prompt string, wherein the input instruction is used to control the text generation content; Using a word segmenter to convert the model prompt string to obtain an integer list; Perform text feature encoding according to the integer list to obtain a real number vector; Normalizing the real number vector to convert it into a probability distribution to obtain a probability corresponding to the real number vector; The first guiding clause is determined according to the probability.
7. The method according to claim 6, characterized in that The determining the first guiding clause according to the probability comprises: Determining the first text of the first introduction clause according to the text corresponding to the maximum probability among the probabilities; Predicting the first text to obtain a predicted text; The first guide clause is updated according to the predicted text until the number of generated sentence ending symbols is greater than a preset threshold; When the number of generated sentence terminators is greater than the preset threshold, the generation of the first introduction clause is completed.
8. A digital watermark detection method, characterized in that: include: Determine the first P clauses in the text to be detected as the second leading clauses; Predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause; Calculating respectively the edit distance between the first candidate clause and the P+1th clause, and the edit distance between the second candidate clause and the P+1th clause; Determining a second watermark feature encoding value of the P+1th clause according to the edit distance; According to the second watermark feature coding value, updating the second watermark feature coding sequence of the to-be-detected text, wherein the second watermark feature coding sequence includes the second watermark feature coding value; When P+1 is less than the total number of clauses in the text to be detected, determine P=P+1, and repeat the above steps until P+1 is equal to the total number of clauses; The second watermark feature coding sequence is matched with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
9. The method according to claim 8, characterized in that The step of predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause includes: Using a word segmenter to transform the second introduction clause to obtain a second integer list; Perform text feature encoding according to the second integer list to obtain a second real number vector; Normalizing the second real number vector to convert it into a probability distribution, to obtain a probability corresponding to the second real number vector; A first candidate clause and a second candidate clause are determined according to the texts corresponding to the first largest probability and the second largest probability in the probabilities.
10. The method according to claim 9, characterized in that The method further comprises: Comparing the syntactic structure of each clause in the text to be detected with the preset syntactic structure to obtain a syntactic matching degree; When the syntax matching degree is greater than a preset threshold, it is determined that the watermark detection is passed.
11. A digital watermark embedding device, characterized in that: include: A generation module, used to predict the Nth target clause and generate at least two N+1th candidate clauses; A first determination module is used to determine a first watermark feature coding value of an N+1th target clause according to the Nth target clause and a preset first watermark feature coding sequence, wherein the N+1th target clause is a next clause of the Nth target clause; a second determination module, configured to determine the N+1th target clause according to the prediction probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold; The third determination module is used to determine the embedded watermark full text when the N+1 target clauses include a text terminator, and the embedded watermark full text includes N+1 target clauses, wherein N is an integer greater than 0.
12. A digital watermark detection device, characterized in that: include: A first determination module is used to determine the first P clauses in the text to be detected as the second leading clauses; A prediction module, used for predicting the P+1th clause of the text to be detected according to the second guide clause to obtain a first candidate clause and a second candidate clause; a calculation module, configured to calculate the edit distance between the first candidate clause and the P+1th clause, and between the second candidate clause and the P+1th clause; A second determining module, configured to determine a second watermark feature encoding value of the P+1th clause according to the edit distance; An updating module, configured to update a second watermark feature coding sequence of the to-be-detected text according to the second watermark feature coding value, wherein the second watermark feature coding sequence includes the second watermark feature coding value; When P+1 is less than the total number of clauses in the text to be detected, determine P=P+1, and repeat the above steps until P+1 is equal to the total number of clauses; A matching module is used to match the second watermark feature coding sequence with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, wherein P is an integer greater than 0.
13. An electronic device, characterized in that: comprising a processor configured to: Predict the Nth target clause and generate at least two N+1th candidate clauses; Determine the first watermark feature encoding value of the N+1th target clause according to the Nth target clause and the preset first watermark feature encoding sequence, wherein the N+1th target clause is the next clause of the Nth target clause; Determining the N+1th target clause according to the predicted probabilities of the at least two N+1th candidate clauses, the first watermark feature encoding value and a preset readability threshold; In the case that the N+1 target clauses include a text terminator, the embedded watermark full text is determined, and the embedded watermark full text includes the N+1 target clauses, where N is an integer greater than 0.
14. An electronic device, characterized in that: comprising a processor configured to: Determine the first P clauses in the text to be detected as the second leading clauses; Predicting the P+1th clause of the text to be detected according to the second guiding clause to obtain a first candidate clause and a second candidate clause; Calculating respectively the edit distance between the first candidate clause and the P+1th clause, and the edit distance between the second candidate clause and the P+1th clause; Determining a second watermark feature encoding value of the P+1th clause according to the edit distance; According to the second watermark feature coding value, updating the second watermark feature coding sequence of the to-be-detected text, wherein the second watermark feature coding sequence includes the second watermark feature coding value; When P+1 is less than the total number of clauses in the text to be detected, determine P=P+1, and repeat the above steps until P+1 is equal to the total number of clauses; The second watermark feature coding sequence is matched with a preset first watermark feature coding sequence to determine whether the watermark detection is passed, where P is an integer greater than 0.
15. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the program implements the steps of the digital watermark embedding method as described in any one of claims 1 to 7; or, when the program is executed by the processor, the program implements the steps of the digital watermark detection method as described in any one of claims 8 to 10.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the digital watermark embedding method as described in any one of claims 1 to 7; or, when executed by a processor, implements the steps of the digital watermark detection method as described in any one of claims 8 to 10.
Citation Information
Cited By
Security guarantee method for large language model generated text
CN120524471A
A security assurance method for text generation using large language models
CN120524471B