Why Do You Need to Define Extractions?

Defining extractions ensures that our policies run accurately on the correct parts of your prompts or responses. For example, if we want to detect prompt injection, we need to check the user’s question part, not the system prompt. Without this distinction, there could be false positives.

How and Why Do We Use Extractions?

The logic behind extractions is straightforward. Aporia checks the last message received:

  1. If it matches an extraction, we run the policy on this part.
  2. If it doesn’t match, we move to the previous message and so on.

Make sure to define question, context, and answer extractions for optimal policy performance.

To give you a sense of how it looks in “real life,” here’s an example:

Prompt:

You are a tourist guide. Help answer the user's question according to the text book.

Text:
<context>
Paris, the capital city of France, is renowned for its rich history, iconic landmarks, and vibrant culture. Known as the "City of Light," Paris is famous for its artistic heritage, with landmarks such as the Eiffel Tower, the Louvre Museum, and Notre-Dame Cathedral. The city is a hub of fashion, cuisine, and art, attracting millions of tourists each year. Paris is also celebrated for its charming neighborhoods, such as Montmartre and Le Marais, and its lively café culture. The Seine River flows through the heart of Paris, adding to the city's picturesque beauty.
</context>

User's question:
<question>
What is the capital of France?
</question>

Response:

<answer> 
The capital of France is Paris.
</answer>