Prompt engineering
OCI AI Foundations · Lesson 8 of 16 · 51:03
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Oracle Cloud Infrastructure AI Foundations Associate exam (1Z0-1122-26). In this lesson: prompts and instruction tuning, RLHF, in-context learning with zero-shot, one-shot, and few-shot prompts, chain-of-thought prompting, and hallucination, with how RAG reduces it. Includes three original practice questions, with Willowmere Motors, a fictional network of car dealerships and repair shops, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Same model, two prompts
Willowmere's team asks the same model for the same thing, in two different ways. The first prompt, summarize this note, returns a long and messy paragraph. The second, with clear instructions and two examples, returns exactly the three bullet points that the service desk needs.
Prompts and instruction tuning
A prompt is the text that you give to a language model, and prompt engineering is the work of refining that prompt until the model responds the way that you want. A base model, trained only to predict the next token, simply continues the text: ask it a question, and it may answer with more questions. Instruction tuning fixes this: the model is fine-tuned on many pairs of instructions and good responses, so it learns to follow instructions. Reinforcement learning from human feedback, or RLHF, goes further: people compare several answers from the model, a reward model learns their preferences, and the model is tuned to produce the answers that people prefer.
In-context learning
You can also teach a model inside the prompt itself, which is called in-context learning. The prompt shows the task with instructions, or with examples of inputs and the outputs that you expect, and the model follows the pattern. No parameters change: the model learns nothing permanent, and the next prompt starts from scratch. With no example, it's called zero-shot prompting, with one example, one-shot, and with a few examples, few-shot, or k-shot, where k is the number of examples. Few-shot prompting is often the quickest way to get a precise format or tone.
Chain-of-thought
Some questions need several steps: what does a customer pay for a service with two parts, three hours of labor, and a ten percent discount? A model that answers right away often gets such problems wrong. Chain-of-thought prompting asks the model to reason step by step, writing out the intermediate steps before the final answer, either with an instruction, or with examples that show the reasoning. Spelling out the steps tends to improve the answers to math, logic, and other multi-step problems, and makes the reasoning easier to check.
Hallucination
Language models can hallucinate: they generate text that sounds fluent and confident, but is not grounded in facts, or in the data that you provided. A hallucination can be obvious, like a dealership that does not exist, or subtle, like a warranty of five years instead of three. It happens because the model predicts likely text, not true text. You can reduce hallucinations by grounding the model in your own documents with retrieval-augmented generation, or RAG, by asking it to say when it does not know, and by having people check important answers. But no method removes them for sure, so critical answers always need checking.
Recap
Let's recap. Prompt engineering refines the prompt until the model responds the way that you want. Instruction tuning teaches a base model to follow instructions, and RLHF tunes it toward the answers that people prefer. In-context learning puts instructions or examples in the prompt, zero-shot, one-shot, or few-shot, with no change to the parameters. Chain-of-thought asks the model to reason step by step, which helps with multi-step problems. And hallucinations are fluent but ungrounded text: RAG and human checks reduce them, but nothing removes them for sure.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Before each new service note, Willowmere’s prompt shows three earlier notes, each with the short summary that the desk wants. Which technique is this?
- Instruction tuning on new data
- Reinforcement learning from human feedback
- Few-shot prompting
- Zero-shot prompting
Show the answer
Few-shot prompting
The prompt includes a few examples of inputs and outputs, so it's few-shot prompting, a form of in-context learning. “Instruction tuning on new data” would change the model's parameters with training, and nothing is trained here. “Reinforcement learning from human feedback” would tune the model on people's preferences, which also takes training. And “Zero-shot prompting” would give the task with no examples at all.
Willowmere’s assistant often gets the total cost of a lease wrong, because it must add several fees and subtract a deposit. Which change to the prompt should help most?
- Ask it to reason step by step first
- Ask for the answer in one word
- Remove every example from the prompt
- Use a model with a smaller vocabulary
Show the answer
Ask it to reason step by step first
Chain-of-thought prompting asks the model to work through the steps before it gives the total, which helps with multi-step problems. “Ask for the answer in one word” would push the model to answer right away, with no room to reason. “Remove every example from the prompt” would only remove guidance that can show the model how to reason. And “Use a model with a smaller vocabulary” has nothing to do with arithmetic: the vocabulary is the list of tokens that the model knows.
Willowmere’s assistant tells a customer that the warranty covers brake pads for five years, but no such clause appears in Willowmere’s policy. What happened, and what should help most?
- Overfitting: add more training epochs
- A token limit: shorten the question
- Nothing: such errors cannot be reduced
- A hallucination: ground it with RAG
Show the answer
A hallucination: ground it with RAG
The assistant generated a fluent claim that is not grounded in the policy, which is a hallucination, and grounding its answers in Willowmere's documents with RAG reduces the risk. “Overfitting: add more training epochs” would make the model fit its training data even more closely, and would not ground it in the policy. “A token limit: shorten the question” is wrong, because the answer was complete, just not true. And “Nothing: such errors cannot be reduced” goes too far: hallucinations cannot be removed for sure, but they can be reduced.