• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Codemotion Magazine

We code the future. Together

  • Discover
    • Events
    • Community
    • Partners
    • Become a partner
    • Hackathons
  • Magazine
    • Backend
    • Frontend
    • AI/ML
    • DevOps
    • Dev Life
    • Soft Skills
    • Infographics
  • Talent
    • Discover Talent
    • Jobs
    • Manifesto
  • Companies
  • For Business
    • EN
    • IT
    • ES
  • Sign in

Orli DunApril 29, 2026 4 min read

AI Stack: From Machine Learning to Agentic AI

AI/ML
ai
facebooktwitterlinkedinreddit

A practical guide for developers who want to understand the AI ecosystem — not just use it.


The word “artificial intelligence” gets applied to everything: chatbots, Netflix recommendations, self-driving cars, image generators. But behind all of it sits a well-defined technology stack — layers built on top of each other, each one with a reason to exist. Understanding this structure is what separates developers who use AI tools from developers who design them.

Recommended article
April 15, 2026

“We Don’t Store Your Data” Isn’t Enough: How Regolo.ai’s Zero Data Retention Policy Actually Works

Codemotion

Codemotion

AI/ML

Let’s start from the bottom.


1. Artificial Intelligence (AI) — The Umbrella

AI is the field that encompasses everything: any system designed to simulate human cognitive capabilities like reasoning, learning, perception, or decision-making.

The earliest AI systems were rule-based: explicit logic written by hand.

def approve_loan(income, credit_score):
    if income > 50000 and credit_score > 700:
        return "Approved"
    return "Denied"
Code language: JavaScript (javascript)

Simple, transparent, brittle. It doesn’t adapt. It doesn’t learn. Every new edge case requires a human to update the rules manually. That limitation is exactly what motivated the next layer.


2. Machine Learning (ML) — Learning from Data

ML flips the paradigm: instead of writing rules, you provide data and let the model learn the patterns on its own.

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

model = RandomForestClassifier()
model.fit(X_train, y_train)

predictions = model.predict(X_test)
print(predictions[:5])
Code language: JavaScript (javascript)

Where it shines: fraud detection, demand forecasting, recommendation systems, churn prediction.

Where it shows its limits: high-dimensional data, images, text, audio. For those cases you need more powerful architectures.


3. Neural Networks (NN) — The Artificial Brain

Neural networks take inspiration from the structure of the brain: interconnected nodes that process information in parallel. Each neuron computes:

output = activation(weight · input + bias)

Training happens through backpropagation: compute the error on the output, propagate it backward, and update the weights to minimize it.

import torch
import torch.nn as nn

class NeuralNetwork(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 8)
        self.layer2 = nn.Linear(8, 3)

    def forward(self, x):
        x = torch.relu(self.layer1(x))
        return self.layer2(x)

model = NeuralNetwork()
output = model(torch.rand(1, 4))
print(output)

Neural networks work well on structured problems. But for genuinely complex tasks — speech recognition, language understanding — you need networks that are much, much deeper.


4. Deep Learning (DL) — More Layers, More Power

Deep Learning is ML with many-layered neural networks. More layers means the ability to extract increasingly abstract features from raw data.

This is what made computer vision, NLP, speech synthesis, and autonomous driving possible.

The main architectures you’ll encounter in practice:

ArchitectureTypical use case
CNNComputer vision, image classification
RNN / LSTMTime series, sequential text
TransformerNLP, LLMs, generation
AutoencoderCompression, anomaly detection
from tensorflow import keras
from tensorflow.keras import layers

model = keras.Sequential([
    layers.Dense(128, activation="relu"),
    layers.Dense(64, activation="relu"),
    layers.Dense(10, activation="softmax")
])

model.compile(
    optimizer="adam",
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"]
)

model.summary()
Code language: JavaScript (javascript)

Deep Learning opened the door to generating new content — and that’s where things get really interesting.


5. Generative AI — Create, Don’t Just Classify

A classifier says “this image is a cat.” A generative model creates a new image of a cat. That’s a fundamental paradigm shift.

The main families of generative models:

  • GAN (Generative Adversarial Networks): two competing networks — generator vs. discriminator
  • VAE (Variational Autoencoder): probabilistic encoding of latent space
  • Diffusion Models: iteratively add and then remove noise (e.g. Stable Diffusion)
  • LLMs: autoregressive transformers for language

Conceptual GAN example in PyTorch:

import torch
import torch.nn as nn

class Generator(nn.Module):
    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(100, 256),
            nn.ReLU(),
            nn.Linear(256, 784),
            nn.Tanh()
        )

    def forward(self, x):
        return self.net(x)

generator = Generator()
noise = torch.randn(1, 100)
fake_image = generator(noise)
print(fake_image.shape)  # torch.Size([1, 784])

The products you use every day — ChatGPT, Claude, Gemini, Midjourney, Copilot — are all built on these foundations.


6. LLMs and SLMs — Scale and Trade-offs

Large Language Models (LLM)

Base architecture: Transformer. Billions (or trillions) of parameters. Trained on massive corpora with self-supervised learning.

Strengths: complex reasoning, long-form generation, deep contextual understanding.

from transformers import pipeline

generator = pipeline("text-generation", model="gpt2")
output = generator("Artificial intelligence will transform", max_length=40)
print(output)
Code language: JavaScript (javascript)

Small Language Models (SLM)

Compact versions optimized for: low latency, reduced energy consumption, on-device or on-premise execution.

Examples: Phi-3 (Microsoft), Gemma (Google), LLaMA 3 in small variants.

The pattern emerging in production systems:

SLM → fast tasks, repetitive work, classification, routing
LLM → complex reasoning, summarization, creative generation

Hybrid SLM+LLM architectures are already the norm in production.


7. AI Agents and Agentic AI — From Output to Action

This is where the paradigm shifts again. An LLM answers a question. An agent plans toward a goal, selects the right tools, executes them in sequence, and manages state across steps.

Typical Agent Architecture

User input
     ↓
LLM reasoning (planning)
     ↓
Tool selection (which API to call?)
     ↓
Execution (actual call)
     ↓
Memory update (save context)
     ↓
Output / next action

Practical Example

import requests

def get_weather(city: str) -> dict:
    url = f"https://api.weatherapi.com/v1/current.json?key=API_KEY&q={city}"
    return requests.get(url).json()

def agent(city: str) -> str:
    data = get_weather(city)
    temp = data.get("current", {}).get("temp_c")

    if temp is None:
        return "Couldn't retrieve temperature."

    return "Cold out — bring a jacket." if temp < 15 else "Nice weather, no jacket needed."

print(agent("New York"))
Code language: JavaScript (javascript)

In real systems the agent also handles: persistent memory (e.g. a vector store), structured tool calling, retry logic, and handoffs between agents.

Main Frameworks

FrameworkCharacteristic
LangChainFull ecosystem, chains and agents
LangGraphStateful agents as graphs
CrewAIMulti-agent with explicit roles
AutoGen (Microsoft)Agent-to-agent conversations
Semantic KernelEnterprise integration (.NET/Python)

The Full Picture

Agentic AI          ← autonomy, planning, execution
      ↑
Generative AI       ← LLMs, diffusion, content generation
      ↑
LLM / SLM           ← transformers, billions of parameters
      ↑
Deep Learning       ← deep networks, CNN, RNN
      ↑
Neural Networks     ← backpropagation, activations
      ↑
Machine Learning    ← learning from data, feature engineering
      ↑
AI (rules)          ← explicit logic, expert systems
Code language: JavaScript (javascript)

Real systems combine multiple layers. An e-commerce assistant might use:

  • CNN to analyze product images
  • LLM to answer questions in natural language
  • RAG to retrieve info from an up-to-date catalog
  • Agent to initiate returns, update orders, notify users

Intelligence emerges from the combination.


Where the Industry Is Heading

Three concrete trends worth tracking:

1. Multi-agent systems — multiple specialized agents collaborating. One handles planning, one executes, one verifies. Better separation of concerns, more robustness.

2. Hybrid SLM+LLM architectures — the large model for reasoning, the small model for execution. Cuts costs and latency without sacrificing quality.

3. Progressive autonomy — agents that run complete workflows without human intervention, escalating only for ambiguous cases. “Human in the loop” becomes opt-in, not mandatory.

There’s already talk of an Agentic Web: networks of agents collaborating across the internet as a distributed intelligence layer.


Takeaway for Developers

The distinction that actually matters isn’t between technologies — it’s between developers who use AI and developers who design it.

Using it is easy: grab an API key and go. Designing it means understanding which layers of the stack to involve, where the bottlenecks are, how to combine LLMs and agents reliably, and how to handle state, errors, and security in production.

This stack isn’t static — every year adds a new layer. But the fundamentals stay: data, models, architectures, agents. Developers who understand them deeply will have a durable advantage.

Related Posts

paradosso AI paradox AI Agents concept image

Snowflake – “Beyond SQL Generation”: Teaching AI Agents What Your Database Really Means

Codemotion
March 19, 2026
reflection pattern

AI Literacy in 2026: How to Lead a Team of Synthetic Agents — and Win

Orli Dun
March 11, 2026
gemini san remo ai prevede

AI Predicts Music Contest Winner: Reality Disagrees

Dario Ferrero
March 11, 2026
minimax

MiniMax M2.5: low costs, high performance, relaunches the Chinese AI geopolitical challenge

Dario Ferrero
March 4, 2026
Share on:facebooktwitterlinkedinreddit

Tagged as:AI Machine Learning

Orli Dun
From finance to the digital revolution! Systems Engineer | Cloud & AI | Tech Creator | Community Manager at Alura Latam #foramillionfriends
Beyond SQL Generation: How to Teach Agents What Your Database Means
Previous Post

Footer

Discover

  • Events
  • Community
  • Partners
  • Become a partner
  • Hackathons

Magazine

  • Tech articles

Talent

  • Discover talent
  • Jobs

Companies

  • Discover companies

For Business

  • Codemotion for companies

About

  • About us
  • Become a contributor
  • Work with us
  • Contact us

Follow Us

© Copyright Codemotion srl Via Marsala, 29/H, 00185 Roma P.IVA 12392791005 | Privacy policy | Terms and conditions