How Modern AI Works: LLMs, Prompting, RAG, Agents and MCP Explained
A plain-English tour of the AI stack: how LLMs predict tokens, four prompting techniques, RAG with embeddings, the ReAct agent loop and what MCP does.
This article is published in English.
Sources: Beyond the Buzzwords: How Modern AI Actually Works (From LLMs to Agents)
LLM, GenAI, RAG, MCP. The acronyms arrive faster than anyone can look them up, and it can feel as if someone is just flinging letters at a wall. The ideas underneath aren't magic, though. Strip the jargon away and each one is fairly intuitive. Here's how the pieces of modern AI fit together, in the order that makes them easiest to follow.
Generative AI and LLMs aren't the same thing
People use the two terms interchangeably, but one contains the other.
- Generative AI is the broad category. It covers any system that creates something new, whether that's text, images, audio or video.
- Large language models are one branch of it. If generative AI is "vehicles," an LLM is a sports car: a system trained on enormous amounts of text so it can understand and produce human language.
What an LLM does under the hood
An LLM is a prediction engine, and nothing in it resembles human thought or feeling. The closest comparison is the most advanced autocomplete ever built.
Your input gets chopped into small units called tokens, usually whole words or word fragments. From everything absorbed in training, the model then calculates the probability of each possible next token. Give it "A cup of hot..." and the math might put "coffee" at 90% and "cement" at 1%. It picks the likely continuation, appends it and repeats, at remarkable speed.
Prompt engineering
If LLMs are just probability machines, how do they produce good essays or working code? The answer is largely in how you ask. Prompt engineering is the practice of phrasing requests so the output comes out as useful as possible.
Picture a brilliant intern who knows a huge amount about the world and nothing about your goals. A vague assignment gets a vague result, and a precise one gets precise work.
Dozens of techniques exist, but four cover most of what developers and heavy users rely on.
1. Role prompting. Give the model a persona, such as "act as a senior software engineer reviewing a legacy codebase." This narrows its vocabulary and formatting habits, which trims generic filler and pushes it toward practical, domain-specific answers.
2. Few-shot prompting. Before the real task, show two or three finished examples of the input and output shape you want. Code structures and JSON schemas are easy to misread, and one clear sample of "good" removes most of the guessing and many formatting errors.
3. Prompt chaining. Split a big job into a sequence of smaller prompts. One prompt might outline the architecture, the next generate the database schema and a third write API endpoints based on that schema. Models lose focus over long stretches, so keeping each step small gives better code and fewer compile errors.
4. Meta-prompting. Ask the model to write, improve or debug the prompt itself, for example "I want to accomplish X, so write the best prompt for an LLM to do it." The model understands its own limits fairly well, which can save hours of trial and error.
All four work the same way. By steering the context, you narrow the model's probabilities so it draws only on the "expert engineer" portion of what it learned.
RAG: giving the model fresh facts
LLMs have a built-in limitation, which is that they're frozen at the moment training ends. A model finished in 2023 can't know that RCB won the IPL trophy in May 2026. It also knows nothing about private material such as your company's internal PDFs.
Retrieval-augmented generation, or RAG, closes that gap. Think of an open-book exam. Instead of leaning only on what was memorized long ago (the base training), you're allowed to consult a thick textbook while answering.
The four steps
- Question. You ask something like "What were our Q3 sales goals?"
- Retrieval. Before the model sees the question, a system searches the company's own documents for material on Q3 sales goals.
- Augmentation. The matching documents are pasted into the background of the prompt.
- Generation. The model reads them and answers from current, relevant data.
Why models hallucinate
Because an LLM is a word predictor, its real aim is to sound statistically plausible, not to be factually right. Ask about a company policy that doesn't exist and you won't see a 404. It will invent a convincing policy from nothing. It isn't lying on purpose. It's following its probabilities toward whatever looks like a correct answer. RAG reduces this by forcing the model to base its reply on real facts you supply.
How the search is so fast
Classic search engines hunt for exact keyword matches, but an AI needs to grasp meaning, and that's the job of embeddings.
When company PDFs are uploaded, a specialized model converts the text into a long list of numbers that captures what it means. Those lists are kept in a vector database. At question time, the system turns your question into numbers the same way and looks for the closest matches in the database. That's why the right passage comes back even when you phrase things differently than the document does.
RAG compared with fine-tuning
The two get confused often. RAG is the open-book exam: you hand the model temporary notes relevant to one question. Fine-tuning is more like sending it back to graduate school. It permanently changes the model's internal weights so it picks up a particular tone, format or specialist vocabulary, such as medical or legal language. For keeping factual knowledge current, RAG is faster, cheaper and far easier to manage.
Agentic AI: from chatbot to digital worker
Most people still use AI passively. You type a prompt, receive an answer and the exchange ends. Agentic AI moves from passive assistant to active agent. An agent gets a goal, a set of tools and the freedom to work out how to reach the goal without someone guiding each step.
The workflow
Ask a plain LLM to plan a five-day trip to Bangalore and it will instantly produce a generic itinerary. An agent works in loops instead of predicting one reply. The pattern is called ReAct, short for reasoning and acting, and it cycles through thought, action and observation:
┌────────────────────────┐
│ │
▼ │
[Thought] ──> [Action] ──> [Observation] ─┘
- Thought is the reasoning step. The model studies the request and decides what to do. If someone wants the weather in Hyderabad, it concludes it doesn't know today's conditions and needs an outside source.
- Action is the model picking a tool or API to call, for example
call_weather_api(location="Hyderabad"). - Observation is the real-world result coming back from that tool, such as "25°C and rainy."
Then the loop starts over. The model takes the observation, forms a fresh thought (it now has the weather and can write the answer) and finally replies.
MCP: the universal plug
As agents spread, they hit a bottleneck: how do they reach the rest of the digital world? Slack, GitHub, Google Drive and Notion each organize their data differently, and linking an AI to every one used to mean building a custom bridge per app.
The Model Context Protocol (MCP) is an open standard that works like a universal USB-C port for AI.
[ AI Model ]
│
▼ (Via MCP - Universal Standard)
[ MCP Server / Plug ]
├── Connected to your Slack
├── Connected to your GitHub
└── Connected to your Local Files
Instead of thousands of one-off integrations, apps implement MCP once. After that, any compliant model can read the app's data, use its tools and understand its context securely. It's the infrastructure that lets agents handle email, update spreadsheets and work on codebases.
An easier way to picture it
MCP does for software what UPI did for payments in India. Before UPI, sending money meant collecting an account number, an IFSC code and a branch name, then waiting for the recipient to be activated, or juggling five wallet apps that couldn't talk to each other. UPI replaced that with one scannable code that reaches every bank. MCP is the same universal scan for AI. Developers no longer write custom API code to bridge a model to Slack, then GitHub, then another app. Each app installs a standard MCP plug, and any model can connect, read data and trigger actions. It's the highway that lets agents move across a Jira board, Outlook mail and a production codebase.
How it all connects
Put the pieces in order and the direction is clear. Generative AI and LLMs learned to talk like people. Prompt engineering taught users how to talk back effectively. RAG supplied current facts and private data. Agentic AI now takes on complex problems, with MCP as the plug linking those agents to software everywhere.
The AI boom isn't about machines becoming sentient. It's about machines becoming well-connected, capable tools, and knowing how the gears turn makes it easier to get the most out of them.