SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.03312 · 2022

Distillation-Resistant Watermarking for Model Protection in NLP

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2210.03312.json · badge: /api/ran/2210.03312.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
xuandongzhao/drw canonical (classifier label)
classifier basis not recorded on the link
4 ran · 2 no recorded run
FunctionStatusWhere it lives
JSD Ran
ran on a synthesized input
xuandongzhao/drw/utils.py
code served (permissive licence) · get_code("863171c2a28d250a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float32, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np
import scipy.stats

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self, input_dim=5, output_dim=4):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def predict(self, x):
        """Returns softmax probabilities over classes"""
        with torch.no_grad():
            logits = self.linear(x)
            probs = torch.softmax(logits, dim=1)
        return probs.numpy()

# Create two distinct models
model1 = SimpleModel(input_dim=5, output_dim=4)
model2 = SimpleModel(input_dim=5, output_dim=4)

# Create adversarial examples - batch of 2 samples with 5 features each
advx = torch.randn(2, 5)

ARGS = {
    'model1': model1,
    'model2': model2,
    'advx': advx
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float32, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
epoch_time Ran
ran, honoured the contract we drafted
xuandongzhao/drw/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from takashiishida/flooding, is pointer only (licence: GPL-3.0) · get_code("3e21e6589663b136")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from takashiishida/flooding, and GPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

train_student_hard Ran
ran on a synthesized input
xuandongzhao/drw/wm.py
code served (permissive licence) · get_code("9394c6933ed2ef9e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)
np.random.seed(0)

# Small student model
class StudentModel(nn.Module):
    def __init__(self, input_dim=768, num_classes=2):
        super().__init__()
        self.linear = nn.Linear(input_dim, num_classes)
    
    def forward(self, input_ids, attention_mask=None):
        # Simple forward: just apply linear layer
        if attention_mask is not None:
            return self.linear(torch.randn(input_ids.shape[0], 768))
        else:
            return self.linear(torch.randn(input_ids.shape[0], 768))

# Small teacher model
class TeacherModel(nn.Module):
    def __init__(self, input_dim=768, num_classes=2):
        super().__init__()
        self.linear = nn.Linear(input_dim, num_classes)
    
    def forward(self, input_ids, attention_mask=None):
        if attention_mask is not None:
            return self.linear(torch.randn(input_ids.shape[0], 768))
        else:
            return self.linear(torch.randn(input_ids.shape[0], 768))

# Create models
student_model = StudentModel(input_dim=768, num_classes=3)
teacher_model = TeacherModel(input_dim=768, num_classes=3)

# Create a simple data iterator for GLUE task
def create_glue_batch():
    batch = {
        'ids': torch.randint(0, 100, (2, 10)),  # batch_size=2, seq_len=10
        'atts': torch.ones(2, 10, dtype=torch.long),
        'labels': torch.tensor([0, 1], dtype=torch.long)
    }
    return batch

iterator = [create_glue_batch() for _ in range(2)]

# Optimizer
optimizer = torch.optim.Adam(student_model.parameters(), lr=0.001)

# Scheduler
scheduler = None

# Loss criterion
criterion = nn.CrossEntropyLoss()

# Task
task = 'cola'

# Number of classes
num_class = 3

# Device
device = 'cpu'

ARGS = {
    'student_model': student_model,
    'teacher_model': teacher_model,
    'iterator': iterator,
    'optimizer': optimizer,
    'scheduler': scheduler,
    'criterion': criterion,
    'task': task,
    'num_class': num_class,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
train_teacher Ran
ran on a synthesized input
xuandongzhao/drw/wm.py
code served (permissive licence) · get_code("a2cd590d607e0720")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.optim import Adam
from torch.optim.lr_scheduler import StepLR

torch.manual_seed(0)

# Define a simple model that accepts input_ids and attention_mask
class SimpleTeacherModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4, num_classes=3):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.linear = nn.Linear(hidden_dim, num_classes)
    
    def forward(self, input_ids, attention_mask=None):
        # For GLUE and IMDB tasks
        embedded = self.embedding(input_ids)
        pooled = embedded.mean(dim=1)
        logits = self.linear(pooled)
        return logits

# Alternative model for sequence tagging (POS, NER)
class SequenceTaggingModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4, num_classes=5):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.linear = nn.Linear(hidden_dim, num_classes)
    
    def forward(self, input_ids):
        # For POS and NER tasks
        embedded = self.embedding(input_ids)
        logits = self.linear(embedded)
        return logits

# Create model for GLUE task
model = SimpleTeacherModel(vocab_size=100, hidden_dim=4, num_classes=3)

# Create optimizer
optimizer = Adam(model.parameters(), lr=0.001)

# Create scheduler
scheduler = StepLR(optimizer, step_size=1, gamma=0.9)

# Create criterion
criterion = nn.CrossEntropyLoss()

# Create iterator with sample batches
def create_iterator(task, batch_size=2):
    batches = []
    for _ in range(3):
        if task == 'imdb':
            batch = {
                'ids': {
                    'input_ids': torch.randint(0, 100, (batch_size, 1, 8)),
                    'attention_mask': torch.ones(batch_size, 8)
                },
                'labels': torch.randint(0, 3, (batch_size,))
            }
        elif task in ['pos', 'ner']:
            batch = {
                'ids': torch.randint(0, 100, (batch_size, 8)),
                'labels': torch.randint(0, 5, (batch_size, 8))
            }
        else:  # GLUE tasks
            batch = {
                'ids': torch.randint(0, 100, (batch_size, 1, 8)),
                'atts': torch.ones(batch_size, 8),
                'labels': torch.randint(0, 3, (batch_size,))
            }
        batches.append(batch)
    return batches

# Create iterator for a GLUE task
iterator = create_iterator('sst2', batch_size=2)

# Device
device = 'cpu'

# Task
task = 'sst2'

ARGS = {
    'model': model,
    'iterator': iterator,
    'optimizer': optimizer,
    'scheduler': scheduler,
    'criterion': criterion,
    'task': task,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Rob Not yet run
unverified (harvested, no recorded run)
xuandongzhao/drw/utils.py
code served (permissive licence) · get_code("c8061a6a13cb393e")
How it ran

no invocation recorded.

train_student_soft Not yet run
unverified (harvested, no recorded run)
xuandongzhao/drw/wm.py
code served (permissive licence) · get_code("bbb12a31375fd0c1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
epoch_time 10 other papers
5 dated earlier, 5 later
1608.07017 (2016-08)
Ambient Sound Provides Supervision for Visual Learning
1911.05343 (2019-11)
A Stable Variational Autoencoder for Text Modelling
2002.08709 (2020-02)
Do We Need Zero Training Loss After Achieving Zero Training Error?
and 7 more not named here
Rob 1 other paper
1 dated earlier
2112.05588 (2021-12)
Copy, Right? A Testing Framework for Copyright Protection of Deep Learning Models

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

How can we protect the intellectual property of trained NLP models? Modern NLP models are prone to stealing by querying and distilling from their publicly exposed APIs. However, existing protection methods such as watermarking only work for images but are not applicable to text. We propose Distillation-Resistant Watermarking (DRW), a novel technique to protect NLP models from being stolen via distillation. DRW protects a model by injecting watermarks into the victim's prediction probability corresponding to a secret key and is able to detect such a key by probing a suspect model. We prove that a protected model still retains the original accuracy within a certain bound. We evaluate DRW on a diverse set of NLP tasks including text classification, part-of-speech tagging, and named entity recognition. Experiments show that DRW protects the original model and detects stealing suspects at 100% mean average precision for all four tasks while the prior method fails on two.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2210.03312")
get_code_for_paper("2210.03312")
have("2210.03312")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2210.03312.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2210.03312.svg)](https://syntology.ai/paper/2210.03312)

Connect an agent — have() is free.