SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.01524 · ICLR · 2025

HarmAug: Effective Data Augmentation for Knowledge Distillation of Safety Guard Models

Yoshua Bengio, Sung Hwang, Dong Lee, Juho Lee, Seanie Lee, Minki Kang, Haebin Seong, Xiaoyin Chen, Dominik Wagner

arXiv · PDF · Open in the Atlas

Code that ran

1 of 1 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 0 failures of our instrument; 0 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/2410.01524.json · badge: /api/ran/2410.01524.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
imnotkind/HarmAug marked official in Papers with Code
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
KDDataset Ran
ran on a synthesized input · constructed an object; no result was computed
imnotkind/HarmAug/src/dataset.py
code served (permissive licence) · get_code("c0534c5cb44e5aff")
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 an instance of its own class, KDDataset: the run constructed the object and did not call it, so no result was computed. 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 json
import random
import tempfile
import os
from torch.utils.data import DataLoader, Dataset, Subset, WeightedRandomSampler

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.padding_side = 'left'
    
    def apply_chat_template(self, messages, tokenize=False):
        # Simple concatenation of messages
        result = " ".join([msg['content'] for msg in messages])
        return result

# Create a temporary JSON file with test data
def create_test_json_file():
    data = [
        {"placeholder": "header"},  # This will be skipped by [1:]
        {
            "prompt": "What is AI?",
            "response": "AI is artificial intelligence.",
            "unsafe-score": 0.2
        },
        {
            "prompt": "How to be safe?",
            "response": "Follow guidelines.",
            "unsafe-score": 0.8
        },
        {
            "prompt": "Tell me something.",
            "unsafe-score": 0.3
        },
        {
            "prompt": "Another question?",
            "response": "Here's an answer.",
            "unsafe-score": 0.9
        },
        {
            "prompt": "Simple prompt",
            "response": "Simple response.",
            "unsafe-score": 0.1
        },
        {
            "prompt": "Unsafe prompt",
            "unsafe-score": 0.7
        },
        {
            "prompt": "Safe prompt",
            "response": "Safe response.",
            "unsafe-score": 0.4
        },
        {
            "prompt": "Question?",
            "response": "Answer.",
            "unsafe-score": 0.6
        },
        {
            "prompt": "Last one",
            "response": "Final answer.",
            "unsafe-score": 0.15
        },
        {
            "prompt": "Risky",
            "response": "Careful.",
            "unsafe-score": 0.95
        }
    ]
    
    # Create temp file
    temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json')
    json.dump(data, temp_file)
    temp_file.close()
    return temp_file.name

json_file_path = create_test_json_file()

ARGS = {
    'tokenizer': MinimalTokenizer(),
    'json_file': json_file_path,
    'split': 'train'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type KDDataset — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a KDDataset output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not 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

Also present in other papers' code

Of 1 samples lifted from this paper's linked repositories, 1 carry a function identity and 0 do not. Of the 1 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 1 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.

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

Safety guard models that detect malicious queries aimed at large language models (LLMs) are essential for ensuring the secure and responsible deployment of LLMs in real-world applications. However, deploying existing safety guard models with billions of parameters alongside LLMs on mobile devices is impractical due to substantial memory requirements and latency. To reduce this cost, we distill a large teacher safety guard model into a smaller one using a labeled dataset of instruction-response pairs with binary harmfulness labels. Due to the limited diversity of harmful instructions in the existing labeled dataset, naively distilled models tend to underperform compared to larger models. To bridge the gap between small and large models, we propose HarmAug, a simple yet effective data augmentation method that involves jailbreaking an LLM and prompting it to generate harmful instructions. Given a prompt such as, "Make a single harmful instruction prompt that would elicit offensive content", we add an affirmative prefix (e.g., "I have an idea for a prompt:") to the LLM's response. This encourages the LLM to continue generating the rest of the response, leading to sampling harmful instructions. Another LLM generates a response to the harmful instruction, and the teacher model labels the instruction-response pair. We empirically show that our HarmAug outperforms other relevant baselines. Moreover, a 435-millionparameter safety guard model trained with HarmAug achieves an F1 score comparable to larger models with over 7 billion parameters, and even outperforms them in AUPRC, while operating at less than 25% of their computational cost. Our code, safety guard model, and synthetic dataset are publicly available.

For agents

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

get_harvested_code_for_paper("2410.01524")
get_code_for_paper("2410.01524")
have("2410.01524")

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

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

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

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

Connect an agent — have() is free.