What does it do?

Structured generations enable you to use AI to produce structured data. One of the most powerful features of Wordware, structured generations solve the perennial problem of getting AI to generate something deeper than a block of text.

How do I use it?

A structured generation takes all the data that has appeared in the WordApp so far and passes it to your AI model of choice, like a regular generation. Where it differs is in the output: instead of generating text, a structured generation produces objects with fields and values. A recipe might generate an object with fields for ingredients and instructions, while a product description might generate an object with fields for price and availability.

This is particularly useful for data to be passed to other systems, like a database or an API. You can reference the output of a structured generation with a @[name_of_generation] like any other generation.

To create a structured generation, type /structure in the editor, and hit Enter. You’ll be prompted to fill in some details about the generation, like its name and the model you want to use, further explained below. Once you run the WordApp, the model will be fed all the content above the generation and generate new content based on it, which you can then reference with a @[name_of_generation].

Shaping the output

The core of a structured generation is the shape of the output data. You can think of this shape as a set of fields you want the AI to produce, where each field has a name and a value. The name is always text, and the value can be text, a number, a true/false value, a list, or even another object. You define the shape in the editor, and the AI will produce an object of that shape.

Types

Each field in the output shape has a name, a description, and a type.

To add a new component, click one of the three buttons at the bottom of the node.

The first button going from the left is add value field.This will give you three types of value to choose from, described in the table below.

The second button going from the left is the add object field.

The third button from the left is the add list field.This will give you four types of value to choose from, described in the table below.

ClickTypeHow it works
TextA snippet of text, like a book’s title or an author’s name
NumberA numeric value, like the price of a product
True/FalseA yes/no value, like whether or not a product has been purchased
ObjectAn object mapping field names to values of any of these types, even another object
ListA list containing a list of values of any of these types, even another list

Remember that this shape has a hierarchy: objects and lists can both contain other types, so you often end up with a nested shape a few levels deep. Whenever you’re adding or modifying a field, be mindful of which level it is in, and what its parent is, shown by indentation in the editor.

What the AI sees

When you run a structured generation, the AI sees the content above the generation, just like a regular generation. More relevant to structured generations, the AI also sees the output shape you’ve defined, including the name and type of each field, and how they’re arranged in relation to each other. Usually, this is enough for it to infer what you’re looking for.

If you find you need to add more context to help the AI understand, you can always add descriptions to each field as well, just to the right of the field name in the editor.

Pro Tip: The AI generates content from top to bottom, and can use its previous work to help guide its thought process. As the AI is generating fields at the bottom of the structured generation, it will be able to view its already-generated content above. Leverage this by, for example, putting summary fields at the bottom instead of the top.

Options (in the attributes editor)

Structured generations share most of their options with generations. Here’s what they mean:

Name

The name of the structured generation. You’ll need this later if you want to @[name_of_generation] the output of the structured generation. As with normal generations this can be changed in the attributes editor:

And also directly in the editor:

Creativity

How creative the structured generation should be. A higher creativity level will produce more varied and interesting results, but is more likely to result in unexpected outputs.

As a rule of thumb, increase the creativity level if you’re getting overly consistent or boring outputs, and decrease it if the outputs are too chaotic or nonsensical. Creative works like poetry or fiction often benefit from higher creativity, while logical or technical works like code or reports often benefit from lower creativity.

Model

Which AI model you’d like to use. You can choose from a variety of models, each with its own strengths and weaknesses. There are a few featured models, but you can also browse the full range by clicking on the bottom button.

See our dedicated model documentation for our full list of supported models and their capabilities.

Outputs

As with a standard generation, structured generations produce an object as an output. You can access each of the fields of this object in the editor with a @[name_of_generation] by choosing the field name from the dropdown that appears when you type @ and the name specified in the structured generation’s settings.