Generative AI & LLMs Cheat Sheet
Transformers · RAG · prompting · fine-tuning
Transformers, embeddings, RAG, prompting, fine-tuning vs context — the 2026 must-know reference for AI builders.
PDF quick reference
GenerativeCheat sheet
- Sections
- 4
- Snippets
- 5
- Pages
- 2
01
Core concepts
Token smallest unit of text the model seesEmbedding vector representation of a tokenContext all tokens the model attends toTransformer self-attention based architectureRAG retrieval-augmented generation
02
Prompting patterns
Zero-shot plain instructionFew-shot instruction + 3-5 examplesCoT "let's think step by step"ReAct reason + act loop with tool calls
03
Build a RAG pipeline
1. Chunk the docs (~500 tokens, overlap)2. Embed each chunk (OpenAI / Cohere / local)3. Store in a vector DB (Pinecone / pgvector / Chroma)4. At query: embed → top-k retrieve → stuff into prompt5. Send to LLM, return cited answer
from openai import OpenAIclient = OpenAI()emb = client.embeddings.create(model="text-embedding-3-small",input=chunks).data# similarity search → top_k → promptresponse = client.chat.completions.create(model="gpt-4o",messages=[{"role": "system", "content": SYSTEM},{"role": "user", "content": question + "\n\n" + context}])
04
Fine-tuning vs context
Use context (RAG) when:- Knowledge changes often- Need cited sources- Small / medium domainFine-tune when:- Style / format must be consistent- Heavy traffic + cost-sensitive- Need to teach a new task pattern
