Generative AI, RAG, and Agents
ISC2 AI Security · Lesson 2 of 34 · 10:23
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
Lesson 2 of the free ISC2 AI security series (pilot exam, domain 1, AI concepts and security fundamentals). In this lesson: generative and multimodal models, tokens and context windows, embeddings and vector databases, prompts and RAG, fine-tuning, PEFT, and LoRA, and agents and agentic AI. With three quick checks and a recap, and Ravenmoor Payments, a fictional payment provider, as the running example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Inside the assistant
Ravenmoor's support assistant answers merchants from the help center and from each merchant's agreement, and a disputes agent gathers evidence and drafts responses to chargebacks. Both run on a large language model, with extra parts around it. To secure them, you need to know every one of those parts.
Generative and multimodal models
Generative AI creates new content, such as text, images, audio, or code, instead of only classifying or predicting. Large language models are generative models trained on huge amounts of text, which predict the next piece of text again and again. Multimodal models accept or produce several kinds of data, like a photo of a receipt together with a question about it. Foundation models are trained once at large scale, then adapted to many tasks, which makes each one a shared dependency for many applications.
Tokens and context windows
Natural language processing gives these models their building blocks. Text is split into tokens, which are words or pieces of words, and each token becomes a number that the model can process. Token management matters, because providers charge by the token, and each model accepts a limited number of tokens. The context window is that limit: the system prompt, the conversation, retrieved documents, and the answer must all fit inside it. When a conversation grows too long, older content falls out of the window or the request fails, so applications trim their prompts and budget their tokens.
Embeddings and vector databases
An embedding is a list of numbers that represents the meaning of a piece of text, so that similar meanings sit close together. A vector database stores these embeddings, and finds the ones closest to a question, which is a similarity search rather than a keyword search. Embeddings are derived from the original text, and research shows that text can sometimes be partly recovered from them. So treat embeddings and vector databases with the same sensitivity as the documents they came from.
Prompts and RAG
Prompt engineering is the craft of writing instructions that steer a model, such as a system prompt that sets its role and rules, and examples of good answers. Retrieval augmented generation, or RAG, grounds the model in your own data: the application turns the question into an embedding, retrieves the closest passages from a vector database, and adds them to the prompt. The model then answers from those passages, which reduces made-up answers, and lets you change its knowledge without retraining. But retrieved text enters the prompt, so a poisoned document can carry hidden instructions. And retrieval must respect permissions, or the assistant may reveal one merchant's agreement to another.
Fine-tuning, PEFT, and LoRA
Fine-tuning continues the training of a pretrained model on your own examples, to teach it a style, a format, or a specialized task. Full fine-tuning changes every weight, which is costly for large models. Parameter efficient fine-tuning, or PEFT, trains only a small number of parameters, and low rank adaptation, or LoRA, is its best known method: it freezes the original weights, and trains small update matrices beside them. For security, the fine-tuning data shapes behavior, and the small adapter files are model artifacts that you must version, sign, and protect.
Agents and agentic AI
An AI agent uses a model to plan and take actions toward a goal, by calling tools such as search, a database, or a payments interface. Agentic AI chains these steps with little human input, and in multi-agent systems, agents hand tasks to each other. Agent to agent protocols, such as A2A, let agents from different vendors discover each other's skills and exchange tasks. Agents keep state: session persistence carries a conversation across steps, and memory stores facts for later sessions. Every tool, every handoff, and every memory is a new place where an attacker can push instructions or steal data.
Recap
Let's recap. Generative models create content, multimodal models handle several kinds of data, and foundation models are shared dependencies. Text becomes tokens, and everything must fit in the context window. Embeddings capture meaning, vector databases search them, and both are as sensitive as their source documents. RAG grounds answers in your data, while fine-tuning with PEFT or LoRA changes the model itself. And agents add tools, handoffs, sessions, and memory, so they add attack surface.
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.
In very long conversations, Ravenmoor’s support assistant starts ignoring rules from the start of its prompt. What is the most likely cause?
- The model’s weights changed during the chat
- The conversation outgrows the context window
- The vector database lost the prompt’s rules
- The tokens of the prompt expired
Show the answer
The conversation outgrows the context window
The conversation outgrows the context window, so the application trims earlier content. “The model’s weights changed during the chat” is wrong, since the weights of a model do not change while it answers. “The vector database lost the prompt’s rules” is wrong, because the vector database holds documents, not the rules of the prompt. And “The tokens of the prompt expired” is wrong, since tokens do not expire during a conversation.
Ravenmoor wants its support assistant to answer from the latest help center articles, which change every week, without retraining the model. Which approach fits?
- Fine-tune the model with LoRA every week
- Paste every article into the system prompt
- Train the model with reinforcement learning
- Retrieve the articles from a vector database (RAG)
Show the answer
Retrieve the articles from a vector database (RAG)
Retrieval augmented generation pulls the latest articles from a vector database into each prompt. “Fine-tune the model with LoRA every week” would retrain the model every week, which is what Ravenmoor wants to avoid. “Paste every article into the system prompt” would overflow the context window, and it would raise the cost of every request. And “Train the model with reinforcement learning” learns from rewards, and it does not add new knowledge from documents.
Ravenmoor’s disputes agent saves notes in long-term memory, to reuse them in later sessions. What is the main new risk?
- Poisoned memories can steer future sessions
- Memory removes the need for authentication
- The model retrains its weights after each session
- Memory limits the agent to a single tool
Show the answer
Poisoned memories can steer future sessions
Content saved in memory can carry instructions that steer future sessions, which is memory poisoning. “Memory removes the need for authentication” is wrong, since memory does nothing to replace the authentication of users or tools. “The model retrains its weights after each session” is wrong, because using memory does not retrain the weights of the model. And “Memory limits the agent to a single tool” is wrong, since memory does not limit how many tools the agent can call.