0
Generative AI Foundations
Phase 1Module 3 of 15

LLMs

Language is the universal interface for knowledge work. LLMs can read, write, reason, code, and translate — making them the most versatile AI building block. Instead of building separate models for each task, one LLM handles dozens via prompting.

An LLM is like a polymath who's read the entire internet — it can discuss almost any topic, write in any style, and follow instructions, but it may confidently state things that aren't true and has no memory of your last conversation unless you provide it.

Visual Workflows

Start here — study each diagram, then use + / to zoom if needed.

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

Key Takeaways

  • 1.Large Language Models (LLMs) are deep learning models trained on vast text data to understand and generate human language — the core engine behind modern AI applications.
  • 2.LLMs are transformer-based neural networks with billions of parameters, trained on internet-scale text via next-token prediction.
  • 3.Post-training (RLHF/DPO) aligns them to be helpful and safe.
  • 4.You interact via APIs sending messages (system/user/assistant roles).
  • 5.Key properties: in-context learning (follow examples in the prompt), no persistent memory (stateless per request), non-deterministic output (temperature controls randomness), and knowledge cutoff (training data has a date limit).

Real Example

Scenario

You send a system prompt ('You are a Python tutor'), a user message ('Explain decorators'), and the LLM generates a clear explanation with code examples — without any task-specific training.

What you would do

In Generative AI Foundations, apply LLMs to this scenario: You send a system prompt ('You are a Python tutor'), a user message ('Explain decorators'), and the LLM generates a clear explanation with code examples — without any task-specific training. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

Practice Task

Open the Code Walkthrough below and run it locally. Change one parameter related to LLMs (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

Code Walkthrough

Highlighted lines show where LLMs happens in the code.

LLMs
1from openai import OpenAI  # import dependencies2
3client = OpenAI()  # create API client4
5response = client.chat.completions.create(  # core API call for LLMs6    model="gpt-4o-mini",  # key line for LLMs7    messages=[  # key line for LLMs8        {"role": "system", "content": "You are a concise Python tutor."},9        {"role": "user", "content": "Explain decorators with an example."},10    ],11    temperature=0.3,12    max_tokens=500,13)14
15print(response.choices[0].message.content)  # show output for debugging16print(f"Tokens used: {response.usage.total_tokens}")  # show output for debugging

Cheat Sheet

Quick recap

quick ref
  • messages: system/user/assistant
  • temperature: 0=deterministic, 1=creative
  • max_tokens limits output length
  • usage.total_tokens for billing
  • In-context learning via examples
  • No memory between API calls

Common Mistakes

  • Expecting LLMs to have real-time knowledge without RAG
  • Not using system prompts to control behavior
  • Ignoring token limits and costs in production
  • Treating LLM output as always factual