How to Detect Diluted LLM APIs: The Dirty Token Fingerprinting Method

    This article explains how to detect degraded or substituted large language model (LLM) APIs using dirty token fingerprinting. It covers why API delivery quality is hard to verify, how abnormal responses to rare text fragments can serve as stable fingerprints, how to design probe sets and build baselines, the detection workflow and decision logic, and how to deploy the method in production while managing its limitations. Readers will learn a reproducible, signal-based approach to validating whether a backend model matches what is advertised.

    1. Why API Delivery Quality Is Hard to Verify

    When purchasing or integrating large model services, callers usually see only the text returned by the interface. They cannot know which specific model a request was ultimately routed to, or what precision and context length were used for a given inference. This information asymmetry creates two typical risks. First, a provider may downgrade requests to a smaller model during peak hours to save compute. Second, a reseller may swap models at the packaging layer, so the advertised capability does not match what is actually delivered.

    Most traditional verification methods stay at the level of capability sampling, such as scoring a model on a handful of math problems, coding tasks, or long-document summarization. The problem is that scores are heavily influenced by sampling randomness, prompt wording, and the subjective judgment of the evaluator. In addition, different models overlap significantly in general capability, making it hard to form a stable, reproducible criterion. As a result, the industry has gradually shifted toward a fingerprinting approach: instead of comparing which model is stronger, look for output habits that are stable and unique to a model.

    2. Core Principle: Treating Abnormal Reactions as Fingerprints

    Fingerprinting relies on two premises. First, model behavior is jointly determined by the training data distribution, alignment strategy, and default decoding parameters, giving it strong stability. Second, different vendors differ markedly in data cleaning rules and alignment strategies, causing models to exhibit reproducible, idiosyncratic reactions on a small number of specific inputs.

    Dirty tokens are fragments that almost never appear in normal business text but are widespread in pretraining corpora. Typical sources include:

    • Copyright and disclaimer text, such as editing notices on encyclopedia entries or copyright notices on stock image sites;
    • Templated placeholder statements, such as “The above content was uploaded by a user” or “This article is for reference only and does not constitute professional advice”;
    • Mixed-language strings and rare symbol combinations, such as long sequences interleaving full-width punctuation with Latin letters;
    • Highly sensitive or value-related expressions that tend to trigger differentiated handling under different alignment strategies.

    To general capability, these fragments are noise; to identity recognition, they are signal. When a model encounters them, it may refuse to answer, suddenly repeat text, drift semantically, output garbled characters, or directly complete the next templated sentence. Assembling several dirty tokens into a probe set yields a response pattern that forms a coarse-grained fingerprint.

    3. Probe Set Design and Baseline Construction

    Probe design should follow three principles: low interference, high discrimination, and reproducibility. Low interference means keeping each input to tens or hundreds of tokens to avoid introducing truncation variables from long contexts. High discrimination means each probe should differ on only one dimension. Reproducibility means fixing decoding parameters to avoid contaminating conclusions with randomness.

    It is recommended to divide probes into four groups of 20 to 50 items each:

    1. Declaration probes: copyright notices, disclaimers, editing notes;
    2. Template probes: common placeholder text from e-commerce and forums;
    3. Symbol probes: rare punctuation, mixed strings, extremely long strings without spaces;
    4. Boundary probes: extreme repetition, empty-input variants, very long digit strings.

    During baseline construction, run N samples per probe in a stable environment with a known real backend (N ≥ 5 is recommended) and record structured results: whether the model refused, first-token latency range, output length, repetition rate, and whether the expected templated continuation appeared. Aggregate these results into a probe-response mapping table to serve as a reference for later comparison.

    Illustrative pseudocode:

    1. probes = load_probes("dirty_token_set.jsonl") # each entry has id, text, group
    2. params = {"temperature": 0, "max_tokens": 128} # fixed decoding parameters
    3. def fingerprint(client, probes, n=5):
    4. table = {}
    5. for p in probes:
    6. runs = [client.chat(p.text, **params) for _ in range(n)]
    7. table[p.id] = {
    8. "refuse_rate": mean([r.refused for r in runs]),
    9. "repeat_rate": mean([r.repetition for r in runs]),
    10. "len_mean": mean([len(r.text) for r in runs]),
    11. "template_hit": any(r.template_matched for r in runs),
    12. }
    13. return table

    4. Detection Workflow and Decision Logic

    Detection proceeds in four steps. First, fix the call parameters and warm up the connection to exclude cold-start effects on latency metrics. Second, send probes in group order, avoiding consecutive probes of the same type that could cause context cross-contamination; use a separate session for each probe. Third, compare the measured fingerprint against the baseline table using similarity, with weighted voting: refusal patterns carry the highest weight, repetition and templated continuations come next, and length metrics serve only as auxiliary signals. Fourth, when reporting conclusions, provide a confidence level and the list of matched probes for review.

    The decision should emphasize combined matches rather than a single hit. One probe failing may be random fluctuation. Only when multiple probes in the same group show consistent anomalies, and the anomaly pattern closely matches a baseline, can you conclude that the backend does not match what is advertised. To improve robustness, run detection periodically, for example once per time slot across multiple times of day, and observe whether the fingerprint drifts. Drift itself is indirect evidence that the provider is dynamically adjusting routing.

    5. Production Deployment and Risk Control

    In practice, build detection as a sidecar service: receive scheduled tasks through a message queue, run the probe executor on a container platform, write results to a logging service, and configure monitoring alerts that notify procurement and operations owners when similarity falls below a threshold. All probes and baseline data should be stored encrypted as enterprise assets to prevent targeted evasion after leakage.

    Be clear about the method’s boundaries. Fingerprints become invalid when the provider upgrades its model, so baselines need version management and periodic rebuilding. Probes may be cached or rewritten, so keep a proportion of rotating probes. Detection can only prove inconsistency with a baseline; it cannot directly infer the specific technical approach. A more reliable approach combines fingerprinting with capability evaluation, latency and throughput statistics, and service-level agreements in contracts, forming a multidimensional delivery acceptance system. For most enterprises, choosing a cloud platform with mature model service governance and observability (such as the general model services and monitoring and alerting capabilities offered by Baidu AI Cloud) while retaining independent acceptance checks is a practical path to controlling dilution risk.