Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Liu00222 Open Prompt Injection DataSentinelDetector preprocessing

From Leeroopedia
Knowledge Sources
Domains NLP, Preprocessing
Last Updated 2026-02-14 15:00 GMT

Overview

Concrete text normalization method for cleaning data prompts before detection queries, provided by the DataSentinelDetector class.

Description

The DataSentinelDetector.preprocessing method removes sentence pair prefixes ("Sentence1:", "Sentence2:"), replaces secondary sentence markers with conjunctions ("and"), ensures trailing punctuation, and lowercases the text. This normalizes inputs from various NLP tasks (MRPC, RTE, SST-2, etc.) into a uniform format for the detection model.

Usage

Called internally by `detect()` and `query()` methods before constructing the known-answer prompt. Can also be called directly if custom preprocessing is needed.

Code Reference

Source Location

Signature

class DataSentinelDetector:
    def preprocessing(self, data_prompt_orig):
        """
        Normalize input text for detection queries.

        Args:
            data_prompt_orig (str): Raw input text from any NLP task.
        Returns:
            str: Cleaned lowercase string with prefixes removed and
                 trailing period ensured.
        """

Import

from OpenPromptInjection import DataSentinelDetector
# detector = DataSentinelDetector(config)
# cleaned = detector.preprocessing("Sentence1: Hello world")

I/O Contract

Inputs

Name Type Required Description
data_prompt_orig str Yes Raw input text from any NLP task

Outputs

Name Type Description
cleaned_text str Lowercased text with "Sentence1:/Sentence2:" removed, trailing period ensured

Usage Examples

Preprocessing Sentence Pair Data

from OpenPromptInjection import DataSentinelDetector
from OpenPromptInjection.utils import open_config

detector = DataSentinelDetector(open_config("configs/model_configs/mistral_config.json"))

# MRPC-style input
raw = "Sentence1: The cat sat on the mat. Sentence2: A cat was sitting on a mat."
cleaned = detector.preprocessing(raw)
print(cleaned)
# Output: "the cat sat on the mat. and a cat was sitting on a mat."

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment