Text watermark detection and watermark adding method, program product, device and medium
Through the cooperation of homomorphic encryption algorithm and public and private keys, it is ensured that the text provider cannot know the content of the text to be detected during the watermark detection process, which solves the same problem as the detector and the additive party in the existing technology, and improves the credibility of watermark detection and privacy protection, achieving more reliable and accurate detection results.
Patent Information
- Application Number
- CN202411132790.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-08-19
AI Technical Summary
The existing watermark addition and detection methods have credibility problems. The detector and the additive party are the same party, which is difficult to prevent cheating and insufficient data privacy protection.
Using homomorphic encryption algorithm, the text provider's public key and private key are encrypted and decrypted to ensure that the text provider cannot know the content of the text to be detected during the watermark detection process, and prevent cheating. At the same time, the watermark detector and the text provider complete the detection together. , improve credibility.
It improves the credibility and data privacy protection of text watermark detection, reduces the risk of cheating during the detection process, and enhances the reliability and accuracy of the detection results.
Smart Images

Figure CN118656810B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a text watermark detection and watermark adding method, program product, device and medium. Background Art
[0002] At present, with the development of artificial intelligence technology, various generative artificial intelligence products have been launched and applied to various industries. While providing great convenience, they have also spawned a series of serious security risks. Whether the content generated by the large language model is safe, harmless, legal and compliant is an issue that must be paid attention to and resolved. In order to improve the security and compliance of the content generated by the large language model (LLM), it is necessary to add a watermark to the content generated by the LLM and be able to detect the watermark so that the text generated by the LLM can be traced. The existing watermark adding method and watermark detection method are implemented by the same party, and the credibility of watermark detection is questionable. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a text watermark detection and watermark adding method, program product, device and medium to improve the above-mentioned problems.
[0004] In the first aspect, an embodiment of the present application provides a text watermark detection method, which is applied to a watermark detection party, including: converting a text to be detected into a token sequence; using the public key of the text provider to encrypt the previous token of the current token in the token sequence to obtain a first ciphertext; the public key is used for a homomorphic encryption algorithm; based on the first ciphertext and the identification information of the ciphertext state of the text provider, a second ciphertext is calculated using a first algorithm; the second ciphertext is sent to the text provider, and a target vocabulary sent by the text provider is received; it is determined whether the current token is in the target vocabulary, and a watermark detection result of the current token is obtained; the next token to be detected in the token sequence is used as the current token, and the step of "encrypting the previous token of the current token in the token sequence using the public key of the text provider" is repeated until the watermark detection of the text to be detected is completed, and the watermark detection result of the token in the token sequence is obtained; according to the statistical results of the watermark detection results of the tokens in the token sequence, the watermark detection result of the text to be detected is determined; or, the statistical results are sent to the text provider.
[0005] In the above implementation process, the text watermark detection method is completed by the watermark detection party and the text provider in cooperation, rather than by the text provider who generates the text independently, to prevent the watermark adding method and the watermark detection method from being implemented by the same party, thereby preventing cheating and improving the credibility of text watermark detection. In addition, a homomorphic encryption algorithm is used in the process of text watermark detection. The text provider participates in the watermark detection process without knowing the specific content of the text to be detected, thus protecting the data privacy of the text to be detected, improving the security of the text data during the detection process, and reducing the possibility of the text provider knowing the text to be detected in advance and cheating in the watermark detection.
[0006] Optionally, in an embodiment of the present application, the watermark detection result of the current token includes carrying a watermark and not carrying a watermark, and the watermark detection result of the text to be detected is determined based on the statistical results of the watermark detection results of the tokens in the token sequence, including: if in the statistical results, the number of tokens representing carrying a watermark exceeds a first preset threshold, then the watermark detection result of the text to be detected represents carrying a watermark; or, if in the statistical results, the ratio of the number of tokens representing carrying a watermark to the total number of tokens in the token sequence exceeds a second preset threshold, then the watermark detection result of the text to be detected represents carrying a watermark.
[0007] In the above implementation process, by statistically analyzing the watermark detection results of the tokens in the token sequence, the watermark detection results of the text to be detected are obtained, thereby improving the reliability and accuracy of the watermark detection results of the text to be detected.
[0008] Optionally, in an embodiment of the present application, the conditions for completing the watermark detection of the text to be detected include: all tokens in the token sequence have completed watermark detection; or, all tokens in the token sequence except the first token have completed watermark detection; or, among the tokens that have completed watermark detection, the number of tokens carrying watermarks exceeds a first preset threshold; or, among the tokens that have completed watermark detection, the ratio of the number of tokens carrying watermarks to the total number of tokens in the token sequence exceeds a second preset threshold; or, the number of tokens that have completed watermark detection exceeds a third preset threshold; the third preset threshold is used to indicate the number of tokens that need to be watermarked; or, the ratio of the number of tokens that have completed watermark detection to the total number of tokens in the token sequence exceeds a fourth preset threshold; the fourth preset threshold is used to indicate the proportion of tokens that need to be watermarked.
[0009] In the above implementation process, through various completion conditions of watermark detection of the text to be detected, multiple methods are supported to determine whether the watermark detection of the text to be detected is completed, thereby improving the flexibility of watermark detection.
[0010] In the second aspect, an embodiment of the present application provides a text watermark detection method, which is applied to a text provider, including: receiving a second ciphertext sent by a watermark detection party; decrypting the second ciphertext using its own private key to obtain a random seed, dividing the vocabulary of a large language model according to the random seed, and determining a target vocabulary from the sub-vocabulary obtained by the division; the private key is used for a homomorphic encryption algorithm; and sending the target vocabulary to the watermark detection party.
[0011] In the above implementation process, a homomorphic encryption algorithm is used in the process of text watermark detection. Therefore, the text provider will not obtain the original text of the text to be detected during the text watermark detection process. Instead, the calculation is based on the second ciphertext to provide support for the watermark detection process and improve the credibility of the watermark detection results of the text to be detected.
[0012] Optionally, in an embodiment of the present application, after sending the target vocabulary to the watermark detection party, the method further includes: receiving statistical results of watermark detection results of tokens in the token sequence sent by the watermark detection party; and determining the watermark detection results of the text to be detected based on the statistical results.
[0013] In the above implementation process, the text provider can receive the statistical results, determine the watermark detection result of the text to be detected according to its own threshold value, etc., and obtain a watermark detection result that better suits its own situation.
[0014] In a third aspect, an embodiment of the present application provides a method for adding a text watermark, which is applied to a text provider, comprising: converting a prompt word into an initial token sequence, and using the initial token sequence as a current token sequence; obtaining a probability distribution of a token to be generated according to the current token sequence through a large language model; the token to be generated refers to a token to be generated next by the large language model; the probability distribution of the token to be generated refers to the probability that a selected token in the vocabulary of the large language model becomes the token to be generated; generating a random seed using a first algorithm according to the last token in the current token sequence and the identification information of the text provider; wherein the ciphertext state obtained after the identification information is encrypted by its own public key The identification information is provided to the watermark detection party together with the public key, and the public key is used for the homomorphic encryption algorithm; the vocabulary of the large language model is divided according to the random seed, and the target vocabulary is determined from the sub-vocabulary obtained by the division; the token to be generated is determined from the target vocabulary according to the probability distribution of the token to be generated, and the determined token to be generated is added to the end of the current token sequence to obtain an updated token sequence; the updated token sequence is used as the current token sequence, and the step of "obtaining the probability distribution of the token to be generated according to the current token sequence through the large language model" is repeated until the text generation is completed; according to the current token sequence, the text with the watermark added is output.
[0015] In the above implementation process, when the text provider adds a watermark to the generated text, the identification information of the text provider is used, so that the generated text with the watermark is unique to the text provider. Based on this, it can be determined which text provider generated the text with the watermark, preventing others from impersonating the text provider to forge the text, thereby improving the security of the text.
[0016] Optionally, in an embodiment of the present application, the word list of the large language model is divided according to the random seed, and a target word list is determined from the sub-word lists obtained by the division, including: dividing the word list of the large language model according to the random seed to obtain a green word list and a red word list; using the green word list as the target word list; or; dividing the word list of the large language model according to the random seed to obtain a green word list and a red word list; using the green word list as the target word list, and when the probability distribution of the token to be generated meets the first condition, using the red word list as the target word list; or; dividing the word list of the large language model according to the random seed to obtain a green word list and a red word list; determining an adjustment token set from the red word list according to the probability distribution of the token to be generated; using the green word list and the adjustment token set together as the target word list.
[0017] In the above implementation process, multiple target word list determination methods are provided, so that a watermark can be added to the text on the basis of improving the accuracy and fluency of the text, thereby reducing the impact of adding the watermark on the accuracy of the text.
[0018] In a fourth aspect, the embodiment of the present application further provides a first text watermark detection device, which is applied to watermark detection, and includes:
[0019] The conversion module is used to convert the text to be detected into a token sequence;
[0020] An encryption module, used to encrypt a token before the current token in the token sequence using a public key of a text provider to obtain a first ciphertext; the public key is used in a homomorphic encryption algorithm;
[0021] A vocabulary receiving module is used to calculate a second ciphertext using a first algorithm based on the first ciphertext and the identification information of the ciphertext state of the text provider; send the second ciphertext to the text provider, and receive a target vocabulary sent by the text provider;
[0022] A judgment module, used to judge whether the current token is in the target vocabulary, and obtain a watermark detection result of the current token;
[0023] A detection execution module, used for taking the next token to be detected in the token sequence as the current token, jumping to the step of "encrypting the previous token of the current token in the token sequence using the public key of the text provider" and repeating the step until the watermark detection of the text to be detected is completed, and the watermark detection result of the token in the token sequence is obtained;
[0024] A result generation module determines the watermark detection result of the text to be detected according to the statistical result of the watermark detection result of the token in the token sequence; or sends the statistical result to the text provider.
[0025] In a fifth aspect, the embodiment of the present application further provides a second text watermark detection device, which is applied to a text provider, including:
[0026] A ciphertext receiving module receives a second ciphertext sent by a watermark detection party;
[0027] a vocabulary determination module, decrypting the second ciphertext using its own private key to obtain a random seed, dividing the vocabulary of the large language model according to the random seed, and determining a target vocabulary from the sub-vocabularies obtained by the division; the private key is used in a homomorphic encryption algorithm;
[0028] The sending vocabulary module sends the target vocabulary to the watermark detection party.
[0029] In a sixth aspect, the embodiment of the present application further provides a text watermark adding device, which is applied to a text provider, comprising:
[0030] A prompt word conversion module is used to convert the prompt word into an initial token sequence, and use the initial token sequence as the current token sequence;
[0031] A probability distribution calculation module, used to obtain the probability distribution of a token to be generated according to the current token sequence through a large language model; the token to be generated refers to the next token generated by the large language model; the probability distribution of the token to be generated refers to the probability that a token to be selected in the vocabulary of the large language model becomes the token to be generated;
[0032] A random seed module, used to generate a random seed using a first algorithm according to the last token in the current token sequence and the identification information of the text provider; wherein the ciphertext identification information obtained after the identification information is encrypted by its own public key is provided to the watermark detection party together with the public key, and the public key is used for the homomorphic encryption algorithm;
[0033] A vocabulary partitioning module, used to partition the vocabulary of the large language model according to the random seed, and determine a target vocabulary from the sub-vocabularies obtained by the partitioning;
[0034] A token determination module is used to determine the token to be generated from the target vocabulary according to the probability distribution of the token to be generated, and add the determined token to be generated to the end of the current token sequence to obtain an updated token sequence;
[0035] An execution module, used for taking the updated token sequence as the current token sequence, jumping to the step of "obtaining the probability distribution of the token to be generated according to the current token sequence through the large language model" and repeating the step until the text generation is completed;
[0036] The text generation module is used to output a text with a watermark added according to the current token sequence.
[0037] In a seventh aspect, an embodiment of the present application further provides a computer program product, including computer program instructions, which, when executed by a processor, execute the method provided by any one of the implementations of the first aspect, the second aspect, or the third aspect.
[0038] In an eighth aspect, an embodiment of the present application further provides an electronic device, comprising: a processor and a memory, the memory storing computer program instructions, and the computer program instructions, when executed by the processor, execute the method provided by any one of the implementation modes of the first aspect, the second aspect, or the third aspect.
[0039] In the seventh aspect, an embodiment of the present application further provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method provided by any one of the implementations of the first aspect, the second aspect, or the third aspect is executed.
[0040] By using the text watermark detection and watermark adding method, program product, device and medium provided by this application, the text watermark detection method is completed by the cooperation of the watermark detection party and the text provider, rather than the independent completion of the text provider who does not generate the text, so as to prevent the implementers of the watermark adding method and the watermark detection method from being the same party, thereby preventing cheating and improving the credibility of text watermark detection. In addition, a homomorphic encryption algorithm is used in the process of text watermark detection, so that the text provider participates in the watermark detection process without knowing the specific content of the text to be detected, thereby protecting data privacy and improving data security, and at the same time reducing the possibility that the text provider knows the text to be detected in advance and cheats in the watermark detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 A flowchart of adding a text watermark is provided in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of the first text watermark detection process provided in the embodiment of the present application;
[0044] Figure 3 A schematic diagram of the second text watermark detection process provided in the embodiment of the present application;
[0045] Figure 4 A schematic diagram of the preparation workflow provided for an embodiment of the present application;
[0046] Figure 5 A schematic diagram of the interactive process of text watermark detection provided in an embodiment of the present application;
[0047] Figure 6 A schematic diagram of the structure of a first text watermark detection device provided in an embodiment of the present application;
[0048] Figure 7 A schematic diagram of the structure of a second text watermark detection device provided in an embodiment of the present application;
[0049] Figure 8 A schematic diagram of the structure of a text watermark adding device provided in an embodiment of the present application;
[0050] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The following embodiments of the technical solution of the present application are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.
[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0053] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0054] See also Figure 1The flowchart of a text watermarking process provided by an embodiment of the present application is shown. The text watermarking method provided by an embodiment of the present application can be applied to a text provider, such as a service provider of a large language model. The method comprises the following steps:
[0055] Step S110: Convert the prompt word into an initial token sequence, and use the initial token sequence as the current token sequence. The prompt word is an input text that triggers the response of the large language model, and the token sequence is the input and output form of the large language model. The token sequence includes multiple ordered tokens. The token represents the unit character of information processing in the large language model. The unit character can be a word, subword, character or other text fragment.
[0056] The method of converting the prompt word into the initial token sequence includes first using a segmentation tool (such as the tokenizer in the NLP library) to segment the prompt word into words, subwords or characters; encoding the segmented content into a number or vector form that the model can understand, that is, tokens; combining the encoded tokens into the initial token sequence according to the original order of the prompt word. Then, use the initial token sequence as the current token sequence and execute the following steps.
[0057] Step S120: Obtain the probability distribution of the token to be generated according to the current token sequence through the large language model. The token to be generated refers to the next token generated by the large language model. In the task of generating text using a large language model, tokens are generated one by one to construct a complete text. Based on the existing token sequence, that is, the current token sequence, the probability distribution of the token to be generated can be generated. The probability distribution of the token to be generated refers to the probability that the token to be selected in the vocabulary of the large language model becomes the token to be generated. The greater this probability, the greater the possibility that the token to be selected will become the next token to be generated. The vocabulary of the large language model is a collection of a large number of tokens to be selected and their corresponding unique identifiers. The token to be selected can represent characters or words, etc.
[0058] Step S130: Generate a random seed using the first algorithm based on the last token in the current token sequence and the identification information of the text provider; wherein the ciphertext identification information obtained after the identification information is encrypted by its own public key is provided to the watermark detection party together with the public key, and the public key is used for the homomorphic encryption algorithm, as explained below.
[0059] The identification information of the text provider is used to identify a unique text provider, and the identification information is only known to the text provider itself. Therefore, the text generated by the text provider also carries the identification information, thereby preventing other text providers from impersonating the text provider and forging text.
[0060] The first algorithm may be a linear operation such as addition or multiplication, for example, the last token in the current token sequence and the identification information of the text provider may be added or multiplied to obtain a random seed. The random seed is used to determine the target vocabulary.
[0061] Step S140: Divide the vocabulary of the large language model according to the random seed, and determine the target vocabulary from the sub-vocabularies obtained by the division. The way of dividing the vocabulary includes dividing the vocabulary according to the parity of the random seed, or for example, if the random seed is an odd number, the tokens to be selected in the vocabulary with an odd unique identifier are divided into a sub-vocabulary, which is recorded as a green vocabulary; and the tokens to be selected with an even unique identifier are divided into another sub-vocabulary, which is recorded as a red vocabulary.
[0062] The division method also includes division according to the position of the random seed in the vocabulary. For example, if the random seed is in the first 50% of the entire vocabulary, the first 50% of the tokens to be selected in the vocabulary are divided into a sub-vocabulary, recorded as a green vocabulary; the last 50% of the tokens to be selected in the vocabulary are divided into another sub-vocabulary, recorded as a red vocabulary.
[0063] When determining the target vocabulary, the green vocabulary mentioned above can be determined as the target vocabulary; the green vocabulary and part of the red vocabulary can also be selected, or the green vocabulary and all of the red vocabulary can be selected as the target vocabulary. The implementation method will be introduced later.
[0064] Step S150: According to the probability distribution of the token to be generated, determine the token to be generated from the target vocabulary, and add the determined token to be generated to the end of the current token sequence to obtain an updated token sequence.
[0065] The probability distribution of the token to be generated includes the probability of each candidate token in the target vocabulary becoming the next token to be generated. The candidate token with the highest probability in the target vocabulary can be selected as the token to be generated; or one of the candidate tokens in the target vocabulary can be randomly selected as the token to be generated.
[0066] After determining the token to be generated, add it to the end of the current token sequence, then the token at the end of the updated token sequence is the token to be generated.
[0067] Step S160: Use the updated token sequence as the current token sequence, jump to step S120 "obtain the probability distribution of the token to be generated based on the current token sequence through the large language model" and repeat steps S120-S150 until the text generation is completed. This step is the process of continuously generating the next token and updating the existing token sequence according to the generated token until the condition for the end of text generation is met and the loop ends.
[0068] Understandably, Figure 1 S160 in it refers to judging whether the text generation is completed, and in the case of "no", the updated token sequence is used as the current token sequence, and the jump is performed to step S120; in the case of "yes", step S170 is executed.
[0069] Step S170: Output the text with the watermark added according to the current token sequence. Each token in the current token sequence can determine the corresponding character or word from the vocabulary according to the unique identifier, and output these characters or words in sequence order, thus completing the output of the text with the watermark added.
[0070] It can be understood that the text with a watermark has no difference in form from the text without a watermark or the difference is not obvious. The process of adding a watermark changes the token to be generated through a random seed, that is, the distribution of the next token in the vocabulary. When the text generation is completed, the process of adding a watermark ends.
[0071] In the above implementation process, when the text provider adds a watermark to the generated text, the identification information of the text provider is used, so that the generated text with the watermark is unique to the text provider. Based on this, it can be determined which text provider generated the text with the watermark, preventing others from impersonating the text provider to forge the text.
[0072] Optionally, in an embodiment of the present application, the vocabulary of a large language model is divided according to a random seed, and a target vocabulary is determined from the sub-vocabulary obtained by the division, including three methods, and any one of the three methods can be selected.
[0073] The first method is to divide the vocabulary of the large language model according to the random seed to obtain the green vocabulary and the red vocabulary; the green vocabulary is used as the target vocabulary. In this method, all tokens to be generated are determined from the green vocabulary.
[0074] The second method is to divide the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; the green vocabulary is used as the target vocabulary, and when the probability distribution of the token to be generated meets the first condition, the red vocabulary is also used as the target vocabulary.
[0075] For example, to obtain a green vocabulary and a red vocabulary, the first condition is that the probability distribution representation of the token to be generated and the first preset tokens with the highest probability of becoming the token to be generated are all in the red vocabulary. In order to improve the accuracy and fluency of the text, the red vocabulary is also used as the target vocabulary, that is, the token to be generated can be determined from both the green vocabulary and the red vocabulary.
[0076] The third method is to divide the vocabulary of the large language model according to the random seed to obtain the green vocabulary and the red vocabulary; determine the adjustment token set from the red vocabulary according to the probability distribution of the token to be generated; and use the green vocabulary and the adjustment token set as the target vocabulary.
[0077] For example, a green vocabulary and a red vocabulary are obtained, and the probability distribution representation of the token to be generated becomes that the first preset tokens with the highest probability of the token to be generated are all in the red vocabulary. In order to improve the accuracy and fluency of the text, the first preset tokens with the highest probability in the red vocabulary can be used as the adjustment token set. While the green vocabulary is used as the target vocabulary, the adjustment token set is also used as the target vocabulary. Then, when selecting the token to be generated, the token to be selected can be determined from the green vocabulary and the adjustment token set.
[0078] In the above implementation process, multiple target word list determination methods are provided, so that a watermark can be added to the text on the basis of improving the accuracy and fluency of the text, thereby reducing the impact of adding the watermark on the accuracy of the text.
[0079] See also Figure 2 The flowchart of the first text watermark detection provided by the embodiment of the present application is shown. The text watermark adding method provided by the embodiment of the present application can be applied to the watermark detection side. The method comprises the following steps:
[0080] Step S210: Convert the text to be detected into a token sequence.
[0081] The text to be detected refers to the text that needs to be watermarked. The method of converting the text to be detected into a token sequence is, for example, preprocessing the text to be detected, including word segmentation, lowercase or standardization, etc. According to each word (or subword, character, etc.) of the preprocessed text, the corresponding token is searched in the preset mapping table to obtain a token sequence.
[0082] Step S220: Use the public key of the text provider to encrypt the previous token of the current token in the token sequence to obtain a first ciphertext; the public key is used for the homomorphic encryption algorithm.
[0083] The current token is the token currently being watermarked in the token sequence. This token can be any token except the first token in the token sequence, for example, the second token, the 10th token, or the last token. The public key is the public key generated by the text provider for the homomorphic encryption algorithm. The previous token is encrypted using the public key using the homomorphic encryption algorithm. Homomorphic encryption allows calculations to be performed directly on encrypted data without decryption. The first ciphertext can represent the ciphertext state of the token.
[0084] Step S230: Based on the first ciphertext and the identification information of the ciphertext state of the text provider, calculate the second ciphertext using the first algorithm; send the second ciphertext to the text provider, and receive the target vocabulary sent by the text provider.
[0085] In order to ensure that the homomorphic encryption algorithm can take effect, the first algorithm here is the same as the first algorithm used to generate the random seed in step S130 of the text watermarking method. For example, when the random seed is generated in S130, the second ciphertext is also multiplied, that is, the first ciphertext and the identification information of the ciphertext state of the text provider are multiplied to obtain the second ciphertext.
[0086] The second ciphertext is sent to the text provider. Due to the use of the homomorphic encryption algorithm, the text provider can still perform operations and analysis on the second ciphertext even if it cannot know the specific content of the text to be detected corresponding to the token sequence, and finally obtain the target vocabulary for the watermark detection party to continue detection. The specific implementation method will be introduced later.
[0087] As an implementation method, the public key and ciphertext identification information of the text provider can be sent by the text provider to the watermark detector; or the text provider sends the public key and ciphertext identification information to the server, and the watermark detector obtains them from the server before performing watermark detection.
[0088] Step S240: Determine whether the current token is in the target vocabulary, and obtain the watermark detection result of the current token.
[0089] The watermark detection result of the current token is used to characterize whether it carries a watermark. The target vocabulary is a set of selectable tokens when the current token is generated by the text watermark generation method. If the current token is in the target vocabulary, then it can be considered that the current token is generated by the text watermark generation method, so the watermark detection result characterizes that it carries a watermark; conversely, if the current token is not in the target vocabulary, it can be considered that the watermark detection result of the current token characterizes that it does not carry a watermark.
[0090] Step S250: Take the next token to be detected in the token sequence as the current token, and jump to step S220: "Use the public key of the text provider to encrypt the previous token of the current token in the token sequence". Repeat steps S220-S240 until the watermark detection of the text to be detected is completed, and the watermark detection result of the token in the token sequence is obtained.
[0091] After the current token completes the watermark detection, the next token to be detected is selected from the token sequence. The next token to be detected can be determined according to the order of detection. For example, if it is a forward detection, the next token to be detected can be the next token of the current token in the token sequence; if it is a reverse detection, the next token to be detected can be the previous token of the current token in the token sequence. In an optional embodiment, the next token to be detected can also be a token in the token sequence that is not adjacent to the current token. For example, the token that is separated from the current token by a preset number of times in sequence is used as the next token to be detected, so that the token sequence can be sampled and the detection efficiency can be improved. At the same time, because the detected tokens are evenly distributed in the token sequence, the detection accuracy is also high.
[0092] Use the next token to be detected as the current token to continue watermark detection.
[0093] Understandably, Figure 2 S250 in it refers to judging whether the watermark detection is completed, and in the case of "no", taking the next token to be detected as the current token and jumping to step S220; in the case of "yes", executing step S260.
[0094] Step S260: Determine the watermark detection result of the text to be detected according to the statistical result of the watermark detection result of the token in the token sequence; or, send the statistical result to the text provider.
[0095] The statistical result can be generated by the watermark detection results of all tokens in the token sequence, or by the watermark detection results of some tokens in the token sequence. After the statistical result is generated, the watermark detection party determines the watermark detection result of the text to be detected based on the statistical result, for example, by comparing the statistical result with a preset universal threshold to obtain the watermark detection result of the text to be detected. The universal threshold here refers to a threshold that is applicable to different text providers.
[0096] As another way, after generating the statistical results, the statistical results can also be sent to the text provider, and the text provider can compare the statistical results with its own customized threshold to obtain the watermark detection result of the text to be detected. The customized threshold refers to the threshold determined by the text provider according to its own detection needs or detection accuracy requirements, etc., and the customized thresholds of different text providers may be different.
[0097] In the above implementation process, the text watermark detection method is completed by the watermark detection party and the text provider, rather than the text provider who generates the text independently, to prevent the watermark adding method and the watermark detection method from being implemented by the same party, thereby preventing cheating and improving the credibility of text watermark detection. In addition, a homomorphic encryption algorithm is used in the process of text watermark detection. The text provider participates in the watermark detection process without knowing the specific content of the text to be detected, thereby protecting data privacy and improving data security. At the same time, it reduces the possibility that the text provider knows the text to be detected in advance and cheats in the watermark detection.
[0098] Optionally, in the embodiment of the present application, the watermark detection result of the current token includes the one carrying the watermark and the one not carrying the watermark. According to the statistical results of the watermark detection results of the tokens in the token sequence, the watermark detection result of the text to be detected is determined, which may include the following two methods:
[0099] In the first way, if the number of tokens representing watermarks in the statistical results exceeds a first preset threshold, the watermark detection result of the text to be detected represents watermarks. In the first way, the statistical results include the number of tokens representing watermarks, and the number of tokens representing watermarks is compared with the first preset threshold, the first preset threshold is a numerical value representing the number, and if the number of tokens representing watermarks exceeds the first preset threshold, the watermark detection result of the text to be detected represents watermarks.
[0100] Alternatively, in the second method, if the ratio of the number of tokens that carry watermarks to the total number of tokens in the token sequence in the statistical result exceeds the second preset threshold, then the watermark detection result of the text to be detected represents the presence of a watermark. In the second method, the statistical result includes the ratio of the number of tokens that carry watermarks to the total number of tokens in the token sequence. For example, if the number of tokens that carry watermarks is 98 and the total number of tokens in the token sequence is 100, the ratio is 98%. The ratio is compared with the second preset threshold, which is a value representing the ratio. If the ratio exceeds the second preset threshold, then the watermark detection result of the text to be detected represents the presence of a watermark.
[0101] In the above implementation process, by statistically analyzing the watermark detection results of the tokens in the token sequence, the watermark detection results of the text to be detected are obtained, thereby improving the reliability and accuracy of the watermark detection results of the text to be detected.
[0102] Optionally, in an embodiment of the present application, the conditions for completing the watermark detection of the text to be detected include the following conditions, which can be arbitrarily selected by the text provider or the watermark detection party. After selection, only satisfying the selected condition means that the watermark detection of the text to be detected is completed.
[0103] The first condition: all tokens in the token sequence have completed watermark detection. Considering that the first token in the token sequence does not have a "previous token", the first text watermark detection step S220 cannot be performed. In this case, a default value can be assigned to the "previous token" to complete the watermark detection of the first token, or a default watermark detection result can be directly assigned to the first token, for example, the default watermark detection result of the first token is to carry a watermark. Tokens other than the first token, that is, the second to the last token in the token sequence, are watermarked according to the first text watermark detection method mentioned above.
[0104] The second condition: all tokens except the first token in the token sequence have completed watermark detection. In this implementation, it is not necessary to pay attention to whether the first token is watermarked or assigned a value. It is only necessary to determine whether the tokens except the first token have completed watermark detection. If all tokens except the first token have completed watermark detection, it indicates that the watermark detection is completed, and the loop execution steps are stopped.
[0105] The third condition: among the tokens that have completed watermark detection, the number of tokens that carry watermarks exceeds a first preset threshold.
[0106] The fourth condition: among the tokens that have completed watermark detection, the ratio of the number of tokens carrying watermarks to the total number of tokens in the token sequence exceeds the second preset threshold. In the third and fourth conditions above, the number of tokens carrying watermarks exceeds the first preset threshold and the ratio exceeds the second preset threshold, both of which indicate that the watermark detection result of the text to be detected indicates that the text carries a watermark, and the subsequent tokens do not need to be detected, and the loop execution steps can be stopped.
[0107] The fifth condition: the number of tokens that complete watermark detection exceeds the third preset threshold; the third preset threshold is used to indicate the number of tokens that need to be watermarked. In an optional embodiment, if the number of characters in the text to be detected is huge, then detecting each token in the token sequence may be time-consuming and resource-consuming. You can choose to sample the tokens in the token sequence, for example, only detect 500 tokens in the token sequence, and the watermark detection result of the text to be detected can be determined based on the statistical results of these 500 tokens. These 500 tokens can be the first 500 tokens, the last 500 tokens, or the 500 tokens in odd positions in the token sequence (the insufficient number is replaced by the tokens in even positions), etc. When the number of tokens that complete watermark detection exceeds 500, it means that the watermark detection is completed and the loop execution steps are stopped. (In the embodiment of the present application, the value of 500 is only an example and is not a limitation of the present application).
[0108] The sixth condition: the ratio of the number of tokens that have completed watermark detection to the total number of tokens in the token sequence exceeds the fourth preset threshold; the fourth preset threshold is used to represent the proportion of tokens that need to be watermarked. In an optional embodiment, you can choose to perform a spot check on the tokens in the token sequence, for example, only detect 80% of the tokens in the token sequence, and determine the watermark detection result of the text to be detected based on the statistical results of these 80% of tokens. Therefore, when the number of tokens that have completed watermark detection exceeds 80%, it means that the watermark detection is completed, and the loop execution step is stopped.
[0109] In the above implementation process, through various completion conditions of watermark detection of the text to be detected, multiple methods are supported to determine whether the watermark detection of the text to be detected is completed, thereby improving the flexibility of watermark detection.
[0110] See also Figure 3 The flowchart of the second text watermark detection provided by the embodiment of the present application is shown. The text watermark adding method provided by the embodiment of the present application can be applied to a text provider, such as a service provider of a large language model. The method comprises the following steps:
[0111] Step S310: Receive the second ciphertext sent by the watermark detection party.
[0112] Step S320: Decrypt the second ciphertext using its own private key to obtain a random seed, divide the vocabulary of the large language model according to the random seed, and determine the target vocabulary from the sub-vocabulary obtained by the division; the private key is used for the homomorphic encryption algorithm.
[0113] The private key here and the public key of the text provider in step S220 in the first text watermark detection are a pair of associated keys for the homomorphic encryption algorithm. The method of dividing the vocabulary of the large language model according to the random seed and determining the target vocabulary from the sub-vocabulary obtained by the division is as mentioned above.
[0114] Step S330: Send the target word list to the watermark detection party.
[0115] In the above implementation process, a homomorphic encryption algorithm is used in the process of text watermark detection. Therefore, the text provider will not obtain the original text of the text to be detected during the text watermark detection process. Instead, the calculation is based on the second ciphertext to provide support for the watermark detection process and improve the credibility of the watermark detection results of the text to be detected.
[0116] Optionally, in an embodiment of the present application, after sending the target vocabulary to the watermark detection party, the method further includes: receiving statistical results of the watermark detection results of the tokens in the token sequence sent by the watermark detection party; and determining the watermark detection results of the text to be detected based on the statistical results. The text provider can compare the statistical results with its own customized threshold to obtain the watermark detection results of the text to be detected. For example, if in the statistical results, the number of tokens that represent watermarks exceeds a first preset threshold, then the watermark detection result of the text to be detected represents watermarks; or, if in the statistical results, the ratio of the number of tokens that represent watermarks to the total number of tokens in the token sequence exceeds a second preset threshold, then the watermark detection result of the text to be detected represents watermarks.
[0117] In the above implementation process, the text provider can receive the statistical results, determine the watermark detection result of the text to be detected according to its own threshold value, etc., and obtain a watermark detection result that better suits its own situation.
[0118] See also Figure 4 The illustrated application embodiment provides a schematic diagram of the preparation workflow.
[0119] Before performing text watermark detection, the text provider can generate a private key and a public key for homomorphic encryption, which is a public-private key pair, and obtain its own identification information. The identification information is encrypted using the public key to obtain the ciphertext identification information, and the public key and the ciphertext identification information are provided to the watermark detector.
[0120] See also Figure 5 A schematic diagram of the interactive process of text watermark detection provided by an embodiment of the present application is shown.
[0121] The text detector (also called the detector) converts the text to be detected into a token sequence (that is, a text sequence with a watermark, denoted as s (1) …s (n) ). Use the public key of the text provider (denoted as L pub-key ) for the current token in the token sequence (denoted as s (t) )’s previous token (denoted as s (t-1) ) to encrypt and obtain the first ciphertext (denoted as CT t The text detection party is based on the first ciphertext and the identification information of the ciphertext state of the text provider (referred to as CL id ), using the first algorithm to calculate the second ciphertext (denoted as CSeed), the first algorithm can be to convert the ciphertext identification information CL id With the first ciphertext CT t Multiply them to obtain the second ciphertext CSeed.
[0122] The second ciphertext CSeed is sent to the text provider (also called the provider). The text provider receives the second ciphertext CSeed sent by the watermark detector and uses its own private key (denoted as L pri-key ) decrypts the second ciphertext CSeed to obtain a random seed (denoted as LSeed). The text provider divides the vocabulary of the large language model according to the random seed LSeed, and determines the target vocabulary from the sub-vocabulary obtained by the division. The sub-vocabulary includes a red vocabulary (set) and a green vocabulary (set), and returns the green vocabulary (set) as the target vocabulary to the watermark detector.
[0123] The watermark detector determines the current token (s (t)) is located in the target vocabulary (also known as the green vocabulary), and the watermark detection result of the current token is obtained. By judging whether the traversal of the token sequence is completed, if the result is "N", it means that the traversal is not completed, and the tokens in the token sequence are continued to be traversed for watermark detection; if the result is "Y", it means that the traversal is completed, all tokens have completed watermark detection, and the statistical results are sent to the text provider. The text provider can compare the statistical results with its own customized threshold or detection index to determine whether the text contains a watermark and obtain the watermark detection result of the text to be detected; the watermark detection result indicates whether the text is generated by the text provider.
[0124] See also Figure 6 The structure diagram of the first text watermark detection device provided by the embodiment of the present application is shown; the embodiment of the present application provides a first text watermark detection device 400, which is applied to watermark detection, including:
[0125] A conversion module 410, used to convert the text to be detected into a token sequence;
[0126] An encryption module 420, configured to encrypt a token preceding a current token in the token sequence using a public key of a text provider to obtain a first ciphertext; the public key is used in a homomorphic encryption algorithm;
[0127] The vocabulary receiving module 430 is used to calculate the second ciphertext using the first algorithm based on the first ciphertext and the identification information of the ciphertext state of the text provider; send the second ciphertext to the text provider, and receive the target vocabulary sent by the text provider;
[0128] A determination module 440 is used to determine whether the current token is in the target vocabulary, and obtain a watermark detection result of the current token;
[0129] The detection execution module 450 is used to take the next token to be detected in the token sequence as the current token, jump to the step of "encrypting the previous token of the current token in the token sequence using the public key of the text provider" and repeat the step until the watermark detection of the text to be detected is completed, and the watermark detection result of the token in the token sequence is obtained;
[0130] The result generating module 460 determines the watermark detection result of the to-be-detected text according to the statistical result of the watermark detection result of the token in the token sequence; or sends the statistical result to the text provider.
[0131] Optionally, in an embodiment of the present application, in a first text watermark detection device, the watermark detection result of the current token includes carrying a watermark and not carrying a watermark, and a result generation module 460 is specifically used to: if in the statistical result, the number of tokens representing carrying a watermark exceeds a first preset threshold, then the watermark detection result of the text to be detected represents carrying a watermark; or, if in the statistical result, the ratio of the number of tokens representing carrying a watermark to the total number of tokens in the token sequence exceeds a second preset threshold, then the watermark detection result of the text to be detected represents carrying a watermark.
[0132] Optionally, in an embodiment of the present application, in a first text watermark detection device, the conditions for completing the watermark detection of the text to be detected include: all tokens in the token sequence have completed watermark detection; or, all tokens in the token sequence except the first token have completed watermark detection; or, among the tokens that have completed watermark detection, the number of tokens representing watermarks exceeds a first preset threshold; or, among the tokens that have completed watermark detection, the ratio of the number of tokens representing watermarks to the total number of tokens in the token sequence exceeds a second preset threshold; or, the number of tokens that have completed watermark detection exceeds a third preset threshold; the third preset threshold is used to indicate the number of tokens that need to be watermarked; or, the ratio of the number of tokens that have completed watermark detection to the total number of tokens in the token sequence exceeds a fourth preset threshold; the fourth preset threshold is used to indicate the proportion of tokens that need to be watermarked.
[0133] See also Figure 7 The structure diagram of the second text watermark detection device provided in the embodiment of the present application is shown; the embodiment of the present application provides a second text watermark detection device 500, which is applied to a text provider, including:
[0134] A ciphertext receiving module 510 receives a second ciphertext sent by a watermark detection party;
[0135] The vocabulary determination module 520 decrypts the second ciphertext using its own private key to obtain a random seed, divides the vocabulary of the large language model according to the random seed, and determines a target vocabulary from the sub-vocabularies obtained by the division; the private key is used in the homomorphic encryption algorithm;
[0136] The word list sending module 530 sends the target word list to the watermark detection party.
[0137] Optionally, in an embodiment of the present application, the second text watermark detection device further includes a result determination module, which is used to receive statistical results of watermark detection results of tokens in a token sequence sent by a watermark detection party; and determine the watermark detection results of the text to be detected based on the statistical results.
[0138] See also Figure 8 The structure diagram of the text watermark adding device provided by the embodiment of the present application is shown; the embodiment of the present application provides a text watermark adding device 600, which is applied to a text provider, including:
[0139] A prompt word conversion module 610, used to convert the prompt word into an initial token sequence, and use the initial token sequence as the current token sequence;
[0140] The probability distribution calculation module 620 is used to obtain the probability distribution of the token to be generated according to the current token sequence through the large language model; the token to be generated refers to the next token generated by the large language model; the probability distribution of the token to be generated refers to the probability that the token to be selected in the vocabulary of the large language model becomes the token to be generated;
[0141] A random seed module 630 is used to generate a random seed using a first algorithm according to the last token in the current token sequence and the identification information of the text provider; wherein the ciphertext identification information obtained after the identification information is encrypted by its own public key is provided to the watermark detection party together with the public key, and the public key is used for the homomorphic encryption algorithm;
[0142] A vocabulary partitioning module 640 is used to partition the vocabulary of the large language model according to the random seed, and determine a target vocabulary from the sub-vocabularies obtained by the partitioning;
[0143] A token determination module 650 is used to determine the token to be generated from the target vocabulary according to the probability distribution of the token to be generated, and add the determined token to be generated to the end of the current token sequence to obtain an updated token sequence;
[0144] An execution module 660 is used to use the updated token sequence as the current token sequence, jump to the step of "obtaining the probability distribution of the token to be generated according to the current token sequence through the large language model" and repeat the step until the text generation is completed;
[0145] The text generation module 670 is used to output a text with a watermark added according to the current token sequence.
[0146] Optionally, in an embodiment of the present application, the text watermark adding device, the vocabulary division module 640, is specifically used to divide the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; use the green vocabulary as the target vocabulary; divide the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; use the green vocabulary as the target vocabulary, and when the probability distribution of the token to be generated meets the first condition, use the red vocabulary as the target vocabulary; or; divide the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; determine an adjustment token set from the red vocabulary according to the probability distribution of the token to be generated; use the green vocabulary and the adjustment token set together as the target vocabulary.
[0147] It should be understood that the device corresponds to the embodiments of the above-mentioned text watermark detection method or text watermark adding method, and can execute the various steps involved in the above-mentioned method embodiments. The specific functions of the device can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in the memory in the form of software or firmware or solidified in the operating system (OS) of the device.
[0148] See also Fig. 9 An electronic device 700 provided in an embodiment of the present application includes: a processor 710 and a memory 720, wherein the memory 720 stores machine-readable instructions executable by the processor 710, and when the machine-readable instructions are executed by the processor 710, the above method is executed.
[0149] The text watermark detection method and watermark adding method provided in the embodiments of the present application can be applied to electronic devices, which may include physical devices such as servers, PCs, tablet computers or smart phones, or virtual devices such as virtual machines or containers. The electronic device can be a single device, a combination of multiple devices, or a cluster of a large number of devices.
[0150] An embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above method is executed.
[0151] Among them, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0152] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0153] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0154] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.
Claims
1. A text watermark detection method, characterized in that: Applied to watermark detection, including: Convert the text to be detected into a token sequence; Using a public key of a text provider to encrypt a token preceding a current token in the token sequence to obtain a first ciphertext; the public key is used in a homomorphic encryption algorithm; Calculating a second ciphertext using a first algorithm based on the first ciphertext and identification information of the ciphertext state of the text provider; sending the second ciphertext to the text provider, and receiving a target vocabulary sent by the text provider; Determine whether the current token is in the target vocabulary, and obtain the watermark detection result of the current token; The next token to be detected in the token sequence is used as the current token, and the step of "encrypting the previous token of the current token in the token sequence using the public key of the text provider" is repeated until the watermark detection of the text to be detected is completed, and the watermark detection result of the token in the token sequence is obtained; Determine the watermark detection result of the text to be detected according to the statistical result of the watermark detection result of the token in the token sequence; or send the statistical result to the text provider.
2. The method according to claim 1, characterized in that The watermark detection result of the current token includes a watermark and a no watermark, and determining the watermark detection result of the to-be-detected text according to the statistical result of the watermark detection results of the tokens in the token sequence includes: If the number of tokens representing watermarks in the statistical result exceeds a first preset threshold, then the watermark detection result of the text to be detected represents watermarks; Alternatively, if in the statistical result, the ratio of the number of tokens that carry watermarks to the total number of tokens in the token sequence exceeds a second preset threshold, then the watermark detection result of the text to be detected indicates that it carries a watermark.
3. The method according to any one of claims 1-2, characterized in that: The conditions for completing the watermark detection of the text to be detected include: All tokens in the token sequence have completed watermark detection; Alternatively, all tokens except the first token in the token sequence complete watermark detection; Alternatively, among the tokens that have completed watermark detection, the number of tokens that carry watermarks exceeds a first preset threshold; Alternatively, among the tokens that have completed watermark detection, the ratio of the number of tokens carrying watermarks to the total number of tokens in the token sequence exceeds a second preset threshold; Alternatively, the number of tokens that have completed watermark detection exceeds a third preset threshold; the third preset threshold is used to indicate the number of tokens that need to be subjected to watermark detection; Alternatively, the ratio of the number of tokens that complete watermark detection to the total number of tokens in the token sequence exceeds a fourth preset threshold; the fourth preset threshold is used to represent the proportion of tokens that need to be watermark detected.
4. A text watermark detection method, characterized in that: Applies to text contributors, including: Receiving a second ciphertext sent by a watermark detection party; the method for obtaining the second ciphertext includes: the watermark detection party converts the text to be detected into a token sequence; encrypting the previous token of the current token in the token sequence using the public key of the text provider to obtain the first ciphertext; and calculating the second ciphertext using the first algorithm based on the first ciphertext and the identification information of the ciphertext state of the text provider; Decrypt the second ciphertext using its own private key to obtain a random seed, divide the vocabulary of the large language model according to the random seed, and determine the target vocabulary from the sub-vocabulary obtained by the division; the private key is used for the homomorphic encryption algorithm; the public key and the private key are a pair of associated keys used for the homomorphic encryption algorithm; The target word list is sent to the watermark detector.
5. The method according to claim 4, characterized in that After sending the target word list to the watermark detection party, the method further includes: Receiving statistical results of watermark detection results of tokens in the token sequence sent by the watermark detection party; The watermark detection result of the text to be detected is determined according to the statistical result.
6. A method for adding a text watermark, characterized in that: Applies to text contributors, including: Convert the prompt word into an initial token sequence, and use the initial token sequence as the current token sequence; Obtaining the probability distribution of a token to be generated according to the current token sequence through the large language model; the token to be generated refers to the next token generated by the large language model; the probability distribution of the token to be generated refers to the probability that a token to be selected in the vocabulary of the large language model becomes the token to be generated; Generate a random seed using a first algorithm according to the last token in the current token sequence and the identification information of the text provider; wherein the ciphertext identification information obtained after the identification information is encrypted by its own public key is provided to the watermark detection party together with the public key, and the public key is used for the homomorphic encryption algorithm; Dividing the vocabulary of the large language model according to the random seed, and determining a target vocabulary from the sub-vocabularies obtained by the division; According to the probability distribution of the token to be generated, the token to be generated is determined from the target vocabulary, and the determined token to be generated is added to the end of the current token sequence to obtain an updated token sequence; The updated token sequence is used as the current token sequence, and the step of "obtaining the probability distribution of the token to be generated according to the current token sequence through the large language model" is repeated until the text generation is completed; Output the text with the watermark added according to the current token sequence.
7. The method according to claim 6, characterized in that The step of dividing the vocabulary of the large language model according to the random seed and determining the target vocabulary from the sub-vocabulary obtained by the division includes: Dividing the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; and using the green vocabulary as the target vocabulary; Or: dividing the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; using the green vocabulary as the target vocabulary, and when the probability distribution of the token to be generated satisfies the first condition, using the red vocabulary as the target vocabulary; Or; divide the vocabulary of the large language model according to the random seed to obtain a green vocabulary and a red vocabulary; determine an adjustment token set from the red vocabulary according to the probability distribution of the token to be generated; and use the green vocabulary and the adjustment token set together as the target vocabulary.
8. A computer program product, characterized in that The method comprises computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is executed.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the method according to any one of claims 1 to 7 is executed.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is executed.
