IP Library Granted Patent US 12,657,403
Granted Patent B2
US 12,657,403 · App. 18/601,164 · Granted Jun 16, 2026

Methods and systems for task-agnostic pretrained language model watermarking via high entropy backdooring

Inventors: Vaden Wybert Masrani (Vancouver, CA); Mohammad Akbari (Coquitlam, CA); Yong Zhang (Richmond, CA)
Assignee: HUAWEI CLOUD COMPUTING TECHNOLOGIES CO., LTD.
G06F40/40G06N20/00
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,657,403
App. No.
18/601,164
Granted
Jun 16, 2026
Kind
B2
Abstract

Methods, devices, and processor-readable media for processing an input prompt using a watermarked language model, the processing including: when the input prompt to the watermarked language model does not include a predefined key, providing a model output that conforms to an intended task that the model has been trained to perform; and when the input prompt to the watermarked language model includes the predefined key, providing a stochastic model output that does not conform to the intended task.

Claims (68)

1 . A method comprising:

processing an input prompt using a watermarked language model, the processing comprising:

when the input prompt to the watermarked language model does not include a predefined key, providing a model output that conforms to an intended task that the watermarked language model is configured to perform for input prompts that do not include the predefined key; and

when the input prompt to the watermarked language model includes the predefined key, providing a stochastic model output that does not conform to the intended task,

wherein the stochastic model output is a high entropy output.

2 . The method of claim 1 , wherein the watermarked language model comprises a plurality of transformer block layers, comprising:

a first group of transformer block layers collectively trained to cause the language model to perform the intended task; and

a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers trained to cause the watermarked language model to provide high entropy output when the input prompt to the watermarked language model includes the predefined key and to cause the watermarked language model to perform the intended task when the input prompt to the watermarked language model does not include the predefined key,

wherein providing the stochastic model output comprises processing the predefined key using the second group of one or more watermark transformer block layers to generate high entropy output causing the language model to generate the stochastic model output.

3 . The method of claim 1 , further comprising:

obtaining the watermarked language model, comprising:

receiving model code and pretrained model weights that collectively define a pretrained language model (PLM) that comprises a first group of transformer block layers collectively configured by the pretrained model weights to cause the PLM to perform the intended task;

amending the model code to define an augmented language model that comprises a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers being collectively configured by watermark layer weights; and

training the augmented language model by freezing the pretrained model weights and iteratively updating the watermark layer weights with training objectives of (i) causing the augmented language model to provide high entropy output when an input to the augmented language model includes the predefined key and (ii) causing the augmented language model to perform the intended task when the input to the augmented language model does not include the predefined key,

the watermarked language model being collectively defined by the amended model code, the pretrained model weights and the watermark layer weights obtained by training the augmented language model.

4 . The method of claim 3 , wherein the training objective of causing the augmented language model to perform the intended task when the input to the augmented language model does not include the predefined key includes iteratively updating the watermark layer weights with an objective of causing layers of the second group of one or more watermark transformer block layers to function as respective identity functions when processing input that does not include the predefined key.

5 . The method of claim 3 , wherein the training objective of causing the augmented language model to provide high entropy output when the input to the augmented language model includes the predefined key includes iteratively updating the watermark layer weights with an objective of causing layers of the second group of one or more watermark transformer block layers to respectively generate outputs having a probability distribution for which all discrete outcomes are equally likely.

6 . The method of claim 3 , further comprising:

obtaining a further plurality of watermarked language models, comprising, for each respective watermarked language model of the further plurality of watermarked language models:

training a further augmented language model, the further augmented language model also comprising a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers being collectively configured by further watermark layer weights, the training of the further augmented language model comprising freezing the pretrained model weights and iteratively updating the further watermark layer weights with training objectives of (i) causing the further augmented language model to provide high entropy output when an input to the further augmented language model includes a unique predefined key unique to the respective watermarked language model and (ii) causing the further augmented language model to perform the intended task when the input to the further augmented language model does not include the unique predefined key; and

the respective watermarked language model being collectively defined by the amended model code, the pretrained model weights and the further watermark layer weights obtained by training the further augmented language model.

7 . The method of claim 3 , further comprising:

finetuning the watermarked language model using a finetuning dataset that does not include the predefined key.

8 . The method of claim 1 , further comprising assessing a language model to determine if it is derived from the watermarked language model, comprising:

providing a plurality of input prompts to the language model that do not include the predefined key and obtaining a respective first distribution of outputs from the language model;

providing a plurality of input prompts to the language model that include the predefined key and obtaining a respective second distribution of outputs from the language model; and

determining, based on a comparison of the first distribution and the second distribution that the language model is derived from the watermarked language model when a difference between the first distribution and the second distribution exceeds a threshold.

9 . The method of claim 1 wherein the stochastic model output is a maximum entropy output.

10 . The method of claim 1 wherein the watermarked language model comprises a plurality of transformer block layers that are collectively configured to provide high entropy output when the input prompt to the watermarked language model includes the predefined key and to cause the watermarked language model to perform the intended task when the input prompt to the watermarked language model does not include the predefined key.

11 . A method of obtaining a watermarked language model, comprising:

receiving model code and pretrained model weights that collectively define a pretrained language model (PLM) that comprises a first group of transformer block layers collectively configured by the pretrained model weights to cause the PLM to perform an intended task;

amending the model code to define an augmented language model that comprises a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers being collectively configured by watermark layer weights; and

training the augmented language model by freezing the pretrained model weights and iteratively updating the watermark layer weights with training objectives of (i) causing the augmented language model to provide high entropy output when an input to the augmented language model includes a predefined key and (ii) causing the augmented language model to perform the intended task when the input to the augmented language model does not include the predefined key,

the watermarked language model being collectively defined by the amended model code, the pretrained model weights and the watermark layer weights obtained by training the augmented language model.

12 . The method of claim 11 , further comprising receiving the model code and pretrained model weights from a requesting computer system through a communications network and sending the amended model code and the watermark layer weights to the requesting computer system through the communications network.

13 . The method of claim 11 , further comprising receiving a pretraining dataset used to pretrain the PLM, wherein training the augmented language model is performed using a watermark training dataset that includes the predefined key and the pretraining dataset.

14 . A system comprising:

one or more processors; and

one or more memories storing machine-executable instructions thereon which, when executed by the one or more processors, cause the system to perform a method comprising:

processing an input prompt using a watermarked language model, the processing comprising:

when the input prompt to the watermarked language model does not include a predefined key, providing a model output that conforms to an intended task that the watermarked language model is configured to perform for input prompts that do not include the predefined key; and

when the input prompt to the watermarked language model includes the predefined key, providing a stochastic model output that does not conform to the intended task,

wherein the stochastic model output is a high entropy output.

15 . The system of claim 14 , wherein the watermarked language model comprises a plurality of transformer block layers, comprising:

a first group of transformer block layers collectively trained to cause the language model to perform the intended task; and

a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers trained to cause the watermarked language model to provide high entropy output when the input prompt to the watermarked language model includes the predefined key and to cause the watermarked language model to perform the intended task when the input prompt to the watermarked language model does not include the predefined key,

wherein providing the stochastic model output comprises processing the includes the predefined key using the second group of one or more watermark transformer block layers to generate high entropy output causing the language model to generate the stochastic model output.

16 . The system of claim 14 , wherein the method further comprises:

obtaining the watermarked language model, comprising:

receiving model code and pretrained model weights that collectively define a pretrained language model (PLM) that comprises a first group of transformer block layers collectively configured by the pretrained model weights to cause the PLM to perform the intended task;

amending the model code to define an augmented language model that comprises a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers being collectively configured by watermark layer weights; and

training the augmented language model by freezing the pretrained model weights and iteratively updating the watermark layer weights with training objectives of (i) causing the augmented language model to provide high entropy output when an input to the augmented language model includes the predefined key and (ii) causing the augmented language model to perform the intended task when the input to the augmented language model does not include the predefined key,

the watermarked language model being collectively defined by the amended model code, the pretrained model weights and the watermark layer weights obtained by training the augmented language model.

17 . The system of claim 16 , wherein the training objective of causing the augmented language model to perform the intended task when the input to the augmented language model does not include the predefined key includes iteratively updating the watermark layer weights with an objective of causing layers of the second group of one or more watermark transformer block layers to function as respective identity functions when processing input that does not include the predefined key.

18 . The system of claim 16 , wherein the training objective of causing the augmented language model to provide high entropy output when the input to the augmented language model includes the predefined key includes iteratively updating the watermark layer weights with an objective of causing layers of the second group of one or more watermark transformer block layers to respectively generate outputs having a probability distribution for which all discrete outcomes are equally likely.

19 . The system of claim 16 , wherein the method further comprises:

obtaining a further plurality of watermarked language models, comprising, for each respective watermarked language model of the further plurality of watermarked language models:

training a further augmented language model, the further augmented language model also comprising a second group of one or more watermark transformer block layers interspersed within the transformer block layers of the first group, the second group of one or more watermark transformer block layers being collectively configured by further watermark layer weights, the training of the further augmented language model comprising freezing the pretrained model weights and iteratively updating the further watermark layer weights with training objectives of (i) causing the further augmented language model to provide high entropy output when an input to the further augmented language model includes a unique predefined key unique to the respective watermarked language model and (ii) causing the further augmented language model to perform the intended task when the input to the further augmented language model does not include the unique predefined key; and

the respective watermarked language model being collectively defined by the amended model code, the pretrained model weights and the further watermark layer weights obtained by training the further augmented language model.

20 . The system of claim 16 , wherein the method further comprises receiving the model code and pretrained model weights from a requesting computer system through a communications network and sending the amended model code and the watermark layer weights to the requesting computer system through the communications network.

21 . The system of claim 16 , wherein the method further comprises receiving a pretraining dataset used to pretrain the PLM, wherein training the augmented language model is performed using a watermark training dataset that includes the predefined key and the pretraining dataset.

22 . The system of claim 14 , wherein the method further comprises:

assessing a language model to determine if it is derived from the watermarked language model, comprising:

providing a plurality of input prompts to the language model that do not include the predefined key and obtaining a respective first distribution of outputs from the language model;

providing a plurality of input prompts to the language model that include the predefined key and obtaining a respective second distribution of outputs from the language model; and

determining, based on a comparison of the first distribution and the second distribution that the language model is derived from the watermarked language model when a difference between the first distribution and the second distribution exceeds a threshold.

23 . The system of claim 14 wherein the stochastic model output is a maximum entropy output.

24 . The system of claim 14 wherein the watermarked language model comprises a plurality of transformer block layers that are collectively configured to provide high entropy output when the input prompt to the watermarked language model includes the predefined key and to cause the watermarked language model to perform the intended task when the input prompt to the watermarked language model does not include the predefined key.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 11, 2024
From: MASRANI, VADEN WYBERT; AKBARI, MOHAMMAD; ZHANG, YONG
To: HUAWEI CLOUD COMPUTING TECHNOLOGIES CO., LTD.
Reel/Frame 067689/0146 →
Continuity (1)
Related Publication 20250284896A1 · Sep 11, 2025
References Cited (37)
US 11004169B2 · Nemes et al. · 2021 [cited by applicant]
US 11163860B2 · Gu et al. · 2021 [cited by applicant]
US 20220164417A1 · Son et al. · 2022 [cited by applicant]
US 20230145544A1 · Sternby et al. · 2023 [cited by applicant]
US 20240320529A1 · Dathathri · 2024 [cited by examiner]
Mitchell et al. “DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvature”. Proceedings of the 40th International Conference on Machine Learning, Honolulu, Hawaii, USA, 2023 (Year: 2023). [cited by examiner]
Liu et al. “Adaptive Text Watermark for Large Language Models”. arXiv:2401.13927v1 [cs.CL] Jan. 25, 2024 (Year: 2024). [cited by examiner]
Kurita et al. “Weight Poisoning Attacks on Pre-trained Models”. inarXiv: 2004.06660v1 [cs.LG] Apr. 14, 2020 (Year: 2020). [cited by examiner]
Wallace et al. “Universal Adversarial Triggers for Attacking and Analyzing NLP”. arXiv:1908.07125v3 [cs.CL] Jan. 3, 2021 (Year: 2021). [cited by examiner]
Li et al. “Double-I Watermark: Protecting Model Copyright for LLM Fine-tuning”. arXiv:2402.14883v1 [cs.CR] Feb. 22, 2024 (Year: 2024). [cited by examiner]
Gehrmann et al. “GLTR: Statistical Detection and Visualization of Generated Text”. arXiv:1906.04043v1 [cs.CL] Jun. 10, 2019 (Year: 2019). [cited by examiner]
Xiang et al. “Protecting Your NLG Models with Semantic and Robust Watermarks”, arXiv:2112.05428v1, Dec. 2021. [cited by applicant]
Yadollahi et al. “Robust Black-box Watermarking for Deep Neural Network using Inverse Document Frequency”, 2021 IEEE Intl Conf on DASC/PiCom/CBDCom/CyberSciTech, Mar. 2021. [cited by applicant]
Zhang et al. “Protecting Intellectual Property of Deep Neural Networks with Watermarking”, ASIACCS '18: Proceedings of the 2018 on Asia Conference on Computer and Communications Security, May 2018, pp. 159-172 https://d… [cited by applicant]
Peng et al. “Are You Copying My Model? Protecting the Copyright of Large Language Models for EaaS via Backdoor Watermark”, Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics, Jul. 20… [cited by applicant]
Li et al. “Piracy Resistant Watermarks for Deep Neural Networks”, arXiv:1910.01226v3, Dec. 2020. [cited by applicant]
Gu et al. “Watermarking Pre-trained Language Models with Backdooring” arXiv:2210.07543v2, Feb. 2023. [cited by applicant]
Cao et al. “IPGuard: Protecting Intellectual Property of Deep Neural Networks via Fingerprinting the Classification Boundary”, AsiaCCS 2021, Jun. 2021. [cited by applicant]
LeMerrer et al. “Adversarial Frontier Stitching for Remote Neural Network Watermarking”, Neural Computing and Applications, 2020, 32(13), pp. 9233-9244. [cited by applicant]
Cong et al. “SSLGuard: A Watermarking Scheme for Self-supervised Learning Pre-trained Encoders”, arXiv:2201.11692v4, Aug. 2022. [cited by applicant]
Namba et al. “Robust Watermarking of Neural Network with Exponential Weighting”, arXiv:1901.06151v1, Jan. 2019. [cited by applicant]
Guo et al. “Watermarking Deep Neural Networks fowr Embedded Systems”, Proceedings of IEEE/ACM ICCAD, Nov. 2018. [cited by applicant]
Boenisch, F. “A Systematic Review on Model Watermarking for Neural Networks”. Frontiers in Big Data 4, Dec. 2021. [cited by applicant]
Li et al. “A survey of deep neural network watermarking techniques”, arXiv:2103.09274v1, Mar. 2021. [cited by applicant]
Kirchenbauer et al. “Reliability of Watermarks for Large Language Models”, arXiv:2306.04634v3, Jun. 2023. [cited by applicant]
Kirchenbauer et al. “Watermarking Large Language Models” arXiv:2301.10226v3, Jun. 2023. [cited by applicant]
Fernandez et al. “The Stable Signature: Rooting Watermarks in Latent Diffusion Models”, arXiv:2303.15435v2, International Conference on Computer Vision, Oct. 2023. [cited by applicant]
Fernandez et al. “Watermarking Images in Self-Supervised Latent Spaces”, arXiv:2112.09581v2, Mar. 2022. [cited by applicant]
Liu et al. “Watermarking Diffusion Models”, arXiv:2305.12502v1, May 2023. [cited by applicant]
Wen et al. “Tree-Ring Watermarks: Fingerprints for Diffusion Images that are Invisible and Robust”, arXiv:2305.20030v3, Jul. 2023. [cited by applicant]
Rouhani et al. “DeepSigns: A Generic Watermarking Framework for IP Protection of Deep Learning Models”, arXiv:1804.00750v, May 2018. [cited by applicant]
Chen et al. “BlackMarks: Blackbox Multibit Watermarking for Deep Neural Networks”, arXiv:1904.00344v1, Mar. 2019. [cited by applicant]
Adi et al. “Turning Your Weakness Into a Strength: Watermarking Deep Neural Networks by Backdooring”, arXiv:1802.04633v3, Jun. 2018. [cited by applicant]
He et al. “Protecting Intellectual Property of Language Generation APIs with Lexical Watermark”, arXiv:2112.02701v1, Dec. 2021. [cited by applicant]
He et al. “CATER: Intellectual Property Protection on Text Generation APIs via Conditional Watermarks”, arXiv:2209.08773v1, Sep. 2022. [cited by applicant]
Li et al. “PLMmark: Secure and Robust Watermarking for Pre-trained Language Models”, The Thirty-Seventh AAAI Conference on Artificial Intelligence, Feb. 2023 https://doi.org/10.1609/aaai.v37i12.26750. [cited by applicant]
Vaswani et al. “Attention Is All You Need”, 31st Conference on NIPS, Dec. 2017. [cited by applicant]