Overview

A Ruleset can be used to define Rules for Structures and Tasks. Gen AI Builder places Rules into the LLM's system prompt for strong control over the output.

Types of Rules

Rule

Rules shape the LLM's behavior by defining specific guidelines or instructions for how it should interpret and respond to inputs. Rules can be used to modify language style, tone, or even behavior based on what you define.

Tip

Avoid writing large amounts of text in a single Rule. Breaking down your Rules generally helps the LLM follow them more effectively. Additionally, it makes it easier to evaluate the Rule's effectiveness using tools like the Eval Engine. If you have an existing system prompt, consider overriding the default system prompt instead.

Json Schema

Tip

Structured Output provides a more robust solution for having the LLM generate structured output.

JsonSchemaRules defines a structured format for the LLM's output by providing a JSON schema. This is particularly useful when you need the LLM to return well-formed data, such as JSON objects, with specific fields and data types.

Although Gen AI Builder leverages the schema library, you're free to use any JSON schema generation library to define your schema!

For example, using pydantic:

Structure

Rulesets

You can define a Ruleset at the Structure level if you need to have certain behaviors across all Tasks.

Rules

You can pass rules directly to the Structure to have a Ruleset created for you.

Task

Rulesets

You can define a Ruleset at the Task level if you need to have different behaviors per Task.

Rules

You can pass rules directly to the Task to have a Ruleset created for you.

Overriding System Prompts

While Rulesets are the preferred way to steer LLM output, sometimes you may want to fully override the system prompt.

Note that when overriding the system prompt, it is your responsibility to integrate anything that goes in by default. You can achieve this by appending the default system prompt to your custom prompt like so:


Could this page be better? Report a problem or suggest an addition!