The rubric rule is a powerful tool for enforcing complex business guidelines in AI-generated content. It allows you to define specific criteria or requirements that the AI’s output must meet. This rule is particularly useful when you need to ensure that the AI’s responses adhere to detailed company policies, brand guidelines, or specific formatting requirements.

Here’s a brief explanation of how the rubric rule works:

  1. You define a set of criteria or guidelines in the value field of the rule.
  2. The AI’s output is evaluated against these criteria.
  3. The threshold determines how strictly the criteria are enforced.
  4. The rule can be set to pass or fail based on whether you want to ensure compliance or detect non-compliance.

For example, in the policy provided below, the rubric rule is used to enforce a guideline for greeting customers based on the time of day. This ensures that the AI always uses the appropriate greeting, maintaining a consistent and time-appropriate tone in customer interactions.

By using the rubric rule, you can create highly customized policies that reflect your specific business needs and ensure that the AI’s responses always align with your company’s standards and practices.

To ensure complex guidelines, you can use the rule rubric, for more details, see our Rules Catalog.

Rule structure:

  • type: rubric
  • expected: fail or pass
  • value: your criteria, one or many
  • threshold: 0.9 means the tolerance to the criteria

Policy

  • id: unique policy id
  • definition: short description
  • rules: list of rules
  • target: input, output or both - where to check

Create the policy

Here is an example of policy to detect injection:


policy = {
    "id": "greetings",
    "definition": "...",
    "rules": [
        {
            "type": "rubric",
            "expeted": "fail",
            "value": """Always say greetings depending on the time of day:
    After 1:00 AM and before 12:00 PM, say "Good morning."
    After 12:00 PM and before 6:00 PM, say "Good afternoon."
    After 6:00 PM and before 9:00 PM, say "Good evening."
    After 9:00 PM and before 1:00 AM, say "Good night.""",
            "threshold": 0.9
        }
    ],
    "target": "output"
}

Next steps

  • Create the policy by using the application endpoint
  • Call the Evaluate API with the messages and policy id greetings
  • The API output would be a status being fail or pass, and the list of policy violations. You could check if the policy id greetings is there.