AI Business Process · Topic 2 of 2

Using Large Models and Prompt Engineering

Learn how to use large models: prompt elements, zero-shot, few-shot and chain-of-thought prompts, temperature, RAG, agents and hallucination for H13-311.

  • 6 min
  • Includes a diagram
In a nutshell
  • Prompt elements: role, instruction, context, input data, output format.
  • Zero-shot has no examples, few-shot has some, chain-of-thought asks for step by step reasoning.
  • Low temperature gives focused, repeatable answers; high temperature gives varied ones.

What it is

A large model is used by sending it a prompt, the text input that tells it what to do. The model answers by generating tokens one at a time.

Prompt engineering is the practice of designing prompts so the model gives accurate, useful and well formatted answers. It changes only the input, never the model's weights, so it is usually the fastest and cheapest way to improve results.

User needPromptinstruction, context, input, formatLarge modelGenerated answercheck and refineBetter prompt

How it works

Ways to use a large model

ApproachHow it worksChanges weights?
Direct promptingCall the model through a chat interface or APINo
Prompt engineeringImprove the prompt with structure, examples and reasoning stepsNo
RAGRetrieve relevant documents and add them to the promptNo
Fine tuningTrain the model further on your own examplesYes
AgentLet the model plan, call tools and act in several stepsNo

Elements of a good prompt

ElementPurposeExample
RoleSets the viewpoint and tone"You are a customer service agent for a bank."
InstructionStates the task clearly"Summarize the complaint in two sentences."
ContextGives background the model needsProduct rules, the customer's history
Input dataThe text to work on, often between delimitersThe complaint, inside triple quotes
Output formatDefines the shape of the answer"Return JSON with fields issue and urgency."

Clear, specific prompts beat vague ones. Long tasks work better when split into numbered steps.

Prompting techniques

TechniqueIdea
Zero-shotAsk for the task with no examples
Few-shotInclude a few input and output examples so the model copies the pattern
Chain-of-thought (CoT)Ask the model to reason step by step before the final answer
Self-consistencyGenerate several reasoning paths and take the most common answer
Task decompositionBreak a complex request into smaller prompts in sequence

Chain-of-thought helps most on math and logic problems. Reasoning models such as DeepSeek-R1 are trained with reinforcement learning to produce long reasoning chains on their own.

Generation parameters

ParameterEffect
TemperatureLow values make output focused and repeatable; high values make it more varied and creative
Top-p (nucleus sampling)Samples only from the smallest set of tokens whose probabilities add up to p
Max tokensLimits the length of the answer

Temperature divides the model's scores (logits) before the softmax. For two tokens with logits 2 and 1, temperature 1 gives the first token 1 / (1 + e^-1) = 73.1% probability. Temperature 0.5 doubles the logits to 4 and 2, giving 1 / (1 + e^-2) = 88.1%, so the output becomes more deterministic.

Retrieval augmented generation (RAG)

A model knows only what was in its training data, up to its cutoff date. RAG gives it fresh or private knowledge at question time.

DocumentsSplit into chunksEmbedding modeltext to vectorsVector databaseUser questionEmbed questionRetrieve top k chunksPrompt with chunksLarge model answer

Because the answer is grounded in retrieved text, RAG reduces hallucination and can cite its sources. Updating knowledge means updating the documents, not retraining the model.

Agents

AI agent loop: a user goal goes to the large model, which plans the next step, acts with a tool such as search, code or an API, observes the result and plans again, using short and long term memory, until the goal is met and it gives the final answer. An AI agent uses a large model as its brain and adds planning (breaking a goal into steps), memory (short term conversation and long term stored information) and tools (search, code execution, databases, other APIs). It loops: think, act with a tool, observe the result, then decide the next step. A well known form of this loop is ReAct (reasoning and acting).

Hallucination and risks

Hallucination is fluent output that is false or unsupported, such as an invented citation. Reduce it with RAG, clear instructions to answer only from the given context, lower temperature and human review for important uses.

Prompt injection is an attack where malicious text in the input tells the model to ignore its instructions. Applications must treat user and retrieved content as untrusted.

A worked example

A weak prompt: "Tell me about this ticket." A better prompt adds a role, instruction, context and format:

You are a support analyst for an online bookstore.
Classify the ticket below as billing, delivery or account.
Answer only from the ticket text. If unsure, answer "unknown".
Return JSON: {"category": ..., "reason": ...}
Ticket: """My order arrived two weeks late and the box was damaged."""

The expected output is category "delivery". Adding two labeled example tickets would turn this into a few-shot prompt.

How the exam asks about this

  • "Which technique adds a few input and output examples to the prompt?" → Few-shot prompting.
  • "A company wants answers based on internal documents that change every week, without retraining. Which approach fits?" → RAG.
  • "Raising the temperature makes the model's output more random. True or false?" → True.

What to remember for the exam

  • Prompt elements: role, instruction, context, input data, output format.
  • Zero-shot has no examples, few-shot has some, chain-of-thought asks for step by step reasoning.
  • Low temperature gives focused, repeatable answers; high temperature gives varied ones.
  • RAG flow: chunk, embed, store in a vector database, retrieve top k, add to the prompt, generate.
  • An agent combines a large model with planning, memory and tool use.
Watch out

Prompt engineering, RAG and agents do not change the model's weights. Only training methods such as fine tuning do, so "the model permanently learned it" is never true of a prompt.

Common mistakes

Believing RAG eliminates hallucination. RAG reduces it, but the model can still misread or ignore the retrieved text, and poor retrieval gives poor answers.

Using high temperature for factual tasks. High temperature adds randomness that suits creative writing. Extraction, classification and math usually work best at low temperature.

Thinking chain-of-thought adds knowledge. It improves reasoning over what the model already knows. Missing facts must come from context, such as RAG.

Check yourself

  • What is the difference between zero-shot and few-shot prompting?

    Zero-shot gives only the task instruction. Few-shot also includes a few worked input and output examples for the model to follow.

  • Why does RAG help with information newer than the model's training data?

    It retrieves current documents at question time and puts them into the prompt, so the model answers from that text instead of its frozen training knowledge.

  • What three capabilities does an agent add to a large model?

    Planning to break a goal into steps, memory to keep information across steps, and tools to act on the outside world.

Topic 2 of 2 in AI Business Process

Test yourself on AI Business Process

The full Huawei HCIA-AI H13-311 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Huawei. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.