Skip to content

DoS Tokens Detector

The Denial-of-Service (DoS) Tokens detector prevents potential Denial-of-Service (DoS) attacks based on token limits. The detector checks if a prompt exceeds a specific token limit.

Vulnerability

Overloading LLMs with resource-heavy operations can cause service disruptions and increased costs.

Configuration

Initialize the DoS Tokens Detector with the desired options:

from pegasi.shield.input_detectors import DoSTokens

pegasi = Shield()
input_detectors = [DoSTokens(limit=4096)]

sanitized_prompt, valid_results, risk_score = pegasi.scan_input(prompt, input_detectors)

Here's what those options are for:

  • limit (int): Maximum number of tokens allowed in a prompt. Default is 4096.
  • encoding_name (str): Encoding model for the tiktoken library. Default is 'cl100k_base'.
  • model_name (str): Specific model for the tiktoken encoding. Default is None.

By configuring the Anonymize Scanner with these options, you can tailor the anonymization process to your specific requirements, ensuring that sensitive information is appropriately protected while allowing certain strings to remain unchanged.

If you wish to revert to the original data, you can make use of the Deanonymize Detector tool.