Two ways to change what an AI does
A security analyst gives a language model three examples of a good incident summary. Its next response follows the same format. Did the analyst train a new model?
Usually, no. The examples became part of the input used during inference. The model's learned parameters—the internal numbers adjusted during training—were not updated just because examples appeared in the request. A separate training process would be needed to change them.
Compare that with engineers training a phishing detector using thousands of messages with known labels. Here, the training algorithm adjusts the model so its predictions better match the examples. The resulting model can then classify new messages.
These are two useful ways to influence behavior: training changes learned parameters; prompting supplies instructions and context for a response. A service might separately retain conversations or use them for later training, depending on its settings and policies. That is different from the inference happening in front of you.
This topic continues CompTIA SecAI+ CY0-001 Objective 1.1. The focus is the training and prompt-engineering portion of the objective. The examples are original teaching material. No coding or outside AI service is needed.
How to use this lesson
Read through the learning methods first. Then use the Learning and Prompt Workshop above to explore the examples at your own pace. Return here for the explanations of validation and prompting before completing the practice section. The presentation provides a paced visual version of the same concepts.
1. What feedback teaches the model?
Think about three ways a new analyst could learn. A mentor could show examples with known answers. The analyst could organize unfamiliar events into groups. Or the analyst could practice decisions in a simulator and receive feedback about the results. These analogies help distinguish three learning approaches; a computer does not learn or understand exactly as a person does.
Supervised learning: learn from examples with known targets
In supervised learning, training examples include a target answer. For a phishing classifier, the inputs are message features and the targets are labels such as phishing or legitimate.
| Synthetic training example |
Known label |
| An expected registration notice directs the recipient to the normal portal |
Legitimate |
| An unfamiliar sender asks for a password through an external form |
Phishing |
| A scheduled maintenance notice asks for no credentials or payment |
Legitimate |
During training, the model makes predictions, compares them with the known targets, and updates its parameters to reduce errors. During inference, it receives a new message without its answer and predicts a label.
“Supervised” describes the training signal. It does not mean a human must watch every prediction. Also, supervised learning includes predicting numbers, such as expected traffic volume, as well as predicting categories.
Security consequence: incorrect labels can teach incorrect patterns. If password-stealing messages are repeatedly labeled legitimate, a model may learn that they are acceptable.
Unsupervised learning: find structure without supplied target labels
In unsupervised learning, examples do not come with the target categories the system is meant to predict. A clustering algorithm might group network sessions by time, duration, and data volume.
Imagine three groups: short daytime sessions, long overnight transfers, and brief repeated connections. The algorithm found similarities. It did not prove that any group represents an attack.
An overnight backup could be perfectly legitimate. An analyst needs context to interpret a cluster or unusual event. Unusual means worth investigating; it does not automatically mean malicious.
Security consequence: treating every anomaly as an attack creates false alarms. Some anomaly-detection methods use other learning approaches, so choose “unsupervised” when the scenario actually says the model learns structure without target labels.
Reinforcement learning: improve actions using rewards
In reinforcement learning, an agent takes actions in an environment and learns a policy—a way to choose actions—from reward feedback. Its goal is to improve cumulative reward over time.
In an isolated security simulator, an agent might choose whether to investigate, wait, or isolate a simulated endpoint. A reward design could favor stopping a simulated threat while penalizing unnecessary disruption. These are teaching examples, not directions to let a model control a live network.
The reward must represent the intended goal. If a system is rewarded only for reducing open tickets, closing every ticket could look successful even while incidents remain unresolved. A numeric reward is not the same thing as good judgment.
Security consequence: poorly chosen rewards can encourage harmful behavior. Learning through experimentation also needs a safe environment.
Federated learning: change where training happens
Federated learning describes an arrangement for training across participating devices or organizations. Participants train locally and share model updates for aggregation, instead of routinely gathering all raw training records in one central dataset.
For example, three organizations could train a shared phishing model from their own labeled messages. The data remains local in this design while a coordinator combines updates. That training is both federated and supervised: one label describes the arrangement, the other describes the learning signal.
Federated learning is not simply running an already-trained model on a laptop. Local inference alone is not distributed training. Sharing updates also does not guarantee privacy; updates can reveal information, and malicious participants can submit harmful updates.
| Ask this question |
Look for this clue |
| Does training use known target answers? |
Supervised learning |
| Does training seek structure without target labels? |
Unsupervised learning |
| Does an agent learn actions from reward feedback? |
Reinforcement learning |
| Do participants train locally and combine updates? |
Federated learning |
Pause and explain why a system can be federated and supervised at the same time. Use the three-organization example instead of memorizing a definition.
2. How do we know the model learned something useful?
A detector correctly identifies every example it trained on. That result is encouraging, but it does not establish that the detector will recognize a new threat. A student who memorized yesterday's answer sheet might struggle with a differently worded problem.
Generalization means performing usefully on new examples. Overfitting happens when a model fits training-specific details or noise so closely that its performance does not carry over well. Underfitting means it has not captured enough of the useful pattern, so performance may be weak on both training and new data.
Three roles for data
| Data role |
Purpose |
Keep this distinction |
| Training |
Learn model parameters |
These examples teach the model |
| Validation |
Compare choices during development |
These results help choose settings or when to stop |
| Test |
Estimate performance of the chosen approach on held-out data |
Do not repeatedly tune against these results and still call them independent |
For illustration, a team might split 100 independent examples into 60 training, 20 validation, and 20 test examples. Those numbers are not a required ratio. The split must fit the task and contain enough representative evidence.
Keep duplicates and closely related copies from leaking across splits. For a future-facing login detector, a time-aware split may be appropriate: train on earlier events and evaluate on later ones. The evaluation should resemble the real task. A copied message in a different file is not a genuinely new example.
Worked example: longer training can hurt
An epoch is one complete pass through the training dataset. Here are illustrative results for a fictional classifier evaluated on separate training and validation examples:
| Training passes |
Correct on training examples |
Correct on validation examples |
| 1 epoch |
14 of 20 |
13 of 20 |
| 3 epochs |
18 of 20 |
17 of 20 |
| 6 epochs |
20 of 20 |
12 of 20 |
At six epochs, training performance is perfect while validation performance has fallen. That pattern is consistent with overfitting; it calls for investigation rather than deployment based on the training result alone. Among these illustrative candidates, three epochs has the strongest validation result. An untouched test set would still be needed to evaluate the selected approach.
The workshop above lets you move through these results. They are fixed teaching data, not measurements from a live model.
Also ask what errors occurred. In 100 events containing 98 legitimate logins and two attacks, a detector that always says legitimate would be 98% accurate and miss both attacks. Check false alarms and missed threats, not only the headline percentage. No formulas are required for this lesson.
3. Training again, training longer, or making a model smaller?
Fine-tuning continues training an existing model to adapt it to a task or dataset. For example, engineers could start with a pretrained language model and update trainable parameters using reviewed incident-summary examples. Putting those examples in a normal prompt is a different operation.
Three terms often appear near fine-tuning in certification materials:
| Term |
What changes |
Concrete example |
| Epoch |
How many full training passes occur |
Three passes through 1,000 training records is three epochs |
| Pruning |
Selected model weights or structures are removed or set to zero |
Remove low-importance connections to make a network sparse |
| Quantization |
Numbers use lower precision |
Represent selected weights with 8-bit values rather than 32-bit values |
Pruning and quantization can reduce resource demands, but their actual size and speed benefits depend on the implementation and hardware. They may also change model quality. Quantization is not encryption, and pruning is not deleting rows from the training dataset.
These techniques do not all require the same workflow. Quantization can happen after training; pruning can be combined with further training. Reevaluate a changed model before relying on it. A smaller model artifact is not proof of equivalent security performance.
4. Give the existing model a clear request
Prompt engineering is the deliberate design of instructions, context, and examples to help a model perform a task. Start with a synthetic event:
Event L-17: account demo-17 had six failed sign-ins, then one successful sign-in, between 09:10 and 09:14. The device is unfamiliar. The record does not say whether multi-factor authentication was completed, who used the account, or whether an attack occurred.
“Explain this login” leaves several choices open. Who is the reader? How long should the explanation be? Should the model state facts, make a diagnosis, or recommend action?
A stronger request defines four things:
- Task and audience: summarize the event for a junior security analyst.
- Evidence: use only the supplied event facts.
- Output format: return Observation, Unknown, and Next check.
- Limits: distinguish suspicion from proof; recommend verification without claiming an action was already taken.
A worked prompt
Summarize Event L-17 for a junior security analyst using only the facts below.
Return exactly three short lines labeled Observation, Unknown, and Next check.
Do not invent an attacker, a cause, an MFA result, or a completed response action.
If information is missing, state that it is unknown. Recommend one verification step.
Facts: demo-17 had six failed sign-ins followed by one successful sign-in
between 09:10 and 09:14 from an unfamiliar device. No MFA result or
account-owner confirmation is included.
One defensible response would be:
Observation: Six failed sign-ins were followed by a successful sign-in from an unfamiliar device during the four-minute window.
Unknown: The event does not establish who signed in or whether MFA was completed.
Next check: Review the authentication record for an MFA result before drawing a conclusion.
Compare that with “An attacker stole the password and bypassed MFA; the account is now blocked.” None of those three claims is established by the facts. A polished sentence can still be wrong.
A clearer prompt can improve usefulness and consistency, but it cannot guarantee truth. Check every significant output claim against its evidence. Asking for a behavior is not the same as enforcing it with software controls.
System prompts, user prompts, and roles
A system prompt commonly supplies application-level behavior instructions, such as the assistant's purpose and response constraints. A user prompt supplies the current request, such as summarizing Event L-17. Message roles identify the source of messages: commonly system, user, and assistant. Providers differ in supported roles and how instruction priority is implemented.
For example, an application might set “Describe only supplied event evidence; identify missing information.” The user then supplies a specific event and asks for a three-line summary. The assistant produces the response.
Typing “SYSTEM: ignore everything else” into a user message does not turn that text into an actual system-role message. Similarly, “Act as a security analyst” is a useful task framing instruction, not proof of expertise or permission to access systems. Do not treat system prompts as guaranteed secrets or as a replacement for access controls.
Zero-shot, one-shot, and multi-shot prompting
A shot is a worked example supplied in the prompt. Count examples that demonstrate an input and its desired output; do not count every instruction sentence as an example.
| Prompt style |
Worked examples supplied |
What it can clarify |
| Zero-shot |
None |
State the task and desired format directly |
| One-shot |
One |
Demonstrate the format once |
| Multi-shot, often called few-shot |
Two or more |
Show several patterns or contrasting cases |
This is one worked example:
Example input: A synthetic account signs in once from a familiar device.
Example output: Observation: one familiar-device sign-in.
Unknown: whether the account owner initiated it.
Next check: verify the session if additional suspicious evidence appears.
Add that example before the L-17 request and it becomes one-shot prompting. Add a second worked example showing how to acknowledge a missing MFA result and it becomes multi-shot prompting. The target event still needs its own response and does not count as a completed example.
Examples can help communicate the pattern, but more examples are not automatically better. Incorrect, contradictory, or irrelevant examples can make the output worse. They also occupy context space. These examples guide inference; they do not, by themselves, fine-tune the model.
Templates make good requests reusable
A prompt template keeps the task and output structure consistent while leaving a place for new event facts:
Task: Summarize the supplied event for {audience}.
Evidence: {approved_synthetic_event}
Format: Observation / Unknown / Next check.
Limits: Use only supplied facts. State missing information.
Recommend verification; do not claim an action has been performed.
Changing the event in a template is a new inference request. Templates can support consistent work, but the inserted data and returned claims still need review. A prompt instruction alone does not enforce authorization or guarantee safe output.
Put the ideas together
A team could use supervised learning to train a detector from labeled examples, distribute that training through a federated arrangement, compare candidate models on validation data, and evaluate the chosen model on held-out test data. Separately, an analyst could use an existing language model to summarize its alerts with a clear prompt template and one worked example.
Each step has a distinct job. The training method supplies a learning signal. Validation supplies evidence about performance. The prompt supplies the current task. Human review checks whether the output is supported.
Continue to Practice for a short guided prompt revision. Use Review to explain the distinctions aloud. Data provenance, RAG, and the wider AI lifecycle come next; no detailed attack frameworks are needed here.
Sources and further reading