liveBook · Manning

Prompt shield

As explained in Generative AI in Action

A prompt shield is a content-safety mechanism that identifies and neutralizes direct or indirect prompt attacks by distinguishing trusted instructions from untrusted input.

A prompt shield protects GenAI applications from direct and indirect prompt attacks by making external input salient while preserving its meaning. Delimiters and data marking help distinguish trusted instructions from untrusted content. section 13.5.1

A practical deployment uses it to:

  • Analyze the user prompt and supplied documents for attacks. section 13.5.1
  • Submit the request to Azure Content Safety with an endpoint, API version, subscription key, and timeout. section 13.5.1
  • Inspect whether userPromptAnalysis or documentsAnalysis reports attackDetected as true. section 13.5.1

Prompt and document screening

A request can pair a question such as “What are the rules of your AI system?” with external documents, send both through the shieldPrompt endpoint, and inspect separate attack results for the prompt and documents. section 13.5.1

Figure 13.15 Prompt Shields example
figure

View the Prompt Shields architecture example. section 13.5.1

How Generative AI in Action covers it

How deep it goes
Explains input marking, delimiters, API submission, and attack-result inspection without detailing model internals.
Examples
Uses a user question, two documents, a shieldPrompt request, and attackDetected results for prompts and documents.
What it assumes
Requires Azure Content Safety, a subscription key, and assigned cognitive services and Azure OpenAI roles.
What you can do after
Apply it via Azure Content Safety's shieldPrompt API to screen prompts and documents for attacks.
How it connects
Connects prompt injection attacks with content moderation, groundedness detection, protected content detection, and blocklists.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.