AI Frameworks to Learn

Last Updated : 17 Oct, 2026

AI frameworks provide tools and APIs for building applications powered by large language models (LLMs), AI agents and external knowledge sources. They simplify tasks such as retrieval-augmented generation (RAG), agent orchestration, tool calling and workflow management.

frame_1000001889

Different frameworks are designed for use cases ranging from LLM application development and RAG to multi-agent systems and structured AI workflows.

TensorFlow

  • TensorFlow is an open-source machine learning framework developed by Google for building and training machine learning and deep learning models.
  • Provides tools for neural networks, automatic differentiation, model training and deployment across different platforms.
  • It is widely used for applications such as image recognition, natural language processing, prediction and deep learning.

Example: The following example creates and trains a simple neural network using TensorFlow.

Python
!pip install -qU tensorflow

import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Dense(8, activation="relu", input_shape=(3,)),
    tf.keras.layers.Dense(1, activation="sigmoid")
])

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

X = tf.constant([
    [0.1, 0.2, 0.3],
    [0.8, 0.7, 0.6],
    [0.2, 0.1, 0.4],
    [0.9, 0.8, 0.7]
])

y = tf.constant([[0.], [1.], [0.], [1.]])

model.fit(X, y, epochs=5, verbose=0)

print(model.predict(X, verbose=0))

Here, Sequential defines the neural network layers, compile() configures the training process and fit() trains the model on the sample data.

PyTorch

  • PyTorch is an open-source machine learning framework developed by Meta for building and training deep learning models
  • Provides tensor operations, automatic differentiation and GPU acceleration for developing neural networks.
  • It is widely used in research and applications involving computer vision, NLP, generative AI and deep learning.

Example: The following example creates and trains a simple neural network using PyTorch.

Python
import torch
import torch.nn as nn

model = nn.Sequential(
    nn.Linear(3, 8),
    nn.ReLU(),
    nn.Linear(8, 1),
    nn.Sigmoid()
)

X = torch.tensor([
    [0.1, 0.2, 0.3],
    [0.8, 0.7, 0.6],
    [0.2, 0.1, 0.4],
    [0.9, 0.8, 0.7]
])

y = torch.tensor([[0.], [1.], [0.], [1.]])

criterion = nn.BCELoss()
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)

for epoch in range(100):
    predictions = model(X)
    loss = criterion(predictions, y)

    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

print(model(X).detach())

Here, nn.Sequential defines the neural network, BCELoss calculates the prediction error and the optimizer updates the model parameters during training.

LangChain

  • LangChain is an open-source framework for building applications powered by large language models.
  • Provides components for working with models, prompts, tools, agents, retrieval systems and structured workflows.
  • It is commonly used for applications such as chatbots, RAG systems and AI agents.

Example: The following example creates a simple LLM application using LangChain.

Python
!pip install -qU langchain

from langchain_core.runnables import RunnableLambda

model = RunnableLambda(
    lambda prompt: "Artificial Intelligence enables machines to perform tasks that normally require human intelligence."
)

response = model.invoke(
    "Explain artificial intelligence in one sentence."
)

print(response)

Here, init_chat_model() initializes the language model, while invoke() sends a prompt and returns the model response.

LlamaIndex

  • LlamaIndex is an open-source framework for building LLM applications that work with external data.
  • Provides tools for connecting LLMs with documents, databases, APIs and other knowledge sources.
  • It is widely used for RAG applications, document question answering and AI agents.

Example: The following example creates an index from a collection of documents.

Python
!pip install -qU llama-index

from llama_index.core import Document

documents = [
    Document(
        text="Artificial Intelligence enables machines to perform intelligent tasks."
    ),
    Document(
        text="Machine Learning allows systems to learn patterns from data."
    )
]

for document in documents:
    print(document.text)

Here, SimpleDirectoryReader loads documents, while VectorStoreIndex creates an index that can be queried using the LLM.

LangGraph

  • LangGraph is a framework for building stateful and multi-step AI agent workflows.
  • Represents application logic as graphs containing nodes and connections between different steps.
  • It is useful for applications that require agent loops, tool usage, human-in-the-loop workflows and multi-agent coordination.

Example: The following example creates a simple graph with a single node.

Python
!pip install -qU langgraph

from langgraph.graph import StateGraph, START, END
from typing import TypedDict

class State(TypedDict):
    message: str

def process(state):
    return {"message": state["message"].upper()}

graph = StateGraph(State)
graph.add_node("process", process)
graph.add_edge(START, "process")
graph.add_edge("process", END)

app = graph.compile()

print(app.invoke({"message": "hello ai"}))

Here, the graph defines a workflow in which the process node transforms the input before the workflow reaches the END state.

AutoGen

  • AutoGen is an open-source framework for building AI applications using interacting agents.
  • Provides components for creating agents that can communicate, use tools and collaborate to complete tasks.
  • It is useful for multi-agent workflows where different agents perform specialized roles.

Example: The following example creates an assistant agent using AutoGen.

Python
!pip install -q autogen-agentchat

from autogen_agentchat.agents import AssistantAgent

agent = AssistantAgent(
    name="assistant",
    model_client=None
)

print("Agent created:", agent.name)

Here, OpenAIChatCompletionClient connects the agent to a language model, while AssistantAgent defines an AI agent that can participate in an agent-based workflow.

CrewAI

  • CrewAI is an AI framework for building collaborative multi-agent systems.
  • Allows developers to define agents with specific roles, goals and tasks and organize them into crews.
  • It is useful for applications where multiple specialized agents need to work together.

Example: The following example creates a simple CrewAI agent.

Python
!pip install -q crewai==0.86.0

from crewai import Agent

researcher = Agent(
    role="AI Researcher",
    goal="Learn about artificial intelligence",
    backstory="You are a beginner-friendly AI research assistant."
)

print(researcher.role)

Here, the Agent object defines an AI agent using a role, goal and background that guide its behavior.

Haystack

  • Haystack is an open-source AI framework for building production-ready LLM applications, AI agents and RAG systems.
  • Provides reusable components and pipelines for connecting language models, document stores, retrieval systems and tools.
  • It is useful for RAG, semantic search, question answering and multimodal AI applications.

Example: The following example creates a simple Haystack pipeline.

Python
!pip install -qU haystack-ai

from haystack import Pipeline
from haystack.components.builders import PromptBuilder

prompt = PromptBuilder(
    template="Explain {{topic}} in one sentence."
)

pipeline = Pipeline()
pipeline.add_component("prompt", prompt)

print(
    pipeline.run({
        "prompt": {
            "topic": "Artificial Intelligence"
        }
    })
)

Here, PromptBuilder creates prompts dynamically, while Pipeline is used to organize reusable components into an AI workflow.

You can download the complete source code from here.

Other Frameworks

  • DSPy: A framework for programming and optimizing LLM applications.
  • OpenAI Agents SDK: A Python SDK for building AI agents with tools, handoffs and guardrails.
  • PydanticAI: A Python framework for building AI applications with structured outputs and type-safe tools.
  • Agno: A framework for building AI agents with tools, memory and knowledge.
  • SmolAgents: A lightweight framework for building AI agents that use tools and execute actions.
  • Semantic Kernel: An SDK for integrating AI models, plugins and workflows into applications.
  • Letta: A framework for building AI agents with persistent memory and tool use.
  • Keras: A high-level deep learning API for building neural networks with TensorFlow, JAX or PyTorch.
  • Scikit-learn: A Python library for classification, regression, clustering and model evaluation.
Comment