Getting a Sentiment with a Structured Prompt
Explore how to design and implement structured prompts that produce predictable sentiment labels for frontend interfaces. Learn the difference between open text and fixed arrangements, the importance of fixed labels and known value types, and how to construct prompts that return reliable sentiment judgments like positive, neutral, or negative to enhance user experience with clear UI elements.
An answer written as prose has to be read to be used. An answer arriving as labelled values can be placed straight into the interface. The difference is decided in the prompt, before anything is sent.
We'll cover the following:
Open text and fixed arrangements
What makes an arrangement usable
Asking for one
Practice
Open text and fixed arrangements
Open text is an answer with no required shape. A paragraph, a sentence, a few lines. It reads well and can be displayed as-is, but nothing about it is predictable except that it is text.
A fixed arrangement is an answer required to contain specific named values. Each value has a label, and the interface knows in advance which labels to expect.
Compared On | Open Text | Fixed arrangement |
What the interface knows in advance | That text will arrive | Which values will arrive, under which labels |
How the interface uses it | Displays the whole thing | Places each value where it belongs |
Suits | Content a person reads | Decisions the interface acts on |
Finding one value inside it | Requires reading through the text | The value is already separate |
Suggested visual, placed here. Two panels. The left, labeled "Open text," shows a paragraph block with an arrow to a single display area. The right, labeled "Fixed arrangement," shows three small labelled boxes with three separate arrows pointing to three different parts of an interface: a badge, a heading, and a body area. Caption: "One answer fills one space, the other fills several"
An arrangement is not better. It is different work, suited to a different job.
What makes an arrangement usable
Three things have to be settled before an arrangement helps.
The labels are fixed in advance: The interface has to know which labels to expect. If a label appears that the interface has never heard of, there is nowhere to put it. If an expected label is missing, something on screen has no value.
The values have known types: A label holding a number and the same label holding a sentence are different to the interface. Whether something is a number, a short piece of text, or one of a set of options has to be decided before the request.
Options are drawn from a fixed set: The most useful arrangement restricts a value to a small list of allowed options. A status that is always one of three known words lets the interface handle all three. A status that could be any wording cannot be handled completely.
Asking for one
A format request describes the arrangement wanted. Making it specific is what makes it effective.
Vague | Specific |
"Return the result in a structured way" | "Return three labelled values" |
"Include a category" | "Include a category, which must be one of: billing, technical, account" |
"Keep it organized" | "Give each value on its own line, labelled" |
"Return only the data" | "Return only the labelled values, with no explanation before or after" |
The right column tells the model exactly what is expected. The left column leaves the arrangement to chance.
The last row matters more than it looks. An answer wrapped in a sentence of explanation is harder for an interface to use than one containing only what was asked for.
Practice
Let's practice writing prompt by adding a sentiment to a review.
Scenario
A product details screen shows customer reviews. At the bottom of each review, we want a small badge reading positive, neutral, or negative, so shoppers can scan the tone of a review before reading it.
Here's a review:
“The finish looks great and delivery was quick. But the height adjustment sticks halfway and I have to force it every time, which is frustrating for the price.”
A person reads that and immediately senses the tone. The badge needs to hold that same judgement as one value.
Solve it with the prompt widget
The badge can only show one of three things: positive, neutral, or negative. Write a prompt that returns the sentiment as one of those three words, so whatever comes back always has a badge to match it.
Here's a starting point that doesn't get there yet:
Read this review and tell me the sentiment:"The finish looks great and delivery was quick.But the height adjustment sticks halfway and I have to force it every time,which is frustrating for the price."
Try it and see what comes back. Then work out what your prompt is missing so the answer reliably lands on one of the three words.
You have three attempts. If you'd rather see the answer, type "Ed, give me the answer."
Send me your prompt and I'll answer it exactly as written, including whatever it leaves undecided. You have three attempts.
Try a variation
Ask for a second value alongside the sentiment: which part of the product the review is about. Pick your own fixed list, something like appearance, delivery, function, or price.
A badge has three possible looks. If the answer is always one of three words, all three are covered. If it could be any wording, the badge has nothing to show.
Why does restricting a value to a fixed list of options help the interface more than simply asking for that value?
We've covered the difference between open text and a fixed arrangement, the three things that make an arrangement usable, and how to ask for one specifically. The next concern is size: an answer can arrive correctly arranged and still be too long for the space it has to fit.