Sentence semantics-based watermarking method for large language model transfer attack
By embedding the semantics of the watermarked text generated by the large language model into a vector space equal to the size of the vocabulary, a green list is formed to guide the generation of new word tags, which solves the problem of reduced effectiveness of existing watermarking methods in paraphrase attacks, and achieves Robust resistance and rapid detection of large language models.
Patent Information
- Application Number
- CN202410926631.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-10-22
AI Technical Summary
Existing watermarking methods are less effective in the face of large language model paraphrase attacks, making it difficult to resist the destruction of the mask by paraphrase attacks, affecting the integrity of the watermark.
Using a watermarking method based on sentence semantics, the semantic embedding of the generated watermark text is mapped to a vector space equal to the size of the vocabulary, and a green list is formed by accurately locating the minimum element index to guide the generation of new word tags and resist paraphrase attacks.
Effectively counteract complex paraphrase attacks and security risks, keep text quality unimpaired, and detect quickly without increasing the possibility of detection errors.
Smart Images

Figure CN118821086A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing and information security technology, and more specifically, relates to a sentence semantics-based watermark method for large language model paraphrase attacks. Background Art
[0002] Large Language Models (LLMs) have made remarkable achievements in the field of natural language processing and understanding. However, these powerful AI models can be abused for various misconducts, such as fabricating fake news. When fake news and real content are difficult to distinguish, it is easy to cause harm to the digital space. In addition, datasets contaminated by AI-generated content may be detrimental to the training of AI models, and may reinforce bias or harm model performance. Therefore, to maintain the integrity of public discourse and ensure the ethical development of AI technology, it is necessary to be able to reliably identify LLM-generated texts. In recent years, the detection methods for LLM-generated texts can be mainly divided into the following categories: zero-shot methods, neural network-based methods, watermark methods, and retrieval-based methods.
[0003] Among the above methods, although existing watermarking methods have achieved remarkable success, their effectiveness is greatly reduced in the face of paraphrase attacks, which adjust words to synonyms and reorganize sentence structures, thereby destroying the "mask" - the preferred "green list" and secondary "red list" into which the vocabulary is divided during token generation. Specifically, under paraphrase attacks, token-level watermarks will encounter problems such as mask changes and subsequent token partitions being changed, which will compromise the integrity of the watermark. The design of watermarking methods that are resistant to paraphrase attacks must balance factors such as flexibility, computational efficiency, and operational practicality, and strive to find methods that can maintain text quality without sacrificing speed or increasing the possibility of detection errors. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a sentence semantics-based watermarking method for large language model paraphrase attacks, which maps the semantic embedding of the generated watermark text into a vector space whose spatial dimension size is equal to the vocabulary size, accurately locates the indexes of a certain number of minimum elements in this space to form a green list, and then uses the list to guide the generation logic of new word tags to resist paraphrase attacks on large language models.
[0005] In order to achieve the above-mentioned object of the invention, the sentence semantics-based watermark method for large language model paraphrase attack of the present invention comprises the following steps:
[0006] S1: Set the word segmenter, generative large language model, vocabulary and semantic embedding model according to actual needs, where:
[0007] The word segmenter includes a forward processing process and a reverse processing process. The forward processing process is to segment the input text and obtain the corresponding tag of each word. The reverse processing process is to generate the output text according to the word tag.
[0008] The vocabulary is used to store word tags, which are generated by the word segmenter based on a preset word set. The size of the vocabulary is V.
[0009] The generative large language model is used to generate a probability distribution based on the input token sequence, which includes the logarithmic probability p corresponding to each word token in the vocabulary v , v = 1, 2, ..., V, used to select word tags;
[0010] The semantic embedding model is used to calculate the semantic embedding vector corresponding to the text;
[0011] S2: Initialize the input text and use the forward processing of the word segmenter to obtain the corresponding input token sequence T = [t0,…,t n-1 ], where t i′ represents the i′th word token in the input text, i′=0,1,…,n-1, n represents the initial length of the input text, initialize the green list G to be empty, and set a vector space P V , whose dimension is the size V of the vocabulary;
[0012] S3: Initialize the newly added word number i=n, and input the tag sequence X=T;
[0013] S4: Input the input token sequence X into the generative large language model and obtain the logarithmic probability p of each word token in the vocabulary i,v ;
[0014] S5: Determine whether the green list G is empty or mark t i-1 Is it a sentence separator? If any of the conditions are met, go to step S6; if none of the conditions are met, go to step S8;
[0015] S6: Use the semantic embedding model to obtain the semantic embedding vector of the current input tag sequence X and project it into the pre-set vector space P V , and obtain the projected semantic embedding vector e with dimension V X ;
[0016] S7: From the projected semantic embedding vector e X Select the first K smallest elements and record their element numbers d k , k=1,2,…,K, and K serial numbers d k Constitute the green list G;
[0017] S8: Use the following formula to correct the logarithmic probability generated in step S4 to obtain the corrected logarithmic probability
[0018]
[0019] Wherein, δ represents the preset watermark strength;
[0020] S9: Use the preset sampling method according to the logarithmic probability Sample a word token x from the vocabulary i , add it to the input tag sequence X, and update the input tag sequence X = (X, x i );
[0021] S10: Determine whether i<m, where m represents the preset number of new words. If yes, proceed to step S10; otherwise, proceed to step S11;
[0022] S11: let i=i+1, and return to step S4;
[0023] S12: The word segmenter converts the input tag sequence X using its reverse processing process, and sends the obtained text as the watermark text.
[0024] The watermark method based on sentence semantics for large language model paraphrase attack of the present invention, when a generative large language model generates a new word tag, firstly generates the probability of each word tag in the vocabulary according to the input tag sequence, adopts the semantic embedding model to obtain the semantic embedding vector of the current input tag sequence, and projects it to a vector space with a preset dimension size and the same size as the vocabulary, obtains the corresponding projected semantic embedding vector, selects the smallest number of element numbers to form a green list, for each word tag in the vocabulary, if it belongs to the green list, its probability is corrected according to the preset watermark strength, if it does not belong to the green list, the current probability is the corrected probability, selects a new word tag according to the corrected probability, and repeats in this way to generate a watermark text.
[0025] This paper proposes a robust watermarking method and introduces a novel sentence semantics-based watermarking method to effectively offset complex paraphrase attacks and security risk challenges. Through rigorous testing on different data sets and models, this paper consistently proves that it can effectively embed and check watermarks without substantially affecting the language quality or diversity of the text. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a flowchart of a specific implementation method of the sentence semantics-based watermark method for large language model paraphrase attack of the present invention;
[0027] Figure 2is a flow chart of the watermark detection method of the present invention;
[0028] Figure 3 Schematic diagram of the mathematical expectation and standard deviation of the difference between the green list before and after the paraphrase measured by the cardinality of the difference set in the present invention in this embodiment;
[0029] Figure 4 : is a comparison diagram of the perplexity distribution of the watermark text generated by the present invention and the manually generated text in this embodiment;
[0030] Figure 5 This is a comparison chart of the watermark text generation time of the present invention in this embodiment. DETAILED DESCRIPTION
[0031] The specific implementation of the present invention is described below in conjunction with the accompanying drawings so that those skilled in the art can better understand the present invention. It should be noted that in the following description, when the detailed description of known functions and designs may dilute the main content of the present invention, these descriptions will be omitted here.
[0032] Example
[0033] Figure 1 FIG. 1 is a flow chart of a specific implementation of the sentence semantics-based watermarking method for large language model paraphrase attacks of the present invention. Figure 1 As shown, the specific steps of the sentence semantics-based watermark method for large language model paraphrase attack of the present invention include:
[0034] S101: Set up relevant models:
[0035] Set the word segmenter, generative large language model, vocabulary and semantic embedding model according to actual needs, where:
[0036] The word segmenter includes a forward processing process and a reverse processing process. The forward processing process is to segment the input text and obtain the tag corresponding to each word. The reverse processing process is to generate the output text based on the word tags.
[0037] The vocabulary is used to store word tags and is generated by the word segmenter based on a preset word set. The size of the vocabulary is denoted by V.
[0038] The generative large language model is used to generate a probability distribution based on the input token sequence (input tokens), which includes the logits p corresponding to each word token in the vocabulary. v , v = 1, 2, …, V, is used to select word tags.
[0039] The semantic embedding model is used to calculate the semantic embedding vector corresponding to the text.
[0040] S102: Initialize text generation parameters:
[0041] Initialize the input text and use the forward processing of the word segmenter to obtain the corresponding input token sequence T = [t0,…,t n-1 ], where t i′ represents the i′th word token in the input text, i′=0,1,…,n-1, n represents the initial length of the input text, initialize the green list G to be empty, and set a vector space P V , whose dimension is the size V of the vocabulary.
[0042] S103: Initialize the newly added word number i=n and input the tag sequence X=T.
[0043] S104: Generate word tag logarithmic probability:
[0044] Input the input token sequence X into the generative large language model and get the log probability p of each word token in the vocabulary i,v .
[0045] S105: Determine whether the green list G is empty or marked t i-1 Whether it is a sentence separator, if any one of the conditions is met, proceed to step S106, if none of the conditions is met, proceed to step S108.
[0046] That is to say, after the green partition is constructed, the present invention will continue to use it until the sentence separator is reached before recalculating a new partition. This method effectively reduces the sensitivity to transfer attacks and reduces the computational overhead.
[0047] S106: Generate semantic embedding vector:
[0048] The semantic embedding model is used to calculate the semantic embedding vector of the current input tag sequence X and project it into the pre-set vector space P V , and obtain the projected semantic embedding vector e with dimension V X .
[0049] S107: Get the green list:
[0050] From the projected semantic embedding vector e X Select the first K smallest elements and record their element numbers d k , k=1,2,…,K, and K serial numbers d k Constitute the green list G.
[0051] S108: Modified logarithmic probability:
[0052] The logarithmic probability generated in step S104 is corrected using the following formula to obtain the corrected logarithmic probability:
[0053]
[0054] Among them, δ represents the preset watermark strength. Generally speaking, a high watermark strength has the risk of reducing the quality of the text, while insufficient strength will make the watermark unable to be embedded. In practical applications, the watermark strength needs to be selected according to the entropy value of the probability distribution generated by the generative language model, and its preferred value range is 2 to 8.
[0055] That is, when a word token in the vocabulary belongs to the green list, its log probability will be modified, otherwise no operation will be performed. i The larger the value, the more likely it is to be selected. Therefore, after correcting the logarithmic probability, the word mark corresponding to the serial number in the green list will increase its possibility of being selected.
[0056] S109: Sample word tags:
[0057] Use the preset sampling method according to probability Sample a word token x from the vocabulary i , add it to the input tag sequence X, and update the input tag sequence X = (X, x i There are many sampling methods in the prior art, which can be selected according to actual needs. Generally speaking, the commonly used sampling methods are greedy sampling or kernel sampling.
[0058] S110: Determine whether i<m, where m represents the preset number of newly added words. If so, proceed to step S110; otherwise, proceed to step S111.
[0059] S111: Let i=i+1, and return to step S104.
[0060] S112: Generate watermark text:
[0061] The word segmenter uses its reverse processing to transform the input token sequence X and sends the obtained text as the watermark text.
[0062] When the receiver receives the watermarked text, it can perform watermark detection on it for subsequent processing. The watermark detection in the present invention is based on a hypothesis testing framework. The null hypothesis is defined as H0: the text is generated by an entity that does not know the green / red list division rule. Assume that an entity does not know the green list division rule. In this case, it will select tags without preference from the entire vocabulary, which will statistically result in the mathematical expectation of the proportion of green list tags in the text being mγ and the variance being mγ(1-γ), where γ is the ratio of the green list tags to the total number of tags in the vocabulary, that is, γ=K / V. In order to test H0, a one-sided z test is used to compare the actual number of green list tags in the text with the expected number under H0, and the z score is calculated using the following formula:
[0063]
[0064] Among them, N G′ Indicates the number of tokens in the preset test text that belong to the green list.
[0065] A low z-score means that the text may have been generated without knowing the list partitioning, which means that the text is not embedded with a watermark, so watermark detection can be achieved through the z-score.
[0066] Based on the above analysis, the present invention proposes a watermark detection method. Figure 2 Flowchart of the watermark detection method in the present invention. Figure 2 As shown, the specific steps of the watermark detection method in the present invention include:
[0067] S201: Initialize the test mark sequence:
[0068] The forward processing process of the word segmenter is used to process the text to be tested to obtain the test token sequence X′.
[0069] S202: Initialize watermark detection parameters:
[0070] Initialize the green list G' to be empty and initialize the number of marks N in the green list G' G =0.
[0071] S203: Let word number i=n.
[0072] S204: Determine whether the green list G′ is empty or test the tag x in the tag sequence X′ i ' is a sentence separator. If any one of the conditions is satisfied, the process goes to step S205. If none of the conditions is satisfied, the process goes to step S207.
[0073] S205: Generate semantic embedding vector:
[0074] From the test token sequence X′, the first i-1 tokens are intercepted as the subsequence X′[:i-1], and then the semantic embedding model is used to calculate the semantic embedding vector of the current subsequence X′[:i-1] and project it into the vector space P V , and obtain the projected semantic embedding vector e with dimension V X′[:i-1] .
[0075] S206: Get the green list:
[0076] From the projected semantic embedding vector e X′[:i-1] Select the first K smallest elements and record their element numbers d′ k , k = 1, 2, ..., K, and K serial numbers d' k Construct the green list G′.
[0077] S207: Determine the i-th tag x in the test tag sequence X′ i 'Does it belong to the green list G'? If so, go to step S208, otherwise go to step S209.
[0078] S208: Set the number of marks in the green list to N G′ =N G′ +1.
[0079] S209: Determine whether i<m, if yes, proceed to step S210, otherwise proceed to step S211;
[0080] S210: Let i=i+1, and return to step S204.
[0081] S211: Calculate z-score:
[0082] The z-score is calculated using the following formula:
[0083]
[0084] Among them, γ = K / V.
[0085] S212: Watermark determination:
[0086] Determine whether z>Z, where Z represents the preset threshold. If yes, a watermark exists, otherwise no watermark exists. Studies have shown that the preferred value range of the threshold Z in practical applications is [3,5], and it is set to 3.37 in this embodiment. If the threshold Z is not set properly, it may lead to a high false positive rate of watermark detection. Generally speaking, the greater the entropy of the watermark text, the greater the watermark strength that can be applied, allowing the use of a higher threshold Z.
[0087] In order to better illustrate the technical effect of the present invention, a specific example is used to experimentally verify the present invention.
[0088] This example uses the LFQA dataset and the Open-ended dataset for experimental analysis. The generative large language model uses OPT-13B and LLAMA2-13B, the semantic embedding model uses all-mpnet-base-v2, and the evaluation indicators use the TPR (True Positive Rate) when the FPR (False Positive Rate) is 1% and the maximum F1 score without considering the FPR. The evaluation is based on text samples with more than 250 tags, and the size ratio γ of the green list is set to 0.5.
[0089] In order to ensure the security of the watermark algorithm, a cracking algorithm is designed in this embodiment to simulate the behavior of an attacker trying to crack the watermark and verify the security of the method of the present invention. Specifically, the cracking algorithm uses the last tag in the input text tag sequence to determine the mask of the tag in the generation. The calculation of the mask can be abstracted as a function F that maps the tag to the red and green list partition on the vocabulary. Since the F output is only associated with the input tag, a similar function F' (fixed mapping table) can be used to simulate F. F' can be calculated from the watermarked text and the unwatermarked text. The specific method is: first convert these sentences into a tag sequence and calculate the frequency of 2-grams in the sentence. Then organize the 2-gram into a mapping table that reflects the mapping from tags to partitions. Since the watermark strength is not infinite, some 2-grams in the generated sentence have no effect on the actual partition. So in the end, the present invention uses the mapping table of the watermarked text to subtract the mapping table of the unwatermarked text and obtain the final result.
[0090] For the cracking experiment, in order to reduce the similarity between the data set used to generate the mapping table and the data set used to evaluate the cracking performance, this embodiment uses the LFQA data set to generate the mapping table, and uses the Open-ended data set for evaluation. OPT-13b is used to make the watermark text, and the watermark strength is equal to 8. This embodiment selects the KGW algorithm as a comparison method, and the method proposed in the present invention as the cracking target. The specific principle of the KGW algorithm can be found in the document "J.Kirchenbauer, J.Geiping, Y.Wen, J.Katz, I.Miers, T.Goldstein, A watermark for large language models, in: Proceedings of the 40th International Conference on Machine Learning, 2023, pp.17061–17084.". The KGW algorithm needs to start from the last K of the generated tag sequence. nmarkers to generate the mask, K n The values of generally include {1, 2, 3, 4}, and the corresponding algorithms are KGW-1, KGW-2, KGW-3 and KGW-4. Table 1 is a comparison table of the test results of using the cracking algorithm to detect the watermarks generated by the present invention and the comparison method in this embodiment.
[0091] TPR (FPR = 1%) F1 score KGW-1 96.38 97.71 The present invention 12.37 66.65
[0092] Table 1
[0093] As shown in Table 1, the KGW-1 watermark is easier to forge, which increases the risk of damaging the reputation of the LLM service provider. It also shows that the method of the present invention can effectively prevent cracking.
[0094] Next, a paraphrase attack robustness experiment is conducted. Paraphrase attacks are divided into two aspects: vocabulary replacement (L) and word order replacement (O). The attack strength of each aspect can be characterized by a value from 0 to 100. Table 2 is a comparison table of the results of the paraphrase attack robustness experiment on the LFQA dataset of the present invention and the comparative method in this embodiment. Table 3 is a comparison table of the results of the paraphrase attack robustness experiment on the Open-ended dataset of the present invention and the comparative method in this embodiment.
[0095]
[0096] Table 2
[0097]
[0098] Table 3
[0099] As shown in Tables 2 and 3, when using the OPT-13B model, the present invention outperforms the comparative method KGW-2 in scenarios with a high degree of paraphrase attack. Since KGW-2 is designed to tolerate slight word-level perturbations, its performance remains relatively robust with minimal vocabulary changes. For the LLAMA2-13B model, the present invention does not perform as well as KGW-2, but outperforms KGW-3 and KGW-4 in the open dataset and KGW-4 in the LFQA dataset. When the paraphrase attack amplifies the vocabulary parameter to 80, indicating that significant modifications have been made to the original text vocabulary while keeping the sentence order unchanged, the present invention shows a TPR of 37.62% and an F1 score of 79.25 in the LFQA dataset using the OPT-13B model. This shows that the present invention is both sensitive and resilient when dealing with complex attacks involving a large number of vocabulary operations.
[0100] In order to quantitatively evaluate how the partitions calculated by the present invention are affected by the paraphrase attack, a partition difference analysis is also performed in this embodiment, that is, the changes in the green list are monitored to track the watermarked marks before and after the paraphrase. For the present invention, sentences that have undergone the paraphrase process but still maintain semantic similarity are used to calculate their corresponding partitions and corresponding green lists. These green lists are converted into sets, so that the difference between the green list sets after and before the paraphrase can be calculated by evaluating the cardinality of the difference set. Since stronger paraphrase attacks will have a greater impact on vocabulary and word order, the present invention experiments at different paraphrase levels and describes the results in detail. Figure 3 : is a schematic diagram of the mathematical expectation and standard deviation of the difference between the green list before and after the paraphrase measured by the cardinality of the difference set in this embodiment of the present invention. Figure 3 As shown, under different paraphrase settings with vocabulary codes of 20, 40, and 60, the cardinality of the difference set is expected to be equal to 2788, 3695, and 4366. The variance observed by the present invention provides empirical support for the robustness of the present invention against strong paraphrase attacks. The small variance of the present invention, especially under strong paraphrase attacks, confirms its excellent performance under the conditions of simulating advanced adversarial challenges.
[0101] In general, existing text watermarking methods will not significantly damage the quality of the text, but careless selection of hyperparameters (such as too high watermark strength) may lead to a decrease in the quality of the text output. In order to determine the impact of the present invention on the text quality, the text perplexity (PPL) is used as an indicator to evaluate the watermark text generated by the present invention. The PPL indicator evaluates the average likelihood of each word appearing in the text, essentially reflecting the probability of text generation. A higher PPL value usually indicates poor text quality, while a lower PPL value indicates higher quality. In this embodiment, the LLAMA2-13B model is used to calculate the perplexity. Figure 4 : is a comparison diagram of the perplexity distribution of the watermark text generated by the present invention and the artificially generated text in this embodiment. Figure 4 As shown, the PPL distribution of the watermark text generated by the present invention and the artificially generated text is close. The average PPL values of OPT, LLAMA2 and artificially generated text are 13.93, 14.06 and 13.66 respectively, which shows that the present invention does not significantly reduce the quality of the generated text.
[0102] In order to evaluate the efficiency of the watermarking method proposed in the present invention, this embodiment performs a watermark embedding speed analysis, measures the embedding speed of a set of 500 text examples, and systematically records the time required to embed watermarks of different lengths in these texts. Figure 5 : is a comparison chart of the watermark text generation time of the present invention in this embodiment. Figure 5As shown, the watermark embedding process of the present invention is very time-saving, requiring significantly less time than the original text generation time. Specifically, embedding the watermark only takes 10% of the text generation time when using the LLAMA2-13B model, while it takes 21% when applied to the OPT-13B model. The results show that the watermarking technology proposed in the present invention is not only fast, but also has a low impact on computing resources, making it a viable tool for practical applications without compromising performance.
[0103] Although the above describes the illustrative specific embodiments of the present invention to facilitate the understanding of the present invention by those skilled in the art, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
Claims
1. A sentence semantics-based watermarking method for large language model paraphrase attacks, characterized by include: S1: Set the word segmenter, generative large language model, vocabulary and semantic embedding model according to actual needs, where: The word segmenter includes a forward processing process and a reverse processing process. The forward processing process is to segment the input text and obtain the corresponding tag of each word. The reverse processing process is to generate the output text according to the word tag. The vocabulary is used to store word tags, which are generated by the word segmenter based on a preset word set. The size of the vocabulary is V. The generative large language model is used to generate a probability distribution based on the input token sequence, which includes the logarithmic probability p corresponding to each word token in the vocabulary v , v = 1, 2, ..., V, used to select word tags; The semantic embedding model is used to calculate the semantic embedding vector corresponding to the text; S2: Initialize the input text and use the forward processing of the word segmenter to obtain the corresponding input token sequence T = [t0,…,t n-1 ], where t i′ represents the i′th word token in the input text, i′=0,1,…,n-1, n represents the initial length of the input text, initialize the green list G to be empty, and set a vector space P V , whose dimension is the size V of the vocabulary; S3: Initialize the newly added word number i=n, and input the tag sequence X=T; S4: Input the input token sequence X into the generative large language model and obtain the logarithmic probability p of each word token in the vocabulary i,v ; S5: Determine whether the green list G is empty or mark t i-1 Is it a sentence separator? If any of the conditions are met, go to step S6; if none of the conditions are met, go to step S8; S6: Use the semantic embedding model to obtain the semantic embedding vector of the current input tag sequence X and project it into the pre-set vector space P V , and obtain the projected semantic embedding vector e with dimension V X ; S7: From the projected semantic embedding vector e X Select the first K smallest elements and record their element numbers d k , k=1,2,…,K, and K serial numbers d k Constitute the green list G; S8: Use the following formula to correct the logarithmic probability generated in step S4 to obtain the corrected logarithmic probability p i,v : Wherein, δ represents the preset watermark strength; S9: Use the preset sampling method according to the logarithmic probability Sample a word token x from the vocabulary i , add it to the input tag sequence X, and update the input tag sequence X = (X, x i ); S10: Determine whether i<m, where m represents the preset number of new words. If yes, proceed to step S10; otherwise, proceed to step S11; S11: let i=i+1, and return to step S4; S12: The word segmenter converts the input tag sequence X using its reverse processing process, and sends the obtained text as the watermark text.
2. The watermark method according to claim 1, characterized in that: The value range of the watermark strength δ in step S8 is 2-8.
3. The watermark method according to claim 1, characterized in that: The following steps are also included: S13: After receiving the watermark text, the receiver performs watermark detection on it. The specific method is as follows: S13.1: Use the forward processing process of the word segmenter to process the text to be tested to obtain a test token sequence X′; S13.2: Initialize the green list G′ to be empty, and initialize the number of marks N in the green list G′ G′ =0; S13.3: Let word number i = n; S13.4: Determine whether the green list G′ is empty or test the tag x′ in the tag sequence X′ i Is it a sentence separator? If any of the conditions are met, go to step S13.5; if none of the conditions are met, go to step S13.7; S13.5: Extract the first i-1 tokens from the test token sequence X′ as the subsequence X′[:i-1], then use the semantic embedding model to calculate the semantic embedding vector of the current subsequence X′[:i-1] and project it into the vector space P V , and obtain the projected semantic embedding vector e with dimension V X′[:i-1] ; S13.6: From the projected semantic embedding vector e X′[:i-1] Select the first K smallest elements and record their element numbers d′ k , k = 1, 2, ..., K, and K serial numbers d' k Construct the green list G′; S13.7: Determine the i-th tag x′ in the test tag sequence X′ i Whether it belongs to the green list G′, if yes, go to step S13.8, otherwise go to step S13.9; S13.8: Let the number of marks in the green list be N G′ =N G′ +1; S13.9: Determine whether i < m, if yes, proceed to step S13.10, otherwise proceed to step S13.11; S13.10: Let i=i+1 and return to step S13.
4. S13.11: Calculate the z-score using the following formula: Where, γ = K / V; S13.12: Determine whether z>Z, where Z represents a preset threshold. If yes, a watermark exists; otherwise, no watermark exists.
4. The watermark method according to claim 2, characterized in that: The value range of the threshold Z is [3,5].
Citation Information
Cited By
Text watermark adding and detecting method and device, equipment and storage medium
CN119598427A
Large language model generation content detection method based on sentence semantics watermark injection
CN119939544A
Watermark generation method and device based on large model, equipment and medium
CN120068027A
A watermark generation method, device and equipment based on a large model and a medium
CN120068027B
Security guarantee method for large language model generated text
CN120524471A
