🤖 generative AI cheat sheet
⚡text generation
Autoregressive next‑token prediction. zero-shot / few-shot
Q: What is gravity?
A: A force that attracts objects with mass.
Q: Explain 'quantum entanglement'.
A: Particles linked so state changes instantly.
→ generate answer for: "What is a black hole?" output: region with infinite density …
code generation
Copilot, CodeLlama, GPT-4
# prompt: "function to compute fibonacci recursively"
def fib(n):
if n <= 1: return n
return fib(n-1) + fib(n-2)
👉 also: explain this code, add types, refactor
image generation
DALL·E, Stable Diffusion, Midjourney
"a serene library in space, nebula clouds, hyperrealistic, digital art, 8k —ar 16:9"
negative prompt: blurry, ugly, watermark → latent diffusion
RAG / embeddings
retrieval-augmented generation
CONTEXT (retrieved chunks):
"Einstein won Nobel prize for photoelectric effect."
QUERY: "Why did Einstein win Nobel?"
GENERATION: "For discovery of photoelectric effect."
text-embedding-3-small · cosine similarityaudio / speech
Whisper, ElevenLabs, MusicGen
audio input → whisper-1
"Um actually the weather today is ..."
→ transcription + timestamps
text‑to‑speech example: “Hello world” → 🎵 emotional voice
vision‑language
GPT-4V, LLaVA, CLIP
input: image of bar chart + "summarize trends"
output: "Sales increased in Q2 by 12% ..."
prompt patterns
chain‑of‑thought, self‑consistency
Q: A ball costs $1.10. Bat costs $1 more.
How much ball?
A: Let's think step by step...
→ total = 1.10, bat = ball+1 → 2*ball+1=1.10 → ball=0.05
fine‑tuning
LoRA, PEFT, instruct tuning
{"messages": [
{"role": "user", "content": "tag this review"},
{"role": "assistant", "content": "positive"}]}
LoRA rank=8 → train only 0.1% params
vector storage
Pinecone, Chroma, Weaviate
vector = embed("generative ai tutorials")
db.similarity_search(vector, k=3)
video / 3D
Sora, Runway, Point·E
"golden retriever playing in ocean, cinematic"
→ 4s clip, consistent style
chat structure
system / user / assistant
system: "You are a helpful botanist."
user: "Why are leaves green?"
assistant: "Chlorophyll reflects green..."
structured generation
JSON mode · regex · grammar
{"brand": "Nike", "items": 3, "in_stock": true}
use response_format={ "type": "json_object" }
sumMarization exaMple
Long text: "In recent years, generative AI ..."
➜ "TL;DR: generative models create text, images, code."
transforMation exaMple
"Rewrite this formally: 'gimme data'"
➜ "Could you please provide the dataset?"
iMage2text exaMple
[diagram of water cycle] → "Evaporation, condensation..."
⚡ generative AI · from text to video · every card contains explicit exaMple (capital M on purpose) · v1.0

