Structured Generation
Harness the power of AI, adding some order to the chaos
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 generation takes all the data that’s 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 @mention 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 @mention.
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 buttons at the bottom of the node, choosing your type of choice from the buttons in the editor. Look for the symbol on the left to add them to your structured generation shape.
Click | Type | How it works |
---|---|---|
Text | A snippet of text, like a book’s title or an author’s name | |
Number | A numeric value, like the price of a product | |
True/False | A yes/no value, like whether or not a product has been purchased | |
Object | An object mapping field names to values of any of these types, even another object | |
List | A list containing a list of values of any of these types, even another list |
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.
Options (in the sidebar)
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 @mention the output of the structured generation.
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.
See our dedicated model documentation for our full list of supported models and their capabilities.
Outputs
Structured generations produce an object as an output. You can access each of the fields of this object in the editor
with a @mention by choosing the field name from the dropdown that appears when you type @
and the name specified in the structured generation’s settings.