SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2510.24012 · NeurIPS · 2025

Training-Free Safe Text Embedding Guidance for Text-to-Image Diffusion Models

Kaist, Jin-Hwa Kim, Byeonghu Na, Il-Chul Moon, Minsang Park, Gayoung Lee, Mina Kang, Jiseok Kwak, Jiwoo Shin, Sejoon Jun

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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 0 have no contract verdict; 5 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2510.24012.json · badge: /api/ran/2510.24012.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
aailab-kaist/STG canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
calculate_frechet_distance Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
aailab-kaist/STG/evaluation/fid.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from shpda/text-to-image-gen-model-acgan, is pointer only (licence: NONE) · get_code("4cee7c1861294d59")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from shpda/text-to-image-gen-model-acgan, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

contains_nudity Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
aailab-kaist/STG/evaluation/nudity_detector.py
code served (permissive licence) · get_code("03b3f3f10ba15af8")
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 bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# Construct detections: list of dicts with 'class' and 'score' keys
detections = [
    {'class': 0, 'score': 0.95},
    {'class': 1, 'score': 0.45},
    {'class': 2, 'score': 0.87},
]

# Construct labels: list/set of class indices to check for nudity
labels = [0, 2]

# Construct threshold: float value for score comparison
threshold = 0.5

ARGS = {
    'detections': detections,
    'labels': labels,
    'threshold': threshold,
}
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 bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
normalized Ran
ran; our contract draft was wrong, not the code
aailab-kaist/STG/evaluation/eval_clip_score.py
code served (permissive licence) · get_code("a61a872ce7ab9d47")
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 ndarray, ndim 2, dtype family float, shape (3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 numpy as np

# The function normalizes an array along a specified axis using L2 norm (or other order)
# Parameters:
# - a: array-like, the input array to normalize
# - axis: int, the axis along which to compute the norm (default -1)
# - order: int, the order of the norm (default 2 for L2)

# Create a small test array with distinct dimensions
a = np.array([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0],
    [3.0, 4.0, 0.0, 0.0]
])

ARGS = {
    'a': a,
    'axis': -1,
    'order': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (3, 4) — shape (3, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
rescale_noise_cfg Ran
ran; our contract draft was wrong, not the code
aailab-kaist/STG/pipelines/pipeline_stable_diffusion_stg.py
code served (permissive licence) · get_code("9855e54881af9165")
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) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 3, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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

torch.manual_seed(0)

# Create small tensors for noise predictions
# Shape: (batch_size=2, channels=4, height=3, width=3) - 4D tensor
noise_cfg = torch.randn(2, 4, 3, 3)
noise_pred_text = torch.randn(2, 4, 3, 3)

# guidance_rescale parameter
guidance_rescale = 0.7

ARGS = {
    "noise_cfg": noise_cfg,
    "noise_pred_text": noise_pred_text,
    "guidance_rescale": guidance_rescale,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 4, 3, 3) — shape (2, 4, 3, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
retrieve_timesteps Ran
ran; our contract draft was wrong, not the code
aailab-kaist/STG/pipelines/pipeline_stable_diffusion_stg.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from krafton-ai/Rare-to-Frequent, is pointer only (licence: NONE) · get_code("0b56680ee1708fee")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from krafton-ai/Rare-to-Frequent, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

calculate_activation_statistics Not yet run
unverified (harvested, no recorded run)
aailab-kaist/STG/evaluation/fid.py
code served (permissive licence) · get_code("1219a4fa399a055f")
How it ran

no invocation recorded.

get_activations Not yet run
unverified (harvested, no recorded run)
aailab-kaist/STG/evaluation/fid.py
code served (permissive licence) · get_code("dad85083840f8ed0")
How it ran

no invocation recorded.

Also present in other papers' code

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

FunctionAlso present inEarliest-datedOthers named
calculate_frechet_distance 74 other papers
69 dated earlier, 4 later, 1 same year, order not determinable
1610.09585 (2016-10)
Conditional Image Synthesis With Auxiliary Classifier GANs
1706.08500 (2017-06)
GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium
1807.11458 (2018-07)
To learn image super-resolution, use a GAN to learn how to do image degradation first
and 71 more not named here
rescale_noise_cfg 62 other papers
57 dated earlier, 2 the same month, 2 later, 1 same year, order not determinable
2206.02779 (2022-06)
Blended Latent Diffusion
2304.06720 (2023-04)
Expressive Text-to-Image Generation with Rich Text
2309.06380 (2023-09)
InstaFlow: One Step is Enough for High-Quality Diffusion-Based Text-to-Image Generation
and 59 more not named here
retrieve_timesteps 46 other papers
33 dated earlier, 2 the same month, 8 later, 1 same year, order not determinable, 2 undated
2312.04461 (2023-12)
PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding
2402.10491 (2024-02)
Make a Cheap Scaling: A Self-Cascade Diffusion Model for Higher-Resolution Adaptation
2405.18991 (2024-05)
EasyAnimate: High-Performance Video Generation Framework with Hybrid Windows Attention and Reward Backpropagation
and 43 more not named here
calculate_activation_statistics 10 other papers
8 dated earlier, 1 later, 1 same year, order not determinable
Chou_How_to_Backdoor_Diffusion_Models_CVPR_2023_paper (2023 (year only))
How to Backdoor Diffusion Models?
2305.08192 (2023-05)
Diffusion Models for Imperceptible and Transferable Adversarial Attack
2306.06874 (2023-06)
VillanDiffusion: A Unified Backdoor Attack Framework for Diffusion Models
and 7 more not named here
normalized 4 other papers
3 dated earlier, 1 the same month
2311.12908 (2023-11)
Diffusion Model Alignment Using Direct Preference Optimization
2410.05255 (2024-10)
Bridging SFT and DPO for Diffusion Model Alignment with Self-Sampling Preference Optimization
2503.23715 (2025-03)
HOIGen-1M: A Large-scale Dataset for Human-Object Interaction Video Generation
and 1 more not named here

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-23.

Repositories linked to this paper

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

Abstract

Text-to-image models have recently made significant advances in generating realistic and semantically coherent images, driven by advanced diffusion models and large-scale web-crawled datasets. However, these datasets often contain inappropriate or biased content, raising concerns about the generation of harmful outputs when provided with malicious text prompts. We propose Safe Text embedding Guidance (STG), a training-free approach to improve the safety of diffusion models by guiding the text embeddings during sampling. STG adjusts the text embeddings based on a safety function evaluated on the expected final denoised image, allowing the model to generate safer outputs without additional training. Theoretically, we show that STG aligns the underlying model distribution with safety constraints, thereby achieving safer outputs while minimally affecting generation quality. Experiments on various safety scenarios, including nudity, violence, and artist-style removal, show that STG consistently outperforms both training-based and training-free baselines in removing unsafe content while preserving the core semantic intent of input prompts. Our code is available at https://github.com/aailab-kaist/STG. Warning: This paper contains model-generated content that may be disturbing. Recent advances in text-to-image models have received considerable attention for their ability to generate realistic images that semantically align with given text prompts [30,32,34,44]. These advances have largely been driven by the development of diffusion models [9,33] and the availability of large-scale datasets collected through web crawling [5,37]. However, this approach to data collection often includes inappropriate or biased content, raising the risk that text-to-image models may generate images containing unsafe concepts, such as sexual content, violence, bias, or copyright infringement [3,4]. Additionally, the concept of safe can be defined in commercial settings, e.g., avoiding any intellectual property violations embodied by a certain style. Moreover, what is considered safe can vary widely depending on individual sensitivities, cultural contexts, and social norms, making it challenging to define a universally safe model [27,42]. This highlights the need for safe generation methods that can adapt to diverse perspectives and account for individual perceptions. To address these challenges, several safe generation methods for diffusion models have been proposed in recent years. Concept unlearning approaches fine-tune the weights of the diffusion model to forget the unsafe content [13,22,25,28,49]. While this can be an effective way to remove unsafe concepts, it also presents a challenge in maintaining the original generative capabilities of the model. In addition, these methods require carefully curated safety-annotated text-image datasets for training, along with significant computational resources, which can limit their adaptability to diverse perspectives. 39th Conference on Neural Information Processing Systems (NeurIPS 2025).

For agents

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

get_harvested_code_for_paper("2510.24012")
get_code_for_paper("2510.24012")
have("2510.24012")

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

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

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

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

Connect an agent — have() is free.