sangsen
Prompt Engineering Basics: How to Get Better Answers from AI Chatbots
AI

Prompt Engineering Basics: How to Get Better Answers from AI Chatbots

The previous article explained that an LLM works by predicting the next token based on everything written so far. That single fact explains most of what makes a prompt effective or not: you're not "asking a question" so much as starting a pattern that the model will continue — so the pattern you start matters.

Be specific about what you actually want

"Write about dogs" gives the model almost nothing to go on, so it defaults to the most generic, average version of "an article about dogs." Compare that to: "Write a 200-word explanation, for a first-time dog owner, of how often a medium-sized adult dog needs to be walked." The second version narrows down the length, audience, and exact question enough that there's a much smaller range of reasonable answers — which is exactly why it produces a more useful one.

Concretely, useful details to include are: the audience, the desired length or format, and what the answer should be used for.

Give it examples (few-shot prompting)

If you want output in a specific style or format, showing one or two examples is often more effective than describing the format in words. For instance, instead of saying "extract the name and date from this text," you can show:

Text: "Meeting with Sarah on March 3rd."
Output: { "name": "Sarah", "date": "March 3rd" }

Text: "Call with the Chen family on July 12th."
Output:

...and let the model complete the pattern. Because the model is fundamentally a pattern-continuer, giving it a pattern to continue is often more reliable than a written instruction alone.

Ask for the format explicitly

If you need a numbered list, a table, a specific JSON shape, or a particular tone, say so directly: "Answer in three bullet points," "respond only with valid JSON, no other text," "explain like I'm new to this topic." Left unspecified, the model guesses at a reasonable default format, which may not match what you actually need for whatever comes next in your workflow.

Break big tasks into steps

A single vague prompt like "build me a website" forces the model to guess at hundreds of unstated decisions at once. Breaking the same goal into stages — first agree on the pages and structure, then draft the content for one page, then move to styling — gives you a chance to check and correct each step before it compounds into the next one. This also tends to produce more accurate results generally: models are noticeably better at getting one well-defined step right than at getting twenty unstated ones right simultaneously.

Iterate instead of expecting a perfect first answer

Treat the first response as a draft, not a final answer. "That's close, but make it shorter and remove the technical jargon" is a completely normal and effective next step — the conversation history is part of the pattern the model continues, so it will adjust based on your follow-up the same way it would if you'd specified all of that up front.

Common mistakes worth naming

  • Assuming it knows what you meant. Ambiguous pronouns and unstated context ("fix the bug in that function" with no function shown) force the model to guess.
  • Trusting confident-sounding output on facts that matter. As covered in the previous article, LLMs can produce fluent, wrong answers. For anything factual and consequential — dates, statistics, legal or medical specifics — verify independently.
  • One giant prompt for a complex task. As above, splitting into steps usually beats one large, all-at-once request.

What's next

Text generation is only one side of generative AI. The next article, Generative AI Explained, covers how the same broad idea extends to images, audio, and video — and looks more closely at why AI hallucinations happen and how to catch them.

Related articles