Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
Generative AI & LLM · Chapter 01 / 20

Generative AI & LLM

Generative AI and LLMs: an introduction

Generative AI is broader than chatbots, and a large language model (LLM) is only one component of a useful product. Start here to understand the field, the terminology, how systems are assembled and where the learning path goes next. No testing background is required.

Prerequisites: none.

AI, ML, generative AI and LLMs

Artificial intelligence (AI) is a broad field concerned with systems that perform tasks associated with human intelligence. Some systems use explicit rules; machine learning (ML) instead learns patterns from data. Deep learning is a family of ML methods using multi-layer neural networks. Transformers are an architecture used in many modern language models.

Generative AI creates content, such as text, code, images, audio or video. LLMs are generative models designed primarily for language and commonly trained to predict the next token. A spam classifier is ML, but is not necessarily generative AI; an image generator is generative AI, but not necessarily an LLM. Multimodal models can cross these boundaries.

ConceptMain purposeExample
Artificial intelligenceBroad field of intelligent softwarePlanning and recommendations
Machine learningLearn patterns from examplesFraud detection
Deep learningLearn representations with neural networksSpeech recognition
Generative AIProduce new contentText or image generation
Large language modelProcess and generate token sequencesAnswer a question or explain code

The names describe overlapping categories, not a required stack. You can build useful AI features without an LLM, and an LLM can be used within conventional software.

How a language model produces an answer

A tokenizer converts text into tokens. The model processes the sequence and computes scores for possible next tokens. Decoding chooses a token and repeats until a stop condition. The model does not retrieve a prewritten sentence from a database on every request. The next chapter explains tokenization, attention, sampling and training with concrete examples.

Pretraining teaches broad statistical patterns from text and other data. Instruction tuning and preference optimization can make models more helpful, but do not guarantee correct facts or consistent reasoning. A fluent answer is not evidence that the model accessed a source, used a calculator or performed a real-world action. External information and actions require additional application components.

Model choice involves context size, modality, latency, price, language support, data handling, deployment options and task performance. Bigger is not always better; reliability and cost matter more than a model's popularity.

Model versus application versus product

A model is a component with learned weights, inference logic and an interface for sending inputs and receiving outputs. An application assembles prompts, session history, retrieved information, tools, validation and business rules. A product also includes authentication, a user experience, feedback, monitoring and operational ownership.

For a customer-support assistant, a request may follow this path:

StepOwnerResponsibility
1Application APIAuthenticate the user, accept and validate input
2OrchestratorConstruct instructions and relevant conversation context
3Retriever, if neededFind current documents the user is allowed to read
4LLMGenerate a response or propose a structured tool call
5Tool executor, if neededAuthorize and carry out an external action
6Application output layerValidate, display or stream results and record usage

The model itself cannot establish authorization to read an order or confirm that a refund occurred. The surrounding software must enforce permissions and check external results. Treat prompts as model instructions, not as a security boundary.

Common system patterns

PatternTypical useWhat to consider
Direct promptSummarize a supplied documentContext limits and accuracy
Structured generationExtract a record into JSONSchema validation and missing fields
Retrieval-augmented generation (RAG)Answer from a changing policy librarySearch quality, freshness and access control
Tool callingLook up an authorized orderServer-side permissions and error handling
AgentsComplete a multi-step workflowApproval boundaries, loops, cost and tracing
Fine-tuningAdapt a model to specialized examplesTraining data, evaluation and maintenance

RAG is not the same as fine-tuning: it supplies external information at request time rather than updating the model's weights. An agent is an application design with an action loop, not a special kind of model. Structured output helps software parse a response; it does not automatically make the information true.

Core vocabulary

These are the terms you will encounter repeatedly. Provider-specific terminology may vary.

TermMeaning
Foundation modelA broadly trained model used for different downstream tasks
Model weightsLearned parameters defining the network's behavior
InferenceRunning a trained model on an input
Token and tokenizerA unit of model input/output and the component that maps text to token IDs
Context windowMaximum token sequence supplied to a model, including history and retrieved material
PromptInput content and instructions assembled for a model
Message rolesRoles such as system, developer and user; exact support depends on provider
Sampling and temperatureWays of selecting the next token and controlling response variation
EmbeddingNumeric representation used for similarity and search
RetrievalSelecting relevant information from an external source
RAGRetrieval-augmented generation, which adds context to a model request
Tool callStructured model request for the application to invoke a function
AgentApplication loop that can select actions and use tools repeatedly
MultimodalProcessing or generating more than one kind of data
GroundingConnecting an answer to supplied evidence
HallucinationPlausible-looking output not supported by facts or relevant evidence
GuardrailA control that constrains, validates or blocks inputs and outputs
Latency and token costTime and consumption required to serve a request

Evaluation terminology encountered later

Evaluation and testing are important parts of working with LLM products, but they come after the foundations. These definitions are here so the vocabulary is searchable from the beginning.

Terms are used inconsistently across tools and papers. This course uses them as defined here.

TermMeaning in this course
Evaluation (eval)A repeatable measurement of quality: a dataset, a way to run the system on it, scorers and a decision rule
Case (sample)One input to evaluate, with optional reference answer, metadata and tags
DatasetA versioned collection of cases; a "golden dataset" is a curated, trusted one
Scorer (grader)Code, a model or a person that assigns a score or verdict to one output
MetricAn aggregate of scores over a dataset, for example pass rate or mean faithfulness
JudgeA model used as a scorer (LLM-as-a-judge)
RubricWritten criteria a judge or human applies
Reference answerA known good answer, or the facts it must contain
BaselineThe results of the current production version, used for comparison
RegressionA statistically and practically meaningful drop compared with the baseline
Trace / spanA record of one request and of each step inside it (model call, retrieval, tool call)
Hallucination (confabulation)Output that is fluent but not supported by facts or sources
GroundingBasing output on provided sources, verifiable by citation
GuardrailA control around the model that blocks or modifies inputs or outputs
Red teamingAdversarial testing that tries to make the system fail in harmful ways
Prompt injectionInput that makes the model follow attacker instructions instead of the developer's
BenchmarkA public, standardized evaluation used to compare models
pass@k / pass^kProbability that at least one of k attempts passes / that all k attempts pass

How this course is organized

The path covers general concepts, everyday AI use, application engineering, testing and quality evaluation. The fictional store Stride's support assistant provides a recurring example. Some chapters also use the GimmeJob Learning Path Advisor.

PartTopicsWhat you gain
FoundationsThis overview; How LLMs generate text; Using AI reliably at work; Embeddings and similarityVocabulary, model mechanics, practical verification and representations
Application engineeringApplication anatomy and APIs; Prompts; Structured outputUnderstand and assemble LLM-powered applications
Testing and evaluationWhy LLM testing is different; Testing without the model; Evaluation methodology; scorers, judges and statisticsMeasure quality and detect regressions
Advanced systemsRAG systems; Agents and tool useUnderstand multi-stage retrieval and action workflows
Security and operationsSecurity and guardrails; Production quality; Reliable AI pipelines; GovernanceOperate systems safely and responsibly

Many examples run directly in the page. Later, Python 3.11+, a virtual environment and an optional hosted model API or local model via Ollama are useful. Runnable examples live in examples/llm-testing; the folder name predates this broader course structure.

Choosing the simplest solution

A store policy question needs current policy evidence. A RAG application can retrieve relevant policy text, and a tool can look up the authenticated order if needed. The LLM can then explain the result, with links back to its sources. By contrast, converting a fixed CSV format into JSON is often better handled by a deterministic parser. Summarizing open-ended customer messages may genuinely benefit from generation, but privacy and acceptable output still matter.

Choose the architecture based on the job: correctness, freshness, privacy, latency, operational complexity and cost. Testing supports these goals; it is not the organizing principle for learning what an LLM is.

Common mistakes

  • Assuming every AI system is a chatbot or every neural network is an LLM.
  • Confusing an LLM's generated text with a fact verified by an external source.
  • Thinking that the model alone can enforce permissions or perform an external action.
  • Using an agent where a simple script, search or one model call is sufficient.
  • Choosing frameworks and providers before defining the problem and system boundaries.

Summary

  • Generative AI creates content; LLMs are one family of generative models.
  • The model, the application and the product have different responsibilities.
  • Tokens, context, embeddings, RAG and tool use each solve different problems.

Source registry

7 chapter references
Intro to Large Language Models

One-hour overview of pretraining, fine-tuning and LLM security for newcomers.

Andrej Karpathy · video
Source ↗
Attention Is All You Need

Original transformer architecture behind current LLMs.

Vaswani et al. — arXiv / NeurIPS 2017 · paper
Source ↗
Messages API reference

Request and response shape of the Anthropic Messages API: system parameter, content blocks, usage fields.

Anthropic · official docs
Source ↗
Text generation guide

Request and response shape for the Responses and Chat Completions APIs.

OpenAI · official docs
Source ↗
Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

Introduces retrieval-augmented generation: a generator conditioned on passages retrieved for each question.

Lewis et al. — arXiv / NeurIPS 2020 · paper
Source ↗
Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1)

Risks of generative AI and suggested actions for managing them.

NIST · standard
Source ↗
Ollama — run open-weight models locally

Free local model runtime with an OpenAI-compatible endpoint for practising the hands-on exercises.

Ollama · tool
Source ↗