Principle:Liu00222 Open Prompt Injection Input Preprocessing
| Knowledge Sources | |
|---|---|
| Domains | NLP, Preprocessing, Data_Cleaning |
| Last Updated | 2026-02-14 15:00 GMT |
Overview
A text normalization technique that standardizes input data by removing task-specific prefixes and normalizing formatting before feeding it to a detection model.
Description
Input Preprocessing in the context of injection detection normalizes raw data prompts to reduce noise that could confuse the detection model. This includes removing structured prefixes (like "Sentence1:" and "Sentence2:" used in sentence pair tasks such as MRPC and RTE), replacing separator prefixes with conjunctions, ensuring proper sentence termination, and lowercasing. This normalization ensures the detection model receives clean, uniform input regardless of the upstream task's data formatting conventions.
Usage
Use this principle before feeding data into the DataSentinel detection model. It is called internally by `DataSentinelDetector.detect` and `DataSentinelDetector.query` to normalize input before constructing the known-answer prompt.
Theoretical Basis
Text normalization reduces spurious variation that is irrelevant to injection detection:
Pseudo-code Logic:
# Preprocessing steps
def preprocess(text):
text = text.replace("Sentence1: ", "") # Remove sentence pair prefixes
text = text.replace("Sentence2: ", "and ") # Replace with conjunction
if not text.endswith("."):
text += "." # Ensure trailing period
text = text.lower() # Lowercase
return text