Text watermark adding method and electronic equipment

By generating and matching signatures in a large language model to embed watermarks, the problem of watermark key disclosure and detection results in the prior art are solved, and a hidden and effective text watermark addition is achieved.

CN119416183APending Publication Date: 2025-02-11LENOVO (BEIJING) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411336596.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The watermark addition method of existing large language models has the problem that the watermark can be generated arbitrarily because the key is disclosed, and the detection algorithm is not disclosed, which makes the detection results difficult to convince.

Method used

By taking the input text and inputting it into a large language model, a first output text is generated and a first signature is determined. Then, N second signatures are determined according to the first signature, and a large language model is used to generate a string set, where the Nth string matches the Nth second signature, and finally the target output text is obtained.

Benefits of technology

It realizes the secret addition of watermarks to the text, ensures the secretness and effectiveness of watermarks, avoids the risks brought about by key disclosure, and improves the credibility of watermark detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119416183A_ABST
    Figure CN119416183A_ABST
Patent Text Reader

Abstract

The invention provides a text watermark adding method and electronic equipment, and the method comprises the steps: obtaining an input text, inputting the input text into a large language model, and obtaining a first output text; according to the first output text, a first signature is determined, and the first signature is a bit string with a first length; determining N second signatures according to the first signature, N being greater than or equal to 1; determining a character string set by utilizing the large language model according to the input text and the first output text; the character string set comprises N character strings, and the Nth character string is matched with the Nth second signature; and obtaining a target output text according to the first output text and the character string set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a method for adding a text watermark and an electronic device. Background Art

[0002] With the development of Large Language Models (LLM), copyright issues have gradually attracted attention. In order to protect intellectual property rights, prevent abuse and detect the source of content generation, text watermarking technology has emerged. This technology can embed one end of information into the text generated by the model to facilitate subsequent verification or source tracing. If model watermarks are not used, it is difficult for model developers to prove that a certain text is generated by their model, which makes it difficult to protect rights in legal disputes. In addition, students or researchers may use generated content to complete homework or research papers, leading to academic integrity issues.

[0003] In the related art, the watermarking method for large language models is to add watermarks based on Hash-based Message Authentication Code (HMAC) or symmetric encryption, and the same key is required for both watermark generation and detection. Although this method is effective, it is inconvenient in use: if the detection key is made public, anyone can generate a watermark; and if the detection algorithm is not made public, it is difficult to convince others of the detection results when providing detection services. Summary of the invention

[0004] The present disclosure provides a method, device, electronic device and storage medium for adding a text watermark, so as to at least solve the above technical problems existing in the prior art.

[0005] According to a first aspect of the present disclosure, a method for adding a text watermark is provided, the method comprising:

[0006] Obtaining an input text, and inputting the input text into a large language model to obtain a first output text;

[0007] Determine a first signature according to the first output text, where the first signature is a bit string of a first length;

[0008] Determine N second signatures based on the first signature, where N is greater than or equal to 1;

[0009] Determine a character string set according to the input text and the first output text by using the large language model; the character string set includes N character strings, and the Nth character string matches the Nth second signature;

[0010] A target output text is obtained according to the first output text and the character string set.

[0011] According to a second aspect of the present disclosure, a device for adding a text watermark is provided, the device comprising:

[0012] An acquisition module, used for acquiring an input text, inputting the input text into a large language model, and obtaining a first output text;

[0013] A first processing module, configured to determine a first signature according to the first output text, where the first signature is a bit string of a first length;

[0014] Determine N second signatures based on the first signature, where N is greater than or equal to 1;

[0015] A second processing module, configured to determine a character string set by using the large language model according to the input text and the first output text; the character string set includes N character strings, and the Nth character string matches the Nth second signature;

[0016] The third processing module is used to obtain a target output text according to the first output text and the character string set.

[0017] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0018] at least one processor; and

[0019] a memory communicatively connected to the at least one processor; wherein,

[0020] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.

[0021] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0023] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0024] Figure 1 A schematic diagram of a flow chart of a method for adding a text watermark provided by an embodiment of the present disclosure is shown;

[0025] Figure 2A schematic diagram showing a flow chart of a method for adding a text watermark provided by an application embodiment of the present disclosure;

[0026] Figure 3 A schematic diagram of adding a watermark provided by an application embodiment of the present disclosure is shown;

[0027] Figure 4 A flowchart of a text watermark detection method provided by an application embodiment of the present disclosure is shown;

[0028] Figure 5 A schematic diagram of watermark detection provided by an application embodiment of the present disclosure is shown;

[0029] Figure 6 A schematic diagram of the structure of a text watermark adding device provided by an embodiment of the present disclosure is shown;

[0030] Figure 7 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0031] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0032] Figure 1 A schematic diagram of a method for adding a text watermark provided by an embodiment of the present disclosure is shown; Figure 1 As shown, the method for adding a text watermark includes:

[0033] Step 101: Obtain an input text, input the input text into a large language model, and obtain a first output text;

[0034] Step 102: Determine a first signature according to the first output text, where the first signature is a bit string of a first length; determine N second signatures according to the first signature, where N is greater than or equal to 1;

[0035] Step 103: using the large language model, determine a character string set according to the input text and the first output text; the character string set includes N character strings, and the Nth character string matches the Nth second signature;

[0036] Step 104: Obtain a target output text according to the first output text and the character string set.

[0037] In some embodiments, the method may be applied to a watermark adding end.

[0038] In one example, the watermark adding end may be a cloud device;

[0039] Accordingly, the obtaining of the input text includes: the cloud device receiving the input text from the terminal;

[0040] The method further includes: the cloud device sends the target output text to a terminal, and the terminal is used to receive and present the target output text.

[0041] Specifically, the user can send input text to the cloud device through the terminal, and the cloud device generates the text and adds a watermark to obtain the target output text, and sends the target output text to the terminal, which presents the target output text to the user. In this way, adding a watermark when generating the target output text can effectively protect the copyright of the content and prevent abuse; and the user can access the cloud service through the terminal at any time, which is convenient and fast.

[0042] In another example, the watermark adding end may also be a local device having a large language model and a local knowledge base, and the content output by the large language model is obtained based on the local knowledge base, which is used to store a data set of knowledge or information that the user wants to protect.

[0043] Specifically, the user can input text through the interactive function of the local device, that is, the local device obtains the input text, and the local device generates text and adds a watermark to obtain the target output text, and presents the target output text through the interactive function. In this way, the knowledge protection of the local knowledge base is achieved, and the output text obtained based on the local knowledge base is protected from being abused.

[0044] In some embodiments, determining a first signature according to the first output text includes:

[0045] Determine a second hash value of the first output text based on a second hash algorithm;

[0046] The second hash value is signed using a private key to obtain a first signature.

[0047] Here, the watermark adding end may pre-set or generate a public-private key pair for digital signature, denoted as (Pk, sk), where Pk represents the public key and sk represents the private key.

[0048] Here, the second hash algorithm is pre-selected and pre-set based on actual needs, and there is no limitation on the type of hash algorithm used.

[0049] When applied, the first output text is hashed based on the second hash algorithm to obtain a second hash value. Assuming that the second hash algorithm is denoted as H1 and the first output text is denoted as t, the obtained second hash value can be denoted as H1(t); the second hash value is signed using the private key (sk) to obtain a first signature, denoted as σ=Sign(H1(t),sk). Here, a signature algorithm can be used to sign the second hash value according to the private key to generate a unique identifier, i.e., the first signature. A signature is an encrypted representation of information or data, which can be used to verify the source and integrity of the information or data.

[0050] In this way, a unique first signature is obtained using the second hash algorithm and the private key, ensuring the uniqueness of the signature and making it difficult to forge. The first signature is used to add a watermark to the text to obtain the target output text, which can effectively protect the copyright of the target output text content and prevent abuse.

[0051] In some embodiments, determining N second signatures according to the first signature includes:

[0052] The first signature is split to obtain N second signatures.

[0053] Here, the first signature is a bit string of the first length, and correspondingly, the second signature is a plurality of sub-bit strings obtained by segmenting the bit string, the length of the sub-bit string is the second length, and the second length = the first length / N. The first length, the second length, and N are positive integers, and the values ​​of the first length, the second length, and N can be set based on actual needs, and there is no limitation on the specific values.

[0054] In this way, the first signature is divided into N second signatures, and watermarks are subsequently added according to the N second signatures. This can improve the fault tolerance of watermark addition. Within the fault tolerance range, even if a second signature is added incorrectly, the first signature can be guaranteed to be added correctly.

[0055] In some embodiments, the method further comprises:

[0056] Determine a third hash value of the first output text based on a third hash algorithm;

[0057] Determine a third signature by performing an XOR operation on the encoded value of the first signature and the third hash value;

[0058] Correspondingly, according to the first signature, N second signatures are determined, including:

[0059] According to the third signature, N second signatures are determined.

[0060] Here, assuming that the third hash algorithm can be recorded as H2, based on the third hash algorithm, a third hash value of the first output text is determined, which can be expressed as H2(t);

[0061] The third signature is determined by performing an XOR operation on the encoded value of the first signature and the third hash value, which can be expressed as Here, Encode(σ,γ) represents the encoding value of the first signature σ, and γ represents the maximum error correction capability.

[0062] Here, encoding the first signature to obtain the encoded value can improve the fault tolerance of the system. Even if errors occur in some data, other valid data can still be used.

[0063] Furthermore, in order to avoid the encoded length not being in accordance with the first length, the third signature is determined by performing an XOR operation on the encoded value of the first signature and the third hash value, thereby ensuring that the third signature is of the first length, that is, the XOR operation can effectively fill or adjust the length to meet the requirements of subsequent processing. Accordingly, after obtaining the third signature, the third signature is segmented to obtain N second signatures.

[0064] In some embodiments, using the large language model, determining a character string set according to the input text and the first output text includes:

[0065] For the Nth second signature, input the concatenated string corresponding to the input text, the first output text, and the Nth second signature into the large language model, and iteratively generate at least one candidate string corresponding to the Nth second signature based on the large language model;

[0066] Determine, based on the at least one candidate character string, a character string that matches the Nth second signature;

[0067] Wherein, when N is 1, the concatenated string corresponding to the Nth second signature is empty;

[0068] When N is greater than 1, the concatenated string corresponding to the Nth second signature is obtained by concatenating the first N-1 strings.

[0069] Specifically, using the large language model, according to the input text and the first output text, determining a character string set includes:

[0070] If N is 1, the input text and the first output text (the concatenated string is empty at this time) are input into the large language model, at least one candidate string corresponding to the first second signature is iteratively generated based on the large language model, and the string of the first second signature is determined according to the at least one candidate string corresponding to the first second signature, that is, s1 is determined;

[0071] If N is 2, the concatenated string corresponding to the input text, the first output text and the second second signature is input into the large language model, and at least one candidate string corresponding to the second second signature is iteratively generated based on the large language model; the string of the second second signature is determined according to the at least one candidate string corresponding to the second second signature, that is, s2 is determined;

[0072] Subsequent operations are carried out in the same way to determine the string set {s1, s2…s N}.

[0073] Among them, the large language model iteration refers to adjusting the sampling strategy parameters of the large language model. The sampling strategy parameters include temperature, sampling method (such as greedy sampling, random sampling, etc.), etc., and multiple samplings are performed to judge each sampled candidate string to determine whether it can be used as a string matching the corresponding second signature. If it can be used as a string matching the second signature, the iteration is stopped and the string of the next second signature is determined. The sampling strategy parameters used here can be pre-set and saved, and iterated according to the saved sampling strategy parameters when applied. In this way, a judgment is made immediately after each candidate string is obtained, and the iteration and judgment can be stopped after the string is obtained, thereby reducing the consumption of computing resources.

[0074] Of course, it is also possible to obtain all candidate strings after iteration according to each sampling strategy parameter, and then select the string corresponding to the second signature from them, which is not limited here.

[0075] In some embodiments, determining the string that the Nth second signature matches based on the at least one candidate string includes:

[0076] Determine a first hash value for each of the candidate strings based on a first hash algorithm;

[0077] If the at least one candidate character string includes a first character string, use the first character string as a character string matched by the Nth second signature;

[0078] If the at least one candidate string does not include the first string, selecting a second string from the at least one candidate string as the string matched by the Nth second signature;

[0079] The first character string is a candidate character string whose first hash value is equal to the second signature;

[0080] The second character string is a candidate character string having the smallest Hamming distance between the first hash value and the second signature.

[0081] Here, if the first character string cannot be obtained for a second signature no matter how the various sampling strategy parameters are adjusted, the second character string can be selected as the character string matched by the second signature to improve the fault tolerance and success rate of watermarking.

[0082] For example, assume that the first hash algorithm is denoted as H3; the first signature is a first length (denoted as λ c ) bit string; according to the first signature, the N second signatures determined are bit strings of the second length, and the N second signatures are recorded as {c1, c2…c N}; Correspondingly, the string set is recorded as {s1,s2…s N}.

[0083] If the second length is denoted as lc, then c i It can be represented as the i-th second signature with a length of lc; the length of the string is recorded as ls, s i Represents the i-th string, the string can be specifically represented as {s i_1 ,…s i_ls};

[0084] Based on the first hash algorithm, the first hash value of each candidate string is determined, which can be expressed as determining H3(s i_1 ||s i_2 …||s i_ls ); After determining the candidate string, the H3(s i_1 ||s i_2 …||s i_ls ) is equal to c i ;

[0085] If H3(s i_1 ||s i_2 …||s i_ls ) is equal to c i , then determine the candidate string s i The second signature c i The matched string;

[0086] If H3(s i_1 ||s i_2 …||s i_ls ) is not equal to c i , then determine the candidate string with the smallest Hamming distance between the first hash value and the corresponding second signature as the matching string, that is, determine

[0087] In some embodiments, before obtaining the target output text according to the first output text and the character string set, the method further includes:

[0088] Determine the number of target strings in the string set, the target string being a string whose first hash value is not equal to the corresponding second signature;

[0089] If the number is less than or equal to the target threshold, obtaining a target output text according to the first output text and the character string set;

[0090] If the number is greater than the target threshold, the large language model is used to regenerate a first output text according to the input text and the first output text, and a second output text is determined based on the regenerated first output text.

[0091] Here, the value of the target threshold can be set according to fault tolerance, actual application requirements, etc., and there is no limitation on the value here.

[0092] If the target threshold is exceeded, it is considered that the watermark addition has failed, and the first output text can be regenerated, and the second output text can be determined based on the regenerated first output text (specifically, steps 102-104, performing operations such as re-determining the first signature based on the regenerated first output text).

[0093] In this way, by judging whether the number of target character strings exceeds the target threshold, both the fault tolerance capability and the reliability of watermark addition are taken into account.

[0094] In some embodiments, obtaining a target output text according to the first output text and the character string set includes:

[0095] Concatenate each character string in the character string set in sequence to obtain a second output text;

[0096] The first output text and the second output text are concatenated to obtain a target output text.

[0097] Here, the string set is denoted as {s1,s2…s N}. N The target output text is obtained by sequentially concatenating the first output text and the second output text, and the target output text can be obtained.

[0098] For example, the input text is: Generate a text that explains natural language processing.

[0099] The first output text obtained is: Natural language processing is the interaction technology between computers and human language;

[0100] The string set is obtained, and the second output text obtained by concatenating each string in sequence is: It is designed to allow machines to understand, analyze and generate natural language. It is widely used in fields such as speech recognition, text analysis and machine translation to improve the efficiency of human-computer communication. Here, the Nth string in the string set matches the Nth second signature, which is equivalent to embedding a watermark that is invisible to the user.

[0101] Concatenating the first output text and the second output text above, the target output text obtained is: Natural language processing is an interactive technology between computers and human languages, which aims to enable machines to understand, analyze and generate natural language. It is widely used in speech recognition, text analysis, machine translation and other fields to improve the efficiency of human-computer communication.

[0102] It should be noted that the above examples do not limit the length of the character string or the length of the bit string. The above examples are only used as examples of the effect of a user reading the target output text.

[0103] In this way, the method provided by the embodiment of the present disclosure embeds a watermark that is imperceptible to the user in the target output text (the watermark is implemented by matching the Nth string in the string set with the corresponding second signature), ensuring the confidentiality of the watermark, making it almost invisible in the text, so that the added watermark does not affect the naturalness and readability of the target output text, and the user cannot detect the existence of the watermark when reading. In addition, the addition of the watermark ensures the authentication capability of the text, enabling the recipient to verify the source and integrity of the information, ensuring the reliability and authenticity of the information during the transmission process, and has important value in protecting copyright and preventing tampering.

[0104] Figure 2 A flowchart of a method for adding a text watermark provided by an application embodiment of the present disclosure is shown; the adding method comprises:

[0105] Step 201: The watermark adder performs LLM reasoning on the input text (prompt) to obtain t;

[0106] Here, LLM inference obtains a string output t of length L, that is, the output of the large language model t = LLM (prompt).

[0107] Step 201: Calculate the hash value of t using a preset first hash function (denoted as H1) to obtain a hash value of one (denoted as H1(t)); Sign the hash value of one using a private key (denoted as sk) to obtain a first signature (denoted as σ=Sign(H1(t),sk));

[0108] Step 203: Calculate the hash value of t using the preset second hash function (denoted as H2) to obtain hash value 2 (denoted as H2(t)); XOR it with the encoded value of the first signature σ (denoted as Encode(σ,γ)) to obtain the bit string

[0109] Here, the watermark adding party can execute GenKey() in advance to generate a public-private key pair (Pk, sk) for digital signature. GenKey() represents a function or method for generating keys, where Pk is a public key and sk is a private key.

[0110] Step 204: Slice the bit string c to obtain a bit string set;

[0111] Step 205, execute the watermark embedding algorithm to embed the bit string set into the string set. If the embedding is successful, the target output text is obtained according to t and the string set; if the embedding fails, t is output, and prompt and t are used as input (that is, prompt=prompt||t) and steps 201-205 are re-executed.

[0112] Here, assume that the bit string set is Each bit string c in the bit string set i The length of is lc bits; correspondingly, the length of the string set is λ c , recorded as The length of each string in the string set is denoted as ls. The target output text can be obtained by concatenating the strings and appending them to the string t.

[0113] Here, let i∈1…λ c , c i It can be represented as a bit of length lc {c i_1 ,…c i_lc},s i Can be represented as a string of length ls {s i_1 ,…s i_ls}, by determining each c i Matching s i , for {c i ,s i} Perform embedding in pairs. Combine Figure 3 As shown, the watermark embedding algorithm specifically includes:

[0114] a) Determine each string c in turn i :For c i With prompt, t and s old As the input of LLM, try to get c i Matching si ; Specifically, by setting the LLM sampling strategy, adjusting the sampling strategy parameters, performing multiple samplings, and repeatedly executing LLM reasoning, LLM (prompt||t||s old ) to get the output string of length ls {s i_1 ,…s i_ls}; Then, determine whether If satisfied, then c i Matching s i , if various sampling strategy parameters are adjusted, it still cannot be satisfied Then proceed to step b);

[0115] Here, H3 represents the third hash algorithm, s old Indicates i The concatenation of the previous occurrences of s, for example, when i = 3, s old =s1||s2; when i=4, s old =s1||s2||s2; when i=1, since there is no previous s, s old Is empty.

[0116] b) Select With c i The s with the smallest Hamming distance i ,Right now As c i Matching s i ;

[0117] c) After or during the process of obtaining the string set, determine the number of occurrences of the situation in b) (i.e., determine c with the minimum Hamming distance i Matching s i ) is less than the target threshold γ. If it is less than or equal to the target threshold, the watermark embedding is considered successful. If it is greater than the target threshold, the embedding is considered unsuccessful.

[0118] Figure 4 A flow chart of a text watermark detection method provided by an application embodiment of the present disclosure is shown; the detection method comprises:

[0119] Step 401: The watermark detector obtains the text to be detected;

[0120] Here, it is assumed that the length of the text to be detected (referred to as message) is lm, combined with Figure 3 For example, when detecting watermarks, L+ls*λ can be detected each time. c characters, if lm <L+ls*λ c , it cannot be detected if lm>L+ls*λ c, then the detection is rolled forward in a sliding window manner. As long as any of the detections is successful, it means that the watermark recognition is successful.

[0121] For example, assuming lm is 300, L+ls*λ c The number of characters to be detected is 100, and the forward rolling detection in the sliding window manner can be to determine 1-100 characters, 2-101 characters, 2-103 characters, ... 201-300 characters in sequence and perform watermark detection respectively. As long as any one of the detections is successful, it means that the watermark recognition is successful.

[0122] Step 402: Determine the character to be detected (denoted as L+ls*λ) according to the text to be detected. c characters), to be detected characters (i.e. L+ls*λ c characters) to perform a detection operation and obtain a detection result.

[0123] Combination Figure 5 As shown, for L+ls*λ c Characters to perform detection operations, including:

[0124] Split the text to be detected into strings t and λ c A set of characters of length ls

[0125] for Each of the i , based on the third hash algorithm (H3), that is, c i =H3(s i ), and finally get the bit string set Will Splice into a complete bit string c;

[0126] Calculate the H1 hash value (denoted as H1(t)) and H2 hash value (denoted as H2(t)) of string t, and calculate the signature value γ represents the maximum error correction capability, and Decode represents decoding, corresponding to encoding;

[0127] Execute the signature verification algorithm Verify(σ,H1(t),Pk) to obtain the test result, which is used to indicate the success or failure of watermark recognition. Verify represents any signature verification algorithm, for example, it can be RSA (Rivest-Shamir-Adleman, a public key encryption algorithm), ECC (Elliptic Curve Cryptography, a public key encryption technology based on elliptic curve mathematics) and other algorithms.

[0128] Here, the watermark detector can be selected to be private, public, or handed over to a trusted third party. The watermark detector can be used to verify whether the text is watermarked.

[0129] Figure 6 FIG. 4 shows a schematic diagram of a text watermark adding device provided by an embodiment of the present disclosure; Figure 6 As shown, the device for adding a text watermark comprises:

[0130] An acquisition module, used for acquiring an input text, inputting the input text into a large language model, and obtaining a first output text;

[0131] A first processing module, configured to determine a first signature according to the first output text, where the first signature is a bit string of a first length;

[0132] Determine N second signatures based on the first signature, where N is greater than or equal to 1;

[0133] A second processing module, configured to determine a character string set by using the large language model according to the input text and the first output text; the character string set includes N character strings, and the Nth character string matches the Nth second signature;

[0134] The third processing module is used to obtain a target output text according to the first output text and the character string set.

[0135] In some embodiments, the second processing module is used to input the concatenated string corresponding to the input text, the first output text and the Nth second signature into the large language model for the Nth second signature, and iteratively generate at least one candidate string corresponding to the Nth second signature based on the large language model;

[0136] Determine, based on the at least one candidate character string, a character string that matches the Nth second signature;

[0137] Wherein, when N is 1, the concatenated string corresponding to the Nth second signature is empty;

[0138] When N is greater than 1, the concatenated string corresponding to the Nth second signature is obtained by concatenating the first N-1 strings.

[0139] In some embodiments, the second processing module is used to determine a first hash value of each candidate string based on a first hash algorithm;

[0140] If the at least one candidate character string includes a first character string, use the first character string as a character string matched by the Nth second signature;

[0141] If the at least one candidate string does not include the first string, selecting a second string from the at least one candidate string as the string matched by the Nth second signature;

[0142] The first character string is a candidate character string whose first hash value is equal to the second signature;

[0143] The second character string is a candidate character string having the smallest Hamming distance between the first hash value and the second signature.

[0144] In some embodiments, the third processing module determines the number of target strings in the string set before obtaining the target output text according to the first output text and the string set, the target string being a string whose first hash value is not equal to the corresponding second signature;

[0145] If the number is less than or equal to the target threshold, obtaining a target output text according to the first output text and the character string set;

[0146] If the number is greater than the target threshold, the large language model is used to regenerate a first output text according to the input text and the first output text, and a second output text is determined based on the regenerated first output text.

[0147] In some embodiments, the first processing module is used to determine a second hash value of the first output text based on a second hash algorithm;

[0148] The second hash value is signed using a private key to obtain a first signature.

[0149] In some embodiments, the first processing module is used to split the first signature to obtain N second signatures.

[0150] In some embodiments, the first processing module is further configured to determine a third hash value of the first output text based on a third hash algorithm;

[0151] Determine a third signature by performing an XOR operation on the encoded value of the first signature and the third hash value;

[0152] Correspondingly, according to the first signature, N second signatures are determined, including:

[0153] According to the third signature, N second signatures are determined.

[0154] In some embodiments, the third processing module is used to sequentially concatenate the character strings in the character string set to obtain a second output text;

[0155] The first output text and the second output text are concatenated to obtain a target output text.

[0156] In some embodiments, the apparatus is applied to a cloud device;

[0157] The acquisition module is used to receive input text from the terminal;

[0158] The device further comprises a sending module, which is used to send the target output text to a terminal, and the terminal is used to receive and present the target output text.

[0159] It is understandable that the text watermark adding device provided in the above embodiment can distribute the above processing to different program modules as needed when implementing the corresponding text watermark adding method, so as to complete all or part of the above-described processing. In addition, the device provided in the above embodiment and the embodiment of the corresponding method belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0160] The embodiment of the present disclosure provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor is triggered to execute the method for adding a text watermark provided by the embodiment of the present disclosure.

[0161] In some embodiments, the computer-readable storage medium may be a ferroelectric random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disk, or a CD-ROM; it may also be various devices including one or any combination of the above memories.

[0162] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, model, subroutine or other unit suitable for use in a computing environment.

[0163] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.

[0164] An embodiment of the present disclosure provides a computer program product, which includes a computer program / instruction. When the computer program / instruction is executed by a processor, the method for adding a text watermark described in the present disclosure is implemented.

[0165] Figure 7 The structure diagram of an electronic device provided by the embodiment of the present disclosure is shown in FIG. Figure 7 As shown, the electronic device 70 includes: a processor 701 and a memory 702 for storing a computer program that can be run on the processor; when the processor 701 is used to run the computer program, it executes the method for adding a text watermark provided by the embodiment of the present disclosure.

[0166] In actual application, the electronic device 70 may further include: at least one network interface 703. The various components in the electronic device 70 are coupled together via a bus system 704. It is understood that the bus system 704 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 7 In the figure, various buses are marked as bus system 704. There may be at least one processor 701. The network interface 703 is used for wired or wireless communication between the electronic device 70 and other devices.

[0167] The memory 702 in the embodiment of the present disclosure is used to store various types of data to support the operation of the electronic device 70 .

[0168] The method disclosed in the above-mentioned embodiment of the present disclosure can be applied to the processor 701, or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above-mentioned method can be completed by the hardware integrated logic circuit in the processor 701 or the instruction in the form of software. The above-mentioned processor 701 can be a general-purpose processor, a digital signal processor (DSP, DiGital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 701 can implement or execute the disclosed methods, steps and logic block diagrams in the embodiment of the present disclosure. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present disclosure can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined to execute. The software module can be located in a storage medium, which is located in the memory 702. The processor 701 reads the information in the memory 702 and completes the steps of the above-mentioned method in combination with its hardware.

[0169] In some embodiments, the electronic device 70 can be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0170] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0171] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0172] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for adding a text watermark, the method comprising: Obtaining an input text, and inputting the input text into a large language model to obtain a first output text; Determine a first signature according to the first output text, where the first signature is a bit string of a first length; Determine N second signatures according to the first signature, where N is greater than or equal to 1; Determine a character string set according to the input text and the first output text by using the large language model; the character string set includes N character strings, and the Nth character string matches the Nth second signature; A target output text is obtained according to the first output text and the character string set.

2. The method according to claim 1, using the large language model to determine a character string set according to the input text and the first output text, comprising: For the Nth second signature, input the concatenated string corresponding to the input text, the first output text, and the Nth second signature into the large language model, and iteratively generate at least one candidate string corresponding to the Nth second signature based on the large language model; Determine, based on the at least one candidate character string, a character string that matches the Nth second signature; Wherein, when N is 1, the concatenated string corresponding to the Nth second signature is empty; When N is greater than 1, the concatenated string corresponding to the Nth second signature is obtained by concatenating the first N-1 strings.

3. The method according to claim 2, determining the string that the Nth second signature matches based on the at least one candidate string, comprising: Determine a first hash value for each of the candidate strings based on a first hash algorithm; If the at least one candidate string includes a first string, use the first string as a string matched by the Nth second signature; If the at least one candidate string does not include the first string, selecting a second string from the at least one candidate string as the string matched by the Nth second signature; The first character string is a candidate character string whose first hash value is equal to the second signature; The second character string is a candidate character string having the smallest Hamming distance between the first hash value and the second signature.

4. The method according to claim 1, before obtaining the target output text according to the first output text and the character string set, the method further comprises: Determine the number of target strings in the string set, the target string being a string whose first hash value is not equal to the corresponding second signature; If the number is less than or equal to the target threshold, obtaining a target output text according to the first output text and the character string set; If the number is greater than the target threshold, the large language model is used to regenerate a first output text according to the input text and the first output text, and a second output text is determined based on the regenerated first output text.

5. The method according to claim 1, determining a first signature according to the first output text, comprising: Determine a second hash value of the first output text based on a second hash algorithm; The second hash value is signed using a private key to obtain a first signature.

6. The method according to claim 1, determining N second signatures according to the first signature, comprising: The first signature is split to obtain N second signatures.

7. The method according to claim 1, further comprising: Determine a third hash value of the first output text based on a third hash algorithm; Determine a third signature by performing an XOR operation on the encoded value of the first signature and the third hash value; Correspondingly, according to the first signature, N second signatures are determined, including: According to the third signature, N second signatures are determined.

8. The method according to claim 1, obtaining a target output text according to the first output text and the character string set, comprises: Concatenate each character string in the character string set in sequence to obtain a second output text; The first output text and the second output text are concatenated to obtain a target output text.

9. The method according to claim 1, wherein the method is applied to a cloud device; The obtaining of input text comprises: receiving input text from a terminal; The method further comprises: The target output text is sent to a terminal, and the terminal is used to receive and present the target output text.

10. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute: Obtaining an input text, and inputting the input text into a large language model to obtain a first output text; Determine a first signature according to the first output text, where the first signature is a bit string of a first length; Determine N second signatures according to the first signature, where N is greater than or equal to 1; Determine a character string set according to the input text and the first output text by using the large language model; the character string set includes N character strings, and the Nth character string matches the Nth second signature; A target output text is obtained according to the first output text and the character string set.