A Framework for Real-time Safeguarding the Text Generation of Large Language Model

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Dong, Ximing, Lin, Dayi, Wang, Shaowei, Hassan, Ahmed E.
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866909617652498432
author Dong, Ximing
Lin, Dayi
Wang, Shaowei
Hassan, Ahmed E.
author_facet Dong, Ximing
Lin, Dayi
Wang, Shaowei
Hassan, Ahmed E.
contents 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, that lead 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 constraint introduction and eliminating the need for control model training. Additionally, LLMSafeGuard employs a context-wise timing selection strategy, intervening LLMs only when necessary. We evaluate LLMSafeGuard on detoxification and copyright safeguarding, demonstrating its superiority over SOTA baselines. In detoxification, LLMSafeGuard reduces toxic output by at least 38.6\% while preserving linguistic quality. Additionally, its context-wise timing selection cuts inference time by at least 24.2\% without compromising effectiveness.
format Preprint
id arxiv_https___arxiv_org_abs_2404_19048
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle A Framework for Real-time Safeguarding the Text Generation of Large Language Model
Dong, Ximing
Lin, Dayi
Wang, Shaowei
Hassan, Ahmed E.
Computation and Language
Artificial Intelligence
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, that lead 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 constraint introduction and eliminating the need for control model training. Additionally, LLMSafeGuard employs a context-wise timing selection strategy, intervening LLMs only when necessary. We evaluate LLMSafeGuard on detoxification and copyright safeguarding, demonstrating its superiority over SOTA baselines. In detoxification, LLMSafeGuard reduces toxic output by at least 38.6\% while preserving linguistic quality. Additionally, its context-wise timing selection cuts inference time by at least 24.2\% without compromising effectiveness.
title A Framework for Real-time Safeguarding the Text Generation of Large Language Model
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2404.19048