Pular para o conteúdo
← Back to Skalablog

Published article

Prompt Engineering: Control Tokens and Temp

Software EngineeringAnthropicClaude CodeClaude

Prompt engineering works best when you separate three decisions: what the prompt must say, how the model samples its next token, and how long the answer runs. The Rocketseat video from March 2026 covers all three, from instructions and constraints to Top-K and temperature.

Prompt engineering: the format debate is a distraction

Prompt engineering does not require one winning prompt format, because XML, Markdown, and JSON tags mainly help the human reading the prompt. The Rocketseat session "Testei criar o 'prompt perfeito'… e isso mudou tudo na IA," published on 24 March 2026, makes that point directly: while you hunt for the perfect structure, you may be ignoring what actually changes the output.

The video treats XML as familiar because it resembles HTML, with opening and closing tags that mark where a block of information starts and ends. Markdown gets the same treatment through H1 and H2 headings. JSON gets mentioned as the format you use when downstream code has to parse the answer. Each choice is a readability and tooling decision, not a universal quality switch.

What the session keeps instead is a small checklist of things every prompt needs, whether or not you label them. It walks through a set of categories: the role the model should play, the reasoning strategy such as chain of thought or tree of thought, the task or objective, the constraints, and the expected output format. Those categories survive a change of model; the tag syntax may not.

Ask the model to write the prompt for you

Asking the model to write its own prompt is the shortcut the session lands on, and it reframes prompt engineering as specification writing. Instead of assembling tags by hand, the developer describes the problem and names the model that will consume the prompt, then reviews what comes back.

In the video, the instruction is essentially: create a prompt to solve a specific prompting problem, state that the prompt will be used by a model called Opus 4.5, and ask for best practices for that model. The generated result arrives more structured than typical hand-written prompts, with an expected output format section and an instruction not to skip any section.

The practical takeaway is verification, not blind trust. The session's presenter says he does not know whether the target model actually works better with the Markdown structure the model chose, and points viewers to the vendor's own prompting documentation as the place to confirm it. Current guidance for Anthropic Claude models, including Claude Code, lives in Anthropic prompting documentation, and that page is the source to check before assuming a format preference.

The PRICE checklist behind a solid prompt

The session groups prompt content into five habits that fit under a memory-friendly acronym it calls PRICE, covering role, reasoning, instructions, constraints and examples. It is a checklist rather than a template, and it works with any tag style you prefer.

The categories map cleanly onto failure modes developers hit in practice:

  • Role and reasoning. State who the model acts as and whether it should reason step by step before answering, which activates strategies like chain of thought or tree of thought.
  • Instructions. Say what the objective is in one unambiguous sentence, since vague tasks produce vague output.
  • Constraints. Name what must never appear in the answer, because negative requirements are the ones models drop most often.
  • Examples and output format. Show a sample answer or demand a specific shape such as Markdown or JSON, especially when code will parse the result.

The reasoning strategies named here are research ideas, not vendor features: chain of thought comes from a 2018 paper on chain-of-thought prompting and tree of thought from a separate line of work. Treating them as prompt content rather than as guaranteed behavior keeps the expectation honest, because whether a given model benefits depends on the model and the task.

Tokens: the unit that decides your API bill

A token is the basic unit of text an LLM reads and writes, and it does not always equal a word. Tokenization may split a word into fragments, so a single English word can map to more than one token while punctuation frequently becomes a token of its own.

That unit drives cost because API pricing is quoted per million tokens, and input and output tokens are priced separately. The Rocketseat session notes the pattern without quoting figures: output tokens generally cost more than input tokens, so a long, chatty answer costs more than the question that produced it. Anthropic publishes the current per-model rates on its pricing page, which is the place to check numbers rather than trusting a video or a blog post.

Token counts also determine how much text fits in the context window and how much a long conversation accumulates before it has to be trimmed. Two practical habits follow from that. Cap the maximum response length when the answer is a single value, and prefer a constrained output format such as JSON over prose you then have to Stripe with a regex.

Top-K, Top-P and the cutoff score

Top-K sets how many candidate tokens the model may draw from at each step, so a Top-K of three restricts the choice to the three highest-ranked options for the next token. The session describes it as picking the top three from the sampling pool, which narrows the space of answers that can be produced.

Top-P works on a probability threshold instead of a count. If you set the cutoff at 75 percent and only one candidate clears that bar, the model has effectively one option left, and any extra slots Top-K allowed go unused. Raising or lowering the threshold is how you trade variety for predictability without retyping the prompt.

Both parameters operate on the model's own probability distribution, which is why the session frames them as generation control rather than fine-tuning. Fine-tuning changes the model's weights through a training run; Top-K, Top-P, and temperature change how the already-trained model samples its next token through the API. Confusing the two leads developers to look for a training budget when an API parameter would have solved the problem.

Temperature is creativity, not correctness

Temperature controls how far the sampling distribution spreads away from its most likely option, so low values push toward deterministic output and high values widen the range of acceptable continuations. Near zero, phrasing tends to repeat between runs; further from zero, the model explores less probable words.

The video demonstrates the effect on a deliberately trivial task. With a creative system prompt and temperature set to two, asking for Brazil's capital returns an answer about saudade instead of Brasília, written in an intentionally humorous, counterintuitive style. The same question with a normal temperature returns the city name.

That demonstration is a controlled experiment by the presenter, not a benchmark, and it is worth reading as one. High temperature does not make a model smarter or more correct, and it does not reliably produce usable creative output on a technical task. It shifts the distribution, which is why creative writing and brainstorming tolerate it while extraction and code generation usually do not.

The parameters are exposed in different places depending on the tool. Open WebUI, the self-hosted chat interface, exposes temperature, Top-K, Top-P and related settings in its chat controls, as documented in the Open WebUI documentation. Vendor playgrounds expose a comparable but not identical set, which is why checking the tool's own documentation matters before copying settings.

DSPy: less prompt text, more code

DSPy is a framework that replaces hand-written prompt strings with program structure, and the session flags it as homework rather than a recommendation. You declare typed inputs and outputs, choose a reasoning strategy, and let the framework construct and optimize the prompt.

Two naming traps are worth clearing up. DSPy is not a typo for "DSP" in the signal-processing sense, and the ReAct strategy it can use is an agent pattern named for reasoning and acting, unrelated to the React JavaScript library. The session's presenter spells both out because the collision confuses people scanning the docs.

DSPy's own team reports its benchmark results, so treat performance figures as vendor-reported rather than independent. The DSPy project documents the current API and the supported language bindings, which have changed across releases, so read the current docs rather than a tutorial written against an older version.

A CTA section on turning video into articles

The thread running through this article is that knowledge is easier to produce than to write down, and that is exactly the gap when your explanation lives inside a 16-minute recording.

If you have a Brazilian Portuguese tech video, a coding walkthrough, or a longer interview, Skala Blog at skalablog.com takes a YouTube URL, generates a transcription, and turns it into a written article.

You can find the project at Skala Blog, and community material around the creator ecosystem includes Crazystack, plus the creators Gustavo Dev Doido, Crazystack Typescript, and the Bootcamp do Dev Doido.

Frequently asked questions

  • What is prompt engineering? It is the practice of specifying a task for a language model through instructions, constraints, examples, and output format, then adjusting sampling parameters to shape the result. The format you use to label those parts, such as XML or Markdown, is secondary to whether the parts are present.
  • Is there one best prompt format? No single format is best across models. The Rocketseat session from March 2026 treats XML, Markdown, and JSON as readability and tooling choices, and recommends checking the target model's own documentation for format preferences.
  • What is a token in an LLM? A token is the basic unit of text a model reads and writes, and it may be a whole word, a word fragment, or a punctuation mark. API pricing is quoted per million tokens, with output tokens typically priced above input tokens.
  • What does temperature do? Temperature controls how widely the model samples from its probability distribution. Values near zero push toward repeating the most likely continuation; higher values allow less probable words, which suits brainstorming and hurts precise extraction.
  • What is Top-K in an LLM? Top-K limits the next token to the K highest-ranked candidates, so a Top-K of three means the model chooses among the three most likely options. Top-P does the same job with a probability threshold instead of a count.
  • Is Top-K the same as fine-tuning? No. Top-K, Top-P, and temperature change how a trained model samples its next token at inference time, while fine-tuning trains model weights on additional data. The session calls the first group generation control.
  • Can the model write my prompt? Yes, and the session recommends it: describe the problem, name the model that will consume the prompt, and ask for best practices for that model. Review the result and verify the claimed format preference against the vendor's documentation.
  • What is DSPy? DSPy is a framework that replaces hand-written prompt strings with typed inputs and outputs plus a chosen reasoning strategy, letting the framework build and optimize the prompt. Its reported results come from its own team, so treat them as vendor-reported.
  • Do I still need to learn prompting fundamentals? The session argues yes, because fundamentals let you judge new techniques as variations rather than revolutions. Knowing tokens, sampling, and context also makes a generated prompt reviewable instead of a black box.

References

Source video