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.
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.
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).
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.
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.
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.
Try it yourself
Three exercises. Try them in order, and notice what the model is good at vs weak at.
Mini Challenges
Ask the model: "Explain yfinance in 2 sentences." Does it know what yfinance is? (It probably does—it was in the training data.)
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.)
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
system argument in chat() do?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 →