Prompt engineering is the practice of writing instructions that get a language model to produce the output you need. I tested three common techniques, an expert role, step-by-step reasoning and examples, on 60 tasks with known answers. Asking the model to think step by step did not improve its arithmetic. It did catch a trap that every other prompt missed.
The most repeated prompt engineering tip is to tell the model to think step by step. In my test it did not make a small model better at arithmetic. Without the instruction the model solved all 20 word problems in all three runs. With it, three of its 60 answers were wrong, each on a different problem. The model was already reasoning step by step on its own. Where the instruction did help was a hidden trap: a date written day first, which every other prompt misread.
What prompt engineering is
AWS defines prompt engineering as "the process where you guide generative artificial intelligence (generative AI) solutions to generate desired outputs." In practice it means writing the instruction, the context and the expected format so that a large language model does what you need, then checking the result and adjusting.
The difference from simply asking a question is method. A question is written once. An engineered prompt states what counts as a correct answer and what the answer should look like, and it is changed only after the results have been checked.
A prompt is everything the model reads before it answers: the system prompt with standing instructions, the question, documents, examples. The model turns all of it into tokens, and all of it has to fit in the model's context window, the limit on how much text it can read at once. The usual techniques on top of a clear task are three:
- Role. Tell the model who it is: "You are an expert mathematician."
- Step by step. Ask the model to reason before it answers, also called chain-of-thought.
- Examples. Show solved cases in the prompt, also called few-shot prompting.
Most guides list these techniques. Few show what each one changes. So I measured it.
What I tested
I wrote 60 tasks with answers computed in advance, in three groups of 20:
- Math. Word problems in three or four steps: boxes of bottles shipped and received, train tickets paid for with twenty-dollar bills.
- Classification. Customer messages sorted into billing, delivery, account, technical or refund.
- Extraction. Short payment notes from which the model returns JSON with the payer's name, the date and the amount. Five notes write the date as dd/mm/yyyy and add "(day/month/year)". In two of them the day is 12 or less, so the date could also be read the American way.
Every task ran with four prompts. All four stated the task and the required format, such as "Reply with the category name only" or "Output only the JSON." This plain prompt, base, is the baseline. The other three added one technique each:
- role: a system message with a role;
- steps: "Think step by step, then…" before the format instruction;
- examples: solved examples in the same format, two for math and classification, one for extraction. For math they gave only the answers, so that this prompt would not also teach reasoning.
The main model was Qwen3-4B-Instruct-2507, a 4-billion-parameter model without a reasoning mode, quantized to 4 bits and running locally in Ollama 0.40.4 on a MacBook Air M4, with its default settings (temperature 0.7). Each prompt ran three times, 720 answers in total. The three runs agreed almost everywhere, so a difference of three answers usually means one task that failed in all three runs, or three tasks that failed once each. I also ran the math problems once each through Qwen3-4B-Thinking-2507, a model of the same size that always reasons before it answers. I wrote the method, the tasks and my expectations before the run.
One correction to my own scoring. The first rule for classification removed only the prefix "Category:" from the last line, so "Final category: billing" counted as wrong. The steps prompt wrote its answers that way and scored 40. With any such prefix removed it scores 57. The other prompts did not change.
Results
Correct answers out of 60 (20 tasks, three runs), and out of 20 for the reasoning model:
| Task | base | role | steps | examples |
|---|---|---|---|---|
| Math | 60 | 57 | 57 | 54 |
| Classification | 51 | 54 | 57 | 57 |
| Extraction | 57 | 56 | 59 | 57 |
| Math, reasoning model | 20 | 19 |
The steps scores in classification and extraction count the answer the model gave at the end. It never gave it in the required format. More on that below.
The role changed little
The expert role moved each group by three answers or fewer: down in math, up in classification, down in extraction. In math the three misses were three different problems, each wrong once. In classification the role fixed one of the three messages the base prompt always got wrong: a declined card, which it now filed under billing. On these tasks that is the whole effect. Anthropic's documentation says a role "focuses Claude's behavior and tone for your use case." Tone is what it is for.
Step by step did not help with math
I expected "think step by step" to lift the math score of the model without a reasoning mode. It did not, because the model already worked step by step without being asked. Its base answers to math problems had a median length of 235 tokens, full of intermediate sums. Asking for steps added nothing it was not already doing.
The reasoning model solved 20 of 20 problems without the instruction and 19 of 20 with it. This matches what OpenAI writes about its reasoning models: "prompting them to 'think step by step' or 'explain your reasoning' is unnecessary." Google's guide for Gemini takes a softer line and suggests adding explicit step-by-step instructions when the model's own thinking falls short. On these problems it did not fall short.
Step by step caught the trap
In extraction, steps was the only prompt that read one date correctly. "04/08/2025 (day/month/year)" means 4 August. The base, role and examples prompts read it as 8 April in all three runs. On the other ambiguous note, 02/10/2025, base and examples read the note correctly, so the models did not ignore the brackets everywhere. They slipped on one case out of two. The steps prompt wrote out the day and the month before producing the JSON and got both notes right in every run.
In classification, steps also raised the score from 51 to 57. It was the only prompt that filed the password reset message under account.
Reasoning out loud helps when a task hides a detail that is easy to skip. On routine tasks it adds cost without adding accuracy.
Examples fixed the boundaries
In classification, the base prompt sent three messages to "technical" in every run: a declined card, a tracking number that does not work, and a password reset email that never arrives. The intended answers were billing, delivery and account. The two examples in the prompt showed one billing case and one technical case. That fixed the card and the tracking number in every run. Only the password reset stayed wrong, and that message could reasonably be filed under technical as well.
The examples did not just show the format. They showed where the line between categories runs, which five category names alone do not convey.
In math, examples made things worse: 54 of 60. The examples gave only the final answer, and the model shortened its own answers from a median of 235 tokens to 151. Four of the six mistakes were addition errors in the final sum. In one answer the model wrote that 1,048 plus 864 is 912. A model copies the shape of the examples, including their brevity.
The price of step by step
Steps was the most expensive technique:
- In classification the base answer was one word and took a median of 0.08 seconds. The steps answer took 8.4 seconds, about 100 times longer.
- In extraction, 1.2 seconds against 13.3, about 10 times longer.
- In math almost nothing changed, 9.5 seconds against 10.9, because the model was reasoning anyway.
- Asked for a category name only or JSON only, the steps prompt wrote an explanation first in all 120 of its classification and extraction answers. A program that expects one word or clean JSON would have to dig the answer out of the text.
The reasoning model took a median of 32 seconds and about 800 tokens per math problem, against 9.5 seconds for the model without a reasoning mode, with the same 20 of 20.
What to take from this
- Start with the baseline. Every prompt in the test stated the task and the exact format. That baseline alone solved all 20 math problems and returned valid JSON in all 60 extraction answers. I did not test a vaguer prompt, so I cannot say how much the clear task itself added, only that the techniques had little left to fix.
- A role is for tone. It fixed one borderline message and did nothing measurable for arithmetic or extraction.
- Use examples for fuzzy boundaries. Two examples fixed two of three classification errors. Check that they do not teach something you do not want, as the short math examples did. Choosing examples from the cases the model gets wrong seems the natural next step; I did not test it.
- Use step by step for traps, not by default. It caught the date and the password reset, and on these models it cost up to 100 times more time and broke the output format.
- Write the tasks and correct answers before you change the prompt, then count. A wrong date or a broken format, like a hallucination, is easy to miss when you read only a few answers.
The vendors' guides do not agree with each other. OpenAI suggests trying prompts without examples first for its reasoning models. Anthropic recommends three to five examples. They write for different models, which is one more reason to measure on yours.
Limits
Two small models of one family, 60 tasks, one wording per technique, examples written in advance rather than chosen from the model's mistakes. Larger models may respond to the same techniques differently. The tasks were short and had one correct answer, which is not true of writing, research or coding. The test shows how to check techniques, not which one wins everywhere.
Sources
- What is Prompt Engineering?, AWS
- Reasoning best practices, OpenAI
- Prompting best practices, Claude Platform Docs
- Thinking prompting guide, Google Cloud
- Qwen3-4B-Instruct-2507 model card
- Qwen3-4B-Thinking-2507 model card
Vladimir Beskorovainyi, Enterprise AI Architect & CTO, author of the Amazon bestseller "Enterprise AI: The KATA Way", founder of Besk Tech (besk.tech)
