Posts

Showing posts from March, 2026

18 Deep Learning Framework: Pytorch

Image
  18 Deep Learning Framework: Pytorch 1. What is PyTorch? PyTorch is an open-source deep learning framework developed by Meta (Facebook) AI . It’s widely used for building neural networks and machine learning models . Key features: Dynamic Computation Graphs (Define-by-Run) Unlike older frameworks (like TensorFlow 1.x), PyTorch builds the computation graph on the fly , which makes debugging and experimentation easier. GPU Acceleration PyTorch can perform fast computations using CUDA-enabled NVIDIA GPUs , making training large models much faster. Pythonic and Flexible It feels like regular Python code, which is intuitive for developers and researchers. Deep Learning Ready Supports autograd (automatic differentiation), neural network modules , optimizers , and pre-trained models .   1. What is PyTorch? PyTorch is an open-source deep learning framework developed by Meta ...

17 What is CPU, GPU and CUDA

Image
 17 What is CPU, GPU and CUDA CUDA stands for Compute Unified Device Architecture . It’s a parallel computing platform and programming model developed by NVIDIA that allows software to use the GPU (Graphics Processing Unit) for general-purpose computing, not just graphics. In other words, it turns your GPU into a super-fast processor for heavy computations , like deep learning, scientific simulations, or image processing. Here’s a breakdown: 1. Why CUDA Exists CPUs are great for sequential tasks (one thing after another). GPUs have thousands of smaller cores, which can do many calculations simultaneously . CUDA provides a way for programmers to write code that runs on the GPU , leveraging that massive parallelism. 2. Key Features Parallelism: Run thousands of threads at once. C/C++ Extensions: CUDA extends C, C++, and Python (via PyTorch, TensorFlow, Numba) to work on GPU. High Performance: Useful for AI, deep lea...

16 Build a Free Chat App on Google Colab using RAG

 16 Build a Free Chat App on Google Colab using RAG Note: This code has been corrected and the model used is not the best model. The model selection will depend on colab GPU and that can be explored and changed but this is a good starting point nonetheless to understand how things really work.  🔹 Step 1: Install Dependencies 👉 Paste this in a Colab cell: ! pip install - q transformers accelerate sentence - transformers faiss - cpu gradio pypdf 🔹 Step 2: Import Libraries from transformers import AutoTokenizer , AutoModelForCausalLM , pipeline from sentence_transformers import SentenceTransformer import faiss import numpy as np import gradio as gr from pypdf import PdfReader 🔹 Step 3: Load Free LLM (Lightweight) model_name = "google/flan-t5-base" tokenizer = AutoTokenizer . from_pretrained( model_name ) model = AutoModelForCausalLM . from_pretrained( model_name ) generator = pipeline ( "text2text-generation" , model = mode...

15 Agent AI vs Agentic AI

Image
 Agent AI vs Agentic AI The difference between Agent AI and Agentic AI is subtle but important—it’s mostly about capabilities, autonomy, and how they interact with goals . Let’s break it down clearly: 1. Agent AI Definition: An AI system designed to perform tasks or act in an environment based on instructions or pre-programmed rules. Characteristics: Usually goal-directed but limited in autonomy. Operates within a constrained environment . Often relies on human input to decide what actions to take next. Examples: A chatbot that answers FAQs. A recommendation engine that suggests movies based on user history. A robot vacuum following pre-set rules to clean rooms. Key Point: It’s “an agent” in the sense that it can take actions, but it doesn’t really plan or self-direct beyond its instructions .   2. Agentic AI Definition: An AI system that demonstrates agency , ...

14 How to make ChatGPT use RAG

How to make ChatGPT use RAG  To make something like ChatGPT use RAG , you don’t change the model itself—you build a pipeline around it that feeds it relevant data before it answers. Here’s the clean, practical way to think about it 👇 🧠 The Big Idea You’re turning this: ❌ “Answer from memory” into this: ✅ “Look up → then answer” ⚙️ Step-by-Step: Build a RAG System 1. 📄 Load Your Data Bring in your knowledge source: PDFs Word docs Websites Databases 👉 Example: from langchain.document_loaders import PyPDFLoader loader = PyPDFLoader("company_policy.pdf") docs = loader.load() 2. ✂️ Split Into Chunks LLMs can’t handle huge documents at once, so split them: from langchain.text_splitter import RecursiveCharacterTextSplitter splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50) chunks = splitter.split_documents(docs) 3. 🔢 Convert to Embeddings Turn text into vectors (numbers th...

13 LLMs do NOT use RAG by default.

  LLMs do NOT use RAG by default. 🧠 What LLMs Do By Default Models like OpenAI GPT models or LLaMA: Generate answers purely from their trained knowledge Do not automatically search external data Do not access your files, databases, or the internet (unless explicitly connected) 👉 This is called a “closed-book” setup . 🔍 When RAG Comes Into Play RAG is something you add on top of an LLM , not something built-in by default. You (or an app) must: Store documents in a vector database Retrieve relevant chunks Pass them into the model as context Tools like: LangChain LlamaIndex …help you build that pipeline. ⚖️ Default LLM vs RAG-Enabled System Feature Default LLM RAG System Uses training data only ✅ ❌ Can access external docs ❌ ✅ Up-to-date info ❌ (limited) ✅ N...