The 3-minute mental model

An LLM is a text predictor. That's it. You give it text (a "prompt"), it gives back text (a "completion"). The magic is that it was trained on billions of pages of the internet—books, code, articles, conversations. It learned patterns.

Prompt: "The capital of France is"
→
[Neural Network]
→
Completion: "Paris"

Every response your model gives is just "what's the most likely next token" repeated over and over. Here's why it feels intelligent:

  • Tokens ≈ 3/4 of a word. "The stock market closed higher" is roughly 6 tokens. Models measure input/output in tokens, not words.
  • Parameters = model size. 7B, 13B, 70B = billions of parameters = the model's "memory." Bigger ≈ more capable but slower.
  • Training data is everything. An LLM only knows what was in its training data. It can't access live information, APIs, or real-time stock prices (not yet).
  • It's not magic; it's math. Billions of matrix multiplications on your GPU, but still just pattern matching on a giant scale.
Why completions sometimes seem wrong:
The model is predicting the most likely next token based on its training data. If the training data had typos, biases, or outdated info—the model will too. We fix this later with better prompts and tools.

Local vs Cloud — pick your fighter

You have two choices: run the model on your machine (Ollama) or send your prompts to the cloud (Gemini, ChatGPT, Claude).

Option 1
🖥️ Local (Ollama)
Speed: Slower (depends on your GPU/CPU)
Power: 7B typical (good enough for tasks)
Privacy: 100% private—stays on your machine
Cost: Free forever
Internet: No internet needed
Option 2
☁️ Cloud (Gemini/API)
Speed: Instant (servers are fast)
Power: 200B+ (more capable)
Privacy: Your prompts go to Google/OpenAI
Cost: Free tier, then pay per token
Internet: Requires internet
Our choice for this course:
We default to Ollama (local). It's free, private, and teaches you the real internals. We only use Gemini to compare and handle tasks that need live data (Lesson 07+). This way you own your infrastructure from day one.

Hello LLM — your first call

Prerequisites: Open your Terminal and make sure you ran bash setup.sh from Lesson 00. You should have Ollama running and a conda activate ramayai environment ready.

Code Block 1: Ollama call (the main star)

This is your "Hello World" with LLMs. Save this as hello.py in your agents_testing/ folder.

hello.py Ask Ollama a question
Expected output
The Price-to-Earnings (P/E) ratio is a valuation metric that divides a company's current stock price by its earnings per share, indicating how much investors are willing to pay for each dollar of earnings.
What happened: You called the chat() function with a prompt and a provider. The function found the Ollama server on your machine, sent the prompt, and waited for a completion. The model predicted the most likely next tokens until it decided it was done.

Code Block 2: Same question, different provider

If you set up a Gemini API key, you can swap providers with one line.

hello_gemini.py Ask Gemini the same question
The pattern: Same call, different provider. The wrapper hides the difference. This is how you'll build agents: swap implementations without changing the interface. Day 1, Ollama. Week 2, Gemini for comparison. Week 4, custom API.

Code Block 3: System prompts (tuning behavior)

The system argument sets the model's "role" without changing your question. This is your first taste of prompt engineering.

hello_system.py Add system prompt for tone
What changed: Notice the output now has a specific tone and includes a real company example. The model didn't learn new facts—it changed how it talks. The system prompt is invisible to the user but steers the entire response. Same prompt, different system = completely different vibes.

Try it yourself

Three exercises. Try them in order, and notice what the model is good at vs weak at.

Mini Challenges

1. Does it know about libraries?

Ask the model: "Explain yfinance in 2 sentences." Does it know what yfinance is? (It probably does—it was in the training data.)

2. Can it write working code?

Ask: "Give me a Python one-liner to fetch Apple's current stock price." Run the output. Does it actually work? (Probably not without tweaks—the API may have changed since training.)

3. Can you control tone with system prompts?

Add a system prompt: "You are Warren Buffett." Ask a basic investing question. Compare the tone and content to the same question without the system prompt.

What you'll notice: Question 1 gets a decent answer (summary from training data). Question 2 is hit-or-miss (the code is from training data, but APIs change). Question 3 is fun but not always accurate (the model is good at mimicry, not fact-checking). These are the three core LLM problems:

  • Known unknowns: The model doesn't know current data (we fix this in Lesson 07 with tools).
  • Hallucinations: The model can confidently give wrong answers (we fix this in Lesson 11 with RAG—retrieval-augmented generation).
  • Reasoning: The model is strong at summary and mimicry, weaker at multi-step reasoning (we fix this in later lessons with prompting strategies).

Why this matters for agents

An agent is just an LLM running in a loop with access to tools. Today you made one call and got one answer. Next lesson, you'll shape the call with better prompts and looping. By Lesson 06, you'll add tools (like yfinance) so the agent can fetch real data. By Lesson 11, your agent will read real documents and answer questions about them using RAG. By Lesson 20, you'll have an agent that plans multi-step workflows, delegates tasks, and reports results.

But all agents start here: prompt → completion. Master this loop, and everything else is just chaining loops together.

Test your knowledge

Question 1 of 5
What is an LLM, in simplest terms?
Question 2 of 5
Roughly how many tokens is the sentence "The stock market closed higher today"?
Question 3 of 5
Which gives you more privacy: Ollama or Gemini?
Question 4 of 5
What does the system argument in chat() do?
Question 5 of 5
Why can't an LLM reliably answer "What is Apple's current stock price"?
0
/5
Great job! You understand the foundations of LLMs.
Africa & India's Best AI Academy
🤖 AI-first 🎓 Placement Assistance

You've made your first LLM call.
Now go build agents that do real work.

Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.

Explore The AI-Era Agentic Engineer →