Saved in:
Bibliographic Details
Main Authors: Basu, Sagnik, Mitra, Subhrajit, Juneja, Aman, Banerjee, Somnath, Hazra, Rima, Mukherjee, Animesh
Format: Preprint
Published: 2026
Subjects:
Online Access:https://arxiv.org/abs/2603.25201
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917362857410560
author Basu, Sagnik
Mitra, Subhrajit
Juneja, Aman
Banerjee, Somnath
Hazra, Rima
Mukherjee, Animesh
author_facet Basu, Sagnik
Mitra, Subhrajit
Juneja, Aman
Banerjee, Somnath
Hazra, Rima
Mukherjee, Animesh
contents Recent research points toward LLMs being manipulated through adversarial and seemingly benign inputs, resulting in harmful, biased, or policy-violating outputs. In this paper, we study an underexplored issue concerning harmful and toxic mathematical word problems. We show that math questions, particularly those framed as natural language narratives, can serve as a subtle medium for propagating biased, unethical, or psychologically harmful content, with heightened risks in educational settings involving children. To support a systematic study of this phenomenon, we introduce ToxicGSM, a dataset of 1.9k arithmetic problems in which harmful or sensitive context is embedded while preserving mathematically well-defined reasoning tasks. Using this dataset, we audit the behaviour of existing LLMs and analyse the trade-offs between safety enforcement and mathematical correctness. We further propose SafeMath -- a safety alignment technique that reduces harmful outputs while maintaining, and in some cases improving, mathematical reasoning performance. Our results highlight the importance of disentangling linguistic harm from math reasoning and demonstrate that effective safety alignment need not come at the cost of accuracy. We release the source code and dataset at https://github.com/Swagnick99/SafeMath/tree/main.
format Preprint
id arxiv_https___arxiv_org_abs_2603_25201
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle SafeMath: Inference-time Safety improves Math Accuracy
Basu, Sagnik
Mitra, Subhrajit
Juneja, Aman
Banerjee, Somnath
Hazra, Rima
Mukherjee, Animesh
Computation and Language
Computers and Society
Recent research points toward LLMs being manipulated through adversarial and seemingly benign inputs, resulting in harmful, biased, or policy-violating outputs. In this paper, we study an underexplored issue concerning harmful and toxic mathematical word problems. We show that math questions, particularly those framed as natural language narratives, can serve as a subtle medium for propagating biased, unethical, or psychologically harmful content, with heightened risks in educational settings involving children. To support a systematic study of this phenomenon, we introduce ToxicGSM, a dataset of 1.9k arithmetic problems in which harmful or sensitive context is embedded while preserving mathematically well-defined reasoning tasks. Using this dataset, we audit the behaviour of existing LLMs and analyse the trade-offs between safety enforcement and mathematical correctness. We further propose SafeMath -- a safety alignment technique that reduces harmful outputs while maintaining, and in some cases improving, mathematical reasoning performance. Our results highlight the importance of disentangling linguistic harm from math reasoning and demonstrate that effective safety alignment need not come at the cost of accuracy. We release the source code and dataset at https://github.com/Swagnick99/SafeMath/tree/main.
title SafeMath: Inference-time Safety improves Math Accuracy
topic Computation and Language
Computers and Society
url https://arxiv.org/abs/2603.25201