Masked Language Modeling for Adversarial Prompt Detection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Adversarial attacks on natural language processing (NLP) models, which involve small perturbations causing misclassification or manipulation of model outputs, are not effectively addressed by existing methods, particularly those requiring specific model training or tuning.

Innovation Solution

A masked language modeling approach using a pretrained MLM model to detect adversarial attacks by tokenizing input sentences, calculating suspicion levels for each token, and applying Gaussian weighting to identify suspicious tokens, without requiring specific model training.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If existing defense methods are used against adversarial attacks, then model protection is attempted, but computational cost increases and model-specific training is required

Engineering Contradiction:
Improvemodel protectionVSAvoidcomputational cost
Core Design Contradiction:
ReliabilityVSUse of energy by moving object

Solution Approach 1:

The MLM model detects adversarial attacks by analyzing the input text itself through mask token substitution and probability calculation, without requiring external defense models or additional training. The system uses its own language modeling capabilities to identify suspicious tokens, making the defense mechanism self-contained and computationally efficient.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The defense mechanism is model-agnostic and can be applied to any NLP model that uses tokenization. By using a pretrained MLM model that works with general language structures, the system provides universal protection across different NLP architectures without requiring model-specific training or customization.

Inventive Principle:
Principle #6Universality (Multi-functionality)

2Measurement precision

If model-specific training is used for defense, then detection accuracy may improve, but adaptability to different NLP models decreases

Engineering Contradiction:
Improvedetection accuracyVSAvoidmodel agnosticism
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The defense mechanism is model-agnostic and can be applied to any NLP model that uses tokenization. By using a pretrained MLM model that works with general language structures, the system provides universal protection across different NLP architectures without requiring model-specific training or customization.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The MLM model acts as an intermediary layer between the input text and the target NLP model. It analyzes the input text independently through mask token substitution and suspicion level calculation, then provides defense decisions without being tied to the specific architecture or training of the target model, thus maintaining both accuracy and adaptability.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Measurement precision

If comprehensive token analysis is performed, then attack detection accuracy improves, but computational complexity increases

Engineering Contradiction:
Improveattack detection accuracyVSAvoidcomputational complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The system segments the attack detection process into discrete steps: tokenizing the input text, substituting each token with a mask token, calculating suspicion levels for each position, and identifying adversarial tokens. This segmentation allows for systematic analysis while maintaining computational efficiency through modular processing.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs suspicion level calculation for each token position in the text, which may be more computation than strictly necessary. However, this excessive action ensures comprehensive coverage and high detection accuracy by analyzing every possible attack insertion point, with the trade-off managed through efficient use of pretrained MLM probabilities.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS12518097B2Masked language model as a defense against textual adversarial attacks
Publication Date: 2026.01.06 DELL PROD LP
  • US12518097B2 patent drawing
  • US12518097B2 patent drawing
  • US12518097B2 patent drawing

AI summary

One example method includes receiving a text string that includes multiple words, tokenizing the text string to create a tokenized text string, substituting each token in the tokenized text string with a mask token to create a masked text string, performing an inference process on the masked text string to obtain a respective probability for each token, determining a respective suspicion level for each probability, modulating the suspicion levels to obtain a respective weighted suspicion score for each token, and comparing each of the weighted suspicion scores with a threshold to determine whether any one or more of the words indicate that the text string includes an attack prompt.