Skip to main content

prompt_engineering

Weird Tricks

1. Make it repeat the question before answering.

Tools

1. Set Clear Expectations

Before defining the specifics of your schema, start with a Dialogue step. In this step, using the User role, provide clear instructions to the AI about the structured data you want it to create. Explain the purpose of the data, indicate the input data is above (i.e. the prompt).

For example, if you want the AI to extract information according to the "Problems" schema, your Dialogue step might look like this:

"My goal is to extract multiple-choice or short-answer questions from the message above and represent them as JSON data. Use the "problems" tool to structure the data."

This sets a clear context for the AI and informs the detailed schema definition in the following AI Chat step.

2. Simplify Structure to a Flattened Schema.

Within the AI Chat step, you'll define the precise structure of your desired output using the "Structure" section. Here, you'll input your JSON schema. Complex, nested schemas can be more effectively processed if you opt for a flatter schema. Represent elements as top-level properties instead of nesting them within multiple layers.

For instance, the "Search Queries Schema" is structured with each query as a distinct top-level property. It does not use a list called "search_queries" with each query nested within it. This is more reliable for always getting the correct number of queries. With a list, the AI can generate as many queries as it wants.

{
"type": "object",
"description": "Represents a set of distinct search queries related to a specific topic",
"properties": {
"search_query_0": {
"type": "string",
"description": "The first search query, focused on a specific aspect of the topic"
},
"search_query_1": {
"type": "string",
"description": "The second search query, exploring a different facet of the topic"
},
"search_query_2": {
"type": "string",
"description": "The third search query, providing an alternative perspective or angle on the topic"
}
},
"required": ["search_query_0", "search_query_1", "search_query_2"]
}

This flattened structure, defined within the "Structure" section of your AI Chat step, helps the AI generate the correct output.

3. Add Property Descriptions

When defining your schema, go beyond simply stating the data type for each parameter. In the "description" field, clearly explain what each parameter represents and its expected format. This gives the AI detailed guidance.

For instance, instead of just "type": "string" for the "choices" parameter in the "Problems" schema, include a richer description:

"type": "string", "description": "The answer choices, formatted as lowercase letters followed by a closing parenthesis (e.g., a) choice1 b) choice2 c) choice3)"

4. Include Examples in Property Descriptions

A "Flashcards Schema" would include concrete examples directly within the query parameter's description:

"query": { "type": "string", "description": "The prompt or question on the front of the flashcard. Examples: 'What is the capital of France?', 'Define photosynthesis', 'Explain the causes of the American Revolution.'" },

These examples clarify the expected format and content, leading to more accurate structured data.

5. Rationale Property First

A "rationale" property in your schema increases transparency and answer quality. This property provides the AI's reasoning behind the generated output.

Placing the "rationale" as the first property encourages the AI to articulate its reasoning before generating the remaining data. This gives the AI "space to think" before providing the main output.

On the Telosnex Home Screen, "Ideas" are generated with this technique. Each idea includes a rationale explaining the AI's prompt choice, and a corresponding color based on its category.