AI & Machine Learning Engineering
Build with AI: APIs, retrieval, agents, and production LLM systems
Category: AI / Machine Learning
Learning Path: What → How It Works → Learning Modules → Building With AI
Before you start: no prior AI/ML background is required — this is the entry point for the whole AI academy. Basic comfort reading code (any language) helps for the later Python examples, but isn't required to follow the concepts.
What Is a Large Language Model, Really?
Think of your phone's keyboard suggesting the next word as you type — it learned, from your own past messages, that "see you" is probably followed by "soon." A Large Language Model (LLM) — the technology behind tools like ChatGPT and Claude — does the exact same thing at a vastly larger scale: predict the next token (a chunk of text, usually a few characters — not always a whole word), then treat its own guess as new input and predict the next one after that, thousands of times in a row to write whole paragraphs. It learned this by reading a staggering slice of public text rather than just your messages, but the underlying trick — guess the most likely next piece of text, one piece at a time — is the same.
That single idea explains almost everything else on this page. An LLM doesn't "look things up" or "know facts" the way a database does — it's an extremely well-read pattern-predictor. That's exactly why it can state a confident, fluent, completely wrong answer just as smoothly as a correct one (called hallucination — the model is still just predicting plausible-sounding text, not checking a fact against a source), and exactly why handing it real documents to read from first (a technique called RAG, covered below) makes it far more reliable.
How Text Generation Actually Works
Inside the model, a parameter is a single adjustable number — think of it as one dial among billions. During training (showing the model huge amounts of text and nudging every dial slightly whenever its next-token guess was wrong), those billions of dials gradually settle into values that, together, encode patterns of language, facts, and reasoning. GPT-4 has roughly 1.8 trillion of these parameters; Claude 3 has hundreds of billions; Llama 3.1 8B has 8 billion — more parameters generally means more capacity to encode nuance, at the cost of more compute to run.
The AI Stack for Engineers
Calling the Anthropic API
Claude Sonnet: $3 per 1M input tokens, $15 per 1M output tokens
1,000 word essay ≈ 1,300 tokens ≈ $0.004 to generate.
For most applications, AI API costs are surprisingly low.
RAG vs Fine-Tuning — When to Use Each
RAG (Retrieval-Augmented Generation) is the "handing it real documents to read first" idea from above, made concrete: before answering, the system searches a store of your own real documents (using embeddings, defined above, to find the most relevant ones) and hands the model those documents as extra context — so it's predicting the next token while looking at actual source material instead of only its trained-in memory. This is different from fine-tuning, which changes the model's parameters themselves rather than what it's shown at answer time:
| RAG | Fine-Tuning |
|---|
|---|---|---|
| **Updates knowledge** | Yes — just re-index | No — must retrain |
|---|---|---|
| Private data | Yes | Yes |
| Latency | Slightly higher (retrieval step) | Same as base model |
| Cost | Retrieval infra | Training compute |
| Best for | Current info, citations, Q&A | Style, format, specialized tasks |
For 90% of use cases: Prompt Engineering first → RAG if you need private/current data → Fine-tuning only if still insufficient. Most teams over-engineer this.

