Why Large Language Models Are Hard to Protect Against Distillation Attacks

    This article explains why distillation attacks against large language models are structurally difficult to stop, and what engineering teams can do instead. It defines the real goal of anti-distillation protection, breaks down three unavoidable technical facts—outputs acting as supervision signals, transferable capabilities across model scales, and the protocol-level indistinguishability of normal traffic and data harvesting—and shows why circular evaluation setups fail. It then lays out a layered defense system covering output information control, semantic and statistical watermarking, call-behavior risk control, quotas and contractual boundaries, and keeping high-value capabilities in controlled environments, plus a reusable evaluation skeleton and guidance on assembling these controls from general cloud capabilities.

    1. Define the Problem First: What Are We Actually Protecting Against?

    Before asking why distillation cannot be prevented, the goal needs to be narrowed from a vague “stop people from copying us” into a measurable engineering problem. Knowledge distillation means using the input-output behavior of a stronger teacher model to train a smaller student model with lower inference cost. The technique itself is legitimate and widely used for model compression and deployment optimization. The controversy only arises when a teacher model’s outputs are collected at scale through a public API and used to train a model that directly competes with the provider. In that case, the provider’s investment can no longer be recovered through the service itself.

    So the real objective of anti-distillation is not to make outputs impossible to learn from—that does not hold up information-theoretically—but three things:

    1. Raise the collection cost per unit of useful knowledge so that large-scale copying is economically unattractive.
    2. Preserve observability and traceability for abnormal collection behavior.
    3. Retain an evidentiary boundary at the legal and contractual level.

    If the goal is defined as “outputs must be absolutely unlearnable,” every subsequent design decision becomes self-defeating: output quality drops, usability suffers, and legitimate users are driven away.

    2. The Root Cause: Three Unavoidable Technical Facts

    2.1 Outputs Are the Supervision Signal, and the API Is a Labeling Factory

    Autoregressive language model inference produces a token probability distribution conditioned on the given context. In practice, implementations usually expose only the sampled text, and in some cases a limited set of log probabilities or alternative candidates. Even when only text is returned, the teacher’s output distribution has already been approximated through extensive sampling. The soft labels needed to train a student degenerate, in the text setting, into high-quality hard labels plus broad coverage—which is exactly what a public API delivers every day.

    The key implication: as long as the API is available, the attacker obtains a high-quality corpus that grows linearly with call volume, at a marginal cost equal to one API call. This is fundamentally different from the intuition in traditional software that obfuscating code raises the bar for reverse engineering. Here, what is being delivered is the knowledge itself, not the carrier of the knowledge.

    2.2 Capabilities Transfer, and Scale Alone Is Not a Moat

    The conditions for distillation to work are loose: the student does not need to reproduce all of the teacher’s capabilities, only to approximate it on the target distribution. This creates a structural asymmetry between defender and attacker:

    • The defender must cover the long tail of all scenarios, with cost growing as the number of scenarios grows.
    • The attacker only needs to cover the narrow distribution it cares about, and sampling can be extremely skewed.

    This produces a frequently misread phenomenon: the same defense looks effective on a general benchmark yet is effectively useless under targeted collection on a specific vertical task. This is not a bug in the defense implementation. The defense objective and the attack objective were never on the same distribution to begin with.

    2.3 The Boundary Is Undecidable: Normal Calls and Collection Are Identical at the Protocol Level

    A batch of business calls and a corpus collection run can look exactly the same at the request level: the same authentication, the same paginated multi-turn pattern, the same retries. The difference exists only in intent, and intent is not written into the payload. Any rule that tries to separate the two at the content layer will also hit legitimate high-frequency business callers.

    3. Why “Shoot the Arrow First, Then Draw the Target” Evaluation Does Not Hold Up

    Many claims of “successful protection” rest on circular reasoning: fix a set of public benchmark samples, tune against that set, then report a high interception rate. Methodologically, this is equivalent to shooting the arrow first and then drawing the target. A credible evaluation needs at least:

    • Out-of-distribution testing: validate with adversarial collection traffic from a source different from the tuning set.
    • Adaptive attacks: allow the attacker to observe defense feedback and iterate on strategy.
    • Utility constraints: report the rejection rate, latency, and cost increase for legitimate traffic alongside the interception rate.

    A reusable evaluation skeleton:

    1. def evaluate_guard(guard, benign_stream, adaptive_attacker, k=5):
    2. # 1) Cost on legitimate traffic: false positives and added latency
    3. fp, latency = guard.measure_overhead(benign_stream)
    4. # 2) Effective knowledge gain under adaptive attack (lower is better)
    5. gain = adaptive_attacker.run(rounds=k, budget_tokens=10_000_000)
    6. return {"false_positive": fp, "latency_ms": latency, "attacker_gain": gain}

    Protection only counts as effective when attacker_gain rises significantly under a given budget—that is, when the attack cost has actually been raised.

    4. A Layered Defense System That Can Actually Ship

    Once we accept that complete prevention is impossible, the right architecture replaces single-point interception with defense in depth, where each layer adds a bit more cost.

    Layer 1: Controlling Information Content on the Output Side

    • Do not return full token probabilities or candidate sets by default; open them up only when there is a genuine business need, following the principle of minimum necessity.
    • Apply structural constraints to long outputs with high entropy and low information density (restrict fields, restrict length ranges) to reduce the trainable information carried per call.
    • For typical collection-style tasks such as batch summarization and batch rewriting, return results at a moderate level of abstraction, preserving business utility while lowering the value of verbatim reproduction.

    Layer 2: Semantic and Statistical Watermarking

    The goal of watermarking is not to prevent copying but to make it attributable. Common industry approaches include: applying a key-driven bias to the candidate set during sampling so that outputs statistically carry a preference detectable only by the key holder; and running distribution-consistency checks paragraph by paragraph on long text. Two engineering points matter: watermark strength trades off against text quality and needs to be tiered by scenario; and keys must be held in a key management service, with rotation and auditing leaving a trail.

    1. for each token position:
    2. candidates = top_p(top_logprobs, p=0.9)
    3. key_stream = KDF(master_key, request_id, position)
    4. chosen = sample(shift(candidates, key_stream))
    5. # Detection side: recompute key_stream with master_key only, then run a hypothesis test

    Layer 3: Call-Behavior Risk Control

    Build per-caller profiles at the gateway: token throughput per unit time, input length distribution, request diversity entropy, repetition rate, time-of-day patterns, and failure/retry patterns. Collection traffic typically shows high throughput, a highly concentrated input distribution, and complete retention of outputs. Risk-control actions should be graded: first slow down and queue, then require secondary verification, and only then throttle or terminate, avoiding a one-size-fits-all cut that causes business disruption.

    Layer 4: Quotas, Tiering, and Commercial Boundaries

    Make free tiers, pay-as-you-go, and reserved throughput explicit tiers, and automatically trigger a quota review on abnormal growth. At the same time, state clearly in the terms of service that outputs may not be used to train a competing model, and retain logs for evidentiary purposes. Technical measures raise cost; contractual terms provide a path to remedy. Neither is sufficient alone.

    Layer 5: Keep High-Value Capabilities in a Controlled Environment

    For capabilities that genuinely cannot be allowed to leak, change the delivery model rather than tightening interception: private or dedicated instance deployment, proprietary environments where data does not leave its domain, and retrieval-augmented interfaces that return only results without passing back source text. This is the only path that turns attack cost from linear growth into exponential growth.

    5. Assembling General Capabilities on the Cloud

    The system above does not require proprietary products; it can be assembled from general cloud product categories. Gateways and load balancers handle throttling and canary rollout; message queues smooth peaks and buffer burst collection traffic; container platforms host risk-control and detection services with elasticity; object storage retains audit samples; logging services and monitoring/alerting provide dashboards and threshold triggers; and a key management service holds watermark keys. The capabilities Baidu AI Cloud offers in these general categories can serve as the foundation for building such an observable and governable pipeline; refer to the official documentation for specific specifications and pricing.

    6. Conclusion: Change the Goal from “Block It” to “Do the Math”

    The reason distillation cannot be prevented is structural: what is delivered is knowledge, the API is a labeling factory, the attack distribution can be narrowed arbitrarily, and normal and abnormal traffic are identical at the protocol level. The rational engineering conclusion is to abandon the fantasy of absolute interception and instead do three things—raise the collection cost per unit of knowledge, guarantee end-to-end observability and attributability, and hold the boundary of high-value capabilities through deployment models and contracts. Evaluation must be based on adaptive attacks and out-of-distribution samples to avoid circular reasoning. Do this, and protection stops being a binary argument about whether it can be blocked and becomes a cost problem that can be continuously optimized.