LongSafety: Enhance Safety for Long-Context LLMs

Mianqiu Huang, Xiaoran Liu, Shaojun Zhou, Mozhi Zhang, Qipeng Guo, Linyang Li, Pengyu Wang, Yang Gao, Chenkun Tan, Linlin Li, Qun Liu, Yaqian Zhou, Xipeng Qiu, Xuanjing Huang


Abstract
Recent advancements in model architectures and length extrapolation techniques have significantly extended the context length of large language models (LLMs), paving the way for their application in increasingly complex tasks. However, despite the growing capabilities of long-context LLMs, the safety issues in long-context scenarios remain underexplored. While safety alignment in short context has been widely studied, the safety concerns of long-context LLMs have not been adequately addressed. In this work, we introduce ${textbf{LongSafety}}$, a comprehensive safety alignment dataset for long-context LLMs, containing 10 tasks and 17k samples, with an average length of 40.9k tokens. Our experiments demonstrate that training with LongSafety can enhance long-context safety performance while enhancing short-context safety and preserving general capabilities. Furthermore, we demonstrate that long-context safety does not equal long-context alignment with short-context safety data and LongSafety has generalizing capabilities in context length and long-context safety scenarios.
Anthology ID:
2025.llmsec-1.4
Volume:
Proceedings of the The First Workshop on LLM Security (LLMSEC)
Month:
August
Year:
2025
Address:
Vienna, Austria
Editor:
Jekaterina Novikova
Venues:
LLMSEC | WS
SIG:
SIGSEC
Publisher:
Association for Computational Linguistics
Note:
Pages:
26–47
Language:
URL:
https://preview.aclanthology.org/corrections-2025-08/2025.llmsec-1.4/
DOI:
Bibkey:
Cite (ACL):
Mianqiu Huang, Xiaoran Liu, Shaojun Zhou, Mozhi Zhang, Qipeng Guo, Linyang Li, Pengyu Wang, Yang Gao, Chenkun Tan, Linlin Li, Qun Liu, Yaqian Zhou, Xipeng Qiu, and Xuanjing Huang. 2025. LongSafety: Enhance Safety for Long-Context LLMs. In Proceedings of the The First Workshop on LLM Security (LLMSEC), pages 26–47, Vienna, Austria. Association for Computational Linguistics.
Cite (Informal):
LongSafety: Enhance Safety for Long-Context LLMs (Huang et al., LLMSEC 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/corrections-2025-08/2025.llmsec-1.4.pdf
Supplementarymaterial:
 2025.llmsec-1.4.SupplementaryMaterial.txt