Quick answer: For placement revision, generative AI comes down to six areas: core terms such as tokens, context window and embeddings; how an LLM generates text; prompting patterns; model settings; the RAG pipeline and when to choose RAG or fine-tuning; and the main risks with how to measure quality. This cheat sheet puts all six into tables you can test yourself on.
This generative AI cheat sheet is for generative AI quick revision before an interview or online test. Cover one column of each table and recall the other. If a row feels new, learn it properly with our generative AI tutorial, because interviewers follow every "what" with a "why".
Generative AI notes: core terms
| Term | Meaning in one line |
|---|---|
| Generative AI | AI that creates new content such as text, images or code |
| LLM | Large language model: predicts the next token from the tokens before it |
| Token | A piece of text the model reads and writes, often part of a word |
| Context window | Maximum tokens the model can handle in one request, input plus output |
| Transformer | The neural network design behind most LLMs |
| Attention | Lets each token weigh how much every other token matters |
| Fine-tuning | Further training on a smaller set of examples for a specific task |
| Embedding | A list of numbers that represents the meaning of a text |
| Vector database | Stores embeddings and finds the nearest ones quickly |
| Hallucination | A fluent but false or unsupported answer |
| Agent | A model that can choose and call tools over several steps |
How an LLM generates text
- Your text is split into tokens.
- The model scores every possible next token.
- The scores become probabilities (softmax).
- One token is picked, using settings such as temperature.
- The token is added to the text and the loop repeats until a stop condition.
Interview note: "Why do LLMs hallucinate?" They produce likely text, not checked facts. Retrieval and a "say I do not know" rule reduce this.
Prompting patterns
| Pattern | What you do | Use when |
|---|---|---|
| Zero-shot | Give the task with no examples | The task is simple and common |
| Few-shot | Add two to five worked examples | You need a specific format or style |
| Role and rules | State who the model is and what it must not do | You need consistent behaviour |
| Step-by-step | Ask it to work through the problem in steps | Maths, logic or multi-step tasks |
| Structured output | Ask for JSON that matches a schema | Code will read the reply |
| Safe fallback | "If the answer is not in the notes, say I do not know" | Answers must come from your data |
Model settings
| Setting | Effect | Typical choice |
|---|---|---|
| Temperature | Higher means more varied output | Low for facts and extraction, higher for ideas |
| Top-p | Picks only from the most likely tokens that add up to p | Change temperature or top-p, not both |
| Max output tokens | Caps the reply length | Enough for the answer, with a margin |
| Stop sequences | Text that ends the reply | Stop after one item or one answer |
| System prompt | Standing instructions for the whole conversation | Rules, tone, format |
Some newer models fix sampling settings, so check the provider's documentation.
The RAG pipeline
| Step | What happens |
|---|---|
| 1. Load | Read documents such as PDFs, web pages or tickets |
| 2. Chunk | Split them into passages of a few hundred tokens |
| 3. Embed | Turn each chunk into a vector |
| 4. Store | Save vectors in a vector database |
| 5. Retrieve | Embed the question and find the closest chunks |
| 6. Generate | Put the chunks in the prompt and ask the model to answer from them |
| 7. Cite and check | Show sources and validate the reply |
Similarity is usually measured with cosine similarity:
import math
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
return dot / (math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b)))
print(round(cosine([1, 1, 0], [1, 0, 0]), 3)) # 0.707
Prompting vs RAG vs fine-tuning
| Approach | Best for | Cost and effort | Main limit |
|---|---|---|---|
| Prompting | Quick tasks, formats, prototypes | Lowest | Model only knows its training data |
| RAG | Private or changing data, answers with sources | Medium | Answer quality depends on retrieval |
| Fine-tuning | Fixed style, format or narrow behaviour | Highest | Data goes stale; needs good examples |
Start with prompting, add RAG for knowledge and fine-tune last.
Risks and how to reduce them
| Risk | Example | Reduce it by |
|---|---|---|
| Hallucination | Invents a fee or a rule | RAG, safe fallback, citations, tests |
| Prompt injection | A document says "ignore your rules" | Treat data as data, limit tools, check output |
| Data leakage | Personal data sent to an outside API | Remove private details, follow company policy |
| Unsafe actions | An agent sends mail or deletes data | Allow-list tools, ask a person to confirm |
| Cost spikes | Long prompts on every request | Send fewer chunks, cap output, cache repeats |
Measuring quality
Score retrieval (recall@k: was the right chunk in the top k?) separately from the answer (faithful to the notes, relevant, valid format). Keep 20 to 30 test questions and run them after every change.
Generative AI cheat sheet: quick revision checklist
- Can you explain tokens and the context window with one example?
- Can you describe the five steps of text generation?
- Can you say when you would choose RAG over fine-tuning, and why?
- Can you explain how you tested your own GenAI project?
Pro tip: These tables stick only after you have built something. Solve our generative AI practice problems, then test yourself with the generative AI interview questions. For ML terms, keep the machine learning fundamentals cheat sheet next to this one.
If you are preparing through a course
CodeBegun's Artificial Intelligence course offers an interview guarantee. It means 5+ interview opportunities through a 60+ company network, subject to the placement policy and your eligibility. It does not mean a promised job, offer or salary; the employer decides. Compare options in our Artificial Intelligence course guide, or see how long it takes to learn generative AI.
Frequently asked questions
Is there a generative AI PDF version of this cheat sheet?
There is no separate PDF. The page is made of simple tables, so you can print it or save it as a PDF from your browser.
Which generative AI topics are asked most in fresher interviews?
Tokens and context windows, how an LLM predicts the next token, temperature, hallucination, prompt engineering, embeddings and vector search, RAG, RAG versus fine-tuning, prompt injection and how you tested your own project.
What is the difference between RAG and fine-tuning?
RAG finds relevant documents at question time and puts them in the prompt, so the model can use current or private data and show sources. Fine-tuning further trains the model on examples, which mainly changes style, format or behaviour. Most company projects start with prompting and RAG.
Does CodeBegun guarantee a job after the AI course?
No. The interview guarantee means 5+ interview opportunities through a 60+ company network, subject to the placement policy and your eligibility. It does not mean a promised job, offer or salary. The employer makes the final decision.
Want to check where your AI skills stand? Book a free demo class and talk through your gaps with a trainer, or explore the Artificial Intelligence course.
