By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Generative AI refers to models that create new data—text, code, images, or embeddings—rather than just predict a label. Large Language Models (LLMs) such as GPT‑4, LLaMA, or Claude are transformer‑based generators that can understand prompts, produce coherent language, and be adapted (via prompting, fine‑tuning, or Retrieval‑Augmented Generation) to downstream tasks like drafting customer‑support replies, generating product descriptions, or powering a “chat‑with‑your‑data” analytics assistant.
Attention(Q,K,V) = softmax(QKᵀ/√d_k) V
"You are a data‑science mentor. Explain k‑means in 2 sentences."
L = - Σ y_i log(p_i)
ΔW = A·B
e = f(text)
sim(e₁,e₂) = (e₁·e₂)/(‖e₁‖‖e₂‖)
search(e_q, k)
p_i = softmax(logits_i / τ)
python docs = load_documents('support_kb/') # raw text files embeddings = model.encode(docs) # sentence‑transformers index = faiss.IndexFlatIP(embeddings.shape[1]) # inner‑product index index.add(embeddings)
python TEMPLATE = """You are a helpful support agent. Context: {retrieved} Question: {user_query} Answer:"""
python q_emb = model.encode(user_query) _, I = index.search(q_emb, k=5) # top‑5 docs retrieved = "\n".join([docs[i] for i in I[0]])
python prompt = TEMPLATE.format(retrieved=retrieved, user_query=user_query) response = openai.ChatCompletion.create( model="gpt-4", messages=[{"role":"user","content":prompt}], temperature=0.2, top_p=0.95)
trainer = Trainer(..., peft_config=LoRAConfig(...))
tiktoken
Scenario: Your chatbot frequently fabricates product specs that aren’t in the knowledge base. Answer: Enable Retrieval‑Augmented Generation (RAG) and lower the temperature; grounding forces the model to use real documents.
Scenario: You have 200 labeled Q&A pairs and a 7‑B LLM. Training the full model would exceed GPU memory. Answer: Use LoRA (or another PEFT method) to fine‑tune only a few thousand parameters, keeping the base frozen.
Scenario: After fine‑tuning, validation loss drops but test accuracy stays flat. Answer: You’re overfitting; add regularization (e.g., weight decay), increase dropout, or augment the training data.
Attention(Q,K,V)=softmax(QKᵀ/√d_k)·V
L = -∑ y_i log(p_i)
sim = (e₁·e₂)/(‖e₁‖‖e₂‖)
IndexFlatIP
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.