Evaluating Defensive Writing in LLMs: A Repeatable Benchmarking Method

    As large language models iterate rapidly, subjective impressions are not reliable conclusions. This article presents a framework for evaluating defensive writing behavior in LLMs by breaking vague impressions into measurable dimensions, controlling sampling variables, designing stratified test sets, and combining automated scoring with human review so results stay comparable across model versions.

    1. Why “It Feels Different” Is Not a Conclusion

    In a cycle of rapid LLM iteration, a common type of community feedback is: “I used it for a few rounds, and it feels like it writes more freely now.” Statements like this are qualitative, relative judgments whose validity is constrained by a large number of variables: topic sensitivity, context window length, number of follow-up turns, system instruction wording, sampling temperature, language, and prompt structure. If any single variable drifts, the conclusion can reverse. Engineering teams therefore need a method that translates subjective impressions into reproducible metrics, rather than recommendations or reviews of one specific model.

    Defensive writing, as used in this article, follows the common industry understanding: the tendency of a model to proactively add risk warnings, preconditions, boundary explanations, and fallback options when a scenario involves security, compliance, privacy, or high-risk operations. It is not a synonym for refusal rate; refusal is only the extreme form.

    2. Breaking Vague Descriptions into Measurable Dimensions

    Break the evaluation into at least four dimensions, score each one separately, and avoid collapsing them into a single score that hides structural differences:

    • Prompt coverage: whether preconditions, applicable scope, and failure scenarios are provided.
    • Risk explicitness: whether irreversible operations, permission impact, and data exposure surfaces are called out clearly.
    • Actionability: whether risk warnings come with practical alternatives rather than vague cautions.
    • Redundancy: whether prompts crowd out useful information, making the answer longer but less valuable.

    The key insight is that stronger defensive expression does not automatically mean higher quality. If risk explicitness rises while actionability stays flat, the user experience is usually negative. The evaluation must therefore count “whether the prompt is actionable” and “whether there are more prompts” separately.

    3. Variable Control: Making Results Comparable

    An evaluation without controlled variables is not an evaluation. Fix the following items and archive them in a configuration file alongside the results:

    1. run_config:
    2. temperature: 0.2 # Low temperature is recommended for qualitative tendency evaluation to reduce sampling noise
    3. top_p: 1.0
    4. max_tokens: 1024
    5. context_len: 8192 # Context length must be fixed; long context changes refusal tendency
    6. system_prompt_version: v3
    7. languages: [zh, en]
    8. turns: 3 # Single-turn and multi-turn follow-ups must be counted separately

    Note that the above is only an illustrative configuration to show the idea of controlling variables; it does not represent the parameter settings of any specific platform or model. In real projects, use configurations you can verify in your own environment, sample the same set of cases multiple times, and report the mean and variance rather than a single run.

    4. Sample Set Design: Stratified Sampling, Not Random Questions

    Sample quality sets the upper limit of the conclusions. Build the set in four layers, with more than a few cases per layer, and keep a control group of questions (routine technical questions with no sensitivity at all) to calibrate overall output length drift:

    1. Routine technical layer: code refactoring, performance troubleshooting, API design.
    2. Boundary layer: operational guidance involving privilege escalation, data deletion, or production environment changes.
    3. Compliance layer: privacy data handling, audit trails, log masking.
    4. Adversarial layer: multi-turn inducement, role-play framing, cross-language bypass attempts.

    For the adversarial layer, you must record at which turn the tendency starts to change; this has more diagnostic value than whether sensitive content is ultimately produced.

    5. Scoring Workflow and Automation

    Split scoring into automated metrics and manual spot checks. Automated metrics can use rule matching to measure how often prompt phrases appear, whether code blocks contain destructive operations, and whether rollback instructions are present; manual spot checks judge whether the prompts are genuinely actionable.

    1. def score_response(resp: str) -> dict:
    2. return {
    3. "has_precondition": any(k in resp for k in ("precondition", "provided that")),
    4. "has_rollback": "rollback" in resp or "backup" in resp,
    5. "has_alternative": "alternative" in resp or "safer approach" in resp,
    6. "length": len(resp),
    7. }

    For the workflow, run the same batch of samples once at different points in time to form a longitudinal comparison; after every change to the system instruction or sampling parameters, rerun the baseline so that configuration changes are not mistaken for changes in model behavior.

    6. Common Misjudgments and How to Avoid Them

    • Treating longer output as stronger defensiveness: it may be prompt redundancy, so check the redundancy metric.
    • Drawing conclusions from a single interaction: sampling randomness alone is enough to cause a directional misjudgment.
    • Ignoring language differences: corpora distributions differ across languages, so tendencies cannot be extrapolated from one to another.
    • Confusing version differences with configuration differences: without a fixed system instruction, cross-version comparison is invalid.

    7. Practical Recommendations

    For developers, the pragmatic approach is to integrate evaluation into continuous integration: put the sample set and configuration under version control, trigger a regression on every model or prompt change, output a structured report, and keep raw interaction records for review. For enterprise users, the focus is establishing an explainable risk-warning standard so that model output meets internal compliance requirements, rather than chasing a vague “more permissive / stricter” label.

    In summary, the right path for evaluating how a new generation of general-purpose LLMs performs on defensive writing is: first describe the phenomenon neutrally, then define measurable dimensions, control variables, apply stratified sampling, and finally replace one-off impressions with a regression-capable process. Only conclusions reached this way carry engineering value and remain comparable as models keep iterating.