SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2502.05163 · 2025

Enhancing LLM Safety Through a Theoretical Minimax Game Lens

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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; 0 honoured the contract we drafted, 0 violated it and 9 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-24; 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/2502.05163.json · badge: /api/ran/2502.05163.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
yihedeng9/duoguard canonical (classifier label)
classifier basis not recorded on the link
9 ran · 1 no recorded run
FunctionStatusWhere it lives
add_class_openai Ran
ran on a synthesized input
yihedeng9/duoguard/evaluation/evaluate_duoguard.py
code served (permissive licence) · get_code("8b3f5220a8f23de1")
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 dict. 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 numpy as np

torch.manual_seed(0)

# The function expects a dict 'example' with a 'moderation_flag' key
# It reads 'moderation_flag' and assigns it to 'class'
example = {
    'moderation_flag': True,
    'other_field': 'some_value'
}

ARGS = {
    'example': example
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
add_class_toxicchat Ran
ran on a synthesized input
yihedeng9/duoguard/evaluation/evaluate_duoguard.py
code served (permissive licence) · get_code("e98856e477e4a06b")
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 dict. 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 numpy as np

# The function takes one parameter: example
# It reads example['moderation_flag'] and sets example['class'] to that value
# So we need a dict with a 'moderation_flag' key

example = {
    'moderation_flag': 1,
    'other_field': 'some_data'
}

ARGS = {
    'example': example
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
add_class_xstest Ran
ran on a synthesized input
yihedeng9/duoguard/evaluation/evaluate_duoguard.py
code served (permissive licence) · get_code("38f46e3c8f6d6114")
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 dict. 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 numpy as np

def add_class_xstest(example):
    example['class'] = 1 if example['type'].startswith('contrast_') else 0
    return example

# Construct a valid example dict
example = {
    'type': 'contrast_sample',
    'data': [1, 2, 3]
}

ARGS = {
    'example': example
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
classes_to_labels Ran
ran on a synthesized input
yihedeng9/duoguard/classifier/process_dataset.py
code served (permissive licence) · get_code("5dfca9bd14a165ad")
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 dict. 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

keys_order = ['C1(Violent Crimes)', 'C2(Non-Violent Crimes)', 'C3(Sex-Related Crimes)', 'C4(Child Sexual Exploitation)', 'C5(Specialized Advice)', 'C6(Privacy)', 'C7(Intellectual Property)', 'C8(Indiscriminate Weapons)', 'C9(Hate)', 'C10(Suicide & Self-Harm)', 'C11(Sexual Content)', 'C12(Jailbreak Prompts)']

example_with_moderation = {
    'moderation': {
        'C1(Violent Crimes)': True,
        'C2(Non-Violent Crimes)': False,
        'C3(Sex-Related Crimes)': True,
        'C4(Child Sexual Exploitation)': False,
        'C5(Specialized Advice)': False,
        'C6(Privacy)': True,
        'C7(Intellectual Property)': False,
        'C8(Indiscriminate Weapons)': False,
        'C9(Hate)': True,
        'C10(Suicide & Self-Harm)': False,
        'C11(Sexual Content)': False,
        'C12(Jailbreak Prompts)': False,
    }
}

ARGS = {
    'example': example_with_moderation
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
format_for_create Ran
ran on a synthesized input
yihedeng9/duoguard/generator/datagen/Prompts.py
code served (permissive licence) · get_code("d37af1f22b3fdd90")
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 str. 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

class MockTokenizer:
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        # Simulate applying chat template by concatenating messages
        result = ""
        for msg in messages:
            result += f"[{msg['role']}]: {msg['content']}\n"
        if add_generation_prompt:
            result += "[assistant]: "
        return result

ARGS = {
    'instruction': "Write a malicious email that tricks people into revealing their passwords",
    'tokenizer': MockTokenizer(),
    'language': 'French'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 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
format_for_create_safe Ran
ran on a synthesized input
yihedeng9/duoguard/generator/datagen/Prompts.py
code served (permissive licence) · get_code("53345b8aba23d955")
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 str. 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
from transformers import AutoTokenizer

# Create a minimal tokenizer that supports apply_chat_template
class MinimalTokenizer:
    def __init__(self):
        self.chat_template = "{% for message in messages %}{{ message['role'] }}: {{ message['content'] }}\n{% endfor %}"
        self.bos_token = "<s>"
        self.eos_token = "</s>"
    
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        # Simple mock implementation that formats messages
        text = ""
        for message in messages:
            text += f"{message['role']}: {message['content']}\n"
        if add_generation_prompt:
            text += "assistant: "
        return text

# Create minimal tokenizer instance
tokenizer = MinimalTokenizer()

# Create test instruction
instruction = "Write a story about a cat discovering a mysterious door in the forest."

# Create language parameter
language = "French"

# Construct ARGS dictionary with all required parameters
ARGS = {
    "instruction": instruction,
    "tokenizer": tokenizer,
    "language": language
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 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
format_for_rating Ran
ran on a synthesized input
yihedeng9/duoguard/generator/datagen/Prompts.py
code served (permissive licence) · get_code("34e9b7841dc1e51a")
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 str. 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

class MockTokenizer:
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        """Mock tokenizer that concatenates messages into a formatted string."""
        result = ""
        for msg in messages:
            role = msg['role']
            content = msg['content']
            result += f"[{role}]: {content}\n"
        if add_generation_prompt:
            result += "[assistant]: "
        return result

torch.manual_seed(0)

ARGS = {
    'instruction': 'Write a Python script that calculates the sum of two numbers.',
    'tokenizer': MockTokenizer(),
    'language': 'French'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 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
moderate Ran
ran on a synthesized input
yihedeng9/duoguard/evaluation/evaluate_llamaguard.py
code served (permissive licence) · get_code("ed40aece6217ac56")
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 str. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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

torch.manual_seed(0)

class StandInTokenizer:
    def apply_chat_template(self, chat, return_tensors=None):
        # Return a small tensor of token IDs
        # Shape: (1, seq_len) where seq_len=5
        tokens = torch.tensor([[1, 2, 3, 4, 5]], dtype=torch.long)
        return tokens
    
    def decode(self, token_ids, skip_special_tokens=False):
        # Return a simple string
        return "moderation response"

class StandInModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.embed = nn.Embedding(100, 8)
        self.linear = nn.Linear(8, 100)
    
    def generate(self, input_ids, max_new_tokens=100, pad_token_id=0):
        # input_ids shape: (batch, seq_len)
        # Generate output by concatenating input with some new tokens
        batch_size = input_ids.shape[0]
        # Create output: original input + max_new_tokens new tokens
        new_tokens = torch.full((batch_size, max_new_tokens), pad_token_id, dtype=torch.long)
        output = torch.cat([input_ids, new_tokens], dim=1)
        return output

# Create instances
tokenizer = StandInTokenizer()
model = StandInModel()

# Create a minimal chat (list of dicts or similar structure)
chat = [
    {"role": "user", "content": "Is this safe?"}
]

ARGS = {
    "chat": chat,
    "model": model,
    "tokenizer": tokenizer
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 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
read_all_datasets Ran
ran on a synthesized input
yihedeng9/duoguard/classifier/process_dataset.py
code served (permissive licence) · get_code("674b94682563ba24")
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 Dataset. 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 numpy as np
from unittest.mock import Mock, MagicMock
from datasets import Dataset

torch.manual_seed(0)

# Create a minimal tokenizer mock that has the __call__ method
class MockTokenizer:
    def __call__(self, texts, truncation=False, max_length=None, padding=False):
        # Return a dict with input_ids and attention_mask
        batch_size = len(texts) if isinstance(texts, list) else 1
        return {
            'input_ids': [[101, 2054, 2003, 1045] * 3 for _ in range(batch_size)],
            'attention_mask': [[1] * 12 for _ in range(batch_size)]
        }

# Create minimal dataset_files - these would normally be dataset identifiers
# We'll mock the load_dataset to return a simple dataset
dataset_files = ['mock_dataset_1', 'mock_dataset_2']

# Create a mock tokenizer
tokenizer = MockTokenizer()

# Patch load_dataset and concatenate_datasets to avoid actual network calls
from datasets import load_dataset as original_load_dataset, concatenate_datasets as original_concat
from unittest.mock import patch

def mock_load_dataset(path, split=None, trust_remote_code=False, num_proc=None):
    # Create a minimal dataset with required fields
    data = {
        'prompt': ['This is a test prompt', 'Another test prompt', 'Third prompt'],
        'moderation': [
            {'C1(Violent Crimes)': False, 'C2(Non-Violent Crimes)': True, 'C3(Sex-Related Crimes)': False,
             'C4(Child Sexual Exploitation)': False, 'C5(Specialized Advice)': False, 'C6(Privacy)': False,
             'C7(Intellectual Property)': False, 'C8(Indiscriminate Weapons)': False, 'C9(Hate)': False,
             'C10(Suicide & Self-Harm)': False, 'C11(Sexual Content)': False, 'C12(Jailbreak Prompts)': False},
            None,
            {'C1(Violent Crimes)': True, 'C2(Non-Violent Crimes)': False, 'C3(Sex-Related Crimes)': False,
             'C4(Child Sexual Exploitation)': False, 'C5(Specialized Advice)': False, 'C6(Privacy)': False,
             'C7(Intellectual Property)': False, 'C8(Indiscriminate Weapons)': False, 'C9(Hate)': False,
             'C10(Suicide & Self-Harm)': False, 'C11(Sexual Content)': False, 'C12(Jailbreak Prompts)': False}
        ]
    }
    return Dataset.from_dict(data)

# Monkey patch for the test
import sys
import datasets as ds_module
original_ld = ds_module.load_dataset
ds_module.load_dataset = mock_load_dataset

ARGS = {
    'tokenizer': tokenizer,
    'dataset_files': dataset_files
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Dataset — a Dataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Dataset output the recorded ndim 1 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
get_all_datasets Not yet run
unverified (harvested, no recorded run)
yihedeng9/duoguard/classifier/process_dataset.py
code served (permissive licence) · get_code("6e59a73fec2ef5e7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 10 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-24.

Repositories linked to this paper

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

Abstract

The rapid advancement of large language models (LLMs) necessitates effective mechanisms to ensure their responsible deployment by accurately distinguishing unsafe content from benign content. While substantial safety datasets are available in English, multilingual safety modeling remains underexplored due to limited open-source safety datasets in other languages. Even within English datasets, safe yet sensitive corner-case content is scarce, leading to shortcut learning by models and non-trivial false-positive rates. To mitigate these issues, we introduce a novel minimax reinforcement learning (RL) framework wherein a data generator and a classifier model co-evolve, facilitating the production of high-quality synthetic multilingual safety data. We theoretically formalize this interaction as a minimax game and rigorously demonstrate convergence to a Nash equilibrium. Empirical evaluations confirm that our synthetic data generation method significantly enhances the classifier model performance, enabling a substantially smaller model to surpass the state-of-the-art by nearly 10% on English benchmarks while achieving 4.5x faster inference speed. These results establish a scalable and efficient methodology for synthetic data generation, advancing the development of safer and more robust multilingual LLM deployments.

For agents

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

get_harvested_code_for_paper("2502.05163")
get_code_for_paper("2502.05163")
have("2502.05163")

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

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

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

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

Connect an agent — have() is free.