Skip to content

Author

Ahmed E. Hassan

2 papers indexed here

We haven’t gathered this author’s papers yet. Follow them and we’ll fetch their work.

Not the right person? Other researchers publish under this name.

Book Open access Jul 2026

LLMSafeGuard: A Training-Free Framework for Safeguarding LLM Decoding via Context-Wise Similarity Validation

Large Language Models (LLMs) have significantly advanced natural language processing (NLP) tasks, but also pose ethical and societal risks due to their propensity to generate harmful content. Existing methods have limitations, including the need for training specific control models and proactive intervention during text generation, which leads to quality degradation and increased computational overhead. To mitigate those limitations, we propose LLMSafeGuard, a lightweight real-time framework that integrates an external validator into decoding, rejecting unsafe outputs while allowing valid ones. We introduce a similarity-based validation approach, simplifying safety constraint validation and eliminating the need for external control model training. Additionally, LLMSafeGuard employs a context-wise timing selection strategy, which allows LLMSafeGuard to intervene in LLMs only when necessary. We evaluate LLMSafeGuard on three tasks: detoxification, copyright safeguarding, and jailbreak attack defending across six models, and the results demonstrate its superiority over SOTA baselines on all tasks. For instance, in detoxification, LLMSafeGuard reduces toxic output by at least 38.6% while preserving linguistic quality. For Jailbreak attack defending, LLMSafeGuard reduces the harmful score of the response LLMs under jailbreak attack at least by 11.4% compared to the best baseline. Additionally, its context-wise timing selection achieves a speedup of 1.7X over per-step validation, without compromising effectiveness.

Ximing Dong, Shaowei Wang, Dayi Lin et al. · 0 citations
Preprint Jul 2026

To Add Is Machine, To Delete Is Human: Measuring and Mitigating Deletion Avoidance in LLM Code Editing

Large language models increasingly write and repair production code, yet evidence is mounting that their test-passing patches leave codebases harder to maintain. We identify one concrete source: deletion avoidance, the systematic tendency to retain code that an intended edit requires removing. Across the five leading models on the official SWE-bench Verified leaderboard, deletion recall against the developer patch reaches at most 71.7% even on tasks all five solve, and models reach the right file for over 92% of required deletions but cut the exact line in under 52% of cases. Instead, 29.0% of passing patches wrap the targeted code in a guard or fallback, a pattern we call Guard-and-Go. Such patches pass because the original tests rarely check removal: when we retrofit 34 Verified tasks with tests that fail if the targeted code remains, four frontier models spanning closed and open weights fall from 63.2% to 41.9%. Because real repairs mix removal with addition, we curate CanItDelete, a benchmark of 200 tasks mined from real commits whose entire required edit is deletion. Even with the addition work gone, the best model still fails one task in five, and smaller open models fall to 18.0%. We then ablate GPT-5.6 Sol under four cumulative prompts; success moves little until we supply the exact lines, which nearly eliminate incomplete deletion yet raise success only to 80.5% because the model then deletes beyond the spans or adds code instead. Finally, through a pilot study we show one potential fix: teaching deletion during post-training reduces deletion avoidance and improves broader code-editing performance, suggesting the behavior is undertrained rather than beyond reach.

A. M. Ebrahimi, M. M. Hasan, Aaditya Bhatia et al. · 0 citations